Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using Fulcrum Data Events for routing with Google Maps and MAPS.ME
ON('change', 'routing_options', () => {
if ($routing_options == 'google') {
if (LATITUDE() && LONGITUDE()) {
OPENURL('https://maps.google.com/?q=' + LATITUDE() + ',' + LONGITUDE());
} else {
ALERT('No location provided!', 'A location is required to show Google Maps.')
}
SETVALUE('routing_options', null);
} else if ($routing_options == 'mapsme') {
let location = CURRENTLOCATION();
if (!location) {
// location could not be determined.
} else {
lat = location.latitude;
lng = location.longitude;
if (LATITUDE() && LONGITUDE() && lat && lng) {
// example maps.me URL scheme/intent
// mapsme://route?sll=55.7522,37.6155&saddr=Destination&dll=55.763,37.6155&daddr=Destionation&type=pedestrian
OPENURL('mapsme://route?sll=' + lat + ',' + lng + '&saddr=Start&dll=' + LATITUDE() + ',' + LONGITUDE() + '&daddr=Destination&type=vehicle');
} else {
ALERT('No location provided!', 'A location is required to show MAPS.ME.')
}
SETVALUE('routing_options', null);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.