I am faced with a situation where the user does not want to allow the system to use the google location api to center the map on them.
I need to set a default value if the user opts out of using the location. Is there a way to accomplish this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes there is! Google maps uses navigator.geolocation.getCurrentPosition() method to get your current location. This method allows a success callback (when a user says yes) and error callback (when user says no). It is also good to check if the browser supports geolocation. The following shows how to use it
There is also an example on google maps api docs to show this in context of google maps usage
https://developers.google.com/maps/articles/geolocation