New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
draw the user trip #268
Comments
Can you share a repo showing |
yes sure, here is the Repo |
@epileftro85 Thanks for the repo! I've updated the Mapbox Android SDK and was able to get it working on your repo by delaying tracking a bit (because you can't track unless the location is already shown on the map). So bump the plugin to 4.4.0, and replace import { Component, OnInit } from "@angular/core";
import { MapboxViewApi } from "nativescript-mapbox";
import * as geolocation from "nativescript-geolocation";
import { Accuracy } from "ui/enums";
@Component({
selector: "Map",
moduleId: module.id,
templateUrl: "./map.component.html"
})
export class MapComponent implements OnInit {
private lat_value: number = 0;
private lng_value: number = 0;
private map: MapboxViewApi;
private watchId: any = null;
constructor() {
/************************************************************
* Use the constructor to inject app services that you need in this component.
*************************************************************/
}
ngOnInit(): void {
var that = this;
// get geolocation permitted
if (!geolocation.isEnabled()) {
geolocation.enableLocationRequest();
}
// get current location
var location = geolocation
.getCurrentLocation({
desiredAccuracy: Accuracy.high,
updateDistance: 10,
maximumAge: 20000,
timeout: 20000
})
.then(
function (loc) {
if (loc) {
console.log(
"Current location is: " + loc.latitude + ", " + loc.longitude
);
that.lat_value = loc.latitude;
that.lng_value = loc.longitude;
}
},
function (e) {
console.log("Error: " + e.message);
}
);
}
onMapReady(args): void {
this.map = args.map;
// wait until the location is showing on the map
setTimeout(() => {
this.map.trackUser({mode: "FOLLOW_WITH_HEADING", animated: true})
.then(() => console.log("tracking"))
.catch(err => console.log("tracking error: " + err));
}, 2000);
this.map.getUserLocation().then(userLocation => {
console.log(
"Current user location: " +
userLocation.location.lat +
", " +
userLocation.location.lng
);
console.log("Current user speed: " + userLocation.speed);
});
}
} |
Hi, thanks for the reply, i can't make it work, would you please tell me how do you test it?, i am trying to testing with the iOS simulator with the bike route, but it just console log the first point, after that it just doesn't show any output, i want to save the location every 2 sec in a file, but if i can't get those values i can't save anything, sorry for troubles, thanks in advance |
Hi, i want to draw the user's trip with the gps on real time, i have been trying with track user, but it just fallow the user but not give me the coordinates, i also tried with getUserLocation with no success, there is a way to accomplish this?
The text was updated successfully, but these errors were encountered: