get external jsonp and convert coordinates in leafletjs

المشرف العام

Administrator
طاقم الإدارة
I need to solve two problems:

  1. convert my coordinates from wgs84 to epsg28992
  2. use external geojson from an jsonp url
Both problems are as far as I understand not supported by Leaflet itself. So I took a deep dive to found alternative methods.

The content of the jsonp looks like:

getmyjson({"type":"FeatureCollection","features":[ { "type":"Feature", "properties":{"waarde":72.000000, "code":"002002", "klasse":1, "aant_min_stap":0, "stapgrootte":50.000000, "aant_stappen":4}, "geometry":{"type":"Point", "coordinates":[129544.434902 , 512753.813614]} },..... { "type":"Feature", "properties":{"waarde":54.000000, "code":"BDV032", "klasse":1}, "geometry":{"type":"Point", "coordinates":[117763.299998 , 503647.849492]} }]});The first problem (convert coordinates) I solved by using jquery: Result

relevant code:

function getmyjson(data) { geojsonLayer.addData(data); } $.getJSON("rdtest.json", function(data) { var geojsonLayer = L.geoJson(data, { pointToLayer: function (feature, latlng) { latlngnw=RdWgs84(latlng.lng,latlng.lat) return L.circleMarker(latlngnw,{}) } }); geojsonLayer.addTo(map); });The second problem (use external jsonp) I solved by using the plugin leaflet-ajax: Result

relevant code:

function getmyjson(data) { geojsonLayer.addData(data); geojsonLayer.addTo(map); } var geojsonLayer = new L.GeoJSON.AJAX(["wgs84test.jsonp"], { dataType:"jsonp", callbackParam:"getmyjson", });What I want now is to combine both solutions and I have no clue how to do that. Can anyone help me out ?



أكثر...
 
أعلى