5

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.

3
  • 5
    Is this a web or GUI project? Commented 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. Commented 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. Commented Nov 9, 2012 at 20:12

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

to give you an exemple : using PyQt, the PyQt.QtWebKit module could answer your problem. from PyQt4 import QtCore, QtGui, QtWebKit # assuming you already have created a window etc.. self.web = QtWebKit.QWebView() self.web.load(QtCore.QUrl(page_url))
With PyQt, you can do things like: self.web.page().currentFrame().evaluateJavaScript("zoomMapOut()") to change the map from your the rest of your application.
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
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.