I am developing tracking web view of delivery app using react-google-maps (https://tomchentw.github.io/react-google-maps/). I need to customize the icon of the waypoints marker. I already search in google and integrate to my codes but unfortunately none worked. Data are from api response.
Here's my code.
const TrackingMap = compose(
withProps({
googleMapURL: "https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&v=3.exp&libraries=geometry,drawing,places",
loadingElement: <div style={{ height: `100%` }} />,
containerElement: <div style={{ height: '700px', width:'100%' }} />,
mapElement: <div style={{ height: '100%' }} />,
}),
withScriptjs,
withGoogleMap,
lifecycle({
componentDidMount() {
let destinationLat, destinationLng, pickupLat, pickupLng;
var waypts = [];
var wayptsMarker = [];
const DirectionsService = new google.maps.DirectionsService();
for (let i = 0; i < points.length; i++) {
if (i < points.length-1 ) {
waypts.push({
location: new google.maps.LatLng(parseFloat(points[i].destination_latutude), parseFloat(points[i].destination_longitude)),
stopover: true,
});
}
if (i == 0) {
pickupLat = parseFloat(points[i].pickup_latutude)
pickupLng = parseFloat(points[i].pickup_longitude)
}
if (i == points.length-1) {
destinationLat = parseFloat(points[i].destination_latutude);
destinationLng = parseFloat(points[i].destination_longitude);
}
}
DirectionsService.route({
origin: new google.maps.LatLng(parseFloat(bookingDetails.rider_latitude), parseFloat(bookingDetails.rider_longitude)),
destination: new google.maps.LatLng(destinationLat, destinationLng),
waypoints: waypts,
travelMode: google.maps.TravelMode.DRIVING,
optimizeWaypoints: true,
}, (result, status) => {
if (status === google.maps.DirectionsStatus.OK) {
this.setState({
directions: result,
});
} else {
alert(`error fetching directions ${result}`);
}
});
}
})
)(props =>
<GoogleMap
defaultZoom={7}
defaultCenter={{ lat: parseFloat(bookingDetails.rider_latitude), lng: parseFloat(bookingDetails.rider_longitude) }}
>
{props.directions &&
<DirectionsRenderer
suppressMarkers= {true}
directions={props.directions}
geodesic={true}
options={{
polylineOptions: {
strokeOpacity: 1.0,
strokeColor: '#F36629',
strokeWeight: 6,
},
}}
/>
}
</GoogleMap>
);