kml/kmz Layer

5 years 9 months ago #507 by MODPILOT
kml/kmz Layer was created by MODPILOT
Is there any way to add a kmz/kml layer on top of the current map ?

Please Log in or Create an account to join the conversation.

5 years 9 months ago #508 by meides
Replied by meides on topic kml/kmz Layer
Hey MODPILOT,

there is no official way, but you can navigate to our Explorer (opensky-network.org/network/explorer) and then enter the following into your Javascript console:
kmlLayer = new google.maps.KmlLayer({
          url: 'http://googlemaps.github.io/js-v2-samples/ggeoxml/cta.kml',
          map: flightArchive.hybridMap.map
        });

In Chrome and Firefox the Javascript console can be opened by pression Ctrl-Shift-J on your keyboard. Of course you need to replace the url from the example above with the location of your own kml file.

If you want to delete the kml layer, simply set the map of the layer to null:
kmlLayer.setMap(null);

For details on the Google Maps API on kml layers, please refer to developers.google.com/maps/documentation...t/examples/layer-kml.

Cheers,
Marco
The following user(s) said Thank You: MODPILOT

Please Log in or Create an account to join the conversation.

5 years 9 months ago #509 by MODPILOT
Replied by MODPILOT on topic kml/kmz Layer
Outstanding.... I'm with Civil Air Patrol (we do search and rescue) and was able to put a grid over the map this way. Sure would be nice to make it an option somehow to display (off/on) ...

Please Log in or Create an account to join the conversation.

5 years 9 months ago #510 by meides
Replied by meides on topic kml/kmz Layer
I've added it to our front end to-do list :)

Please Log in or Create an account to join the conversation.

5 years 3 months ago #633 by MODPILOT
Replied by MODPILOT on topic kml/kmz Layer
Its been a while... I tried the same solution and its stopped working. It seems google is not defined. Since you are using open maps will this not work any longer? Thanks

Please Log in or Create an account to join the conversation.

5 years 3 months ago - 5 years 3 months ago #639 by meides
Replied by meides on topic kml/kmz Layer
You're right, it stopped working because we switched to OpenStreetMap. I just added the Leaflet KML plugin to the OpenSky Explorer for you. You can now use KML layers like so:

// Create the new KML layer from a kml file
var kmlLayer = new L.KML("https://googlemaps.github.io/js-v2-samples/ggeoxml/cta.kml", {async: true});

// Wait for the layer to load
kmlLayer.on("loaded", function(e) {

    // Center the map onto the area of interest
    flightArchive.hybridMap.map.fitBounds(e.target.getBounds());
    
    // Add the KML layer
    flightArchive.hybridMap.map.addLayer(kmlLayer);
});

Cheers,
Marco

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum
This website uses cookies to offer you the best experience of our services. By using this website you agree to our privacy policy!