kartena / Proj4Leaflet

Smooth Proj4js integration with Leaflet.
http://kartena.github.io/Proj4Leaflet/
BSD 2-Clause "Simplified" License
589 stars 173 forks source link

L.Proj.geoJson (null ... #76

Closed muhammadm closed 6 years ago

muhammadm commented 10 years ago

Trying to not have to wait for my data to load I was attempting to do the following ...

var geoLayer = L.Proj.geoJson(null, { pointToLayer: function (feature, latlng) {

});

$.getJSON("data.geojson", function (data) { geoLayer.addData(data); });

But it fails to work.

The only way I can get the Projection to work is to load the geojson in a variable and do an asych:false call.

var geojson
$.ajax({
    url: 'data.geojson',
    async: false,
    dataType: 'json',
    success: function (response) {
        geojson = response;
        $("#loading").hide();
}
});

Then this works wonderfully: var geoLayer = L.Proj.geoJson(geojson, { pointToLayer: function (feature, latlng) { ......

});

Any work around?

perliedman commented 6 years ago

This issue should have been closed by #77. Feel free to tell me if this is still an issue in latest Proj4Leaflet.