demo (#22) - Routing on the Fly - using OpenLayers? (#67) - Message List
Hi guys :)
I am trying to make an on-the-fly route display and am following this tutorial : http://pgrouting.postlbs.org/wiki/WorkshopFOSS4G2007#OpenLayersroutingmap
I managed to send the request to the PHP page to generate and XML response and a copy of this response can be found here : http://yancho.pastebin.com/f41432b0d . The URL which is sending the data is : http://yancho.no-ip.org/~yancho/routing.php?startpoint=642983.5%20225176.75&finalpoint=641780.375%20224942.375&method=SPA®ion=streets&srid=-1&_= And these are the headers of the reply according to FireBug? : http://yancho.pastebin.com/f18cadf12
Small Extract Of the XML Output :
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <route> <edge id='1'> <id>3612</id> <wkt>MULTILINESTRING((642847.022664808 225275.125294559,642901.453947967 225273.479351758))</wkt> <length>0.054</length> </edge>
But the problem is when I get to display the route. When I click on Compute Route, on my site : http://yancho.no-ip.org/~yancho/openl.html
I get this error :
String contains an invalid character" code: "5 http://yancho.no-ip.org/~yancho/OpenLayers.js Line 554
And further investigations in FireBug? shows :
String contains an invalid character" code: "5 emptyFunction()OpenLayers?.js (line 189) getImagesLocation()OpenLayers?.js (line 101) emptyFunction()OpenLayers?.js (line 189) dispatch("routing.php ", Object method=get)OpenLayers?.js (line 191) Class()OpenLayers?.js (line 57) nullHandler("routing.php", "startpoint=642983.5%20225176.75&finalpoint=641780.375%20224942.375&method=SPA®ion=streets&srid=-1 ", null, displayRoute(response), undefined)OpenLayers?.js (line 187) compute()openl.html (line 152) onclick(click clientX=0, clientY=0)openl.html (line 1) [Break on this error] if(style.cursor){node.setAttributeNS (null,"cursor",style.cursor);}},createNode:f...
Any idea how I can fix my code please? A copy of the code can be seen highlighted here : http://yancho.pastebin.com/f335b8727
Thanks for your continous help. Much Appreciated
Matthew
-
Message #257
For sure I can say, that this is not a problem with your PHP script, but something goes wrong with the OpenLayers? part. The created XML file with the route looks fine. Did you ask the OpenLayers? list?
daniel11/22/07 19:21:46 (3 years ago)-
Message #258
Thanks daniel for your support .. yes I did ask but didn't get much answers, and was doubting if it was a OpenLayers? problem or else something else.
Thanks mate :)
yancho11/22/07 19:24:01 (3 years ago)-
Message #259
Do you use the latest version of OpenLayers?? The version of the FOSS4G2007 workshop is not the latest one.
You can take a look at this demo of Christopher Schmidt. It's an extended version, which he made during the workshop. http://boston.freemap.in/routing.html
daniel11/22/07 19:29:05 (3 years ago)-
Message #260
Hmm well I downloaded the OpenLayers?.js from their server but used your tutorial to build the source code .. I'll compare it a bith with chris then :)
Thanks for the tip!
yancho11/22/07 19:30:57 (3 years ago)-
Message #261
You could link to his OpenLayers? library to make sure it is not a version problem. If it works with his OpenLayers?.js, then it might be a version incompatibility.
If you find out that our tutorial doesn't work anymore with OpenLayers? 2.5, please let me know.
daniel11/22/07 19:35:59 (3 years ago)-
Message #262
Hi,
I tried to link to his OpenLayers?.js script but same error occured :(
yancho11/22/07 19:45:10 (3 years ago)-
Message #263
Hi,
Just would like to say that finally with the help of crschmidt and pgiraud from #OpenLayers? , I managed to get the routing working.
I would like to say that the tutorial has some old things that I suggest should be changed to reflect the new OpenLayers?.js
function displayRoute(response) {
if (response && response.responseXML) {
// erase the previous results result.removeFeatures(result.features);
// parse the features var edges = response.responseXML.getElementsByTagName('edge'); var features = []; for (var i = 0; i < edges.length; i++) {
var wkt = edges[i].getElementsByTagName('wkt')[0].textContent; var g = parser.read(wkt); features.push(g);
} result.addFeatures(features);
}
}
In the function on the wiki, there is features.push(new OpenLayers?.Feature.Vector(g)); which now should just be changed with features.push(g); since g is already a Feature.Vector array so no need to mention it again.
Thanks alot for your support, and hope this thread helps others with my problem :)
Cheers
yancho11/24/07 02:18:36 (3 years ago)
-
-
-
-
-
-