,這是我的代碼如何使用谷歌API
function show(placelanlat,names)
{
var placenames=names;
var planlat=placelanlat;
var newStr= planlat.replace(/[(\)]/g,'');
var aCars = newStr.split(',');
var infowindow = new google.maps.InfoWindow();
var marker;
var geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(12.588,-83.667);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvass"), myOptions);
var input = newStr;
var latlngStr = input.split(",",2);
var lat = parseFloat(latlngStr[0]);
var lng = parseFloat(latlngStr[1]);
var latlng = new google.maps.LatLng(lat, lng);
geocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
map.setZoom(11);
marker = new google.maps.Marker({
position: latlng,
map: map,
icon: 'images/images.png'
});
infowindow.setContent(placenames+"</br>"+results[0].formatted_address+"</br>");
infowindow.open(map, marker);
}
}
else {
alert("Geocoder failed due to: " + status);
}
});
return false; // MANDATORY!
}
如果我設置
infowindow.setContent(placenames+"</br>"
+results[0].formatted_address
+"</br>"+results[0].formatted_phone);
results[0].formatted_phone ->
這顯示empty.why得到的電話號碼? 我想要更改地點電話號碼。 例如:http://www.google.com/maps源= UDS & DADDR =印度,++%28India%29 + @ 20.593684,78.96288 & SADDR = 37.781287,-122.395575
您看到此鏈接。 http://code.google.com/apis/maps/documentation/places/ – SANR1103219 2012-01-04 06:17:31
我已經更新了我的答案。注意:您必須爲那個 – diEcho 2012-01-04 06:54:16
ya.i需要'API密鑰'。地名和地址名稱以及API密鑰 – SANR1103219 2012-01-04 06:59:32