문제

I'm using the following code (from this guide) to move the user to their current, geographical location. However, although the call-back for success works as supposed to, the one for error doesn't seem to get fired (despite that #1 in the API states that it should).

var geolocationProvider = new Microsoft.Maps
  .GeoLocationProvider(map).getCurrentPosition({
    successCallback: function (data) { alert("Yey!"); },
    errorCallback: function (data) { alert("Buu!"); },
  ...
});

That begs three questions.

  1. Can I, and if so how, react to the user clicking not to share the GIS info?
  2. Can I, and if so how, react to the user preselecting not to share the GIS info?
  3. What event is errorCallback() listening to?
도움이 되었습니까?

해결책

You need to set a timeout for that to work. As mentioned in the docs:

3 The time specified in timeout has been exceeded.

By default there is no timeout specified, so unless there is a real error then nothing will ever happen.

The length of time, in milliseconds, to allow for the geo location request to return. By default there is no timeout.

When the user decided not to share their location information nothing happens. So specify a timeout and then your error message will fire after that amount of time.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top