我正在尝试制作一个显示红色区域的Google Map或MyMap。我知道我需要来自我国(法国)的地区坐标;我找到了this link to download GADM data。
但是这个文件怎么办?我如何从中获取坐标?
我知道之后的步骤,使用坐标,我需要使用this utility。
答案 0 :(得分:1)
您是否尝试将Google地图添加到网站?如果是这样,您可以使用Google Maps API创建地图并添加KML图层,如下所示:https://developers.google.com/maps/documentation/javascript/examples/layer-kml
我根本不会使用折线实用程序。从您在KMZ格式中找到的网站下载相应级别(从0到5)所需的数据,将其解压缩以提取KML并将其用作Google Maps API的图层来源。
如果您的主题与数字地图有关https://gis.stackexchange.com/,您可以更快地获得答案。
见这个简单的例子:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<title>Regions of France</title>
<style>
#map {
height: 100%;
}
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 6,
center: {lat: 47.147583, lng: 2.420839}
});
var ctaLayer = new google.maps.KmlLayer({
url: 'http://evnica.com/kml/France5.kml',
map: map
});
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap">
</script>
</body>
</html>
请注意,您需要拥有Google API密钥。此示例中使用的KML文件的链接是临时的。如果您想使用此文件,请下载并将其托管在您的服务器上。