admin管理员组文章数量:1391937
I want to put labels with information (or a div with a label) on polygons which are drawn by the below code fragment. Style attributes were applied successfully to the features (of type Polygon). Does anybody know how add text to this features which will be shown on the centre of the polygons?
function handleGeoJson(data) {
map.data.addGeoJson(data);
map.data.setStyle(function(feature) {
if (feature.getProperty('isColorful')) {
color = feature.getProperty('color');
}
return /** @type {google.maps.Data.StyleOptions} */( {
fillColor : color,
strokeColor : color,
strokeWeight : 1,
});
});
map.data.setStyle(featureStyle);
}
I want to put labels with information (or a div with a label) on polygons which are drawn by the below code fragment. Style attributes were applied successfully to the features (of type Polygon). Does anybody know how add text to this features which will be shown on the centre of the polygons?
function handleGeoJson(data) {
map.data.addGeoJson(data);
map.data.setStyle(function(feature) {
if (feature.getProperty('isColorful')) {
color = feature.getProperty('color');
}
return /** @type {google.maps.Data.StyleOptions} */( {
fillColor : color,
strokeColor : color,
strokeWeight : 1,
});
});
map.data.setStyle(featureStyle);
}
Share
Improve this question
edited Oct 21, 2017 at 18:49
Brian Burns
22.2k10 gold badges93 silver badges79 bronze badges
asked Sep 19, 2014 at 9:23
DehMotthDehMotth
6893 gold badges13 silver badges22 bronze badges
2
- related question Google Maps Javascript API v3 Map Label and Polygons – geocodezip Commented Sep 19, 2014 at 12:33
- 1 related question Google Maps get the center of coordinates – geocodezip Commented Sep 19, 2014 at 12:33
1 Answer
Reset to default 3If you have a way to get the center of your polygon (like this answer, or with preprocessing your data), the Google Maps Map Label library can be used to put your text at that point on the map.
本文标签: javascriptPut label on Google Maps polygon received by GeoJson dataStack Overflow
版权声明:本文标题:javascript - Put label on Google Maps polygon received by GeoJson data - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744730379a2622013.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论