注册 登录
编程论坛 JavaScript论坛

关于使用JavaScript调用Google Maps实现线路查询的问题。请高手帮忙找一下错误。

hxf474704251 发布于 2010-05-15 10:26, 1419 次点击
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.
<html xmlns="http://www.  xmlns:v="urn:schemas-microsoft-com:vml">
  <head>
    <title>Google Maps JavaScript API Example: Simple Directions</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <script src="http://maps.
      type="text/javascript"></script>
    <script type="text/javascript" language="javascript" >
var map;
    var directionsPanel;
    var directions;

    function initialize() {
    var x1="北京"
    var y1="上海"
     
      map = new GMap2(document.getElementById("map_canvas"));
      map.setCenter(new GLatLng(42.351505,-71.094455), 15);
      
      directionsPanel = document.getElementById("route");
      directions = new GDirections(map, directionsPanel);
      directions.load("from: x to: y ") 路线查询时为什么这样的代码不能实现道路查询,把x、y用北京、南京等具体值代替就可以实现。这是怎么回事,我想把路线查询的地址赋给两个变量,通过给变量赋值实现路线查询。请高手指点一下。
      
    //document.write(x)
     //document.write("<br>")
     //document.write(y)
   
    }
    </script>
  </head>

  <body onload="initialize()">
    <div id="map_canvas" style="width: 70%; height: 480px; float:left; border: 1px solid black;"></div>
    <div id="route" style="width: 25%; height:480px; float:right; border; 1px solid black;"></div>
    <br/>
  </body>
</html>
4 回复
#2
gupiao1752010-05-15 16:41
不是很清楚,帮你顶下!期待了解这方面的高人帮解!
#3
hxf4747042512010-05-15 20:25
谢谢啊
#4
hxf4747042512010-05-15 20:27
有没有高手,快帮我解决一下。做毕业设计很急啊。
#5
cccool2010-05-23 20:04
directions.load("from: x to: y ")
改成
directions.load("from: " + x +" to: " + y )
试一试!
1