Boris D. Teoharov Boris D. Teoharov - 13 days ago 8
Javascript Question

Google maps api-3: Change polygon's default cursor

I can change the map's draggableCursor for example but I even if I change it polygon's cursor is still pointer since the map is behind polygons. I would like to set the polygon's cursor to 'move' so as to be clear that polygon is draggable.

What is the proper way to change polygon's cursor? Is there a property or method to do it? (Ive read Google's documentation but I didnt find anything)

ps.
I have reason to use Polygon over Polyline so Polyline is not an option.

Answer

Actually it seems to be possible. Here is the idea.
css:

.moving,
.moving * {cursor: move !important;} 

js:

google.maps.event.addListener(myPolygon, 'mousemove',
    function(e) {
        if (!isNaN(e.edge) || !isNaN(e.vertex))
            mapCanvas.className = '';
        else
            mapCanvas.className = 'moving';        
    }
);

google.maps.event.addListener(myPolygon, 'mouseout',
    function() {
        mapCanvas.className = '';
    }
);

Cheers!