1

I wanna simply get markers from a kml file and show them on a map, but add "mouseover" for tooltip, not click

using this code, but it don't work (works if i use click)

function initialize() {
    var latlng = new google.maps.LatLng(53.477876, -2.471289);
    var myOptions = {
      zoom: 5,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    //kml begin
    var nyLayer = new google.maps.KmlLayer('http://code.nebtron.com/kml2.kml', {suppressInfoWindows: false});
    nyLayer.setMap(map);
    google.maps.event.addListener(nyLayer, "mouseover", function(kmlEvent) {
      var text = kmlEvent.featureData.description;
      showInDiv(text);
    });

    function showInDiv(text) {
      var sidediv = document.getElementById('contentWindow');
      sidediv.innerHTML = text;
    }//kml end

  }

Demo: http://code.nebtron.com/map3.php

Ron
  • 22,128
  • 31
  • 108
  • 206
Nabeel Khan
  • 3,715
  • 2
  • 24
  • 37
  • You should try the approach [in this post](http://stackoverflow.com/questions/5429444/google-maps-api-v3-event-mouseover-with-infobox-plugin). [1]: http://stackoverflow.com/questions/5429444/google-maps-api-v3-event-mouseover-with-infobox-plugin – Col Wilson Dec 02 '11 at 08:54

1 Answers1

1

As pointed out here, there is no mouseover event for KMLLayers. But maybe you could use a polygon. Here's a link.

Hope this helps!

Community
  • 1
  • 1
Ron
  • 22,128
  • 31
  • 108
  • 206