问题描述
我在 GMap 上使用了地点 APi 和 poi 单击事件,并且能够在地图上获取我需要的信息。但是,我需要在不同的文本字段中显示所有地址组件。我正在获取格式化的地址,但不确定是否适用于所有国家/地区。我已经看到地址组件在其他一些调用中以不同的方式显示所有元素。但我可以在这里看到这个。我需要不同的地址 1、地址 2、房屋编号、城市、州、国家和邮编。
我已经完全引用了这个链接。
https://developers.google.com/maps/documentation/javascript/examples/event-poi
class ClickEventHandler {
origin;
map;
placesService;
infowindow;
infowindowContent;
constructor(map,origin) {
this.origin = origin;
this.map = map;
this.placesService = new google.maps.places.PlacesService(map);
this.infowindow = new google.maps.InfoWindow();
this.infowindowContent = document.getElementById("infowindow-content");
this.infowindow.setContent(this.infowindowContent);
this.map.addListener("click",this.handleClick.bind(this));
}
handleClick(event) {
if (isIconMouseEvent(event)) {
event.stop();
if (event.placeId) {
this.getPlaceinformation(event.placeId);
}
}
}
getPlaceinformation(placeId) {
const me = this;
this.placesService.getDetails({ placeId: placeId },(place,status) => {
if (
status === "OK" && place && place.geometry && place.geometry.location
) {
console.log(place);
}
});
}
}
如何根据地址1、地址2获取地址信息,因为在给定的图像中您无法确定哪个是什么。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)