0
我目前已将Google地图API集成到了我的应用中,并且还希望包含Google地点(https://developers.google.com/maps/documentation/javascript/examples/place-search)。我已经得到了地理位置,但从那时起,我有点失落。我想在附近搜索“超市”,但我正在努力将其转换为Typescript/angular。Google Places API - 附近搜索(Ionic 2)
的代码我现在有,使地理位置是
loadMap(){
Geolocation.getCurrentPosition().then((position) => {
let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
let mapOptions = {
center: latLng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
}, (err) => {
console.log(err);
});
}
addMarker(){
let marker = new google.maps.Marker({
map: this.map,
animation: google.maps.Animation.DROP,
position: this.map.getCenter()
});
let content = "<h4>You are here!</h4>";
this.addInfoWindow(marker, content);
}
addInfoWindow(marker, content){
let infoWindow = new google.maps.InfoWindow({
content: content
});
google.maps.event.addListener(marker, 'click',() => {
infoWindow.open(this.map, marker);
});
}
如果有人能帮助我融入/地方API转换成将高度赞赏我当前的代码。
的可能重复[我怎样才能整合谷歌地图API的角2组件内(http://stackoverflow.com/questions/37326572/how-can -i-integrate-google-maps-apis-inside-an-angular-2-component) – e666
不是重复的Google maps api对我来说工作正常,我想要添加谷歌地点 – BA1995