netbox
netbox copied to clipboard
Google Geocoding
NetBox version
v3.2.3
Feature type
New functionality
Proposed functionality
It would be nice if Netbox could integrate with Google' Geocoding service to grab the GPS coordinates for an address that was inputted into the add new site page. Alternative Geocoding engines could be used, but Google seems the most popular.
Use case
We adding multiple sites, its time consuming to manually lookup the GPS location for each of them. Google's Geocoding API can automate this, and return the Latitude and Longitude for an address.
Database changes
You might have to change the latitude and longitude fields to allow more than 6 decimal places depending on what Google returns.
External dependencies
https://developers.google.com/maps/documentation/geocoding/overview There would have to be a place for the admin to enter the Google API credentials.
https://github.com/netbox-community/reports/blob/master/scripts/geolocate_site.py
There's a script that does exactly what you're wanting. OSM seems to be the most reliable geocoder. There is a small issue with the script....
Lines 17 and 32 need to be changed to:
- region = ObjectVar(model=Region)
- location = ObjectVar(model=Site)
And line 51 needs to be moved (inserted) after line 48. The full_clean() validator doesn't seem to work when it's in the 51 position.
I actually did this yesterday in our environment and it worked flawlessly after changing the above. You can run the script on a single site or against all sites.
I tried messing around with it by changing the geocoder from OSM to other providers (like Google) and I had issues. I ran the script against 4600+ sites and Google failed on more than 80%. OSM was perfect.
Thanks for letting me know. Is it possible to update the script with these changes in github?
Thanks for letting me know. Is it possible to update the script with these changes in github?
@wirestar & @shatt79
I merged the updated script / PR from @shatt79 . I also updated the script to include "All sites for a site group"
As such, I am closing this issue.