2

I'm loading 3 KMLs using an ashx handler taken from http://code.google.com/p/iisproxy. The 3 KMLs I'm trying to load are Openlayers sundials ( http://openlayers.org/dev/examples/kml/sundials.kml ), Marine Traffic KML ( http://www.marinetraffic.com/ais/ge_marinetraffic.kml ), and flightwise ( http://mw1.google.com/mw-earth-vectordb/flightwise/flightwise_root.kml ).

The Sundial is working for me, but the other 2 don't. I'm afraid the problem is because the other 2 KMLs have file links inside while sundials KML has data only.

Is there a way I can make the other two work on my IIS?

This is the code I used:

<!-- language: lang-js -->

function init() {

    var map = new OpenLayers.Map("map");
    OpenLayers.ProxyHost = "/proxy.ashx?url=";

    var osm = new OpenLayers.Layer.OSM();

    var flight = new OpenLayers.Layer.Vector("Flightwise", {
        strategies: [new OpenLayers.Strategy.Fixed()],
        protocol: new OpenLayers.Protocol.HTTP({
            url: "http://mw1.google.com/mw-earth-vectordb/flightwise/flightwise_root.kml",
            format: new OpenLayers.Format.KML({
                extractStyles: true,
                extractAttributes: true
            })
        })
    })

    var marine = new OpenLayers.Layer.Vector("Marine", {
        strategies: [new OpenLayers.Strategy.Fixed()],
        protocol: new OpenLayers.Protocol.HTTP({
            url: "http://www.marinetraffic.com/ais/ge_marinetraffic.kml",
            format: new OpenLayers.Format.KML({
                extractStyles: true,
                extractAttributes: true
            })
        })
    })

    var sundials = new OpenLayers.Layer.Vector("Sundials", {
        strategies: [new OpenLayers.Strategy.Fixed()],
        protocol: new OpenLayers.Protocol.HTTP({
            url: "http://openlayers.org/dev/examples/kml/sundials.kml",
            format: new OpenLayers.Format.KML({
                extractStyles: true,
                extractAttributes: true
            })
        })
    })

    map.addLayers([osm, flight, marine, sundials]);

    var controls = [
                    new OpenLayers.Control.Navigation(),                        
                    new OpenLayers.Control.LayerSwitcher(),                        
                    new OpenLayers.Control.ScaleLine(),                        
                    new OpenLayers.Control.MousePosition(),
                    /*new OpenLayers.Control.OverviewMap(),*/
                    new OpenLayers.Control.KeyboardDefaults()
                ];

    map.addControls(controls);


    map.zoomToMaxExtent();
}

1 Answer 1

0

For fetching remoteData, the maxDepth option must be greater than 0. This option tells the KML parser how far the traverse before giving up. Source

Try adding maxDepth: 20 or something. Play around with the number. I imagine you might have to go deep for the AIS data. Not sure.

...
format: new OpenLayers.Format.KML({
    extractStyles: true,
    extractAttributes: true,
    maxDepth: 20
})
...
4
  • Thank you for the answer , sadly this didn't work for me. Maybe I did something wrong... if you were able to do it , Ill be happy to see how.
    – Alophind
    Nov 14, 2012 at 7:44
  • Sorry, I haven't overlayed KMLs with network links. I just figured it was worth a try.
    – CaptDragon
    Nov 14, 2012 at 14:07
  • Hope anyone can help here.
    – Alophind
    Nov 16, 2012 at 17:51
  • pretty old question, but if you try the network link directly it will work. Your flightwise kml doesn't have 'Document' tag, which is needed for it to work on openlayers. Try the link inside flightwise instead. (but that one doesn't seem to work anymore now)
    – Glenn Plas
    Nov 21, 2013 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.