Re-Center Map to Geolocation

Hello all,

There was a discussion earlier to determine map center address. But we also need method in the workflow to recenter the map to the thing’s geolocation. if you drag the map away from the center there should a workflow to re-center it

Problem

If you use the command “Clear markers”, that will do it, as it resets the map to its default defined settings.

I currently use this method in my app.

I am afraid i had tried that with no success. The thing is the map needs to be reentered and not for the markers to be cleared.

No, you are right, once the map has been moved there seems to be no way to reset it to “initial”. Normally I would expect a group reset to work.

Do you think there could be a quick fix for this @emmanuel?

So yeah, apparently I was wrong. The map wasn’t being re-centered based on the “Clear markers” command in my app, it was re-centered because of how I was dynamically using the map’s center address. :stuck_out_tongue_closed_eyes:

The good news is that I figured out how to do it. But, you’ll actually have to use two maps to accomplish it. This is because apparently, if you try to dynamically change the center address of a map, but the value doesn’t change, the map doesn’t reset.

Anyway, here it is:

Run mode: https://forum_app2.bubbleapps.io/version-test/re-center_

Edit mode: https://bubble.io/page?type=page&name=re-center_&id=forum_app2&tab=tabs-1

You’ll want to change Atlanta, GA to whatever dynamic address you want to center in your app. You can change Columbia, SC to any address. It doesn’t matter. It’s only there to change the value of the hidden map so that it can reset back to default.

That is very complex :slightly_smiling:

Ok, so having a play …

I put a map inside a group, and reset the group and send the default data.

The map recentres … IF you are in debug mode !!! If you are in normal mode it doesn’t.

I have also got this to work by doing a page navigation to the same page …that recentres. Some of the time.

What it seems not to like is if you recentre before it has “loaded” ?

Anyway. The right button here seems to work.

1 Like

Yes, solving this is very complex indeed! :joy:

While there are apparently ways to work around it, it seems the best method to do something like this would be if we had a “re-center map” function like @AliFarahat suggested.

I think it is a bug. If you reset a repeating group, you get the “default” back. The behavior should be the same, it shoudl return to the initialized state.

But yeah, we need something.

Can’t you use the ‘Adjust map zoom’ action and click ‘set center and zoom manually’?

2 Likes

I will give that a try and let you know today!

Aha, never seen that before. It works :slight_smile:

Yep it works! But does not reset the value of the center address. That still remains held in the map element!

1 Like

Ah, so map centre is still where it was when you moved it ?

No, It recenter fine but the value of the center of map remains the last data centerofmap

Sorry, that’s what I meant. So if you recenter and then store the address from the centre… It is a different address ?

To elaberate more in the situation see below steps. Starting from a fresh page load.

  1. Map appears with no centerofmap address for example Value Null
  2. You drag the map and a new centerofmap address is captured. for example value A
  3. You re-center the map
  4. The map still holds Value A
1 Like

Thanks for the detail. Didnt want to end up testing everything again myself.

no problem @NigelG thanks for the support

2 Likes