谷歌地图-设置国家的颜色,如果我点击它链接到一个页面

Google Maps - Setting Countries to a Color and if I click on it links to a page

本文关键字:链接 一个 国家 设置 颜色 如果 谷歌地图      更新时间:2023-09-26

我想把特定的国家设置成特定的颜色,然后如果用户点击它,它会打开一个小窗口,里面有一些文本/链接。

下面是我到现在为止的代码:

        <style>
          #map_canvas {
            width: 100%;
            height: 500px;
          }
        </style>
        <script src="https://maps.googleapis.com/maps/api/js"></script>
        <script>
          function initialize() {
            var map_canvas = document.getElementById('map_canvas');
            var map_options = {
              center: new google.maps.LatLng(22.6006017, -3.845206),
              zoom: 2,
              scrollwheel: false,
              mapTypeId: google.maps.MapTypeId.ROADMAP
            }
            var map = new google.maps.Map(map_canvas, map_options)
            google.maps.event.addListener(map, 'click', function(event){
                this.setOptions({scrollwheel:true});
            });
            google.maps.event.addListener(map, 'mouseout', function(event){
                this.setOptions({scrollwheel:false});  
            });
          }
          google.maps.event.addDomListener(window, 'load', initialize);
        </script>
        <div id="map_canvas"></div>
</div>

在v3 Google maps API中考虑使用下面SO对话中的KML样式重写示例。

如何在谷歌地图覆盖KML的颜色?