admin管理员组文章数量:1401618
this is my code
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!
}
if i set
infowindow.setContent(placenames+"</br>"
+results[0].formatted_address
+"</br>"+results[0].formatted_phone);
results[0].formatted_phone ->
this is showing empty.why? where i want to change to get place phone number. example:;daddr=India,++%28India%[email protected],78.96288&saddr=37.781287,-122.395575
this is my code
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!
}
if i set
infowindow.setContent(placenames+"</br>"
+results[0].formatted_address
+"</br>"+results[0].formatted_phone);
results[0].formatted_phone ->
this is showing empty.why? where i want to change to get place phone number. example:http://www.google./maps?source=uds&daddr=India,++%28India%[email protected],78.96288&saddr=37.781287,-122.395575
Share Improve this question edited Jan 4, 2012 at 6:41 SANR1103219 asked Jan 4, 2012 at 5:42 SANR1103219SANR1103219 1431 gold badge2 silver badges9 bronze badges1 Answer
Reset to default 4if you use The Google Places API (Experimental)
then follow these steps
- first get an API key
now use Place Search Requests
A Place Search request is an HTTP URL of the following form:
https://maps.googleapis./maps/api/place/search/output?parameters
Certain parameters are required to initiate a Place Search request
key (required) — Your application's API key.
location (required) — This must be specified as latitude,longitude.
radius (required) — The distance (in meters) within which to return Place results.
sensor (required) — This value must be either true or false.
Each result within the results array may contain
reference contains a unique token that you can use to retrieve additional information about this place in a Place Details request. You can store this token and use it at any time in future to refresh cached data about this Place, but the same token is not guaranteed to be returned for any given Place across different searches.
Once you have a
reference
from a Place Search request, you can request more details about a particular establishment or point of interest by initiating a Place Details request.A Place Details request returns more prehensive information about the indicated place such as its plete address, phone number, user rating, etc. A Place Details request is an HTTP URL of the following form:
https://maps.googleapis./maps/api/place/details/output?parameters
Certain parameters are required to initiate a search request.
key (required) — Your application's API key.
reference (required) — A textual identifier that uniquely identifies a place, returned from a Place search request.
sensor (required) — This value must be either true or false.
output of Place Details contains
formatted_phone_number
andinternational_phone_number
.
Hope it would helps u.
本文标签: javascripthow to get phone number using google apiStack Overflow
版权声明:本文标题:javascript - how to get phone number using google api - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744301489a2599604.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论