Change google maps default location

Hello

I have a question regarding the map component which I already have an API key for (and it works).

When a user opens the map, I want the map to automatically start from a certain location every time. Since my app revolves around Sweden, I want the map to start from Sweden (Stockholm, more exactly) and not force the user to zoom in every time. Because right now, the map starts from a world view.

I hope this can be solved in Adalo, but I might need to ask the google maps api support.

Nevertheless, this is something I’d love to have in my app, since I’m afraid the users are gonna get soo annoyed from having to zoom into Stockholm every time.

Thanks in advance!

PS. Perhaps this could be done by asking the user to track their location, which possibly means the map automatically zooms into their location. Don’t know though.

If you can’t get this to work I really recommend the tomtom api for maps- more so than google. It’s has a better free tier than google as well.

1 Like

But does that work with tomtom though, to change the maps default location?

(Side note with dumb question: adalo says “enter google maps api key” but then what you’re saying is that tomtom api key works too, right?)

This is quite easy to achieve and can be done a number of ways. The way I would do it is like this:

Create an input field on the same page as your map and name it Stockholm Input.

Reduce the size of the input field and make it invisible with the following style settings:

Now set an action on screen load that sets the Stockholm Input field to Stockholm:

Now set the map marker value to be the Stockholm Input value:

image

Voila!

image

You could customise this further by setting the Stockholm Input to Stockholm only if the user has no address set, amongst many other ways.

Hope this helps. Please mark as solution if it has worked for you and let me know if you need any further advice :slight_smile:

4 Likes

You’re a hero!

And since I actually want my user to have a search bar (which I didnt think of at the time of writing the post) I just made the search bar visible and changed its default value to Stockholm.

Thank you so much for the detailed instructions and for adding pictures.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.