background-geolocation-server icon indicating copy to clipboard operation
background-geolocation-server copied to clipboard

I cannot see markers on map :(

Open Syirrus opened this issue 6 years ago • 4 comments

I'm getting the following error on the background-geolocation-server:

InvalidValueError: setPosition: not a LatLng or LatLngLiteral: in property lat: js?key=AIzaSyBxU4uRlMOXXXXXXXXXXX:51 not a number

I see the post from my Cordova app going to my express server. I have a valid API key, just not markers. Any ideas?

Here is my config file:

url: 'http://correctexpressserver.com:3000/locations', syncUrl: 'http://correctexpressserver.com:3000/sync', syncThreshold: 100, httpHeaders: { 'X-FOO': 'bar' }, // customize post properties postTemplate: { lat: '@latitude', lon: '@longitude', foo: 'bar' // you can also add your own properties

Syirrus avatar Nov 21 '18 21:11 Syirrus

You are using custom post template. Server expects default.

mauron85 avatar Nov 21 '18 22:11 mauron85

You are using custom post template. Server expects default.

Here is my configuration object with the custom postTemplate removed:

BackgroundGeolocation.configure({ locationProvider: BackgroundGeolocation.ACTIVITY_PROVIDER, desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY, stationaryRadius: stationaryRadius, distanceFilter: distanceFilter, notificationTitle: 'background service', notificationText: 'Enabled', notificationIconLarge: 'ic_stat_free_breakfast', notificationIconSmall: 'ic_stat_free_breakfast', debug: false, startOnBoot: true, stopOnTerminate: false, interval: 10000, fastestInterval: 5000, activitiesInterval: 10000, url: 'http://mydomain.info:3000/locations', syncUrl: 'http://mydomain.info:3000/sync', syncThreshold: 100 });

I'm still getting the same error.
Further tinkering revealed that the location object was referenced incorrectly.

OLD: position: {lat: location.latitude, lng: location.longitude},

NEW CHANGE: position: {lat: parseFloat(locations[0].lat), lng: parseFloat(locations[0].lon)},

Now the markers show up for me.

Syirrus avatar Nov 22 '18 09:11 Syirrus

Further tinkering revealed that the location object was referenced incorrectly.

No, keep in mind, if you just remove postTemplate from config options, it doesn't mean it starts using defaults!. You need to set it to null postTemplate: null

mauron85 avatar Nov 22 '18 09:11 mauron85

see https://github.com/mauron85/cordova-plugin-background-geolocation#getconfigsuccess-fail

mauron85 avatar Nov 22 '18 09:11 mauron85