问题描述
基本上,我正在向我的MapBox地图添加标记,但我希望该过程是自动的。
我能够对数据库中的geojson文件进行编码,但仍然无法将该数据传递到mapBox标记中。
这是我的代码:
var Markersgeojson = {
type: 'FeatureCollection',features: [{
type: 'Feature',geometry: {
type: 'Point',coordinates: [35.5099,33.8962]
},properties: {
title: 'Gemmayze Holding',description: '#3'
}
},{
type: 'Feature',coordinates: [35.5107,33.8952]
},properties: {
title: 'Mar Mkhayel Residence',description: '#4'
}
}]
};
geojson.features.forEach(function(marker) {
// create a HTML element for each feature
var el = document.createElement('div');
el.className = 'marker';
// make a marker for each feature and add to the map
new mapBoxgl.Marker(el)
.setLngLat(marker.geometry.coordinates)
new mapBoxgl.Marker(el)
.setLngLat(marker.geometry.coordinates)
.setPopup(new mapBoxgl.Popup({ offset: 25 }) // add popups
.setHTML('<h3>' + marker.properties.title + '</h3><p>' + marker.properties.description + '</p>'))
.addTo(map);
});
是否可以将变量Markersgeojson分配给我的geojson文件的数据?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)