将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.