【发布时间】:2019-05-17 07:07:19
【问题描述】:
如何使用 npm google-map-react 绘制路线?
这就是我所拥有的
this.map = (zoom, lat, lng) => { 让 DirectionsService = new window.google.maps.DirectionsService();
DirectionsService.route(
{
origin: new window.google.maps.LatLng(40.407749, -3.710138), //
destination: new window.google.maps.LatLng(40.762341, -3.788512), //
travelmode: window.google.maps.TravelMode.DRIVING
},
(result, status) => {
if (status === window.google.maps.DirectionsStatus.OK) {
this.setState({
direction: result
});
} else {
console.error(`error fetching directions ${result}`);
}
}
);
【问题讨论】:
标签: reactjs google-maps-api-3 google-map-react