[Python] Failed to display Glyphs (points) on Bokeh Google Map graph with valid API key and...

Discussão em 'Python' iniciado por Stack, Outubro 5, 2024.

  1. Stack

    Stack Membro Participativo

    I am attempting to display points (glyphs) on a Bokeh Google Map graph using valid latitude and longitude data from a CSV file. Although the map renders correctly with the specified API key, the circles representing the data points do not appear on the map. I have verified the data types and ensured the map options are set to a relevant location, yet the points remain absent.

    Below is what I tried:

    from bokeh.models import ColumnDataSource, GMapOptions
    from bokeh.plotting import gmap
    from bokeh.io import output_file, show
    import pandas as pd

    output_file("gmap.html")

    edu = pd.read_csv('adult_education.csv')
    latitude = edu['Latitude']
    longitude = edu['Longitude']

    map_options = GMapOptions(lat=50.748165, lng=-122.595148, map_type="roadmap", zoom=5)

    p = gmap("Valid API", map_options, title="Vancouver")
    source = ColumnDataSource(
    data=dict(lat=latitude.tolist(),
    lon=longitude.tolist()))

    p.circle(x="lon", y="lat", size=20, fill_color="blue", fill_alpha=0.8, source=source)

    show(p)


    Below is what I got:

    enter image description here

    This is what I was expecting: enter image description here

    Continue reading...

Compartilhe esta Página