How do i open different information for each polygon i've created? Google maps api v3

后端 未结 1 991
野性不改
野性不改 2020-12-20 05:46

Here is the code i\'m currently running: The user is able to create their own polygon after their polygons are shown on the map i want to display some information about ever

相关标签:
1条回答
  • 2020-12-20 06:15

    One way to associate the infoWindow contents with the polygon is to use function closure, as done in this example (see the createClickablePoly function). If you don't need a clickable sidebar, you can simplify that function to:

    function createClickablePoly(poly, html) {
        var contentString = html;
        google.maps.event.addListener(poly,'click', function(event) {
          infowindow.setContent(contentString);
          infowindow.setPosition(event.latLng);
          infowindow.open(map);
        }); 
    }
    
    0 讨论(0)
提交回复
热议问题