:https://maps.googleapis.com/maps/api/directions/'
, .
:
https://developers.google.com/maps/documentation/directions/start
:
export function decode (t, e) {
for (var n, o, u = 0, l = 0, r = 0, d = [], h = 0, i = 0,
a = null, c = Math.pow(10, e || 5) ;
u < t.length
;
) {
a = null, h = 0, i = 0
do
a = t.charCodeAt(u++) - 63, i |= (31 & a) << h, h += 5;
while (a >= 32)
n = 1 & i ? ~(i >> 1) : i >> 1, h = i = 0
do
a = t.charCodeAt(u++) - 63, i |= (31 & a) << h, h += 5;
while (a >= 32)
o = 1 & i ? ~(i >> 1) : i >> 1, l += n, r += o,
d.push([l / c, r / c])
}
return d.map(
function (t) {
return {latitude: t[0], longitude: t[1]}
})
}
// https://github.com/airbnb/react-native-maps/issues/929
:
that.setState({
route: [decode(res)]
})
renderRoute (coordinates, i) {
return (
<MapView.Polyline
key={i}
coordinates={coordinates}
strokeColor={......}
strokeWidth={4}
/>
);
}
render () {
return (
<MapView
showsUserLocation
followsUserLocation
loadingEnabled
>
{this.state.route.map(this.renderRoute)}
</MapView>
, , , .