V-Leaflet KML

Hi @Matti
How to add KML support to your great add-on?
I am OK with client side loading if that is simpler to do.
I’m not sure how to use available leaflet plugins for this sort of things.

https://github.com/makinacorpus/Leaflet.FileLayer

@Matti
Actually, Shramov extensions plugin supports KML vector layer but only Bing and Google layers are implemented in your add-on’s add-on. Is there any plan to support KML too?

Hi,

I’d really suggest to do this on server side. It can also be much better performing as you can simplify your vectors on the server side without sending all points to the client.

I have used following library to both read and write KML files:

        <dependency>
            <groupId>de.micromata.jak</groupId>
            <artifactId>JavaAPIforKml</artifactId>
            <version>2.2.1</version>
        </dependency>

After you have read in the KML to Java model, then just convert the vectors to v-leaflet format. The only bit tricky part is the custom RGB format KML uses for colors, IIRC it is RBGA, Red-Blue-Green-Alpha, but you can find that form the specification.

Some re-usable helpers might be nice to have, which convert automaticallly from KML to v-leaflet vectors.

cheers,
matti

Is there in the mean time any renderer available, where I can forward my KML content to, and it would render to a v-leaflet map?

My use-case to provide the uploading of almost any KML into my backend, being delivered/rendered to a v-leaflet OSM.

I would follow the recomendation to do it server side, using the v-leafle API.
But however - it would also be fine to use Leaflet.FileLayer, what seems to me being clien-side, if I got it right. So if this is an easy way to just forward a KML content to a file layer created with a Java API, that would fit also for me.

Sorry - I never did any java script library integration with Vaadin. So if nothing exists: what would you recomment:

  1. writing my own generic KML renderer for KML files using JavaAPIforKml or
  2. trying to make Leaflet.FileLayer as an individual Widget (?)

Currently my project is on Vaadin 7.7.8.

Cheers,
Olaf

Hi,

That certainly is possible. JavaAPIForKml is easy to use here. I don’t have an example for V-Leaflet, but for older Vaadin version and OpenLayers there is. The principle is practically the same:

https://github.com/mstahv/KmlVisualizer/

If you create one, please share the example. This seems to be a popular question.

cheers,
matti