Google maps PLACES API:maps.google.com返回的地址与通过API调用时的地址不同

Google maps PLACES API:maps.google.com返回的地址与通过API调用时的地址不同,google-maps,Google Maps,当我在浏览器中将地址传递给Google Maps.com时,它会在标记上返回地址的特定名称(如图1所示)。但是当我使用GooglePlace和GeocoderAPI传递邮政地址时,它会返回带有标记的地址和地点ID(如图2所示) 如图所示,MAPS应用程序返回的地址值与我通过API获得的地址值不同 是API的某些属性给出了位于该地址的建筑物或中心的名称吗 为了在这个地址显示建筑物的确切名称,我需要购买一些高级服务吗 我尝试了PlacesAPI的各种属性,但没有得到我需要的值 var address

当我在浏览器中将地址传递给Google Maps.com时,它会在标记上返回地址的特定名称(如图1所示)。但是当我使用GooglePlace和GeocoderAPI传递邮政地址时,它会返回带有标记的地址和地点ID(如图2所示)

如图所示,MAPS应用程序返回的地址值与我通过API获得的地址值不同

是API的某些属性给出了位于该地址的建筑物或中心的名称吗

为了在这个地址显示建筑物的确切名称,我需要购买一些高级服务吗

我尝试了PlacesAPI的各种属性,但没有得到我需要的值

var address=“1900 S杰克逊路7号麦卡伦德克萨斯州”;
var映射;
var标记;
var服务;
var请求;
函数初始化(){
var geocoder=new google.maps.geocoder();
map=new google.maps.map(document.getElementById('map_canvas'),
{
中心:{
纬度:-33.866,液化天然气:151.196
},
缩放:15
});
if(地理编码器){
地理编码({
“地址”:地址
},
功能(结果、状态){
if(status==google.maps.GeocoderStatus.OK){
if(status!=google.maps.GeocoderStatus.ZERO\u结果){
服务=新的google.maps.places.PlacesService(地图);
console.log(结果[0].place\u id);
map.setCenter(结果[0].geometry.location);
console.log('resulta ddre'+结果[0]。格式化的\u地址);
服务详情({
placeId:(结果[0]。place\u id)
},
功能(地点、状态){
var infowindow=new google.maps.infowindow();
if(status==google.maps.places.PlacesServiceStatus.OK){
控制台日志(状态);
marker=新的google.maps.marker({
地图:地图,位置:place.geometry.location
});
console.log(“”+place.address_组件+'place ID:'+place.place_ID
+''+place.name
+''+地点。格式化的地址);
google.maps.event.addListener(标记'click',函数(){
infowindow.setContent(“”+place.name+”“+”地点ID:“+place.place\u ID+”
“+place.formatted\u地址+ ''); 打开(地图,这个); }); } }); }; } }); } }
在maps.google.com上搜索“1900 S Jackson Rd Suite 7 MCALLEN TX”时,您会找到“儿科肺部中心:Ayres Roberto A MD”的位置

请注意,地理编码服务仅适用于街道地址,企业不在搜索范围内。在您的代码中,您首先执行地理编码请求,以便获得不同的结果。您必须执行places文本搜索才能获得与maps.google.com相同的业务

请看以下示例:

代码片段:

var映射;
var信息窗口;
var address=“德克萨斯州麦卡伦市杰克逊路1900号7号套房”;
函数initMap(){
var m_center={lat:26.1817228,lng:-98.2098557};
map=new google.maps.map(document.getElementById('map-canvas'){
中心:m_中心,
缩放:16
});
infowindow=new google.maps.infowindow();
var service=newgoogle.maps.places.PlacesService(地图);
service.textSearch({
查询:地址,
边界:map.getBounds()
},回调);
}
函数回调(结果、状态){
if(status==google.maps.places.PlacesServiceStatus.OK){
对于(var i=0;i
html,
身体,
#地图画布{
身高:100%;
宽度:100%;
边际:0px;
填充:0px
}

您的图像在哪里?
var address = "1900 S Jackson Rd Suite 7 MCALLEN TX";
          var map;
          var marker;
          var service;
          var request;

          function initialize() {
              var geocoder = new google.maps.Geocoder();

              map = new google.maps.Map(document.getElementById('map_canvas'), 
              {
                  center :  {
                      lat :  - 33.866, lng : 151.196
                  },
                  zoom : 15
              });
              if (geocoder) {
                  geocoder.geocode( {
                      'address' : address
                  },
                  function (results, status) {
                      if (status == google.maps.GeocoderStatus.OK) {
                          if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
                              service = new google.maps.places.PlacesService(map);
                              console.log(results[0].place_id);
                              map.setCenter(results[0].geometry.location);
                              console.log('resulta ddre '+results[0].formatted_address);
                              service.getDetails( {
                                  placeId : (results[0].place_id)
                              },
                              function (place, status) {
                                  var infowindow = new google.maps.InfoWindow();
                                  if (status === google.maps.places.PlacesServiceStatus.OK) {
                                     console.log(status);
                                      marker = new google.maps.Marker( {
                                          map : map, position : place.geometry.location
                                      });
                                      console.log('<HTML ATT>'+ place.address_components+'Place ID: ' + place.place_id 
                                      +  '<Place Name>' + place.name 
                                      + '<Formatted Address>' + place.formatted_address);
                                      google.maps.event.addListener(marker, 'click', function () {                                        
                                          infowindow.setContent('<div><strong>' + place.name + '</strong><br>' + 'Place ID: ' + place.place_id + '<br>' + place.formatted_address + 
'</div>');
                                          infowindow.open(map, this);
                                      });
                                  }
                              });

                          };

                      }
                  });
              }
          }