KML options not working
-
I am trying to use a KML file that I have uploaded to my server. The file is in the folder at …/wp-content/uploads/KML/
The documentation is not clear how the path to the KML should be written:
Is it:
[leaflet-map fitbounds scrollwheel]
[leaflet-kml src=”wp-content/uploads/KML/mydata.kml”]or, something like the full path. Are quotes necessary?
[leaflet-map fitbounds scrollwheel]
[leaflet-kml src=https://mydomain.com/wp-content/uploads/KML/mydata.kml]Either way, the KML overlay file is not showing.
-
The easiest way is to use Extensions for Leaflet Map. There is a file manager there: https://your-domain.tld/wp-admin/admin.php?page=extensions-leaflet-map&tab=filemgr-list
There you can obtain the shortcode to load the KML and other files. And if the URL is correct, the file in the map will also be loaded.
See https://leafext.de/en/doku/filemgr/
-
This reply was modified 2 years, 2 months ago by
hupe13.
Thank you that confirms the path is correct and it does need to be enclosed in quotes.
However, the KML is still not being rendered over the base map. I know the KML is correct as it works correctly and displays my marker in Google MyMaps.
Is there anything else that needs to be set in the Leaflet Map plugin?
Do you have an URL to a test page with this file?
Here is a test page https://edintone.com/test-kml/
All that is on the page are the two shortcodes:
[leaflet-map fitbounds zoomcontrol scrollwheel]
[leaflet-kml src="https://edintone.com/wp-content/uploads/2024/03/mydata.kml"]-
This reply was modified 2 years, 2 months ago by
mygrove.
Your kml file is okay. The markers are not loaded. I don’t know why. I guess the reason is your theme or any other plugin. Does it work with
circleMarker?[leaflet-kml circleMarker src=...]Like this?
[leaflet-map fitbounds zoomcontrol scrollwheel]
[leaflet-kml circleMarker src="https://edintone.com/wp-content/uploads/2024/03/mydata.kml"]It’s on the test page now. Unfortunately not.
-
This reply was modified 2 years, 2 months ago by
mygrove.
I deactivated all the other plugins except Leaflet Map and Extensions for Leaflet Map. I also switched to a default Twenty-Twenty-Four theme. Sadly the KML still does not display.
I tested the your kml file on my page, it works.
There is a javascript error on your page, I guess, any other javascript file is the reason. But which? The reCAPTCHA?
Here are the errors from the console, it only seems to be pointing towards togeojson.js:
query-migrate.min.js?ver=3.4.1:2 JQMIGRATE: Migrate is installed, version 3.4.1 test-kml/:1307 dragging, scroll, mobile true true false test-kml/:1307 0 'enabled' togeojson.js?ver=3.4.1:15 Uncaught TypeError: Cannot read properties of null (reading 'getElementsByTagName') at get (togeojson.js?ver=3.4.1:15:35) at Object.kml (togeojson.js?ver=3.4.1:110:30) at request.t.onreadystatechange (leaflet-ajax-geojson.min.js?ver=3.4.1:1:561) get @ togeojson.js?ver=3.4.1:15 kml @ togeojson.js?ver=3.4.1:110 request.t.onreadystatechange @ leaflet-ajax-geojson.min.js?ver=3.4.1:1 XMLHttpRequest.send (async) onAdd @ leaflet-ajax-geojson.min.js?ver=3.4.1:1 _layerAdd @ Layer.js:114 whenReady @ Map.js:1477 addLayer @ Layer.js:172 addLayer @ LayerGroup.js:47 addLayer @ FeatureGroup.js:35 addTo @ Layer.js:52 WPLeafletkmlShortcode @ test-kml/:855 t @ construct-leaflet-map.min.js?ver=3.4.1:1 init @ construct-leaflet-map.min.js?ver=3.4.1:1 load (async) (anonymous) @ construct-leaflet-map.min.js?ver=3.4.1:1 (anonymous) @ construct-leaflet-map.min.js?ver=3.4.1:1Any further insights appreciated, thanks.
Please deactive MonsterInsights and try again.
MonsterInsights is off now, but I’m not seeing any difference.
Similar problem like this.
My gpx file is not displayed!
- Is the URL correct?
- Does the webserver return the correct mime type (application/gpx+xml)? Put in your
.htaccess:
AddType application/gpx+xml gpx RewriteRule .*\.gpx$ - [L,T=application/gpx+xml]Put in your .htaccess for the kml file:
AddType application/vnd.google-earth.kml+xml kml-
This reply was modified 2 years, 2 months ago by
hupe13.
Well, I have added to my .htaccess file
AddType application/vnd.google-earth.kml+xml kmlCleared the cache, and reloaded the page, but it still has no effect.
The kml files content type is text/plain, this is not correct. It must be
application/vnd.google-earth.kml+xmlAnd if you write like in gpx statements?AddType application/vnd.google-earth.kml+xml kml RewriteRule .*\.kml$ - [L,T=application/vnd.google-earth.kml+xml]You use a Litespeed server, I don’t know it.
-
This reply was modified 2 years, 2 months ago by
hupe13.
It’s not clear what you are suggesting I need to do here. Can you clarify, please.
Replace my entry in .htaccess or add these two lines?
AddType application/vnd.google-earth.kml+xml kml
RewriteRule .*\.kml$ - [L,T=application/vnd.google-earth.kml+xml] -
This reply was modified 2 years, 2 months ago by
The topic ‘KML options not working’ is closed to new replies.