Specific way of selecting a location on a google map

早过忘川 提交于 2019-12-25 08:18:16

问题


I've inherited a small project. The person before me created a native app for iPhone, implemented in objective-c, and my job is to remake it as a webapp with PhoneGap for iOS and Android.

In my predecessor's original implementation, part of the app has the functionality of allowing the user to drop a marker on a map to select a location. I found a comparable way of doing this, but the supervisor wants the exact way she'd done it, which I'm having a little trouble with. Let me describe:

In her native app, the map appears with a marker in the center of it. The user then slides the map around beneath the marker (which stays in place on the screen), until the marker is positioned over the spot they want. Then they hit a button marked "Select," and those coordinates are sent to the app for irrelevant other operations.

I'm trying to do the exact same thing with the google-maps javascript api and html/css, and I can't figure it out. Do any of you Gmaps pros have any ideas?


回答1:


You may observe the center_changed-Event of the map. When it fires set the position of the marker to the new center of the map.


Another suggestion:

For a better effect instead of a marker you may use a custom control. You may insert a marker-image there so it will look like a marker. To place it in the center, push the control to

map.controls[google.maps.ControlPosition.RIGHT_CENTER] 

(it will be vertically centered then) and apply the horizontal centering by adding a right-margin to the control



来源:https://stackoverflow.com/questions/9855718/specific-way-of-selecting-a-location-on-a-google-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!