1
マップに2つの位置を表示し、この点の中心とズームの中心をイオン2に自動的に設定したい2 このコードは2つの異なる点とマーカーを表示しますが、position
がこのマーカーの位置外にある場合は表示されませんcanvas
地図上に2つの場所を表示し、自動的にこの点のズームレベルと中心をionic2に設定する方法は?
initializeMap() {
let minZoomLevel = 12;
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,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var trafficLayer = new google.maps.TrafficLayer();
trafficLayer.setMap(this.map);
this.OriginMarker(this.start_point);
this.TargetMarker(this.end_point);
});
}
OriginMarker(data){
var latlng : string = data.split(',');
var LatLng = new google.maps.LatLng(+latlng[0],+latlng[1]);
let image = 'assets/img/Untitled-1.png';
let marker = new google.maps.Marker({
map: this.map,
animation: google.maps.Animation.DROP,
position: LatLng, icon: image
});
}
TargetMarker(data) {
var latlng : string = data.split(',');
var LatLng = new google.maps.LatLng(+latlng[0],+latlng[1]);
let image = 'assets/img/Untitled-2.png';
let marker = new google.maps.Marker({
map: this.map,
animation: google.maps.Animation.DROP,
position: LatLng , icon: image
});
}
こんにちは、私はこのコードをどこで使うべきですか? inside initializeMapメソッド内または新しいメソッド内に存在します。 – RSA
私のコードはあなたのコードに依存して更新されます。 – Sabari
@Reza私はあなたのコードに依存して私の答えを更新しました。やってみよう。 – Sabari