|
There are some workarounds for the cross site AJAX problems. Take this
one for instance. It uses a PHP proxy to call a specific site. Create a
PHP file with the following content somewhere in a folder that your web
server can deliver, call it something like yournavigation.php: <?php // PHP Proxy example // Responds to both HTTP GET and POST requests // // Author: Jason Levitt // December 7th, 2005 // // Allowed hostname define ('HOSTNAME', 'http://www.yournavigation.org/'); // Get the REST call path from the AJAX application // Is it a POST or a GET? $path = ($_POST['q']) ? $_POST['q'] : $_GET['q']; $url = ""> // Open the Curl session $session = curl_init($url); // If it's a POST, put the POST data in the body if ($_POST['q']) { $postvars = ''; while ($element = current($_POST)) { $postvars .= key($_POST).'='.$element.'&'; next($_POST); } curl_setopt ($session, CURLOPT_POST, true); curl_setopt ($session, CURLOPT_POSTFIELDS, $postvars); } // Don't return HTTP headers. Do return the contents of the call curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); // Make the call $xml = curl_exec($session); // The web service returns XML. Set the Content-Type appropriately header("Content-Type: text/xml"); echo $xml; curl_close($session); ?> Then include the following call in your _javascript_ file. //Compose request url var path = 'gosmore.php?flat=52.215676&flon=5.963946&tlat=52.2573&tlon=6.1799&v=motorcar&fast=1&layer=mapnik'; // The full path to the PHP proxy var kmlFeedUrl = 'yournavigation.php?q=' + encodeURIComponent(path); Now the URL is local from the _javascript_ point of view. Regards Juangui [email protected] escribió: Send Routing mailing list submissions to [email protected]To subscribe or unsubscribe via the World Wide Web, visit http://lists.openstreetmap.org/listinfo/routing or, via email, send a message with subject or body 'help' to [email protected] You can reach the person managing the list at [email protected] When replying, please edit your Subject line so it is more specific than "Re: Contents of Routing digest..." Today's Topics: 1. Re: OpenLayers, KML: how to display route? (Lambertus) 2. Re: OpenLayers, KML: how to display route? (Marcus Wolschon) ---------------------------------------------------------------------- Message: 1 Date: Sun, 22 Feb 2009 12:09:32 +0100 From: Lambertus <[email protected]> Subject: Re: [Routing] OpenLayers, KML: how to display route? To: [email protected], [email protected] Message-ID: <[email protected]> Content-Type: text/plain; charset=UTF-8; format=flowed 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. Jav Doorn wrote: |
_______________________________________________ Routing mailing list [email protected] http://lists.openstreetmap.org/listinfo/routing
