Plugin Author
bozdoz
(@bozdoz)
What shortcode are you using for leaflet-map?
[leaflet-map]
[leaflet-kml src=”../wp-content/plugins/londonboroughs.kml” fitbounds]
?
(I posted the wrong shortcode above, apologies!)
Thanks, I tried that before but it wasn’t working – I replaced ../ with / and now the KML outlines show up.
The <title> and <description> popups in the KML aren’t showing on clicking the polygons, please let me know if there’s a way to get them. Or is there a way to put the multigeometry shapes and popups straight into Leaflet Map without needing to use the KML file?
Plugin Author
bozdoz
(@bozdoz)
If you have properties in the kml, you should be able to add popups to the shapes like so:
[leaflet-kml src=”/the/src”]{the_property}[/leaflet-kml]
In your case maybe title and description are your properties?
[leaflet-kml src=”/the/src”]<h3>{title}</h3><p>{description}</p>[/leaflet-kml]
That should work, though I don’t remember really testing properties in kml’s
That would work with one shape, but this KML has over a dozen different shapes like this:
<Placemark>
<name>Ealing</name>
<styleUrl>#blue_shape</styleUrl>
<description><a href="http://www.londonspovertyprofile.org.uk/indicators/boroughs/ealing/">Read indicators for this borough</a></description>
<ExtendedData><SchemaData schemaUrl="#london_boroughs_boroughs_kml">
<SimpleData name="cartodb_id">9</SimpleData>
</SchemaData></ExtendedData>
<MultiGeometry><Polygon><outerBoundaryIs><LinearRing><coordinates>-0.334018,51.55671 -0.334456,51.556808 -0.335615,51.557121 -0.336091,51.557232 -0.336437,51.557299 -0.336785,51.557358 -0.337112,51.557406 -0.33728,51.557427 -0.338252,51.557488 -0.339527,51.557546 -0.339877, -0.333999,51.556767 -0.334018,51.55671 ***... and hundreds of other co-ordinates like those *** </coordinates></LinearRing></outerBoundaryIs></Polygon></MultiGeometry>
</Placemark>
I don’t want to have to create a new KML for each shape. Can the co-ordinates be put directly into Leaflet Map via shortcode?
Plugin Author
bozdoz
(@bozdoz)
I’m not sure what you’re asking. If the KML has differing properties then I am not sure there’s a good way to do this. At first thought, you could put all properties in there and hide all empty elements with CSS? This doesn’t seem like a good solution, but it might work:
[leaflet-kml src=”/the/src”]<h1 class=”title”>{first_title}</h1><h1 class=”title”>{second_title}</h1>[/leaflet-kml]
Then with css you could do:
h1.title:empty {
display: none;
}
Can I make insert the multi geometry polygon shapes using Leaflet Map shortcode instead of importing the KML?
e.g. something like
[leaflet-map polygon-fill=”#00CC9966″ polygon-shape=”-0.334018,51.55671 -0.334456,51.556808 -0.335615,51.557121 -0.336091,51.557232 -0.336437,51.557299 -0.336785,51.557358 -0.337112,51.557406 -0.33728,51.557427 -0.338252,51.557488 -0.339527,51.557546 -0.339877, -0.333999,51.556767 -0.334018,51.55671 ***and so on…***”]<h1 class=”title”>{first_title}</h1><h1 class=”title”>{second_title}</h1>[/leaflet-map]