我试图在power Bi web中嵌入的传单地图上渲染一些点。提交给Leaflet的数据采用GeoJSON格式。 当我输入这些数据时,一切正常,点正确显示:
var someFeatures = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-75, 34]
},
"properties": {
"name": "Location A"
}
}
]
}
然后我尝试插入我的数据,这只是一个纬度和经度。 这是我正在运行的代码片段:
function onEachFeature(feature, layer) {
var popupContent = "<p>I started out as a GeoJSON " +
feature.geometry.type + ", but now I'm a Leaflet vector!</p>";
if (feature.properties && feature.properties.popupContent) {
popupContent += feature.properties.popupContent;
}
layer.bindPopup(popupContent);
}
var dat = Visual.converter(options.dataViews[0].table.rows); //just converts the data to lat lon format
var test = GeoJSON.parse(dat, {Point: ['lat', 'lon']})
L.geoJSON([test], {
style: function(feature) {
return feature.properties && feature.properties.style;
},
onEachFeature: onEachFeature,
pointToLayer: function(feature, latlng) {
return L.circleMarker(latlng, {
radius: 8,
fillColor: "#ff7800",
color: "#000",
weight: 1,
opacity: 1,
fillOpacity: 0.8
});
}
}).addTo(this.map);
我非常确定数据是以正确的格式转换的,如开发人员控制台所示:
任何帮助都非常感激,因为我无法弄清楚如何解决这个问题。
编辑:浏览器控制台输出是变量“test”的内容,其中填充了以下输出:GeoJSON.parse(dat,{Point:['lat','lon']})其中“dat”是包含纬度和经度的原始数据。