Routing getIcon missing from api v 2.5.4 - javascript

I am working with the here maps api doing some routing between two points.
I can calculate the route and show the maneuvers to the user but I cannot get the maneuver icon. In the previous api, there was a javascript function getIcon, but that has been removed from the most resent api (2.5.4).
When I take a look at here.com and perform the routing between the two points, I can find the js function in there, but the function is not in the 2.5.4 version of the api.
(I cannot upgrade to v 3 of the api at this point in time, so I don't know if that will help)
What can I do when using v2.5.4 of the api to get the maneuver icon to show it to my users?
Below is a sample screen snip from here.com on the images I am referring to.

The Turn symbols are not part of the API, you can use in the Maneuvers the "direction" and "action" properties to draw your own symbols.

Was this ever exposed in the API?
Just looked through the compressed code and I don't find that symbol anywhere...
Anyways, I believe the last resort is to map the "action" property in the maneuvers to your own images (or an image sprite similar to the one on here.com ;). The possible values of the action property are documented here:
https://developer.here.com/rest-apis/documentation/routing/topics/resource-type-enumerations.html#resource-type-enumerations__enum-private-transport-action-type

Related

Is there a way to omit a certain route when using the mapbox directions API?

I'm using the MapBox directions API to show and calculate the distance between several waypoints. The thing is, this routes are for big trucks, and MapBox generates a route where big trucks can't go through (A tiny one way bridge). Legally, only cars can go through. Is there a way to tell the direction's API to skip that bridge and generate an alternative, longer route?
The only exclusion options currently available in the Mapbox Directions API are for ferries, tolls, and motorways. You can not exclude with waypoints or areas at this time. Where available, Alternative routes may be requested by passing the alternatives=true parameter. If you wish to create custom routes, use the Map Matching API to make a request that will snap your desired coordinates to parts of the network you wish to route on.

GPS location tracking in laravel

I am currently working on a University project and I am going to create a hitch hiking mobile app. I am looking to use phonegap and Javascript on the front end and laravel as my RESTFUL API. I have looked at he Google maps API documentation but I have still not seen a plugin for Laravel which allows GPS route details to be stored on the backend in laravel.
I presume the mapping of routes between drivers and hitch hikers will need to be done on the server as details of all routes (journeys) will need to be stored and for searching.
Has anyone ever worked on a similar hitch hiking project and how would you check if a hitch hicker's route matches with a Driver's route. Surely this mapping must be done on the server and is there any API for Laravel that supports this?
My interpretation to how your service will work is that both hitch hikers and drivers will state their current location and their intended destination, and hitch hikers will be able to request rides based on matching routes/destinations (which is a pretty cool idea actually).
Based on that interpretation, here's how I might go about implementing it.
1. Create a Journey
A Journey model would be a the journey the user wishes to make. It would be comprised of many Waypoint models (at least 2, the minimum being the start and end points).
There would be a one-to-many relationship between a Journey and Waypoint.
A user creates a Journey and you use the Google Maps Directions API to store the Waypoints for it.
2. Periodically update a user's location
A user will eventually move between waypoints. When they do, you want to know where they are so you can update their position so that they're able to be accurately represented on a map of active users (I imagine you'll have one, displaying the locations of various Drivers and Hitchhikers, similar to Uber).
3. Match users based on similar waypoints
Use the waypoint data you have stored against a driver and hitchhiker's routes to find similar routes/journeys and make suggestions as to which hitchhikers a driver may pick up. You can even use the API data to give estimated times of pickup based on the distance between the driver and the hitchhiker.
There's more to consider, but that'd be a pretty decent starting point.
You would want to think about re-routing (what if a user can't go between certain waypoints due to roadworks, or perhaps they take a wrong turn - think about how your SatNav might handle it), perhaps the ability to plan trips in advance, etc.
To actually answer your questions, yes, if you wanted to use Laravel for this you'd map the routes and match the waypoints server-side.
Let's take the scenario where I am a hitchhiker.
I want to get from A to G.
I'm currently at waypoint C
Driver X is on another route which happens to have my waypoints C, D, and E in it. To find Driver X, you could do something like (pseudocode):
// Find a driver with similar waypoints
Driver::withSimilarWaypoints($myJourney->remainingWaypoints())->all();
// withSimilarWaypoints scope
function scopeWithSimilarWaypoints($waypointsCollection)
{
$query->whereHas('waypoints', function ($query) use ($waypointsCollection) {
$query->where('passed', 0)->whereIn('waypoint_identifier', $waypointsCollection->pluck('waypoint_identifier'));
}
}
In this case waypoint_identifier would have to be the same for me and Driver X, so perhaps a hash of the waypoint object or you could use place_id as returned by the API.
You'd also want to make sure you're not matching against waypoints you've both already passed (hence remainingWaypoints() and where('passed', 0).
Driver X is estimated to arrive at waypoint C in 8 minutes, so I decide to wait for them (or I can request a lift via the app)
All that should be a pretty decent jumping off point for your service. I quite like the idea – good luck!

MapQuest JS API - get directions by sticking closely to list of points

I have certain points (locations) which my app has to pass through every time.
I also have a road network (composed of thousands of points).
I need to force my main road to go as close as possible to the network.
I've tried using MQ's ControlPoints but they do not seem to work.
Are there any alternatives/algorithms I could use?
I found a solution.
I am using MapQuest's Directions API "Route control points" functionality.

Google map static api url length is exceeding 2048 char is there any solution ? aim is to save as image

so far I used google map api in javascript as well as in php, I had no problem in creating thousands of markers using these api, but my final aim is to save them as image, so finally I came to know that I have to use static make api, in order to save it as image., so tried static map api with few markers, I could able to save, but when tried with 1000's of markers I did not succeed, through many search on this forum I came to know that url limit is exceeding 2048 char, yes that is true.
So is there any alternate way to save map with thousands of markers ? in case of googlemap api in javascript/php I can see all markers, but nowhere I found solution for how to save them locally ?
whether anyone here found solution to save ? something like screen shot or you can say writing a content of map division to png / jpeg/ gif file ?
Please someone help me.
Thanks.
OK first let's talk TOS. As a couple commenters have pointed out you're not allowed to save maps offline. The specific section 10.1.1(h) which forbids you from using static maps outside of a web based app except in a couple specific situations. Print is not one of those - just in case. Section 10.1.3 also says "No Pre-Fetching, Caching, or Storage of Content" which means you can't take a map and just store it somewhere for later use. Caching for performance reasons is fine.
Now assuming you're OK with both of those things, the static Maps Image API is useful but not really useful for your specific use case. While you can encode polylines using the special encoding function, you can't put on a bunch of markers like you're intending.
One thing you could do is to download the static maps API image without markers. You know the physical dimensions of the image and the bounding box in lat/long. It's trivial to convert that to degrees/pixel. You could use an the PHP image functions to convert the lat/lng to x/y pixels and manually place the markers on the image.
As long as you use the subsequent image output back in your webpage and only cache the image for a specific short period of time (a.k.a performance reasons) you should have no problems with the Maps TOS.
Please note that now (September 2016) the URL limit has been changed to 8192 characters in size.
https://developers.google.com/maps/documentation/static-maps/intro#url-size-restriction
Here is the corresponding feature request.

map city/zipcode polygons using google maps

I am looking for a javascript library that supports the ability to pass a zipcode or city as a parameter, and get a list of x,y coordinates to draw a polygon using google maps?
Does this exist? Does the google maps API support such queries? I am looking for an array of coordinates similar to those that google uses to draw maps on a google query:
Google Maps API doesn't support that kind of solution. There are a couple other places from which you can get the coordinates, though:
Flickr API
There is a Flickr API based on photos that people tag, but it's only as accurate as the people who tag photos: so it's good enough for bootstrapping but probably not for production: http://karya-blog.blogspot.com/2012/12/fetching-city-polygons-with-flickr-api.html
Natural Earth Data
An accurate alternative is www.naturalearthdata.com. To get that data from there you just need to make two requests: one with the city name and one with their ID to get the parameters:
unlock.edina.ac.uk/ws/search?name=berlin&gazetteer=naturalearth&format=json
and then
unlock.edina.ac.uk/ws/footprintLookup?format=json&identifier=14126951
and you're set :)
Mapzen
If it's possible for you to pre-fetch the data, go for Mapzen, they have a full and pretty accurate database: https://mapzen.com/data/borders/
Short answer: I do not think there is any magical getZipCodeBoundaries method in the Google Maps API. However, what you want to do can and has been done. Please see the implementation, and this thread on Google groups concerning the process. Is the first link similar to what you're hoping to accomplish? Also, there is a neighborhood API offered from Zillow under the CC license. You might want to look into that and see if it breaks neighborhoods down by zipcode.
You can get polygon coordenates in json for using with googlemaps using openstreetmap.
Go to http://nominatim.openstreetmap.org/
search a place like "Partido de Ituzaingó"
Steps:
Click on "details"
Look for the OSM ID and copy it (control+c), example: 2018776
Go to http://polygons.openstreetmap.fr/index.py
Paste the ID in
Download the polygon
Look on this site Twitter geo api You have few modes of search, and it gives You boundary box for cities. I am using it now on My site. Try f.e. this link and U will see the results.

Categories