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轉換成將高度讚賞我當前的代碼。

+0

的可能重複[我怎樣才能整合谷歌地圖API的角2組件內(http://stackoverflow.com/questions/37326572/how-can -i-integrate-google-maps-apis-inside-an-angular-2-component) – e666

+0

不是重複的Google maps api對我來說工作正常,我想要添加谷歌地點 – BA1995

回答