0
我在Angular 2中使用mapbox gl来根据用户的当前位置绘制地图。我的代码去如下:Mapbox GL地图没有集中在初始位置
executemap() {
console.log(this.locationService.currentLat, this.locationService.currentLng);
this.map = new mapbox.Map({
style: 'mapbox://styles/mapbox/streets-v10',
center: [this.locationService.currentLat, this.locationService.currentLng],
zoom: 9,
container: 'map'
});
console.log('map loaded');
console.log(this.map);
console.log(this.map.getCenter().toString());
var latLng = new mapbox.LngLat(this.locationService.currentLat,this.locationService.currentLng);
this.map.resize();
this.map.setZoom(2);
}
在这个例子中,我使用的坐标41.8692324 -87.6630301,这是芝加哥(根据我的控制台日志,我可以确认的是,坐标是那里当初始化地图)。我从谷歌的地方得到这些坐标。当我跑地图,由于某种原因,集中在南极洲:
我使用的是默认的样式和地形设置此。我该怎么办?