我使用Google Map API中的路线服务创建了路线 Map .
而现在我正在尝试定制路线中标记的信息 .
但不可能如何改变它 . 该项目是Ionic 3 .
import { Component, ViewChild, ElementRef } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { HttpClient } from "@angular/common/http";
import { Observable } from "rxjs/Observable";
import 'rxjs/add/operator/map';
declare var google;
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
...
loadMap() {
let latLng = new google.maps.LatLng(37.357499, -5.979938);
let mapOptions = {
center: latLng,
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
}
startNavigating() {
let directionsService = new google.maps.DirectionsService;
let directionsDisplay = new google.maps.DirectionsRenderer;
let wayPoints = [];
for (let i = 0; i < this.waypoints.length; i++) {
wayPoints.push({
location: {
lat: Number(this.waypoints[i].latitud),
lng: Number(this.waypoints[i].longitud)
},
stopover: true
});
}
directionsDisplay.setMap(this.map);
directionsService.route({
//Origin Destination and Waypoints populated with Demo Data
origin: {
lat: Number(this.origin.latitud),
lng: Number(this.origin.longitud)
},
destination: {
lat: Number(this.destination.latitud),
lng: Number(this.destination.longitud)
},
waypoints: wayPoints,
optimizeWaypoints: false,
travelMode: google.maps.TravelMode['WALKING']
}, (res, status) => {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(res);
} else {
console.warn(status);
}
});
}
}
我正在尝试为在DirectionsService(Google Maps API V3)的回调函数中创建的标记设置infoWindows . 我尝试了许多不同的方法,没有任何运气 .