I am trying to get GeoJSON data from an API URL to an overlay.
Code;
// - GET GEOJSON DATA WITH AJAX TO OVERLAY REGION - //
// Get the data
var regions = $.ajax({
url:"https://public.opendatasoft.com/api/records/1.0/search/?dataset=sverige-lan-counties-of-sweden&q=&lang=en&rows=37&start=0&facet=id&facet=lan_namn&facet=geo_point_2d",
dataType: "json",
success: console.log("Data successfully loaded!"),
error: function (xhr) {
alert(xhr.statusText)
}
})
$.when(regions).done(function() {
var regions = document.getElementById('lan_namn');
L.geoJSON(regions, {
pointToLayer: function (latlng) {
return L.circleMarkers(latlng, {
radius:6,
opacity: .8
})
.bindPopup("<p><b> " + records.fields.lan-namn + "</b></p>");
}
})
});
regions.addLayer(regions);
{
"nhits": 21,
"parameters": {},
"records": [
{
"datasetid": "sverige-lan-counties-of-sweden",
"recordid": "2bf8cfbfbd622b8d44987da4a8fdc5f957d2ed01",
"fields": {
"geo_shape": {},
"id": "08",
"lan_namn": "Kalmar län",
"geo_point_2d": [
57.2009990015,
16.1929043382
]
},
"geometry": {
"type": "Point",
"coordinates": [
16.1929043382,
57.2009990015
]
},
"record_timestamp": "2019-07-15T12:39:19.034000+00:00"
},
{
"datasetid": "sverige-lan-counties-of-sweden",
"recordid": "b55c4a362b22739db2cdc4896ce10d1be93feb7c",
"fields": {
"geo_shape": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
15.401945130895863,
62.00965766023548
]
............