question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'getLocationServices' of undefined

See original GitHub issue

Hi,

i’m trying to add a mapbox to my view (android). My view uses the RadSideDrawer from Telerik UI (actually I’m using nativescriptng2drawerseed) and implements OnInit.

I’ve used @nraboy’s demo app nativescript-photos-near-me to get into everything. Seemed to be pretty easy, however I’m experiencing some issues.

What i did:

app.module.ts

var map = require("nativescript-mapbox");
registerElement("Mapbox", () => map.Mapbox);

home.page.xml

<ContentView height="240" width="240">
            <Mapbox
            accessToken="MY_API_KEY"
            height="240"
            latitude="52.3702"
            longitude="4.8951"
            zoomLevel="3"
            mapStyle="light"
            showUserLocation="true"
            hideCompass="false"
            (mapReady)="onMapReady($event)">
            </Mapbox>
        </ContentView>

home.page.ts

...
public onMapReady(args) {
    this.mapbox = args.map;
}
...

AndroidManifest.xml First issue: my app doesn’t start, if I add

<service android:name="com.mapbox.mapboxsdk.telemetry.TelemetryService" />

in AndroidManifest.xml. Instead, i have to use

<service android:name="com.mapbox.services.android.telemetry.service.TelemetryService" />

After adding the “right” service, the map shows on my view (without location marker) but as soon as the location permissions are granted, I’m getting following TypeError:

JS: Unhandled Promise rejection: Cannot read property 'getLocationServices' of undefined ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot read property 'getLocationServices' of undefined TypeError: Cannot read property 'getLocationServices' of undefined
JS:     at Object.mapbox._showLocation (file:///data/data/org.nativescript.nativescriptng2drawerseed/files/app/tns_modules/nativescript-mapbox/mapbox.js:189:75)
JS:     at file:///data/data/org.nativescript.nativescriptng2drawerseed/files/app/tns_modules/nativescript-mapbox/mapbox.js:57:28
JS:     at ZoneDelegate.invoke (file:///data/data/org.nativescript.nativescriptng2drawerseed/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:190:28)
JS:     at Zone.run (file:///data/data/org.nativescript.nativescriptng2drawerseed/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:83:43)
JS:     at file:///data/data/org.nativescript.nativescriptng2drawerseed/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:449:57
JS:     at ZoneDelegate.invokeTask (file:///data/data/org.nativescript.nativescriptng2drawerseed/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:223:37)
JS:     at Zone.runTask (file:///data/data/org.nativescript.nativescriptng2drawerseed/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:123:47)
JS:     at drainMicroTaskQueue (file:///data/data/org.nativescript.nativescriptng2drawerseed/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:355:35)
JS: Error: Uncaught (in promise): TypeError: Cannot read property 'getLocationServices' of undefined

Did i miss something?

Thank you in advance!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:15

github_iconTop GitHub Comments

1reaction
GrEg00zcommented, Mar 6, 2017

Works great !

Thanks @EddyVerbruggen

0reactions
EddyVerbruggencommented, Mar 5, 2017

It’s on npm.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'getLocationServices' of undefined #80
Hi, i'm trying to add a mapbox to my view (android). My view uses the RadSideDrawer from Telerik UI (actually I'm using ...
Read more >
Angular 8: ERROR TypeError: Cannot read property ...
Try to put initial value for lat:any; long:any; url:any; weatherUrl:any; , It seems that the urls are undefined when using them. – Fateme...
Read more >
[SSL Pinning Plugin] Error - Cannot read property 'apply' for ...
With original Multilingual, the application crashed and in logs it gave error: [ErrorScreen] Cannot read property 'apply' of undefined. With cloned Multilingual ...
Read more >
How to Avoid Getting 'Cannot read property of undefined' in ...
Learn how you can avoid getting the famous 'Cannot read property of undefined' error in JavaScript with the logical OR operator.
Read more >
Cannot read property 'toLowerCase' of undefined-angular.js
Coding example for the question Angular 8: ERROR TypeError: Cannot read property 'toLowerCase' of undefined-angular.js.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found