I just added the GeoJSON vector layer in Leaflet for my hybrid mobile app using PhoneGap, the problem is that when I add the GeoJSON file of size larger than 2MB the application crashes.

What is the problem can larger GeoJSON files not be loaded this way?

The code for loading GeoJSON file in my map window is below:

var roadStyle = {
     color: "#00ff00",
     weight: 3  
var roads = [geojson]; //GeoJSON data is added in roads variable
L.geoJson(roads, {
 style: roadStyle
  • Is that possible for you to share the GeoJSON file somewhere so we can test it? Your code looks OK so I guess the issue might comes from the GeoJSON file – Vanni Zhang Aug 7 '14 at 4:10
  • I have tested GeoJSON file in web page and it renders the map, but the page get slow as I load it. But when I limit the features from around 5000 to 3000 it works smoothly. so may be the issue is in loading many features in map. – Ahmed Aug 7 '14 at 4:17
  • That makes sense, maybe you can try to simplifies the geometry of your GeoJSON file by using some software like QGIS to improve the performance. – Vanni Zhang Aug 7 '14 at 4:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.