1

I have a geolocation control in OpenLayers 3. The problem is that when clicked in IE11, the user is prompted for permission to geolocate. I want to pan to the geolocation position if and after that permission is granted. I think what happens with my code now is that it tries to pan before permission has been granted:

geolocation.setTracking(true);
map.getView().setCenter(geolocation.getPosition());

How can I do this?

1 Answer 1

1

How about something like:

if(geolocation.position_ != null){
    map.getView().setCenter(geolocation.getPosition());
}

or:

if(geolocation.getPosition != 'undefined)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.