user
user

Reputation: 103

Python gmplot has no attitribute 'GoogleMapPlotter'

I am trying to use gmplot for the first time. I installed it fine. I was trying to run the sample code just to see it work before I started to do anything, and got this: AttributeError: module 'gmplot' has no attribute 'GoogleMapPlotter'

Below is the sample code for gmplot:

import gmplot

gmap = gmplot.GoogleMapPlotter(37.428, -122.145, 16)

gmap.plot(latitudes, longitudes, 'cornflowerblue', edge_width=10)
gmap.scatter(more_lats, more_lngs, '#3B0B39', size=40, marker=False)
gmap.scatter(marker_lats, marker_lngs, 'k', marker=True)
gmap.heatmap(heat_lats, heat_lngs)

gmap.draw("mymap.html")

I installed Google API Client Libraries

pip install --upgrade google-api-python-client

and then upgraded gmplot.

pip install --upgrade gmplot

I tried running it with Python 2.7 and 3.6.

All with the same result. Any ideas?

Upvotes: 1

Views: 2633

Answers (1)

UserK
UserK

Reputation: 908

Try to uninstall gmplot with:

sudo pip uninstall gmplot

Then reinstall it. I used pip3 to install the package and I got the 1.20 version. The sample script provided by the github readme doesn't work out of the box but it is just to illustrate the usage.

Try this and save it test.py

import gmplot

gmap = gmplot.GoogleMapPlotter(37.428, -122.145, 16)
latitudes = [37.428,]
longitudes = [-122.145,]
more_lats = [37.429,]
more_lngs = [-122.147,]

gmap.plot(latitudes, longitudes, 'cornflowerblue', edge_width=10)
gmap.scatter(more_lats, more_lngs, '#3B0B39', size=40, marker=False)

gmap.draw("mymap.html")

Execute it with python3 test.py and a mymap.html file should appear in your folder.

Upvotes: 1

Related Questions