-
Notifications
You must be signed in to change notification settings - Fork 112
Build Route and Show On Map via Intent
MapsMe app can handle following intents coming from external apps:
- Show a point on the map
- Build a route
To show the point on the map you must send the intent with following parameters:
Required
action - com.mapswithme.maps.pro.action.SHOW_ON_MAP
in:lat:float - latitude of the point
in:lon:float - longitude of the point
To build the route you must send the intent with following parameters:
Required
action - com.mapswithme.maps.pro.action.BUILD_ROUTE
in:lat_to:float - latitude of the end point
in:lon_to:float - longtitude of the end point
Optional
in:lat_from:float - latitude of the start point
in:lon_from:float - longitude of the start point
in:saddr:String - name of the start point
in:daddr:String - name of the end point
in:router:String - a route type. Supported types: "vehicle", "pedestrian", "bicycle", "taxi", "transit".
Note: if the start point coordinates are not provided the current location will be considered as the start point.
Intent intent = new Intent("com.mapswithme.maps.pro.action.BUILD_ROUTE");
intent.setPackage("com.mapswithme.maps.pro");
PackageManager pm = getPackageManager();
List<ResolveInfo> infos = pm.queryIntentActivities(intent, 0);
// Check whether MapsMe is installed or not.
if (infos == null || infos.size() == 0) {
// If not - open MapsMe page on Google Play
intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.mapswithme.maps.pro"));
}
else
{
intent.putExtra("lat_from", 55.800800);
intent.putExtra("lon_from", 37.532754);
intent.putExtra("saddr", "Start point");
intent.putExtra("lat_to", 55.760158);
intent.putExtra("lon_to", 37.618756);
intent.putExtra("daddr", "End point");
intent.putExtra("router", "vehicle");
}
// Launch MapsMe.
startActivity(intent);