Overwrite a window information of google map marker for Android

This code is part of a click event implementation from a spinner (dropDown control) in order to add a google map marker. It is defined on my spinner class that implements AdapterView.OnItemSelectedListener.

@Override

public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

MyObject myObject = new MyObject();

myObject.setAddress("Park Avenue 123");

myObject.setStoreName("My little book");


Marker marker= activity.mMap.addMarker(markerOptionsEst);

marker.setTag(myObject);

}


This other code block will be used to able the click event on google map marker to show a window information with information about shop store.

It was overwritten on the previous code.

Also, the popup window has a click event where the below code redirects to other screen transferring data with Shop store information.


This code is implemented into of onMapReady method on my Activity class that implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener, OnMapReadyCallback


mMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {

      @Override

      public void onInfoWindowClick(Marker marker) {

        MyObject obj = (MyObject) marker.getTag();

        String data = gson.toJson(obj);

        Intent intent = new Intent(ExplorerMapActivity.this, InformationActivity.class);

        intent.putExtra("establishment", data);

        intent.putExtra("activity", "NextActivity");

        startActivity(intent);

      }

    });

To view or add a comment, sign in

More articles by Juan Carlos Ramos Villavicencio

Insights from the community

Others also viewed

Explore topics