Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I had my map working with worldCopyJump set to true, but then it stopped working. I'm not sure exactly what broke it (the original form of this question said there was a connection to a plugin, but that doesn't seem to be the case), but it might be that I updated to Leaflet 0.62.

In any case, this is the problem: when the map loads, dragging the map would throw a bunch of errors claiming to have invalid LatLong objects (with a NaN instead of the longitude), and the map would freeze.

Oddly enough, if before dragging the map I zoomed in or out, and then dragged, everything would work fine. Whatever the map is doing during onzoom seems to be somehow fixing whatever problem it had.

Also peculiar is the LatLongs that are reported to be invalid: they are nowhere in the code. I have no idea where those numbers might be coming from.

I traced the error back to the worldCopyJump option. If this is set to false then the map works from the get go. But I need that option turned on. Can anybody think of what might be going on?

You can find a (non-)functional version of the map online here.

In case that does not last, here's the code:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.2/leaflet.css" />
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
  <script src="http://cdn.leafletjs.com/leaflet-0.6.2/leaflet.js"></script>
  <style>
    html, body, #map { width: 100%; height: 100%; margin: 0; padding: 0; }
  </style>
</head>
<body>
<div id="map"></div>
<script type="text/javascript">
  var map = L.map('map',{
        center: [35.67989, 139.76463],
        zoom: 2,
//         Set followign line to false or comment out to fix problem
        worldCopyJump: true,
      }
    );

  L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png', {
    key: "YOURCLOUDMADEKEY",
    styleId: 97789,
    maxZoom: 18
  }).addTo(map);

  L.marker([50.5, 30.5]).addTo(map);
</script>
</body>
</html>
share|improve this question
    
Turns out this has nothing to do with the MarkerCluster plugin in the end. I still have no idea why it's not working, but I kept on trimming down the code, removed the GeoJSON, removed the references to the plugin, even removed the layer control... all to no avail. I updated the code in the question to reflect these changes, and the online version has them as well. Still lost though... –  jja Jul 4 '13 at 21:41
    
Indeed, going back to Leaflet 0.5 fixes the problem. Not sure if this is a bug or if I'm using something wrong, though... –  jja Jul 4 '13 at 21:59
    
Filed a bug report and a solution has been added. See github.com/Leaflet/Leaflet/pull/1833 –  jja Jul 5 '13 at 10:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.