开发者

Hand cursor on mouseover KMLLayer in Google Maps

is it possible to sh开发者_JS百科ow hand cursor on mouseover KMLLayer in Google Maps 3?

I see the two solutions (but it seems that they cannot be used):

  1. handle mouseover event for KMLLayer and change cursor in CSS
  2. handle mouseover event for Map and check if cursor's location is contained by KMLLayer

Do you have any other ideas?

Thanks


The kml polygon cannot have a mouseover event so 1. is not possible. As for second i really don't see an easy way out. If you could change the format of the data to something else than kml things would be way better.


You can't have mouseover event, but you can set a click listener onto the layer, which will show the hand cursor.

var layer = new google.maps.KmlLayer('http://...');
google.maps.event.addListenerOnce(layer, 'click', function () {
    // do nothing here
});

Now whenever you mouse over an area defined in the KML it will show the cursor. You can also obtain the location of the mouse (if the user clicks on the KML Layer) because that will generate a KmlMouseEvent which will contain the LatLng of the point they clicked. It will also tell you information about which KML Placemark they clicked. You can then do your calculations here to see if it's contained by the KML Layer you want...


From what I know you can enable/disable cursor pointer in google maps v3 over kml by the option clickable:

var kml = new google.maps.KmlLayer(
kmlUrl,
  {
    suppressInfoWindows: true,
    preserveViewport: true,
    map: null,
    clickable: false
  }
);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜