You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/06/12 07:11:07 UTC

[GitHub] [cordova-plugin-geolocation] chendengyuanxm removed a comment on issue #152: ERROR TypeError: Object(...) is not a function

chendengyuanxm removed a comment on issue #152:  ERROR TypeError: Object(...) is not a function
URL: https://github.com/apache/cordova-plugin-geolocation/issues/152#issuecomment-501149188
 
 
   > I meet same problem, may someone have solutions fix it?
   
   If you import like this :
   import { Geolocation } from '@ionic-native/geolocation/ngx';
   
   Don't invoke like this when you invoke getCurrentPosition:
   `this.geolocation.getCurrentPosition().then((resp) => {
    // resp.coords.latitude
    // resp.coords.longitude
   }).catch((error) => {
     console.log('Error getting location', error);
   });`
   It should be use navigator instead:
   `navigator.geolocation.getCurrentPosition((position) => {...}));`
   
   > ```js-jsx
   > ERROR TypeError: Object(...) is not a function
   >     at Geolocation.getCurrentPosition (index.js:28)
   >     at SurveyFormPage.webpackJsonp.257.SurveyFormPage.showPopup (survey-form.ts:59)
   >     at Object.eval [as handleEvent] (SurveyFormPage.html:16)
   >     at handleEvent (core.js:13589)
   >     at callWithDebugContext (core.js:15098)
   >     at Object.debugHandleEvent [as handleEvent] (core.js:14685)
   >     at dispatchEvent (core.js:10004)
   >     at core.js:10629
   >     at HTMLButtonElement.<anonymous> (platform-browser.js:2628)
   >     at t.invokeTask (polyfills.js:3)
   > View_SurveyFormPage_0 @ SurveyFormPage.html:16
   > proxyClass @ compiler.js:14659
   > DebugContext_.logError @ core.js:15038
   > ErrorHandler.handleError @ core.js:1510
   > IonicErrorHandler.handleError @ ionic-error-handler.js:61
   > dispatchEvent @ core.js:10008
   > (anonymous) @ core.js:10629
   > (anonymous) @ platform-browser.js:2628
   > t.invokeTask @ polyfills.js:3
   > onInvokeTask @ core.js:4751
   > t.invokeTask @ polyfills.js:3
   > r.runTask @ polyfills.js:3
   > e.invokeTask @ polyfills.js:3
   > p @ polyfills.js:2
   > v @ polyfills.js:2
   > ```
   
   If you import like this :
   import { Geolocation } from '@ionic-native/geolocation/ngx';
   
   Don't invoke like this when you invoke getCurrentPosition:
   `this.geolocation.getCurrentPosition().then((resp) => {
    // resp.coords.latitude
    // resp.coords.longitude
   }).catch((error) => {
     console.log('Error getting location', error);
   });`
   It should be use navigator instead:
   `navigator.geolocation.getCurrentPosition((position) => {...}));`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org