Possibility to add custom controls to Google Map component

Right now it’s only possible to add to a Google Maps component an instance of Google Maps Overlay:

TypeError: Cannot add component. Only GoogleMap overlay components may be added to a GoogleMap instance.

The GoogleMaps module offers all the default controls that you can set on a google maps, however, the option to push custom controls is missing right now:

From what I can see, to add a custom control nothing out of the ordinary is needed: only the position and the component.

I was thinking that you could create a GoogleMaps.CustomControl(content, position) to add like any other overlay.

Is that possible to implement?

If position is in pixels, it looks like you might be able to build one using an XYPanel. Your Google Map component would be the first to go inside. Any components you add later, to the XYPanel, will appear on top of that, at the pixel coordinates you specify.

1 Like

Hum… Yeah, I could possibly do that, however XYPanels don’t usually look ok on different sizes of screen. I’m building an app that should work on different devices, mostly smartphones, so I try to avoid using XYPanels.

I made the request because the Google Map component (to my knowlege) is a wrapper of the Google Map js API from Google, and the option to add controls is already there, so I don’t think that should be too much of a hassle to implement it in python (of course, I don’t know if internally that would require too much work).

But I will try your suggestion for now, to see how it would look, thanks!

And while you could conceivably adjust for that on App startup, Windows users can drag the web page to a different-sized monitor, and mobile users can rotate or screencast the screen, so the adjustment would have to be dynamic (or as they say these days, “responsive”).

Best of luck!

I usually do that for a few pages, like reducing the font size or removing certain information that is less important when I detect that the user is in mobile devices, but I try to do most things in a way that I don’t have to, since it’s super annooying to do haha.

1 Like