Google maps 将存储的位置显示到谷歌地图中

Google maps 将存储的位置显示到谷歌地图中,google-maps,ionic2,Google Maps,Ionic2,我想将数据库中存储的位置显示到google地图中。下面的代码包含函数initializeMap(),该函数显示当前位置,还包括另一个获取存储位置的函数: 从'@angular/core'导入{Component,ViewChild,ElementRef}; 从“离子角度”导入{NavController,Platform}; 从'@ionic native/Geolocation'导入{Geolocation}; 从“../../providers/voituservice”导入{voitus

我想将数据库中存储的位置显示到google地图中。下面的代码包含函数initializeMap(),该函数显示当前位置,还包括另一个获取存储位置的函数:

从'@angular/core'导入{Component,ViewChild,ElementRef};
从“离子角度”导入{NavController,Platform};
从'@ionic native/Geolocation'导入{Geolocation};
从“../../providers/voituservice”导入{voituservice}”;
谷歌公司;
申报var文件;
@组成部分({
选择器:“页面地理定位”,
templateUrl:'GeoLocalization.html',
提供者:[自愿保留]
})
导出类GeoLocalizationPage{
@ViewChild('map')mapElement:ElementRef;
地图:任何;
装载机:任何;
朗:任何;
lat:任何;
项目GEO:任何;
//平台:平台;
构造器(公共虚拟空间:虚拟空间,公共平台:平台,公共导航控制:导航控制器,公共地理位置:地理位置){
这个平台=平台;
}
ionViewDidLoad(){
这个.initializeMap();
}
AddInfo窗口(标记、内容){
让infoWindow=new google.maps.infoWindow({
内容:内容
});
google.maps.event.addListener(标记,'click',()=>{
infoWindow.open(this.map,marker);
});
}
getArrets(){
this.voiturervice.getAllPositions().subscribe(响应=>{
this.itemsGeo=response.geo;
//this.loader.disclose();
for(var i=0,length=this.itemsGeo.length;i{
var minZoomLevel=6;
this.geolocation.getCurrentPosition()。然后((位置)=>{
让latLng=new google.maps.latLng(position.coords.latitude,position.coords.longitude);
this.lon=position.coords.longitude;
this.lat=position.coords.lation;
this.map=new google.maps.map(document.getElementById('map'),
{
zoom:minZoomLevel,
中心:拉特林,
mapTypeId:google.maps.mapTypeId.ROADMAP
});
让marker=new google.maps.marker({
map:this.map,
动画:google.maps.animation.DROP,
职位:latLng
});
让content=“Je suis ici!”;
此.addInfo窗口(标记、内容);
});
});
//获得职位
这个。getArrets();
}

}
您的问题在这行:

posi = new google.maps.LatLng(data.longitude.valueOf(), data.latitude.valueOf());
你得到的纬度和经度值是错误的。如果你,顾名思义,它告诉你应该是
纬度
,然后是
经度
。当你再往下几行创建地图时,你自己就可以正确地完成

应该是:

posi = new google.maps.LatLng(data.latitude.valueOf(), data.longitude.valueOf());