Search code examples
performanceopenlayerskmlregionlevel-of-detail

OpenLayers support for Level of Details in KML


Does OpenLayers support toggling visibility of regions based on Level of Details tag (<Lod/>)? As far as I researched and tried, none of the example KML from the reference mentioned works on OpenLayers/Google Maps. You may also be interested in similar question regarding LoD in gmaps, which suggests that nobody cares about level of details support, thus the questions:

  • Has anyone found any living proof that level of details actually have ever been working?
  • If not, has anybody any clue how to make use of KML regions, if they will still be loaded to the browser all at once?
  • If still not - do you know any way to solve the problem of loading plenty of features (>100000) in a smart and efficient way using KML? Or maybe the "officially supported" solution should be dropped for some custom implementation like zoom in/out events handling and manually toggling features' visibility?

Solution

  • Open Layers does not support level of detail in KML. As you will have noticed, performance is horrific above a certain number of features -- this is not a failure of OpenLayers, but of existing browser rendering and DOM traversal issues. The advent of webGL will no doubt improve this greatly.

    OpenLayers has something called a cluster strategy to get round this issue, whereby points are clustered together as you zoom out, based on various parameters you set: see http://openlayers.org/dev/examples/strategy-cluster.html making the rendering much faster.

    If you have more control over where the data is coming from, you could make different layers server side and load them as separate vector layers in OpenLayers, but with different maxResolution levels to control whether they are drawn or not.

    As sfletche has suggested, you could also pre-render the kml into tiles at different zoom levels or create a wms, so that the work is done server side and you just end up with a raster. This approach will not help you much if you actually need to query those features client side.

    Without knowing a bit more about you set up and usage requirements, it is hard to make firm recommendations.