Closed Tong2203 closed 9 years ago
This plugin does not provide the direction service currently. Many people want to use it, but not yet.
OK, understand. By the way, does this plugin provide the compass mode?
What is the compass mode?
Like this...
Google Maps Android API v2 and Google Maps SDK for iOS provide the map compass. It appears when you change the map heading or set the camera heading.
A direction that is always facing, I want to on the upper side of the screen.
The plugin does not provide the feature.
Ok I see,thank you.
FYI: There is a compass plugin. https://github.com/apache/cordova-plugin-device-orientation
I think we can use google map api v3 javascript to calculate and get lines, and then draw into the map.
directionsService.route(
directionsRequest,
function (response, status) {
//console.log('GOOGLE RESPONSE', response, status);
if (status == google.maps.DirectionsStatus.OK) {
var route = new Array(my_position);
var steps = response.routes[0].legs[0].steps;
//console.log('Steps:', steps)
for (var s = 0; s < steps.length; s++) {
for (var l = 0; l < steps[s]['lat_lngs'].length; l++) {
route.push(new plugin.google.maps.LatLng(steps[s]['lat_lngs'][l]['k'], steps[s]['lat_lngs'][l]['B']))
}
}
//Draw Polyline
if (oldPolyline) oldPolyline.remove();
map.addPolyline({
'points' : route,
'color' : '#3CABDA',
'width' : 10,
'geodesic' : true
},
function (polyline) {
//Keep reference of the last polyline used in order to remove it
// when a new route polyline is drawn
oldPolyline = polyline;
// Assign Event listener to polyline
// when user clicks the polyline he is transfered to the external
// navigation app
polyline.on(plugin.google.maps.event.OVERLAY_CLICK, function () {
plugin.google.maps.external.launchNavigation({
"from": my_position,
"to": position
});
});
});
}
else
console.error("Unable to retrieve route");
}
);
HI @aguilacontrol can u please tell explain this line var route = new Array(my_position);
Before ask to someone, I recommend you search over the internet. http://www.w3schools.com/js/js_arrays.asp
hi , i didnt ask about the array creation. i need to know what implies "my_position ".
I think the value is just LatLng. You can get your position using map.getMyLocation()
i got working..
above one was not working for me, following will work fine.
var gRoute = response.routes[0]['overview_path'];
for (var s = 0; s < gRoute.length; s++) {
route.push(new plugin.google.maps.LatLng(gRoute[s].lat(), gRoute[s].lng()));
}
map.addPolyline({
points: route,
color : '#0088FF',
width: 6
});
In google map api, Route can be generated by DirectionsService. Could you tell how to do that in this plugin? thanks.