在谷歌地图上选择区域或国家的边界

8

我希望能够像Google Maps一样选择县或区域 http://maps.google.com/。 我的意思是这样的:

enter image description here

是否可以使用Google Maps API实现?是否可以选择更多的区域?

3个回答

1

1
是的,但我需要选择非美国地区,并且我想使用与已显示的边界完全匹配的谷歌数据(虚线)。 - michaltaberski
1
在问题中说明这一点会有所帮助,而不是演示单个美国州。只有当您拥有数据时,才能绘制边框。至少有一个类似的问题。 - Andrew Leach

0

我是通过使用GEOJSON文件完成的。

我的JS代码:

function initMap2() {

            map = new google.maps.Map(document.getElementById("map"), {
                zoom: 13,
                mapId: "", // add map id here
                center: {lat: 41.015137, lng: 28.979530},
                //center: { lat: 20.773, lng: -156.01 },

            });
            map.data.loadGeoJson(
                "https://raw.githubusercontent.com/ozanyerli/istanbul-districts-geojson/main/istanbul-districts.json"
            );

            map.data.setStyle({
                fillColor: '#810FCB',
                strokeWeight: 1,
                fillOpacity: 0.5
            });


        }

我使用以下JSON获取伊斯坦布尔的JSON数据:

https://raw.githubusercontent.com/ozanyerli/istanbul-districts-geojson/main/istanbul-districts.json

0

Google已开始以醒目的颜色突出显示搜索区域。

API中不可用。

(将来可能会提供。Google Maps的功能会迁移到API中,但Google不会提前宣布)

您需要找到城市边界并通过叠加层自己绘制线条。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接