我是iOS新手,我想使用google api方向服務,我在google文檔中獲得了java腳本,我也知道如何在iOS中使用UIWebView運行簡單的java腳本,但仍然無法運行腳本給谷歌以下鏈接:https://developers.google.com/maps/documentation/javascript/directions#TransitInformation如何在ios中使用谷歌方向API?
我不需要使用MapView,我只想訪問信息。
<html>
<head>
<script type="text/javascript"
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer();
var chicago = new google.maps.LatLng(41.850033, -87.6500523);
var mapOptions = {
zoom:7,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: chicago
}
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById("directionsPanel"));
};
var root = function(diameter) {
var start = document.getElementById("start").value;
var end = document.getElementById("end").value;
var request = {
origin:start,
destination:end,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
return 100;
};
</script>
</head>
<body>
</body>
</html>
測試我只是返回一定的價值,但它不給我輸出的函數被調用,但在代碼的某個地方掛
你調試它?? – Raj
是的,當我評論其他所有的代碼,它返回稱爲但不是成功執行value.ie功能,所以u能幫助我拉吉? – prabhu