Skip to content

Instantly share code, notes, and snippets.

@stepankuzmin
Created January 30, 2014 13:28
Show Gist options
  • Save stepankuzmin/8708285 to your computer and use it in GitHub Desktop.
Save stepankuzmin/8708285 to your computer and use it in GitHub Desktop.
Leaflet — wrap GeoJSON around date line (antimeredian)
var map = L.map('map').setView([50, 100], 2);
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {continuousWorld: false}).addTo(map);
$.getJSON("data/russia-federative-division-0.1.geojson", function (data) {
L.geoJson(data, {
coordsToLatLng: function (coords) {
longitude = coords[0];
latitude = coords[1];
var latlng = L.latLng(latitude, longitude);
if (longitude < 0) {
return latlng.wrap(360, 0);
}
else
return latlng.wrap();
}
}).addTo(map);
});
@phpmind
Copy link

phpmind commented Jan 15, 2017

What is this wrap() function. I am getting error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment