Comments (17)
@madsodgaard, the library was just rewritten in #47. Are you using version 0.5.0 or the latest version in the master branch? If you run the example application, do you see any output?
from mapbox-directions-swift.
In particular, make sure you’ve entered your access token in the placeholder.
from mapbox-directions-swift.
@1ec5 yes, I just updated the library a few moments ago. You example swift application works fine, do you think it has something to do that I am using the library in an Objective-C project?
from mapbox-directions-swift.
Can you make sure you’ve updated to 4ed92bf? There was a problem preventing error
from being set.
from mapbox-directions-swift.
Okay, that seemed to fix the "error" variable,
this is the content of the variable:
error NSError * domain: "MBDirectionsErrorDomain" - code: 18446744073709551615 0x0000000158253da0
from mapbox-directions-swift.
Error generating route, Error Domain=MBDirectionsErrorDomain Code=-1 "Not Found" UserInfo={NSLocalizedFailureReason=Not Found}
from mapbox-directions-swift.
Would you mind providing the return value of Directions.URLForCalculatingDirections(options:)
? Thanks! (Remember to remove your access token from the URL before commenting.)
from mapbox-directions-swift.
from mapbox-directions-swift.
Ah, the problem is that profileIdentifier
is set to test
. As noted in the Quick Help documentation for that property and the RouteOptions
initializer you’re using, you should specify the MBDirectionsProfileIdentifierAutomobile
, MBDirectionsProfileIdentifierCycling
, or MBDirectionsProfileIdentifierWalking
constants. MBDirectionsProfileIdentifierAutomobile
is the default. The library doesn’t assert that you’re using a different value, because we expect that more profiles may be added to the API in the future.
from mapbox-directions-swift.
Oh, sorry about that. I thought the variable was a unique identifier for the route!
from mapbox-directions-swift.
How would I go about drawing the route on the map, or does it does that by it self?
from mapbox-directions-swift.
This library doesn’t handle drawing the route on the map, but it does give you the data you need to do it. Using the Mapbox iOS SDK or Mapbox OS X SDK, you’d turn it into a polyline annotation like this:
// route is a Route
// mapView is an MGLMapView
// Convert the route’s coordinates into a polyline.
CLLocationCoordinate2D *routeCoordinates = malloc(route.coordinateCount * sizeof(CLLocationCoordinate2D));
[route getCoordinates:routeCoordinates];
MGLPolyline *routeLine = [MGLPolyline polylineWithCoordinates:routeCoordinates count:route.coordinateCount];
// Add the polyline to the map and fit the viewport to the polyline.
[mapView addAnnotation:routeLine];
[mapView setVisibleCoordinates:routeCoordinates count:route.coordinateCount edgePadding:UIEdgeInsetsZero animated:YES];
// Make sure to free this array to avoid leaking memory.
free(routeCoordinates);
By default, the coordinate array is simplified to minimize data usage. That should be fine if you’re showing the entire route on the map at once. If you need to zoom in on a specific portion of the route line, you can set the RouteOptions object’s routeShapeResolution
property to MBRouteShapeResolutionFull
.
from mapbox-directions-swift.
Hey again, since I've fixed the other error the API link now returns a new one:
{"code":"NoSegment","message":"Could not find a matching segment for input coordinates","routes":[]}
from mapbox-directions-swift.
The error’s localizedFailureReason
and localizedRecoverySuggestion
properties provide a little more information. Essentially, one of the coordinates you’ve passed in is too far from the nearest road. You can increase the search radius around that coordinate by setting the MBWaypoint
object’s coordinateAccuracy
property.
If you’ve created the MBRouteOptions
object using CLLocation
s you’ve obtained from CLLocationManager, see this important note (also in Quick Help) about CLLocation’s horizontalAccuracy
property. The least tricky way to create a MBRouteOptions
object is in fact to pass in CLLocationCoordinate2D
s instead of CLLocation
s.
from mapbox-directions-swift.
Okay, I fixed it by increasing the range with waypoint.coordinateaccuracy.
Just a last quick thing, my debug console is constantly getting spammed [ERROR] {Map}[OpenGL]: stencil mask overflow - I've looked around in map box issues on github, and other people had them swell, but I can't find any fix for it.
from mapbox-directions-swift.
Yes, this is being tracked in mapbox/mapbox-gl-native#962. Unfortunately I don’t have a workaround for you at this point. Perhaps using the routeShapeResolution
of MBRouteShapeResolutionSimplified
could work around the issue, since the route geometry is considerably simpler that way.
from mapbox-directions-swift.
I don't think it has something to do with the route, it still said it before I added the routing-system. Just when I had a regular map with annotations, and I moved around and zoomed.
from mapbox-directions-swift.
Related Issues (20)
- Compiler error subclassing RouteOptions — required initializer must be provided by subclass HOT 6
- Add traffic control device flags to Intersection HOT 1
- Add TollCollection.name
- Command line tool should accept URL as input HOT 1
- Update minimum Turf version to v2.4.0
- Add closure attribute option
- Replace AttributeOptions with more extensible type HOT 1
- Estimated Time of Arrival at Waypoint HOT 1
- Unable to configure API endpoint using command line tool
- Command line tool should accept multiple configurations HOT 1
- Build universal framework target for Carthage
- Making `RouteResponse` `Equatable` and the `identifier/uuid` value HOT 6
- RouteResponse and MapMatchingResponse are undocumented
- Documentation lacks method signatures
- The 'cashTollOnly' RoadClasses value causes directions request to fail. HOT 2
- RouteStep "names" property is nil for walking directions HOT 2
- Directions calculation failing for some waypoints HOT 6
- Could not find module 'MapboxDirections' for target 'arm64-apple-ios-simulator' HOT 1
- Incompatible versions of Turf between MapboxMaps 10.16.5 and MapboxDirections HOT 2
- Incompatible versions of Turf between MapboxMaps 11.4 and MapboxDirections 2.12 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapbox-directions-swift.