I'm using this service https://developers.google.com/maps/documentation/javascript/directions to create a route between two markers.
The problem is that when I run the function to create the path, he enters me two markers by default from google maps (the beginning and end) when I had created the markers with different style.
Result: at each point have my marker and the marker's default google maps above.
How can I hide the marker created by google?
The code I'm using is:
function makePathToMarker(position1, position2) {
var request = {
origin: new google.maps.LatLng(myLocation.split(",")[0],myLocation.split(",")[1]),
destination: new google.maps.LatLng(position1, position2),
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
var directionsService = new google.maps.DirectionsService();
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}
Click the marker to reveal the editing options. Click the "Delete" link in the lower-left corner of the dialog box.
Add different color markerspng at the end of the URL to get a blue marker. To add a green marker simply change it to green-dot. png so that the URL will be http://maps.google.com/mapfiles/ms/icons/green-dot.png .
When instatiating the DirectionsRenderer, set suppressMarkers to true.
directionsDisplay = new google.maps.DirectionsRenderer(
{
suppressMarkers: true
});
Here's the reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With