Nowadays, Google map plays an important role in building websites because everyone wants to track the live locations of their customers to acquire some valuable information about them and target those customers to grow their business.
In order to add a marker to the Google map, we have to pass some parameters in the Marker constructor by creating the marker object with the help of google. maps.Marker.
Below are the required parameters for the construction of the marker
- position:- This defines the initial location where the marker is to be placed according to the latitude and longitude.
- map:- This indicates the map on which the marker is to be displayed. This property is optional but if you do not include the map property in the marker construction, you will not be able to see the marker on the map. Alternatively, you can add the marker by calling the setMap() method with the help of the marker object as shown below
Google maps custom marker example
Conclusion:- I hope this tutorial will help you to understand the concept. If there is any doubt then please leave a comment below