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 badges
Add a ment  | 

1 Answer 1

Reset to default 4

if 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 and international_phone_number.

Hope it would helps u.

本文标签: javascripthow to get phone number using google apiStack Overflow