开发者

How to add a combobox and a button to the infoWindow on Google map?

开发者 https://www.devze.com 2022-12-18 22:51 出处:网络
Currently, I\'m developing an application, in which I have to show an infoWindow on click event on map itself.

Currently, I'm developing an application, in which I have to show an infoWindow on click event on map itself.

My question is I w开发者_Python百科ant to show a button as well as a combobox on this infoWindow. How can I do this?


You need to add a custom UIView to your MKMapView and supress the default MKAnnotation callout view. Your custom UIView can include the controls you want in the callout.

You might find the following useful:

  • customize callout bubble for annotationview?
  • A development blog with some posts on customizing MKMapView.

I don't think either of these posts describe a definitive, clean solution to your problem (scrolling problem with the subview position). I suggest you re-think your UI and consider pushing an entirely new view from the standard callout right disclosure button. I feel like customizing the callout (infoWindow equivalent) doesn't translate well to the iPhone platform.

Edit:

Ok. So all you want to know is how to show a check box in an infoWindow using the regular Google Maps Javascript API?

That is a much easier question. If you have a look at the GMarker openInfoWindow, you will find that the first paramter to this method is a string. This string needs to be populated with the HTML that you would like in your infoWindow. So for your checkbox and button you need an input element of type checkbox and button:

<input type="checkbox" name="vehicle" value="Airplane" />
<input type="button" value="Blah" />


Why don't you use the content attribute of InfoWindow itself?

myWindow = new google.maps.InfoWindow({
    content:'<input type="checkbox" name="vehicle" value="Airplane" /><input type="button" value="Blah" />',
});

myWindow.open(map, marker);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号