I already have asked how to reduce file size and increase performance for publishing spatial data on the web using Leaflet, here.

A conversion to TopoJSON has reduced the file size by approximately 10x, which is awesome, and I thought that would solve both of my problems and world would come to peace.

Never have I been so wrong. (in the voice of Bilbo Baggins)

The problem is, when the map is zoomed, I have to wait a while before my polygons come to resolution. Until then, the map freezes and cannot be panned or done anything for about 3-4 seconds. If I overclick the map in this interval, the Chrome tab crashes.

This also happened when using GeoJSON, because I am using this client-side API that converts TopoJSON into GeoJSON within the browser. Thus, using TopoJSON reduces transferred data but does not increase the performance, because basically the browser is still reading data from the bulky GeoJSON, but I just don't see it. It's still taking up 10 times the file size of TopoJSON in the RAM, which explains the freezing.

Which Plugin can draw TopoJSON right within Leaflet without conversion, so that a lot of space frees up on RAM?

Thanks in advance.

EDIT: Although I upvoted R.K.'s answer, I still am in search for a decent plugin.

  • What exactly is your question here? – Devdatta Tengshe Feb 23 '14 at 3:16
  • "...draw topoJson right within Leaflet without conversion". I'm looking for a suitable plugin to handle this. – Doruk Karınca Feb 23 '14 at 12:13

There's this Leaflet plugin called omnivore that adds support for multiple formats like csv, kml, gpx, wkt and topojson. Hopefully, that will solve your problem. Good luck :)

enter image description here

  • Thanks, but the plugin is at version 0.0.1 so it's not surprising why it's throwing errors to my console all the time. On the other hand, I couldn't find any documentation to "style" the polygons, even on Mapbox Examples here. I suppose I'll stick to learn how to use D3 and SVG instead of Leaflet's built-in renderers. – Doruk Karınca Mar 5 '14 at 16:27
  • From topojson API : The client API supports conversion from TopoJSON (to GeoJSON) for display in a browser. The server API supports conversion to TopoJSON (from various formats), as an alternative to the command-line tool. – Hugolpz May 15 '14 at 19:53

What size both mb, features and vertices is your layer? If it's crashing your browser it must be +10mb - just read your initial post - 56mb!! There is a limit to client-side rendering. Have you simplified using mapshaper?

You could look into tilemill and mbutil to create your own tiles and serve them yourself. It will work.

That said you can use geojson-vt to convert large geojson/topojson polygons into vector tiles, which once created on initial load render very well, up to maybe 50k polygons or so.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.