I'm working on a project in Python using tkinter that will allow for geolocation of IP addresses. I have the raw conversions down, and I can take an IP address and know city, state, country, longitude, latitude, etc. I'm wondering if there's any way to embed Google Maps or something similar into my program to offer a visual representation.
-
5Is this a web or GUI project?JeffS– JeffS2012-11-08 18:26:45 +00:00Commented Nov 8, 2012 at 18:26
-
This is just me, but I'd almost rather prefer you open the link to the map in my browser. I am not a huge fan of those limited functionality maps.yurisich– yurisich2012-11-09 16:42:03 +00:00Commented Nov 9, 2012 at 16:42
-
The whole point is that you have a list of IP addresses on one side of the window, and by clicking on one, the map on the other side of the window will show you where the address is located. It's not meant to be fully functional (as far as Google Maps is concerned), just for quick reference.bbbgscott– bbbgscott2012-11-09 20:12:23 +00:00Commented Nov 9, 2012 at 20:12
Add a comment
|
2 Answers
Most GUI Frameworks have a way to embed a web browser frame, with a way to execute javascript from the python code. If this is available to you, you could use the Google Maps JavaScript API v3 to display a map.
If you let us know which GUI framework you're using, we might be able to help more.
3 Comments
JeffS
With PyQt, you can do things like:
self.web.page().currentFrame().evaluateJavaScript("zoomMapOut()") to change the map from your the rest of your application.JeffS
Tkinter doesn't have a way to easily embed webviews, you could look at PyGtk2Tk, or maybe just use Google's static map api and display a non-interactive image
If you don't need interactivity, the Static Maps API should be simple to integrate into your application. Just build a URL for the map and then download the image and display it.
Note that the API Terms have special provisions for non-web-based applications.