关于Google map的两个小问题
最近在学习Google map api,自己参照给的示例做了下。
但是发现一些问题:
1:directions.load()的时候from和to是两个地名的话可以寻求出这两地点的驱车路径,但是如果两个都是经纬度的话好像就解析不出来,不清楚怎么回事。
2:directions.clear()方法好像不起作用。在第一条路线显示后,如果我想清除第一条路线再显示第二条路线,api中说用clear就可以,但是好像不起作用
以上提出两个问题,谢谢大家回答。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" 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.google.com/maps?file=api&v=2.x&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA" type="text/javascript"></script> <script type="text/javascript"> // Create a directions object and register a map and DIV to hold the // resulting computed directions var map; var directionsPanel; var directions; function initialize() { 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: 北京 to: 上海"); //directions.load("from: 22.123456,44.654321 to: 66.147258, 50.321654 "); //解析不出,why? } </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>