Ok Got Cross Browser Safari vs Chrome GEO Location sorted out

Ok Got Cross Browser Safari vs Chrome GEO Location sorted out

For the past few days, amongst the distractions and the on going React.js tutorials I been watching, I have been working on the issue of Safari on the MacBook not looking up the user location.

This works great on Chrome which was the main development platform.

Chrome makes us ask the user for permission to capture their geo location.

That is the popup a user sees when they first visit the map. The question is only enabled on the map page because the initial user experience is “Show me what’s going on around me. It’s part of the WOW factor. If the user closes the popup without reading it or says “no” then the map view has to default to something and we default it to the home office address.

We used to call this the “Africa fix” because the initial default 0.0 lat and 0.0 long map was somewhere off the coast of Africa.

As it turned on, one reason Mapertunity did not initially work on iPhone or Safari browsers was that question.

The Safari browser did not support the “request user permission” command.

I did some further research and figured out a way to test the user browser and if they are on Chrome, then I do the regular syntax to trigger a popup request to get the users permission to capture their location (we don’t currently store that any where, just use it to center the map on their location. If they close the browser, the data is lost till the next time they visit) and if they are on Safari, we skip the permission request. If they say “yes go ahead” then we trigger the next command to get their location.

I was able to test the browser detect logic on both a windows and an apple macBook and that part worked ok.

The second command, get their location, worked fine on Chrome but it was failing on Safari.

After a day of troubleshooting, I was able to track down the issue to Safari has to be enabled to let others capture their location.

Chrome probably has a similar option but I have never had to mess with it.

So on this borrowed MacBook I discovered that the option was turned off. I tried to turn it on but I did not know the users password for the machine so I had to figure out a work around.

So I had a generous Beta Tester in Spain with a macBook who agreed to  test the geolocation part of the map with the Safari browser.

I told the user to make sure the safari geolocation option was enabled and they ran the test.

Worked like a charm.

As it turns out, Safari has it built in to trigger a popup informing the user that an application is requesting their location.

So on Safari the “request user permission” was baked in and not necessary and Safari was able to geolocate the user no problem and center the map on Spain.

But a new issue turned up.

Even though, Safari has captured the users location, this does not trigger an automatic map refresh.

We used to do this but I felt it was too many refreshes and I disabled that.

I think I might need to turn that back on.

There is a hidden map refresh, however, if you mouse over the drop down for center map on “My current location” it will trigger a map refresh.

So new requirement. Trigger a map refresh after capturing user location.

Stay tuned. Or just check the map in a few day.

Doug Ayers

Douglas Ayers

Douglas Ayers

About Mapertunity

Welcome to Mapertunity, a new way of posting jobs and finding jobs. We are on a mission to help every single person and every single business find each other, and then put them to work.

Recent Posts

Subscribe to our Blog

We will notify you every time we publish a new blog.