# Linking x and y\_ranges for GMapPlot

**URL:** <https://discourse.bokeh.org/t/linking-x-and-y-ranges-for-gmapplot/948>\
**Category:** Community Support\
**Created:** [January 19, 2016, 9:54pm UTC](https://discourse.bokeh.org/t/linking-x-and-y-ranges-for-gmapplot/948 "2016-01-19T21:54:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eburgess](https://discourse.bokeh.org/letter_avatar_proxy/v4/letter/e/dc4da7/32.png) [@eburgess](https://discourse.bokeh.org/u/eburgess)\
**Post date:** [January 19, 2016, 9:54pm UTC](https://discourse.bokeh.org/t/linking-x-and-y-ranges-for-gmapplot/948/1 "2016-01-19T21:54:34Z")

</div>

I’m trying to generate a series of GMapPlots with linked axes. I have linked the ranges as one would with a normal plot. This works but only links the plotted glyphs, not the google map background. If you zoom in on one map, the points on the other map also zoom in, but the background map remains stagnant and hence lose their correct location. Is it possible to link the google map range as well? Thanks!

```auto
map_options = GMapOptions(**gmapoptions)
plot1 = GMapPlot(**gmapplotoptions)

circle = Circle(x="lon", y="lat", size=8, fill_color='colors', fill_alpha=0.5, line_color=None)
plot1.add_glyph(source, circle)

map_options = GMapOptions(**gmapoptions)
plot2 = GMapPlot(**gmapplotoptions)

circle = Circle(x="lon", y="lat", size=8, fill_color='colors', fill_alpha=0.5, line_color=None)
plot2.add_glyph(source, circle)

```

```auto

```

```auto

```

plot1.x\_range=plot2.x\_range  
plot1.y\_range=plot2.y\_range

```auto

```

```auto

p = vplot(plot1, plot2)

show(p)
```

---

<div class="post-metadata">

**Author:** ![Bryan](https://discourse.bokeh.org/user_avatar/discourse.bokeh.org/bryan/32/3625_2.png) [@Bryan](https://discourse.bokeh.org/u/Bryan)\
**Post date:** [January 19, 2016, 10:02pm UTC](https://discourse.bokeh.org/t/linking-x-and-y-ranges-for-gmapplot/948/2 "2016-01-19T22:02:35Z")

</div>

Google Maps insist on controlling the displayed view bounds in order to maintain a specific aspect ratio. It is not possible to arbitrarily set the bounds of of a Google Map, you can merely give it a suggested rectangular area, and it computes display bounds to contain that suggested area, according to its own rules. We have no control over that behaviour. If you want a single Google Map to drive other non-GMapPlots, I would say that's probably fine. If you need two GMapPlots linked or want non-GMapPlot ranges to drive a GMapPlot range, I am not sure there is anything that can be done. Though perhaps others will have ideas I am not aware of.

I will say there are new TileRenderer classes that can use different tile sources (e.g. Open Layers) besides Google Maps, and these can have their bounds set arbitrarily. Perhaps that might be a better option to investigate for this use-case.

Bryan

> **···**
>
> > On Jan 19, 2016, at 3:54 PM, eburgess@airsci.com wrote:
> > 
> > I'm trying to generate a series of GMapPlots with linked axes. I have linked the ranges as one would with a normal plot. This works but only links the plotted glyphs, not the google map background. If you zoom in on one map, the points on the other map also zoom in, but the background map remains stagnant and hence lose their correct location. Is it possible to link the google map range as well? Thanks!
> > 
> > map\_options = GMapOptions(\*\*gmapoptions)  
> > plot1 = GMapPlot(\*\*gmapplotoptions)
> > 
> > circle = Circle(x="lon", y="lat", size=8, fill\_color='colors', fill\_alpha=0.5, line\_color=None)  
> > plot1.add\_glyph(source, circle)
> > 
> > map\_options = GMapOptions(\*\*gmapoptions)  
> > plot2 = GMapPlot(\*\*gmapplotoptions)
> > 
> > circle = Circle(x="lon", y="lat", size=8, fill\_color='colors', fill\_alpha=0.5, line\_color=None)  
> > plot2.add\_glyph(source, circle)
> > 
> > plot1.x\_range=plot2.x\_range  
> > plot1.y\_range=plot2.y\_range
> > 
> > p = vplot(plot1, plot2)
> > 
> > show(p)
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.  
> > To post to this group, send email to bokeh@continuum.io.  
> > To view this discussion on the web visit [https://groups.google.com/a/continuum.io/d/msgid/bokeh/0b6a0658-72f8-48e4-98eb-d4e46e305162%40continuum.io\](https://groups.google.com/a/continuum.io/d/msgid/bokeh/0b6a0658-72f8-48e4-98eb-d4e46e305162%40continuum.io%5C).  
> > For more options, visit [https://groups.google.com/a/continuum.io/d/optout\](https://groups.google.com/a/continuum.io/d/optout%5C).

---

<div class="post-metadata">

**Author:** ![eburgess](https://discourse.bokeh.org/letter_avatar_proxy/v4/letter/e/dc4da7/32.png) [@eburgess](https://discourse.bokeh.org/u/eburgess)\
**Post date:** [January 20, 2016, 5:02pm UTC](https://discourse.bokeh.org/t/linking-x-and-y-ranges-for-gmapplot/948/3 "2016-01-20T17:02:10Z")

</div>

Thanks Bryan! Looks like I should look into open layers. Two followups. First, Is there a way to access that rectangle through a GMapPlot instance or would we have to go with the straight google api? Secondly, in a single GMapplot instance how is the the plot scaled to the gmap if you can’t set the Gmap bounds? Is the rectangle specified, then actual map bounds retrieved and then the plot scaled accordingly?

Thanks,

Evan

> **···**
>
> On Tuesday, January 19, 2016 at 2:02:40 PM UTC-8, Bryan Van de ven wrote:
> 
> > Google Maps insist on controlling the displayed view bounds in order to maintain a specific aspect ratio. It is not possible to arbitrarily set the bounds of of a Google Map, you can merely give it a suggested rectangular area, and it computes display bounds to contain that suggested area, according to its own rules. We have no control over that behaviour. If you want a single Google Map to drive other non-GMapPlots, I would say that’s probably fine. If you need two GMapPlots linked or want non-GMapPlot ranges to drive a GMapPlot range, I am not sure there is anything that can be done. Though perhaps others will have ideas I am not aware of.
> > 
> > I will say there are new TileRenderer classes that can use different tile sources (e.g. Open Layers) besides Google Maps, and these can have their bounds set arbitrarily. Perhaps that might be a better option to investigate for this use-case.
> > 
> > Bryan
> > 
> > > On Jan 19, 2016, at 3:54 PM, [ebur...@airsci.com](mailto:ebur...@airsci.com) wrote:
> > 
> > > I’m trying to generate a series of GMapPlots with linked axes. I have linked the ranges as one would with a normal plot. This works but only links the plotted glyphs, not the google map background. If you zoom in on one map, the points on the other map also zoom in, but the background map remains stagnant and hence lose their correct location. Is it possible to link the google map range as well? Thanks!
> > 
> > > map\_options = GMapOptions(\*\*gmapoptions)
> > 
> > > plot1 = GMapPlot(\*\*gmapplotoptions)
> > 
> > > circle = Circle(x=“lon”, y=“lat”, size=8, fill\_color=‘colors’, fill\_alpha=0.5, line\_color=None)
> > 
> > > plot1.add\_glyph(source, circle)
> > 
> > > map\_options = GMapOptions(\*\*gmapoptions)
> > 
> > > plot2 = GMapPlot(\*\*gmapplotoptions)
> > 
> > > circle = Circle(x=“lon”, y=“lat”, size=8, fill\_color=‘colors’, fill\_alpha=0.5, line\_color=None)
> > 
> > > plot2.add\_glyph(source, circle)
> > 
> > > plot1.x\_range=plot2.x\_range
> > 
> > > plot1.y\_range=plot2.y\_range
> > 
> > > p = vplot(plot1, plot2)
> > 
> > > show(p)
> > 
> > > –  
> > > You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
> > 
> > > To unsubscribe from this group and stop receiving emails from it, send an email to [bokeh+un...@continuum.io](mailto:bokeh+un...@continuum.io).
> > 
> > > To post to this group, send email to [bo...@continuum.io](mailto:bo...@continuum.io).
> > 
> > > To view this discussion on the web visit [https://groups.google.com/a/continuum.io/d/msgid/bokeh/0b6a0658-72f8-48e4-98eb-d4e46e305162%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/0b6a0658-72f8-48e4-98eb-d4e46e305162%40continuum.io).
> > 
> > > For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads.bokeh.org/original/2X/1/14eb24f9e10e4e9b78e3f10f66c04ffa96446e5a.svg) [@system](https://discourse.bokeh.org/u/system)\
**Post date:** [July 21, 2021, 9:07pm UTC](https://discourse.bokeh.org/t/linking-x-and-y-ranges-for-gmapplot/948/4 "2021-07-21T21:07:22Z")

</div>


