How can I restrict the Directions API from returning direction steps that include u-turns? - mapbox

We use the Directions API from Mapbox and our drivers cannot make u-turns legally because of their vehicle size. Is there a way to restrict the Directions API from returning directions which include u-turns, and instead return alternative routes?

Related

Standard way to display Bing API Truck Route JSON response on a Bing Map?

I'm successfully calling Bing's Truck Route API (below) to get a JSON response for a route.
https://learn.microsoft.com/en-us/bingmaps/rest-services/routes/calculate-a-truck-route
What's the standard way to get that to show up on a Bing Map? From their documentation here, I can't quite tell.
https://learn.microsoft.com/en-us/bingmaps/rest-services/imagery/get-a-static-map
To display a truck route result on an interactive map in Bing Maps, the easiest option is to leverage the directions module which supports truck routing. The directions module is an integrated part of the interactive map SDK. Here are some examples:
https://www.bing.com/api/maps/sdk/mapcontrol/isdk/directionscreatetruckroute
https://learn.microsoft.com/en-us/bingmaps/v8-web-control/map-control-concepts/directions-module-examples/calculate-driving-directions
If you want to instead directly access the REST routing API and display the results from that on a map, you will need to loop through and extract the route points from the route response, and create a line.

Mapbox: How many tiles were requested by this api key/account

is there a way to request how many tiles were already requested this month for a given API key?
Or would I need a backend, to keep track?
On this side, I can see the requested tiles: https://account.mapbox.com/
But it only updates daily, not live.
Any help is appreciated.
There is a transformRequest option you can use when you instantiate the map. You could add code to it to trigger a counter somewhere else whenever a tile is requested.
See options.transformRequest here:
https://docs.mapbox.com/mapbox-gl-js/api/map/#map
Here is an example of how it is used: How to specify Authorization Header for a source in mapbox-gl-js?

Bing maps 7.0 Geocode Rest service Callback functions not called

Hi I am using a bing maps 7.0 ajax api to display map. I have several addresses which i geocode to get latitude and longitude using rest services in javascript. I have setup up a GeocodeCallback method in the geocode request.
geocodeRequest = "http://dev.virtualearth.net/REST/v1/Locations?"+mapDataAddress[1]+"&output=json&jsonp=GeocodeCallback&jsonso="+mapDataAddress[0]+"&key="+credentials;
CallRestService(geocodeRequest);
When the address are found i get a response in my GeocodeCallback function but for few address i dont get a response. How to figure out this status and error.
I figured this out. So basically you need to do two things.
You need to change your URL structure. I have found out that sometimes if I have weird address, bing will return a 400.
use the suppressStatus parameter and set it to true. I can't find the docs at this moment but basically I have found that if bing returns a 400,404,etc it won't actually call the callBack function. So supressstatus says that no matter what, always return a 200.
Orignially you have:
http://dev.virtualearth.net/REST/v1/Locations?"+mapDataAddress[1]+"&output=json&jsonp=GeocodeCallback&jsonso="+mapDataAddress[0]+"&key="+credentials;
So you want to do this:
http://dev.virtualearth.net/REST/v1/Locations?addressLine="+mapDataAddress[1]+"&output=json&jsonp=GeocodeCallback&suppressStatus=true&jsonso="+mapDataAddress[0]+"&key="+credentials;
Also take a look at the Tips and Tricks for using the Bing Maps REST services listed here: http://www.bing.com/blogs/site_blogs/b/maps/archive/2013/02/14/bing-maps-rest-service-tips-amp-tricks.aspx

Google Geocoding API not returning correct latitudes,longitudes for address as returns in google maps

I am facing a strange problem of google geocoding API.
My requirement is whenever a user types any address all the corresponding locations should show in my map View(I am using MKMap View) like it happens in google maps.
So what I do is I use google geocoding API that returns me a list of latitudes and longitudes for that corresponding location.
But for some location eg:- caribou coffee, chapel hil (When I search for this location in google maps,I get a number of annotations showing that address but when I type this address in geocoding I didnt get nothing.
request url:-http://maps.googleapis.com/maps/api/geocode/xml?address=caribou%20coffee,%20chapel%20hil%20&sensor=false
response:-
-<GeocodeResponse>
<status>ZERO_RESULTS</status>
</GeocodeResponse>
Can any body tell me why I am not getting any latitude and longitude that correspnds to this address like it shown in google maps or there is some other way so that I can integrate the behaviour of google maps in my applications(mk map view).
Please help me as I am stuck here.
Any suggestions will be highly appreciated.
Thanks in advance!
Note that the address is incomplete - e.g. searching for caribou coffee, chapel hill, nc does produce a result.
I would think that Geocoding API can't do anything with such addresses, and you may need to use some extra API - e.g. Places API (https://code.google.com/apis/maps/documentation/places/ ), which can return some results for queries like "coffee". You'd need to supply the user's location to use as a base, however.

Bing maps: Direct Access to tiles and Api key

i am using Bing map tiles in my Android application. I download tiles from http://h0.ortho.tiles.virtualearth.net/tiles/h<quadkey>.jpeg?g=131 and it works fine, but i understand that i need to append a token to this URL in order to make this operation legal (and ask some kind of special permission from Microsoft). It is all well explained here: http://blogs.msdn.com/b/virtualearth/archive/2008/04/29/tracking-virtual-earth-tile-usage.aspx. But this post is from 2008 and i found on msdn site that in 2012, token-auth system will be replaced with key auth system.
Does anybody know how can i perform the direct tile access with this new auth system?
Thanks in advance
Accessing tiles directly with key-based authentication can be accomplished like so:
Using the REST ‘Get Imagery Metadata’ service to obtain the tile URL format for the type of tiles you wish to display:
http://msdn.microsoft.com/en-us/library/ff701716.aspx
- For example, if you wish to display Road tiles, the following request could be used (taken from the above documentation): http://dev.virtualearth.net/REST/V1/Imagery/Metadata/Road?mapVersion=v1&output=xml&key=BingMapsKey
Within the response, the URL for tiles is returned, with a placeholder for the tile quadkey.
A new REST request should be issued each time the map viewer in the application is instantiated, or whenever the map type is changed (eg. You wish to switch to aerial or hybrid map style)
Your platform usage can then be tracked based on the calls to the REST service.