javascript - google maps plot route between two points -


I've written this innocent JavaScript code, which makes the user two markers and gives a plot of the route between them . It works, instead, it returns a strange error:

  Unicode type error: unconstitutional  

property 'or' can not read any Can tell me what's wrong Click one click GEvent.addListener (map, "click", function (overlay, point) {if (isCreateHeadPoint) {// head marker headMarker = new GMarker}:

  (dot, {icon: red icon, title: 'head'}); Map.addOverlay (headMarker); IsCreateHeadPoint = false;} and {// tail marker tail = marker = new GMMakers (point, {icon: green icon, title: 'tail'}); Map.and overlay (tail marker); IsCreateHeadPoint = true; // head-to-tail direction Load ("from:" + headMarker.getPoint (). Lat () + "," + headMarker .getPoint (.Lng) + "to:" + tailMarker.getPoint (.) Lat () + "," + TailMarker.getPoint () .lng (), {getPolyline: true, getSteps: true}); / / Path map.addOverlay Display (direction.getPolyline ()); }});  

The following, you map.addOverlay (Direction GetPolyline ()) Automatically automatically adds polyline to the map in the following example:

   & Lt; Title & gt; Google Maps GDirections & lt; / Title & gt; & Lt; Script src = "http://maps.google.com/maps?file=api&v=2&sensor=false" type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body onunload = "GUnload ()" & gt; & Lt; Div id = "map" style = "width: 400px; height: 300px" & gt; & Lt; / Div & gt; & Lt; Script type = "text / javascript" & gt; Var map = new GMAP2 (document.getElementById ("map")); Var directions = new gedication (map); Var isCreateHeadPoint = true; Var Header, Taylor Marker; Map.setCenter (New GLatLng (51.50, -0.12), 12); GEvent.addListener (map, "click", function (overlay, point) {if (CreateCreateHeadPoint) {// add head marker head marker = new GMarker (point); map.addOverlay (headMarker); isCreateHeadPoint = false;} and {// tail marker tail = new GM marker (point); map.addOverlay (tailMarker); isCreateHeadPoint = true; // Load head-to-tail directions. Load ("from:" + headMarker.getPoint (.) Lat ( ), "+ + TailMarker.getPoint ().", "+ TailMarker.getPoint () .Lng (), {getPolyline: true, GetSteps: true});}}); & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

Screenshots:

Google Maps GDirections


Comments