Opening Google Directions API internally Android Studio -
i developing application in android studio , have included both google maps api , google directions api within app. have included button in app allows user guided selected location.
the following code uses google maps api, opens google maps within application shows marker on maps without giving directions place:
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_maps); supportmapfragment mapfragment = (supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map); mapfragment.getmapasync(this); } @override public void onmapready(googlemap googlemap) { mmap = googlemap; // add marker @ oval , move camera latlng oval = new latlng(53.3484013,-6.2605243); mmap.addmarker(new markeroptions().position(oval).title("oval pub")); mmap.movecamera(cameraupdatefactory.newlatlng(oval));
the below code uses google directions api , gives user guide selected destination:
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_maps); supportmapfragment mapfragment = (supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map); mapfragment.getmapasync(this); } @override public void onmapready(googlemap googlemap) { mmap = googlemap; uri gmmintenturi = uri.parse("google.navigation:q=the+oval+bar,+dublin+ireland"); intent mapintent = new intent(intent.action_view, gmmintenturi); mapintent.setpackage("com.google.android.apps.maps"); startactivity(mapintent);
the problem being above code relating google directions api, opens google maps application outside application. wondering how open within application itself.
you should use fragment com.google.android.gms.maps.mapfragment shown in great lars vogel article: http://www.vogella.com/tutorials/androidgooglemaps/article.html
Comments
Post a Comment