Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]Maps not loading to page #146

Open
phukeo opened this issue Apr 7, 2021 · 11 comments
Open

[bug]Maps not loading to page #146

phukeo opened this issue Apr 7, 2021 · 11 comments
Labels

Comments

@phukeo
Copy link

phukeo commented Apr 7, 2021

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 phukeo added the bug label Apr 7, 2021
@plusangel
Copy link

plusangel commented Apr 13, 2021

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

@phukeo
Copy link
Author

phukeo commented Apr 13, 2021

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

@plusangel
Copy link

plusangel commented Apr 14, 2021

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

@getcake
Copy link
Member

getcake commented Apr 27, 2021

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

edit: worked like a charm :)

@Bhumika-Kothwal
Copy link

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

@plusangel
Copy link

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

@Mengyujun
Copy link

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

Thankyou! You helped me solve the probblem

@yusef1990
Copy link

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!

@getcake
Copy link
Member

getcake commented Jan 25, 2022

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/

@yusef1990
Copy link

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!

@catscrdl
Copy link

catscrdl commented Jun 9, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants