-1

My app has a list of places that when pressed, it will open to its specific page displaying a lot more of the place's information.

Inside the page is an ImageView (Map Marker), that if pressed, it will open a Google Map App with the specific coordinates of the place.

It goes like this: LIST OF PLACES -> SPECIFIC PAGE OF A PLACE -> GOOGLE MAP APP WITH COORDINATES (Please check the Image Attached.)

View Image Here.

This code is working fine for opening Google Map App with only 1 place.

public void MapClick (View v) {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:13.669595,124.4130464?q=13.669595,124.4130464(Binurong Point)"));
        startActivity(intent);
    }

How do I pass the Coordinates from the Array to the ImageView (Map Marker), so that if it is pressed, it will open Google Map App based from what place it is?

This is my starting point:

    String[] attractgeocoordinates = {
//          Place #1
            "13.5735488,124.1371557",

//         Place #2
            "13.7077914,124.3876623",
}

Thanks!

4 Answers4

3

Try this:

String[] attractgeocoordinates = {"13.5735488,124.1371557", "13.7077914,124.3876623"};
String[] mainLatLng =attractgeocoordinates[0].split(",");

String lattitude=mainLatLng[0];
String longitude=mainLatLng[1];

String geoUri = "http://maps.google.com/maps?q=loc:" + lattitude + "," + longitude + " (" + Binurong Point + ")";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(geoUri ));
context.startActivity(intent);
Hemant Parmar
  • 3,924
  • 7
  • 25
  • 49
1

Possible duplicate answer here

Although, as an extra example:

String urlAddress = "http://maps.google.com/maps?q="+ mLatitude  +"," + mLongitude +"("+ mMarkerName + ")&iwloc=A&hl=es";
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlAddress));
                intent.setPackage("com.google.android.apps.maps");
                if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
                    startActivity(intent);
                }
Debdeep
  • 752
  • 10
  • 22
1

You have to get the selected position from list view and access that specific value and pass the content through intent to the image view.

Example : 
listView.setOnItemClickListener(new OnItemClickListener()
 {

 @Override
 public void onItemClick(AdapterView<?> parent, View view,
 int position, long id) 
{ 
Intent intent=new Intent(ListviewActivity.this,ImageviewActivity.class)
intent.putString("value1",attractgeocoordinates[0]);
intent.putString("value1",attractgeocoordinates[1]);
startactivity(intent);

}

 }
 });

}

rawhost
  • 144
  • 1
  • 6
1

Change your lat lang coordinates here. It will launch google maps application and draws pin for the coordinates in maps.

String latlng=13.326574+","+75.770282+("CSM");
    Uri mapUri = Uri.parse("geo:0,0?q="+latlng);
    Intent mapIntent = new Intent(Intent.ACTION_VIEW, mapUri);
    mapIntent.setPackage("com.google.android.apps.maps");
    startActivity(mapIntent);
Mohammed Farhan
  • 1,120
  • 8
  • 14
  • How to change lat lang coordinates dynamically if your coordinates is from array in another activity? ( There are 2 Activities. PlacesListContainerActivity PlacesMainActivity ) The Coordinates are from PlacesListContainerActivity The Button to open the Map is in PlacesMainActivity – Goodbye World Feb 01 '18 at 06:48
  • pass the coordinates using intent from PlacesListContainerActivity. and receive it using intent in placesMainActivity and change the latlng accordingly. – Mohammed Farhan Feb 01 '18 at 07:47