How can I access property of geojson data inside drawn polygon?I have this example:(我如何访问绘制多边形内的geojson数据的属性?)
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({
fillColor: 'green',
strokeWeight: 1
});
var drawingManager = new google.maps.drawing.DrawingManager({
drawingControl: true,
drawingControlOptions: {
position: google.maps.ControlPosition.TOP_CENTER,
drawingModes: ['polygon']
}
});
drawingManager.setMap(map);
google.maps.event.addListener(drawingManager, 'polygoncomplete', function (polygon) {
var coordinates = (polygon.getPath().getArray());
// Get all features from polygon and geojson common part
}
);
}
https://jsfiddle.net/j0f7ggeg/2/(https://jsfiddle.net/j0f7ggeg/2/)
Each feature contains property like letter, color etc. If I draw a polygon over one (or more) of this letters I want to get properties.(每个要素都包含字母,颜色等属性。如果我在一个(或多个)字母上绘制多边形,则希望获得属性。)
ask by miru87 translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…