如何向Google地图上的infoWindow添加组合框和按钮? [英] How to add a combobox and a button to the infoWindow on Google map?

查看:263
本文介绍了如何向Google地图上的infoWindow添加组合框和按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在开发一个应用程序,其中我必须在地图本身的点击事件上显示一个infoWindow。

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

我的问题是我想在这个infoWindow上显示一个按钮以及一个组合框。
我如何做到这一点?

My question is I want to show a button as well as a combobox on this infoWindow. How can I do this?

推荐答案

您需要向您的 MKMapView 添加自定义<支持默认的 MKAnnotation 标注视图。

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.

我不认为这些帖子都描述了一个明确的,干净的解决方案子视图位置)。我建议你重新考虑你的UI,并考虑从标准的宣传权利公开按钮推出一个全新的视图。我觉得自定义标注(等同于infoWindow )不能很好地翻译到iPhone平台。

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:

好的。因此,您只需要知道如何使用在infoWindow中显示一个复选框常规Google Maps Javascript API

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

这是一个更容易解决的问题。如果您查看 GMarker openInfoWindow ,您将发现这个方法的第一个参数是一个字符串。此字符串需要使用您希望在您的 infoWindow 中的HTML填充。因此,对于您的复选框和按钮,您需要一个类型为复选框按钮元素

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" />

这篇关于如何向Google地图上的infoWindow添加组合框和按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆