在此代码映射和标记中运行良好,但标记位置未与实时地理位置集成,并且在标记出现后如果设备替换数百米则不显示移动。
initializeMap() {
var minZoomLevel=16
Geolocation.getCurrentPosition().then((position) => {
this.map = new google.maps.Map(document.getElementById('map_canvas'),
{
zoom: minZoomLevel,
center: new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
mapTypeControl: false,
streetViewControl: false,
disableDefaultUI: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var trafficLayer = new google.maps.TrafficLayer();
trafficLayer.setMap(this.map);
this.Marker();
});
}
Marker(){
let image = 'assets/img/Untitled-1.png';
let marker = new google.maps.Marker({
map: this.map,
animation: google.maps.Animation.DROP,
position: this.map.getCenter(),
// draggable: true,
icon: image
});