/user/willmoffat/apps/RunApp rename
author:
contributor:
published:
updated:
source uri:
Summary
if (!(acre.environ.params && acre.environ.params.id)) {
error('Missing "id"');
}
var loc_id =...
Content
if (!(acre.environ.params && acre.environ.params.id)) {
error('Missing "id"');
}
var loc_id = acre.environ.params.id;
var query = {
"geolocation" : [
{
"latitude" : null,
"longitude" : null
}
],
"id" : loc_id,
"type" : "/location/location"
};
var data = acre.mqlread(query);
if (!data) {
error('Location "'+loc_id+'" was not found');
}
if (!(data.geolocation && data.geolocation[0] && data.geolocation[0].latitude)) {
error('Location "'+loc_id+'" does not have a valid location');
}
acre.log(0);
var lat = data.geolocation[0].latitude;
var lng = data.geolocation[0].longitude;
var uri = 'http://maps.google.com/maps?t=p&z;=13≪='+lat+','+lng;
acre.log('redirect to '+uri);
acre.start_response(301, { 'Location': uri });
acre.exit();
function error(message) {
acre.start_response(404, { 'content-type': 'text/html; charset="UTF-8"' });
acre.write('Error Error');
acre.write(''+message+'');
acre.write('');
acre.exit();
}
Created by:
willmoffat
Mar 28, 2008
Last edited by:
Constant Gardener Process
Aug 18, 2009
Recent Discussions about None
There is no discussion about this document.
Start the Discussion »