Strange Cursor Behavior in Google Maps V3

风流意气都作罢 提交于 2020-01-06 08:56:06

问题


I am trying to change my cursor in google maps to the "wait" cursor while I request information from remote servers. This is weather information from international servers and it can sometimes take a long time to return, so I want the user to know that something is going on.

A user clicks on either a marker or a bounding box and then I make the following call to get the data:

map.setOptions({draggableCursor: "wait"});
$.ajax({
    type:"GET",
    dateType:"html",
    url:url,
    cache:false,
    success:function(response){openInfoWindow(response, 1);},
    error:function() 
        {
        map.setOptions({draggableCursor: null});
        displayMessage("badGet",0);
        }
});;

function openInfoWindow(request, ignoreStatus)
{
map.setOptions({draggableCursor: null});
infoWindow = new InfoBox({maxWidth: 0, position: center, disableAutoPan: true});
}

The first thing that I do in openInfoWindow is map.setOptions({draggableCursor: null}), so the cursor should go back to a normal cursor. After that I open an infoWindow with the results.

Here's what I find to be very strange:

1) If I leave the cursor over the marker or within the bounding box, it never switches to the wait cursor. If I move it off of the marker or outside of the bounding box, it functions as expected.

2) If the cursor is positioned over the location where the infoWindow appears, the cursor switches to the wait cursor, but doesn't switch back to the normal cursor until I move the cursor outside of the infoWindow.

3) When the cursor is not over the clicked object or the location of the infoWindow, it doesn't change from "wait" to normal until the cursor is moved.

I suspect that there's something basic that I'm missing with regards to how/when the cursor gets updated. Any enlightenment would be appreciated.

Note that you can see this behavior at http://www.geoffschultz.org/weather_map_2.php by selecting Weather Charts/BBC In-shore Forecast and lots of other places.

-- Geoff


回答1:


I also had to drag or click to get the cursor to change back after

map.setOptions({draggableCursor: null});

Using this instead worked for me as soon as I move the mouse

map.setOptions({draggableCursor: ''});




回答2:


For question 1, you'll need to set the Marker cursor separately from the Map cursor.

Marker.setCursor("wait");

Not sure about the problems with the InfoWindow.



来源:https://stackoverflow.com/questions/12281440/strange-cursor-behavior-in-google-maps-v3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!