Flask-GoogleMaps icon indicating copy to clipboard operation
Flask-GoogleMaps copied to clipboard

[bug]Maps not loading to page

Open phukeo opened this issue 4 years ago • 11 comments

I can't get the example maps to load to the page 'example.html'. When I go to my API metrics page on the Google Cloud Platform the number of calls to my API is not changing.

I have tested my API key with a standard JS request and it is increasing and therefore the key is working.

I have the following code on my app.py and my 'example.html' is exactly as is given in the repo front page.

Any ideas? Feedback is greatly appreciated.

from flask import Flask, render_template
from flask_googlemaps import GoogleMaps
from flask_googlemaps import Map

app = Flask(__name__)
app.config['GOOGLEMAPS_KEY'] = "my_API_key"
GoogleMaps(app, key="my_API_key")

@app.route("/")
def mapview():
    # creating a map in the view
    mymap = Map(
        identifier="view-side",
        lat=37.4419,
        lng=-122.1419,
        markers=[(37.4419, -122.1419)]
    )
    sndmap = Map(
        identifier="sndmap",
        lat=37.4419,
        lng=-122.1419,
        markers=[
          {
             'icon': 'http://maps.google.com/mapfiles/ms/icons/green-dot.png',
             'lat': 37.4419,
             'lng': -122.1419,
             'infobox': "<b>Hello World</b>"
          },
          {
             'icon': 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png',
             'lat': 37.4300,
             'lng': -122.1400,
             'infobox': "<b>Hello World from other place</b>"
          }
        ]
    )
    return render_template('example.html', mymap=mymap, sndmap=sndmap)

if __name__ == "__main__":
    app.run(debug=True)

phukeo avatar Apr 07 '21 10:04 phukeo

I have the same issue like @phukeo Google Maps API key works on a simple (hello world) page but not with Flask-googlemap plugin. I use version 4.1

plusangel avatar Apr 13 '21 18:04 plusangel

Just FYI I masked my API details in my original comment. As mentioned before my API key is working for other applications

phukeo avatar Apr 13 '21 18:04 phukeo

The solution is to use version 0.4.1.1, downloading the code from the releases page and not install it using pip which supports the previous version 0.4.1 @phukeo

plusangel avatar Apr 14 '21 19:04 plusangel

Just wanted to say I'm encountering the same error. will try @plusangel 's solution.

edit: worked like a charm :)

getcake avatar Apr 27 '21 21:04 getcake

Just wanted to say I'm encountering the same error. will try @plusangel 's solution.

edit: worked like a charm :)

Could you please provide the link to the release page of version 0.4.1.1

Bhumika-Kothwal avatar May 11 '21 05:05 Bhumika-Kothwal

Hello @Bhumika-Kothwal This is your place for the release

plusangel avatar May 11 '21 09:05 plusangel

Hello @Bhumika-Kothwal This is your place for the release

Thankyou! You helped me solve the probblem

Mengyujun avatar May 20 '21 02:05 Mengyujun

Just wanted to say I'm encountering the same error. will try @plusangel 's solution.

edit: worked like a charm :)

I am sorry but I am bit of a noob in python, how do I install it without going through pip? Thanks in advance!

yusef1990 avatar Jan 24 '22 18:01 yusef1990

No worries at all! You can find that specific release here and download a zip of the source.

plusangel mentioned not using pip to install, but this turned out to work fine for my use.

Just specify the directory of the folder when installing, and use a virtual environment if you plan on working with other versions. Also keep in mind the project now fully supports poetry.

pip install ~/bla/Flask-GoogleMaps-0.4.1.1/

getcake avatar Jan 25 '22 02:01 getcake

No worries at all! You can find that specific release here and download a zip of the source.

plusangel mentioned not using pip to install, but this turned out to work fine for my use.

Just specify the directory of the folder when installing, and use a virtual environment if you plan on working with other versions. Also keep in mind the project now fully supports poetry.

pip install ~/bla/Flask-GoogleMaps-0.4.1.1/

As you said before, worked like a charm! :) thank you so much!

yusef1990 avatar Jan 25 '22 15:01 yusef1990

If you're trying to do this in docker, you can add something like

# install python dependencies
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
RUN wget https://github.com/flask-extensions/Flask-GoogleMaps/archive/refs/tags/0.4.1.1.zip -O flask-googlemaps.zip
RUN pip install flask-googlemaps.zip

As I ran into this issue earlier today.

catscrdl avatar Jun 09 '23 04:06 catscrdl