38
Views
4
Comments
Google Map not centering when using Latitude/Longitude
Application Type
Reactive

I am using the stock Outsystems Map block for a list of coordinates (testing with 3).

Going the google API route and using text addresses works fine, zero issues.

Going with Latitude/Longitude values for some reason auto-centers to the first address in the list with no other changes from the working set-up.
It also seems to ignore the Center parameter, as I passed a different lat/long value at it and nothing changes.

Can't share the OML for many reasons, but there is nothing complex to the setup. I am just passing this hardcoded list of 3 coordinates at a block holding the map, and the markers are in a list of those coordinates. I have rotated the values in the list to confirm its centering on index 0's coordinate.

Confirmed all coordinates are correctly passing to the block, and the markers are in the correct place, just appearing off-screen.

Also confirmed no issues on the google console side. The exact same setup works just fine if I go back to explicit addresses.

Has anyone else experienced this?


Thanks,

Kyle

UserImage.jpg
Loi Yih Rong

Halo @Kyle Decker , I've using hardcoded LatLong value in the OS map widget, i didn't faced such issue that you mentioned here. 

"Going with Latitude/Longitude values for some reason auto-centers to the first address in the list with no other changes from the working set-up.
It also seems to ignore the Center parameter, as I passed a different lat/long value at it and nothing changes. "


From what you mentioned above, do you intend to use 3 coordinate values in the list of yours, and the map will center itself accordingly when you switch to those value. Did i get it right?

Perhaps you can provide a snapshot if possible instead of oml so friends in the community can have more insight.

Regards,
Loi

2023-09-06 14-42-47
Kyle Decker

Hi Loi,

That's correct, I'm testing with a list of 3 lat/long values currently, but the plan is to have a variable list based on end-user selections. 

The OS Map does have default values of Auto for zoom to see all markers and on render of my 3 points here is what i get when I set Center to the dark blue marks coordinates.

Here is what i should get.

I'm able to shift to that correct point without changing the zoom, so I think the Auto zoom default is working, but I'm setting the Center input to that dark blue mark and its being ignored.

I found this in the description of the Center input.

It seems like a map with multiple markers doesn't reference the center value.

I can work around that by setting up this block to place the center position to the first in the list, but that's pretty annoying.

I'm curious if using the Google Geocoding API that fires when you use explicit addresses is doing this behind the scenes since the centering works fine with addresses

UserImage.jpg
Loi Yih Rong

Halo @Kyle Decker , sorry that i just saw your reply late. Based on what you mentioned above, its somehow similar to what I've done before. 

For my case, what i did was instead of using the list to get the center, I've used a local variable to store the Lat/Long value that user selected,

so when a user select one of the marker(which one of the list that contain Lat/Long value), it will assign to the local and the map will refresh according to use the local variable as a map center.

Not sure if this same situation with yours, and apologize i dont have the OML for you. But if you want, we can discuss this on other platform as i might missed it here :')


2023-09-06 14-42-47
Kyle Decker

Hi Loi,

That idea won't really work as the map I will be outputting could include various states and countries. So getting all points within the zoom view on first load is important.

Currently I have my block taking the list of all lat/long values and finding the average and placing that in the coordinate list at position 0 so it's the default center, and then I conditionally set the marker Icon to a 1px x 1px fully transparent PNG.

If the map truly only works off the position 0 coordinate in the list when using lat/long, then this is the best way I can think to work around the issue.

Thanks,
Kyle

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.