在 Google 地图 API 上删除 GeoJSON 绘制的多边形中的轮廓并增加不透明度
Removing outline and increasing opacity in GeoJSON drawn polygons on Google Maps API
我正在研究利用 Google 地图 API 使用 GeoJSON 绘制 n
数量的多边形。我绘制成功了,但我还想增加绘制的多边形的 opacity
,以及删除每个多边形上的丑陋轮廓。
我查看了 Google 地图 API here 上的文档,但它只告诉你如何加载 GeoJSON 文件,而不是修改绘制多边形的特征。
map.data.loadGeoJson('google.json');
上面是加载 GeoJSON 的方式和唯一可以使用的命令。我知道我似乎没有尝试过任何东西,但我已经 none 足够大,可以包含在这个问题中。
所以我的问题是 - 如何从 GeoJSON 绘制的图像中删除轮廓并增加不透明度?
下面也是它目前的样子:
在样式选项中使用 fillOpacity: 1
和 strokeWeight: 0
https://plnkr.co/edit/puMK8mAskLiaExmNKIEI?p=preview
<!DOCTYPE html>
<html>
<head>
<title>Data Layer: Styling</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: {lat: -28, lng: 137}
});
// Load GeoJSON.
map.data.loadGeoJson(
'https://storage.googleapis.com/mapsdevsite/json/google.json');
// Set the stroke width, and fill color for each polygon
map.data.setStyle(function(feature) {
var color = feature.getProperty('color');
return {
fillColor: color,
fillOpacity: 1,
strokeWeight: 0
};
});
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?callback=initMap">
</script>
</body>
</html>
我正在研究利用 Google 地图 API 使用 GeoJSON 绘制 n
数量的多边形。我绘制成功了,但我还想增加绘制的多边形的 opacity
,以及删除每个多边形上的丑陋轮廓。
我查看了 Google 地图 API here 上的文档,但它只告诉你如何加载 GeoJSON 文件,而不是修改绘制多边形的特征。
map.data.loadGeoJson('google.json');
上面是加载 GeoJSON 的方式和唯一可以使用的命令。我知道我似乎没有尝试过任何东西,但我已经 none 足够大,可以包含在这个问题中。
所以我的问题是 - 如何从 GeoJSON 绘制的图像中删除轮廓并增加不透明度?
下面也是它目前的样子:
在样式选项中使用 fillOpacity: 1
和 strokeWeight: 0
https://plnkr.co/edit/puMK8mAskLiaExmNKIEI?p=preview
<!DOCTYPE html>
<html>
<head>
<title>Data Layer: Styling</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: {lat: -28, lng: 137}
});
// Load GeoJSON.
map.data.loadGeoJson(
'https://storage.googleapis.com/mapsdevsite/json/google.json');
// Set the stroke width, and fill color for each polygon
map.data.setStyle(function(feature) {
var color = feature.getProperty('color');
return {
fillColor: color,
fillOpacity: 1,
strokeWeight: 0
};
});
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?callback=initMap">
</script>
</body>
</html>