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



Solution 1:[1]

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!

Solution 2:[2]

Building on the answer given by Boris D. Teoharov, this is neater (uses jQuery), uses the exact same cursor as the rest of the map (with a passable fall-back), and still allows the cursor to change over markers:

CSS:

.moving div { cursor: url('https://maps.gstatic.com/mapfiles/openhand_8_8.cur'), grab; }

JS:

map.data.addListener('mouseover', function() {
    $('#map-container-id').addClass('moving');
});

map.data.addListener('mouseout', function() {
    $('#map-container-id').removeClass('moving');
});

Solution 3:[3]

You can set a CSS cursor !important on the div #map, but it always overrides your custom cursor.

#map div
{
    cursor: url("your.url.to.cursor.png"), default !important;
}

Solution 4:[4]

map.getDiv() can be used to implement this.

const polygon = new window.google.maps.Polygon({ map: map, clickable: true });
window.google.maps.event.addListener(polygon, 'mousemove', e => {
    map.getDiv().firstChild.firstChild.childNodes[1].style.cursor = 'copy';
});

Solution 5:[5]

on mouse event for polybon and map do this:
cursor over map:

document.getElementById("map").children[0].children[0].style.cursor = 'url(res/end.png), auto';

cursor over polygon:

document.getElementById("map").style.cursor = 'url(res/end.png), auto';

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2
Solution 3 zx485
Solution 4 Brain Art
Solution 5 C Travel