OpenLayers, KML: how to display route?

Hello,

I am working on a Openstreetmap project which includes routing. I can draw a map:

map = new OpenLayers.Map( $(‘map’), {controls: [] } );
layerTilesAtHome = new OpenLayers.Layer.OSM.Osmarender(“Osmarender”);
map.addLayer(layerTilesAtHome);

The map is drawn correctly.

Next I need to draw a route that is contained in a KML file:

var kmlFeedUrl = “http://www.yournavigation.org/gosmore.php?flat=52.215676&flon=5.963946&tlat=52.2573&tlon=6.1799&v=motorcar&fast=1&layer=mapnik

kmlLayer = new OpenLayers.Layer.GML(“KML”, kmlFeedUrl, {
projection: new OpenLayers.Projection(“EPSG:4326”),
format: OpenLayers.Format.KML,
formatOptions: {
extractStyles: true,
extractAttributes: true
}
});

map.addLayer(kmlLayer);

I can step through this code in the debugger without errors in these particular lines.
As you can see, the url returns a KML file.
Later I get the error ‘access denied’. The map is drawn anyway but no route is displayed.

Can anybody help?

A webbrowser does not allow you to do cross site AJAX calls. You will need to setup a local proxy on your webserver who relais the yournavigation.org queries.

Hi,

I have a issue with display of this kml files.
I have a solution which save the kml files on the ocal machine.
When I use this code

kmlLayer = new OpenLayers.Layer.GML("KML", kmlFeedUrl, {
      projection: new OpenLayers.Projection("EPSG:4326"),
                      format: OpenLayers.Format.KML,
                      formatOptions: {
                        extractStyles: true,
                        extractAttributes: true
                        }
      });

the route will not display.
I make no request to the gosmore server.
Can anyone help?

Thanks
Andy