2

i have to show multiple location on the Native Google Map Application (MapView is not implemented in our application ).i have all the lat- long of all the geo Points . how can i pass the intent to show the multiple points on Native Google Map Application.

i know to show a point on Google map using the following Code.

String uri = String.format(Locale.ENGLISH, "geo:%f,%f", latitude, longitude);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
context.startActivity(intent);

please suggest how to do the needful changes.

Thanks :)

nitwatar
  • 159
  • 2
  • 9
  • I dont know why you need this. AFAIK it is not possible till now. The possible solution is to integrate google map in your application., so that you can add multiple markers at locations – Ansal Ali Feb 15 '16 at 10:20

2 Answers2

1

You can pass the names of the places that you want to show in the Map from the other Activity to the present Activity and then implement Markers to show them in the Map. For this you have to implement Google Map in the present Activity and I hope you have done that. :)

The below code shows multiple locations on a Google Map:

private void AddMarkers(GoogleMap googleMap)
{
    try {
        Intent intent = getIntent();
        Bundle extras = intent.getExtras();
        Geocoder geocoder = new Geocoder(context);
        Origin_Map = extras.getString(MainActivity.ORIGIN_MAP);
        Destination_Map = extras.getString(MainActivity.DESTINATION_MAP);
        Addr_Origin = geocoder.getFromLocationName(Origin_Map, 1);
        Addr_Dest = geocoder.getFromLocationName(Destination_Map, 1);
        if (Addr_Origin.size() > 0) {
            latitude_origin = Addr_Origin.get(0).getLatitude();
            longitude_origin = Addr_Origin.get(0).getLongitude();
        }
        if (Addr_Dest.size() > 0) {
            latitude_destination = Addr_Dest.get(0).getLatitude();
            longitude_destination = Addr_Dest.get(0).getLongitude();
        }
        Marker m1 = googleMap.addMarker(new MarkerOptions().position(new LatLng(latitude_origin, longitude_origin)).title(Origin_Map).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE)));
        Marker m2 = googleMap.addMarker(new MarkerOptions().position(new LatLng(latitude_destination, longitude_destination)).title(Destination_Map).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));

    } catch (Exception e) {
        e.printStackTrace();
    }
}

And call this method once your map is ready!

@Override
public void onMapReady(GoogleMap googleMap)
{
    AddMarkers(googleMap);
}

Hope this helps!!

Saumik Bhattacharya
  • 891
  • 1
  • 12
  • 28
  • 1
    Dear Saumik, i am not showing map in my own application ,i just want to show all the locations on the map in Google Map Application as i have already mentions. – nitwatar Feb 15 '16 at 10:13
0

Judging by this it is not possible. Also the question is a duplicate of this.

Community
  • 1
  • 1
ddog
  • 670
  • 1
  • 10
  • 25