i am trying to render some points on a leaflet map embedded in power Bi web. The data submitted to Leaflet is in GeoJSON format. When i input this data everything works fine and the point is correctly displayed:
var someFeatures = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-75, 34]
},
"properties": {
"name": "Location A"
}
}
]
}
I then tried to insert my data, which is simply a couple Latitude and Longitude. Here is the code snippet that i'm running:
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);
I'm pretty sure the data is converted in a correct format, as shown by the developer console:
Any help is super appreciated, as i cannot figure out how to solve this issue.
EDIT: The browser console output is the content of the variable "test" getting filled with the output of : GeoJSON.parse(dat, {Point: ['lat', 'lon']}) Where "dat" is the raw data that contains latitude and longitude.