• Resolved mygrove

    (@mygrove)


    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.

Viewing 15 replies - 1 through 15 (of 22 total)
  • Plugin Contributor hupe13

    (@hupe13)

    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 8 months ago by hupe13.
    Thread Starter mygrove

    (@mygrove)

    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?

    Plugin Contributor hupe13

    (@hupe13)

    Do you have an URL to a test page with this file?

    Thread Starter mygrove

    (@mygrove)

    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 8 months ago by mygrove.
    Plugin Contributor hupe13

    (@hupe13)

    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=...]
    Thread Starter mygrove

    (@mygrove)

    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 8 months ago by mygrove.
    Thread Starter mygrove

    (@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.

    Plugin Contributor hupe13

    (@hupe13)

    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?

    Thread Starter mygrove

    (@mygrove)

    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:1

    Any further insights appreciated, thanks.

    Plugin Contributor hupe13

    (@hupe13)

    Please deactive MonsterInsights and try again.

    Thread Starter mygrove

    (@mygrove)

    MonsterInsights is off now, but I’m not seeing any difference.

    Plugin Contributor hupe13

    (@hupe13)

    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 8 months ago by hupe13.
    Thread Starter mygrove

    (@mygrove)

    Well, I have added to my .htaccess file

    AddType application/vnd.google-earth.kml+xml kml

    Cleared the cache, and reloaded the page, but it still has no effect.

    Plugin Contributor hupe13

    (@hupe13)

    The kml files content type is text/plain, this is not correct. It must be application/vnd.google-earth.kml+xml And 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 8 months ago by hupe13.
    Thread Starter mygrove

    (@mygrove)

    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]
Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘KML options not working’ is closed to new replies.