1 Reply Latest reply on Apr 22, 2013 12:25 PM by jfuerth

    how to get geolocation with errai-cordova

    milesifrr

      Hi everybody,

       

      I have already used the phonegap camera using @Inject Camera camera and it works perfectly.

       

      Now I need to find my user location with gps, so I thought to use the same approach and tried to inject com.googlecode.gwtphonegap.client.geolocation.Geolocation, but when I compile I get

       

          [exec] [ERROR] org.jboss.errai.ioc.rebind.ioc.exception.InjectionFailure: ambiguous injection type (multiple injectors resolved): com.googlecode.gwtphonegap.client.geolocation.Geolocation  @Any  @Default :

           [exec] [ERROR]      matching> org.jboss.errai.ioc.rebind.ioc.injector.basic.TypeInjector:com.googlecode.gwtphonegap.client.geolocation.js.GeolocationMobileImpl  @Any  @Default

           [exec] [ERROR]      matching> org.jboss.errai.ioc.rebind.ioc.injector.basic.TypeInjector:com.googlecode.gwtphonegap.client.geolocation.browser.GeolocationBrowserEmptyImpl  @Any  @Default

           [exec] [ERROR]   Note: configure an alternative to take precedence or remove all but one matching bean.

       

      So I tried com.googlecode.gwtphonegap.client.geolocation.GeolocationWatcher, but when I compile I get

           [exec] [ERROR] java.util.concurrent.ExecutionException: org.jboss.errai.ioc.rebind.ioc.exception.UnsatisfiedDependenciesException:  @> it.soluzione1.tpl.client.local.activity.ClientFactory

           [exec] [ERROR]  - field org.jboss.errai.codegen.meta.MetaField:it.soluzione1.tpl.client.local.activity.ClientFactory.geolocationWatcher could not be satisfied for type: com.googlecode.gwtphonegap.client.geolocation.GeolocationWatcher

           [exec] [ERROR]   Message: can't resolve bean: com.googlecode.gwtphonegap.client.geolocation.GeolocationWatcher ( @Default  @Any )

       

      I found out I can use org.jboss.errai.location.client.local.GeoLocationProvider that seems to be a wrapper around

      com.google.gwt.geolocation.client.Geolocation

      and seems to get its data from the browser. Does that work with gps? Or should I use the phonegap, classes configuring an alternative as suggested in the error stack trace?

       

      thans for your help

       

      ciao Francesco

        • 1. Re: how to get geolocation with errai-cordova
          jfuerth

          Hi Francesco,

           

          We're using the com.google.gwt.geolocation.client.Geolocation class in our demos.

           

          From the PhoneGap documentation, it appears that it doesn't matter which GWT wrappers you choose, because they actually wrap the same (W3C standard) API:

           

          This API is based on the W3C Geolocation API Specification. Some devices (Android, BlackBerry, Bada, Windows Phone 7, webOS and Tizen, to be specific) already provide an implementation of this spec. For those devices, the built-in support is used instead of replacing it with Cordova's implementation. For devices that don't have geolocation support, the Cordova implementation adheres to the W3C specification.

           

          Whichever way you go, see the PhoneGap docs for some hints about Android (your app needs to request permissions in order to get full GPS location accuracy).

           

          Hope that helps!

           

          Jonathan