将Google地图标记拖到地图中心时拖动?

编程入门 行业动态 更新时间:2024-10-17 09:43:02
本文介绍了将Google地图标记拖到地图中心时拖动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在Google地图的中心显示一些十字线。

I'd like to display some crosshairs in the very centre of a Google Map.

目前我有这样的代码:

Currently I have code like this:

var mapCentre = map.getCenter(); reticleMarker = new google.maps.Marker({ position: mapCentre, map: map, icon: reticleImage, shape: reticleShape, optimized: false, zIndex: 5 }); google.maps.event.addListener(map, 'bounds_changed', function(){reticleMarker.setPosition(map.getCenter());});

在桌面上运行良好,但在移动设备上无法运行。在移动时,当用户的手指拖动地图时,十字线不会留在地图的中心。

Works great on a desktop, but not on mobile. On mobile the crosshairs don't stay in the centre of the map while the user's finger is dragging the map.

使用拖动事件监听程序并不会奏效。

Using a drag event listener doesn't work any better.

任何人都可以建议如何在移动浏览器中处理这个问题吗? (作为参考,我在Android浏览器中看到了这个问题。)

Could anyone suggest how to deal with this in mobile browsers? (For reference, I'm seeing this problem in an Android browser.)

我想或许我应该在CSS中显示十字线,而不是地图标记?

I'm thinking perhaps I should display the crosshairs in CSS, rather than as a map marker?

推荐答案

我想或许我应该在CSS中显示十字线而不是地图marker?

I'm thinking perhaps I should display the crosshairs in CSS, rather than as a map marker?

我使用了类似的方法来取得很好的效果。您可以将任何HTML放入地图容器中,Google Maps不会介意。

I've used a similar approach to great effect. You can put any HTML you want in the maps container, Google Maps wont mind.

更多推荐

将Google地图标记拖到地图中心时拖动?

本文发布于:2023-11-25 00:37:35,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:地图   拖动   拖到   标记   中心

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!