Dynamically Adding Google Maps with Marker In Django

Google Maps allows you to display maps on your website,  we can also customize maps, and the information on maps.

The Google Maps API is a JavaScript library. It can be added to a web page with the following script tags:

 

We are creating a div to holds the google map. Here we are also giving an option to search the place on a google map.

 
   
 

then add a DOM listener that will execute the getGoogleMap() function on window load (when the page is initially loaded):

google.maps.event.addDomListener(window, "load", getGoogleMap)
 

In the above example, we are already loading 3 markers in Bangalore, Chennai, Hyderabad.

Then again if a user marks any location, it will display the marker with longitude, latitude of the place(if u want to store) by deleting user previously selecting markers.


We can also set the position description dynamically using the info window

    By Posted On
SENIOR DEVELOPER at MICROPYRAMID

Latest Comments
Related Articles
How to customize the admin actions in list pages of Django admin? Chaitanya Kattineni

Django by default provides automatic admin interface, that reads metadata from your models to provide a beautiful model interface where trusted users can manage content ...

Continue Reading...
Improving page speed score in Google Page Score test- PART2 Chaitanya Kattineni

In our previous blog post we got an idea of what are the things that Google's Page Speed Insights will take into count to give ...

Continue Reading...
Introduction to Django's Class based views - Understanding how a class based view works Ashwin Kumar

Django has MVT architecture. A view in django is just a callable that takes a request and returns a response. But this can be more ...

Continue Reading...

Subscribe To our news letter

Subscribe to our news letter to receive latest blog posts into your inbox. Please fill your email address in the below form.
*We don't provide your email contact details to any third parties