Google maps v3 polyline tooltip

前端 未结 4 2441
我在风中等你
我在风中等你 2021-02-20 15:08

A google maps marker object (google.maps.Marker) has a title property, so when a user moves their mouse over the marker a simple tooltip is displayed.

There isn\'t a tit

4条回答
  •  说谎
    说谎 (楼主)
    2021-02-20 15:44

    I am not 100% this is the only way, or the best way, but it is a way to create a window over your Polyline

    In Google maps V3, you should to create an InfoWindow then set the content using myInfoWindow.setContent("Hello World!")

    In order to make it show on mouseover, you will need to do something like:

    
    google.maps.event.addListener(myPolyline, 'mouseover', function() {
        myInfoWindow.open(mymap);
        // mymap represents the map you created using google.maps.Map
    });
    
    // assuming you want the InfoWindow to close on mouseout
    google.maps.event.addListener(myPolyline, 'mouseout', function() {
        myInfoWindow.close();
    });
    
    

提交回复
热议问题