可拖动的谷歌地图标记
我一直在使用谷歌地图,现在需要制作一个可以放置在地图上的可拖动标记。
这与仅通过地理位置坐标放置标记在复杂性上有很大差异吗?制作用户可以设置的可拖动标记的最佳方法是什么?
谢谢你, 亚历克斯
I have been working with google maps and now have a requirement to make a draggable marker that I can place on the map.
Is this a big difference in complexity from just placing markers by geolocation coordinates? What is the best way of going about making draggable markers that users can set?
Thank you,
Alex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你没有提到你正在使用哪个版本的 API,所以我假设 v3...有一个可拖动属性,你可以使用选项参数“draggable: true”在构造函数中设置,也可以通过调用 setDraggable(true)创建后的功能。
检查 http://code.google.com/apis/maps/ Documentation/javascript/reference.html#Marker 了解更多信息。
编辑:对于版本2,有enableDragging()和disableDragging()函数...
至于添加标记,也许订阅地图上的鼠标单击事件,然后在其中添加一个标记。坐标作为事件参数的一部分传递到事件处理函数中。
You dont mention which version of the API you are using, so i will asume v3... There is a draggable property that you can either set in the constructor using the options parameter 'draggable: true' or by invoking the setDraggable(true) function after it is created.
Check http://code.google.com/apis/maps/documentation/javascript/reference.html#Marker for more info.
Edit: For version 2 there are enableDragging() and disableDragging() functions...
As for adding markers, perhaps subscribe to the mouse click event on the map, and then add a marker in there. The coordinates are passed into the event handling function as part of the event parameter.