在谷歌地图上选择位置的具体方式 [英] Specific way of selecting a location on a google map

查看:170
本文介绍了在谷歌地图上选择位置的具体方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了一个小项目。之前的人为iPhone创建了一个原生应用程序,以objective-c实现,我的工作是将其重新制作为iOS和Android版PhoneGap的web应用程序。



我的前任的原始实现,部分应用程序具有允许用户在地图上放置标记以选择位置的功能。我发现了一个可以比较的方式,但是主管希望完成它的确切方式,因此我遇到了一些麻烦。让我来描述一下:

在她的本地应用中,地图的中心会出现一个标记。然后用户将地图滑动到标记下面(该标记停留在屏幕上),直到标记定位在他们想要的位置上。然后他们点击一个标记为选择的按钮,这些坐标被发送到应用程序进行无关的其他操作。



我正在尝试使用谷歌地图的JavaScript API和HTML / CSS,我无法弄清楚。您是否有任何Gmaps专业人士有任何想法?

您可能会观察 center_changed - 地图。当它触发时,将标记的位置设置为地图的新中心。






另一个建议:



为了取得更好的效果,您可以使用自定义控件。你可以在那里插入一个标记图像,使它看起来像一个标记。要将它放在中间,请将控件按
$ p $ map $ control $ b

(它将以垂直居中为准),并通过向控件添加右边距来应用水平居中。 p>

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?

解决方案

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

这篇关于在谷歌地图上选择位置的具体方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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