Skip to content

Instantly share code, notes, and snippets.

@oeon
Created October 27, 2019 16:38
Show Gist options
  • Save oeon/77cc510e6db7e0350f5d992f229f6832 to your computer and use it in GitHub Desktop.
Save oeon/77cc510e6db7e0350f5d992f229f6832 to your computer and use it in GitHub Desktop.
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