Coder Social home page Coder Social logo

Comments (17)

1ec5 avatar 1ec5 commented on August 21, 2024

@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.

1ec5 avatar 1ec5 commented on August 21, 2024

In particular, make sure you’ve entered your access token in the placeholder.

from mapbox-directions-swift.

madsodgaard avatar madsodgaard commented on August 21, 2024

@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.

1ec5 avatar 1ec5 commented on August 21, 2024

Can you make sure you’ve updated to 4ed92bf? There was a problem preventing error from being set.

from mapbox-directions-swift.

madsodgaard avatar madsodgaard commented on August 21, 2024

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.

madsodgaard avatar madsodgaard commented on August 21, 2024

Error generating route, Error Domain=MBDirectionsErrorDomain Code=-1 "Not Found" UserInfo={NSLocalizedFailureReason=Not Found}

from mapbox-directions-swift.

1ec5 avatar 1ec5 commented on August 21, 2024

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.

madsodgaard avatar madsodgaard commented on August 21, 2024

https://api.mapbox.com/directions/v5/test/-77.0324047,38.9131752%3B-77.0365,38.8977.json?alternatives=false&geometries=polyline&overview=simplified&steps=true&continue_straight=false&access_token=x

from mapbox-directions-swift.

1ec5 avatar 1ec5 commented on August 21, 2024

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.

madsodgaard avatar madsodgaard commented on August 21, 2024

Oh, sorry about that. I thought the variable was a unique identifier for the route!

from mapbox-directions-swift.

madsodgaard avatar madsodgaard commented on August 21, 2024

How would I go about drawing the route on the map, or does it does that by it self?

from mapbox-directions-swift.

1ec5 avatar 1ec5 commented on August 21, 2024

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.

madsodgaard avatar madsodgaard commented on August 21, 2024

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.

1ec5 avatar 1ec5 commented on August 21, 2024

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 CLLocations 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 CLLocationCoordinate2Ds instead of CLLocations.

from mapbox-directions-swift.

madsodgaard avatar madsodgaard commented on August 21, 2024

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.

1ec5 avatar 1ec5 commented on August 21, 2024

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.

madsodgaard avatar madsodgaard commented on August 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.