Skip to content Skip to sidebar Skip to footer

Android Google Map Location Item Click With Starting New Activity

map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() { public void onInfoWindowClick(Marker marker)

Solution 1:

InfoWindow isn't a live view so this what i have do :

publicclassCustomInfoWindowAdpaterimplementsGoogleMap.InfoWindowAdapter,Picasso.Listener {
        @OverridepublicvoidonImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {

        }

        privatefinal View view;

        publicCustomInfoWindowAdpater() {
            view = getLayoutInflater()
                    .inflate(R.layout.custominfowindow, null);
        }

        public View getInfoWindow(final Marker marker) {
            MainApplication.currentlyClickedMarker = marker;
            finalLinearLayoutlinearLayout= (LinearLayout)view.findViewById(R.id.ll_custominfowindow);
            linearLayout.setTag(marker.getId());


            GoogleMapFragment.this.marker = marker;

            Stringurl=null;

            if (marker.getId() != null && markers != null && markers.size() > 0) {
                if ( markers.get(marker.getId()) != null &&
                        markers.get(marker.getId()) != null) {
                    url = markers.get(marker.getId());
                }
            }

           finalImageViewimage= ((ImageView) view.findViewById(R.id.badge));


            //Get the Image from web using Picasso and update the info contentsif (url != null && !url.equalsIgnoreCase("null")
                    && !url.equalsIgnoreCase("")) {
                Picasso.with(GoogleMapFragment.this).load(Uri.parse(url)).resize(50,50)
                        .into(image, newCallback() {
                            @OverridepublicvoidonSuccess() {
                                getInfoContents(marker);
                            }

                            @OverridepublicvoidonError() {

                            }
                        });
            }
            else{
                image.setImageResource(R.drawable.ic_launcher);
            }

            finalStringtitle= marker.getTitle();
            finalTextViewtitleUi= ((TextView) view.findViewById(R.id.title));
            if (title != null) {
                titleUi.setText(title);
            } else {
                titleUi.setText("");
            }

            finalStringsnippet= marker.getSnippet();
            finalTextViewsnippetUi= ((TextView) view
                    .findViewById(R.id.snippet));
            if (snippet != null) {
                snippetUi.setText("");
            } else {
                snippetUi.setText("");
            }

            return view;
        }

...

@OverridepublicvoidonCreate(Bundle savedInstanceState) {   
        super.onCreate(savedInstanceState);
     googleMap.setInfoWindowAdapter(newCustomInfoWindowAdpater());
}

...

@OverridepublicvoidonInfoWindowClick(Marker marker) {
        // open the applicationIntentintent=newIntent(GoogleMapFragment.this,SplashScreenAppPro.class);
        // SplashScreen
        intent.putExtra("id",marker.getSnippet());
        intent.putExtra("nom_profil",  marker.getTitle());
        startActivity(intent);


    }

*Your Activity/Fragment must implement GoogleMap.OnInfoWindowClickListener

Post a Comment for "Android Google Map Location Item Click With Starting New Activity"