Skip to main content
ProducerTina
Participant
February 25, 2013
Frage

Is it possible to use Geolocation with a StageWebView in Air 3.6 for mobile?

  • February 25, 2013
  • 1 Antwort
  • 873 Ansichten

My project was originally set up in Flash Builder with Air 3.2, and I have a StageWebView that gets called and loads a webpage on my site that uses the Google Maps JS API to mashup the map with some locations from a database call I make elsewhere. This works perfectly fine in all mobile browsers and devices when hitting the URL directly.

However, on both iOS 6 on an iPod Touch, and Android 4.1.1, the code gets as far as this:

function handleGeolocation() {

                                        // turn on local searching

                                        isLocalSearchOn = true;

                                        // Try HTML5 geolocation

                                        alert("hello" + navigator.geolocation);

                                        if( navigator.geolocation ) {

                                                  alert("inside");                                                                                                               // -> This gets alerted

                                                  navigator.geolocation.getCurrentPosition( getMyPosition, posFail );

                                                  } else {

                                                  // Browser doesn't support Geolocation

                                                  alert("fail 3");

                                                  handleNoGeolocation(false);

                                        }

                              }

In case you missed my note above in the ocde, the alert "Inside" appears within the app, and the code does not execute anything further.

getMyPosition and posFail are defined outside the above function, here:

function posFail(err) {

                                        alert("msg: " + err.message);

                              }

function getMyPosition(position) {

                                        alert("get my postition");

                                        alert("pos: " + position.coords.latitude + " " + position.coords.longitude);

                                        try {

                                                  var pos = new google.maps.LatLng( position.coords.latitude, position.coords.longitude );

                                                  map.setCenter( pos );

                                                  map.setZoom( 14 );

                                                  alert("success!");

                                        } catch(err) {

                                                  alert("fail 1");

                                                  handleNoGeolocation(true);

                                        }

                              }

Neither function alerts anything - neither the success, nor the fail functions.

I've checked Location Services on both devices - they are both turned on.

Why is this happening? As I said, the code works in-browser. Why isn't it working in my app?

I've attempted to upgrade to AIR 3.6, but so far, no change in behaviour. It still just craps out at that point.

Dieses Thema wurde für Antworten geschlossen.

1 Antwort

ProducerTina
Participant
March 1, 2013

Okay I've changed my environment to FB 4.7 and Air 3.4 SDK. The permission dialogue now works in iOS 6, however, in Android 4.1.1 it still remains suppressed. Has anyone been able to figure this out?