Skip to content

GMapPlot Coordinate Axes #2940

@avanetten

Description

@avanetten

GmapPlot no longer displays lat/lon coordinates in useful formats. It's hard to quantify this due to issue #2939, but it also appears that points are appearing ~20 pixels to the left of where they ought to be projected on a map. The code below is the exact same as from issue #2822.

from __future__ import print_function
from bokeh.browserlib import view
from bokeh.document import Document
from bokeh.embed import file_html
from bokeh.models.glyphs import Circle
from bokeh.models import (
    GMapPlot, GeoJSPlot, Range1d, ColumnDataSource, LinearAxis,
    PanTool, WheelZoomTool, BoxSelectTool, ResetTool,
    BoxSelectionOverlay, GMapOptions, GeoJSOptions, GeoJSPlot, 
    NumeralTickFormatter, PrintfTickFormatter)
from bokeh.resources import INLINE

gmap_options = GMapOptions(lat=30.2861, lng=-97.7394, map_type="roadmap", zoom=13)

x_range = Range1d()
y_range = Range1d()

plot = GMapPlot(
        x_range=x_range, y_range=y_range,
        map_options=gmap_options,
        title = "Austin")


source = ColumnDataSource(
    data=dict(
        lat=[30.2861, 30.2855, 30.2869],
        lon=[-97.7394, -97.7390, -97.7405],
        fill=['orange', 'blue', 'green']
    )
)

circle = Circle(x="lon", y="lat", size=15, fill_color="fill", line_color="black")
plot.add_glyph(source, circle)

plot.add_tools(PanTool(), WheelZoomTool(), ResetTool())

xaxis = LinearAxis(axis_label="lat", major_tick_in=0, formatter=NumeralTickFormatter(format="0.000"))
plot.add_layout(xaxis, 'below')

yaxis = LinearAxis(axis_label="lon", major_tick_in=0, formatter=PrintfTickFormatter(format="%.3f"))
plot.add_layout(yaxis, 'left')

doc = Document()
doc.add(plot)

if __name__ == "__main__":
    filename = "maps.html"
    with open(filename, "w") as f:
        f.write(file_html(doc, INLINE, "Maps Example"))
    print("Wrote %s" % filename)
    view(filename)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions