Google maps API doesn't work in safari

2019-07-14 05:58发布

问题:

hello im hosting Google maps API on my localhost for now, and it appears fine in Chrome and the mobile phone version. (both safari and chrome iPhone versions).

My problem is Google maps doesn't show when it comes to my Mac version of Safari. the Grey(background) shows and the cursors change to the Google maps cursor, but the map and content doesn't display. what can be the problem?

Here is a link to the map. as you can see the map displays in Chrome but not in safari.(at least not for me).

http://jsbin.com/cahicomame/1/edit?html,output

回答1:

there is no guarantee that navigator.geolocation.getCurrentPosition will return a result. The user may deny the permission or the geolocation-service may not be able to locate the user.

You better initialize the map with a default-center (center is required to display the map).



回答2:

I find the solution after 1 hours , it's because my website (developpement) was in http and not https :) Safari will ask your localisation.