custom info window adapter with custom data in map v2
I have open dialog onMarker()
click. and setContentView(my layout)
.
I have use below code.
@Override
public boolean onMarkerClick(Marker arg0) {
if(arg0.getSnippet() == null){
mMap.moveCamera(CameraUpdateFactory.zoomIn());
return true;
}
//arg0.showInfoWindow();
final DataClass data = myMapData.get(arg0);
final Dialog d = new Dialog(MainActivity.this);
d.requestWindowFeature(Window.FEATURE_NO_TITLE);
//d.setTitle("Select");
d.getWindow().setBackgroundDrawable(new ColorDrawable(Color.WHITE));
d.setContentView(R.layout.info_content);
ivPhoto = (ImageView)d.findViewById(R.id.infocontent_iv_image);
AddImageOnWindow executeDownload = new AddImageOnWindow();
final LatLng l = arg0.getPosition();
executeDownload.execute(l);
TextView tvName = (TextView)d.findViewById(R.id.infocontent_tv_name);
tvName.setText(data.getPlaceName());
TextView tvType = (TextView)d.findViewById(R.id.infocontent_tv_type);
tvType.setText("("+data.getPlaceType()+")");
TextView tvDesc = (TextView)d.findViewById(R.id.infocontent_tv_desc);
tvDesc.setText(data.getPlaceDesc());
TextView tvAddr = (TextView)d.findViewById(R.id.infocontent_tv_addr);
tvAddr.setText(Html.fromHtml(data.getPlaceAddr()));
d.show();
return true;
How do I pass custom data to Google Maps v2 InfoWindowAdapter?
perhaps try adding your info or object to the marker as explained here:
http://bon-app-etit.blogspot.be/2012/12/add-informationobject-to-marker-in.html
Edit: I also made a post that continues the previous to use the InfoWindowAdapter.
Check it out here!
Custom infowindow in Google map android v2
Please refer Info window click events in this link
Info window is not a live View, rather the view is rendered as an image onto the map. As a result, any listeners you set on the view are disregarded and you cannot distinguish between click events on various parts of the view. You are advised not to place interactive components — such as buttons, checkboxes, or text inputs — within your custom info window.
How to pass data to a custom window info in Google Maps API v2?
Since Marker
is final
, you cannot create a subclass from it.
Hence, the best solution that I have found is to use something in the Marker
-- such as the snippet -- to hold a key that allows you to look up additional data. For example, it might be the key to a HashMap
of your data model, or it might be the primary key for your database, or something.
Then, your <????>
do not come from the Marker
directly, but from your real data model, where the Marker
just has the identifying information to tie the two together.
Google map v2 Custom Infowindow with two clickable buttons or ImageView
What you are trying to achieve is possible.
You can see the recipe in this answer: https://stackoverflow.com/a/15040761/2183804
And a working implementation on Google Play.
Custom Info Window for Google Maps v2
try this code,you need to change the default layout frame,you need to set the your inflate view in getInfoWindow()
// Use default InfoWindow frame
@Override
public View getInfoWindow(Marker arg0) {
View v = getActivity().getLayoutInflater().inflate(R.layout.activity_map, null);
Log.e("View","Sucessful");
return v;
}
// Defines the contents of the InfoWindow
@Override
public View getInfoContents(Marker arg0) {
return null;
}
you have the inflate the view in default contents layout,so change to inflate the views.
Related Topics
Android Fade in and Fade Out with Imageview
Reading a JSON File in Android
Drawerlayout Double Drawer (Left and Right Drawers Simultaneously)
Launching Custom Android Application from Android Browser/Chrome
Pass Arraylist from One Activity to Other
How to Create Custom Baseadapter for Autocompletetextview
Service Not Available - Geocoder Android
How to Fix Android.Os.Deadobjectexception Android X
Android: Can You Nest Fragments
Dex Error on Android Studio 3.0 Beta4
Phonegap - Forcing Landscape Orientation
Removecallbacks Not Stopping Runnable