javascript - Google Maps API: Trouble with GDirections object literals -


I successfully GDirections to get maps with directions between point A and point B I'm calling. I have specified, however, I can not get some return value.

Calculate DistanceFromRoute.js:

  var map = new GMAP2 (document.getElementById ("map_canvas")); Function initialize () {if (GBrowserIsCompatible ()) {var map = new GMap2 (document.getElementById ("map_canvas")); Map.setUIToDefault (); Var route = new gedication (map); Route.load ("From: 500 Memorial Drive, Cambridge, MA: 4 Yokie Way, Boston, MA 02215 (Fenway Park)"); Var distance = route.gettastan (); $ ("# District") text (distance ['html']). . $ ("# Moar") text (.root.getStatus () code); $ ("# Moar") attached (route.getSummaryHtml ()). }}  

Mileage. HTML:

  & lt ;! DOCTYPE html "- // W3C // DTT XHTML 1.0 Strongly //n http: //www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> & Lt; Html xmlns = "http://www.w3.org/1999/xhtml" & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = utf-8" /> & Lt; Title & gt; Google Maps JavaScript API Example & lt; / Title & gt; & Lt; Script src = "http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js" type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; Script src = "calculateDistanceFromRoute.js" type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; Script src = "http://maps.google.com/maps?file=api&v=2&sensor=false&key=AQQAAcockAALI9IMRhHpfZzqs20rOLzZhRabMQb63ObuLzgNixJdxkMB1n4URRmY9m2gxwNKKyf2Dx5JWJ5dwyADQ" type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body onload = "initialize ()" onunload = "GUnload ()" & gt; & Lt; Div id = "map_canvas" style = "width: 500px; height: 300px" & gt; & Lt; / Div & gt; & Lt; P & gt; The distance is  Span id = "dist" & gt; Unknown & lt; / Span & gt; & Lt; / P & gt; & Lt; P id = "luggage" & gt; Here are some things & lt; / P & gt; & Lt; P id = "moar" & gt; & Lt; / P & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

The only route call that works is route.load () . Everything fails

By loading the route, you need to subscribe to the load event for the route asynchronously . This new initialization function with load event is:

initialize the function () {if (GBrowserIsCompatible ()) {var map = new GMap2 (document.getElementById ("map_canvas")); Map.setUIToDefault (); Var route = new gedication (map); GEvent.addListener (path, "load", function () {var distance = route.getDistance (); $ ("# dist"). Text (distance ['html']); $ ("# moar"). ( Route. GetStatus (.) Code); $ ("# moar"). Attachments (route. GetSummaryHtml ());}); Route.load ("From: 500 Memorial Drive, Cambridge, MA: 4 Yokie Way, Boston, MA 02215 (Fenway Park)"); }}

Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -