【发布时间】:2017-02-20 10:32:27
【问题描述】:
我目前已在我的应用程序中集成了 Google 地图 api,并且还希望包含 google 地点 (https://developers.google.com/maps/documentation/javascript/examples/place-search)。我已经到了地理位置,但从那时起我有点迷路了。我想在附近搜索“超市”,但我正在努力将其转换为 Typescript/angular。
我目前拥有的启用地理定位的代码是
加载地图(){
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 对我来说工作正常,我想添加谷歌地方
标签: angularjs typescript ionic-framework ionic2 google-places-api