0
我很努力让谷歌地图显示存储在GeoJSON对象中的数据。如果我在多边形上使用点击事件,它首次运行。代码如下:谷歌地图GeoComplete与GeoJson
// Get the GeoJSON file from the server
HTTP.get(Meteor.absoluteUrl("/geo.json"), function(err,result) {
GoogleMaps.maps.fibreMap.instance.data.loadGeoJson("/geo.json");
});
// Add style and colouring to the map
GoogleMaps.maps.fibreMap.instance.data.setStyle(function(feature) {
// Get the Fibrehood Status
var status = feature.getProperty('status');
// Add colour accoring to status
if (status == "live") {
opacity = 0.65;
} else if (status == "build") {
opacity = 0.4;
} else if (status == "register_i") {
opacity = 0.2;
}
// Return the correct styling
return ({
fillColor: '#ec008c',
strokeColor: '#ec008c',
strokeOpacity: 0.35,
strokeWeight: 0,
fillOpacity: opacity
});
});
GoogleMaps.maps.fibreMap.instance.data.addListener('click', function(event) {
var hood = event.feature.getProperty('name');
var status = event.feature.getProperty('status');
console.log(hood + " : " + status);
});
但是,当试图使用GeoComplete删除地址上的一个引脚,它不会运行。我知道这应该由某种事件触发,比如地图上的标记或Dom元素改变,但我无法弄清楚。
有没有人有任何洞察到如何从DOM触发事件或将标记放到地图上?我有点小菜,真的很感谢任何帮助。
感谢 迈克
是否有'geo.json'和geocomplete之间的关系?我不相信你可以通过谷歌以外的其他地址定位地址 – amenadiel