I am working with Google Maps API V3 to calculate all the possible routes from a given Source to the specified Destination. For this I takes the Destination and Source as inputs from the user and pass these values in the request with option provideRouteAlternatives: true. I am successful in calculating different Routes and also marking i.e. displaying them on my Map.
Now I am wondering if it is possible to name the Different Routes. By naming the Routes I mean adding a small description to each Route like the Street Name etc. which that particular route takes while moving from Source to Destination. I want to do this so as to make it look more interactive. For example if there are 3 Routes possible from location A (Arizona Street, San Diego, CA, USA) to location B (Fenton Parkway, San Diego, CA 92108, USA) then instead of showing results like Route 1, Route 2, Route 3 it should show the Street names like "Texas St & Rio San Diego Dr", "Texas St & Friar Rd", "Friars Rd".
I am able to calculate all the other things like the trip distance and total trip time for each of my Route but have no clue to how to add this description to each of my Route.
Any help will be appreciated.
Thanks
That is what appears in the panel if you provide one:
Suggested routes:
Texas St and Rio San Diego Dr 2.6 mi - about 9 mins
Texas St and Friars Rd 3.3 mi - about 10 mins
Friars Rd 4.8 mi - about 11 mins
example
Try using summary from the returned result. From the Google Maps API:
summary contains a short textual description for the route, suitable for naming and disambiguating the route from alternatives.
Related
I'm using https://geocoder.api.here.com/6.2/search.json, and when I make a search for "Ile de Ré, France" I have a response but in the object Address I have this :
Address: {Label: "D735, 17000 La Rochelle, France", Country: "FRA", State: "Nouvelle-Aquitaine",…}
Label: "D735, 17000 La Rochelle, France"
Country: "FRA"
State: "Nouvelle-Aquitaine"
County: "Charente-Maritime"
City: "La Rochelle"
Street: "D735"
PostalCode: "17000"
Instead of having the all island...
Does someone know how to have the all island address instead of just having a road?
This is the resquest :
https://geocoder.api.here.com/6.2/search.json?language=fr&app_id={APPID}&app_code={APPCODE}&searchtext=%C3%8Ele%20de%20R%C3%A9&additionaldata=IncludeShapeLevel%2C%20default&gen=9&mapview=46.14288%2C-1.5629%3B46.2582%2C-1.25416
Thanks ! =)
It is not entirely clear from your question what your expected response is. If you are expecting a list of all addresses in the area, that is not supported.
If you are expecting to get the shape/area of the island as a polygon, then you need to use the mode "retrieveAreas" as Michael has stated above. This blog post on How to Get the Shape of an Area using the HERE Geocoder should hopefully answer most of your questions regarding this feature.
The API call you are looking for would be the following, which retrieves the postal code area around a location. Note that in order to get the location as a lat/long you need to first Geocoder "Ile de Ré, France" using the forward Geocoder.
https://reverse.geocoder.ls.hereapi.com/6.2/reversegeocode.json
?apiKey=YOUR_API_KEY
&prox=46.20054,-1.39985
&mode=retrieveAreas
&additionaldata=IncludeShapeLevel,postalCode
However, the Geocoder can only retrieve areas such as postal codes, administrative districts, counties, etc. In this case, none of them correspond exactly to the island. For example the island has multiple postal codes and its county covers a much larger area.
You can use this code example I've built to experiment. Here's a screenshot made using this tool to show the area of a postal code on the island.
Try adding mode=retrieveAreas to your API call
I'm a student working on a navigation project using Here's REST APIs.
The question I'm asking pertains to discrepancies when searching for a location using the Geocoder REST API and the Here WeGo online map.
I am trying to perform forward geocoding using the search term "Kent Ridge MRT" via the Geocoder API to get the corresponding set of coordinates. This is a subway station located on my campus, which the National University of Singapore.
The following parameters are used
destination_input = "Kent Ridge MRT singapore"
country = "SGP"
gen = 9
These are placed in a dict called geocoding_params
geocoding_params = {"app_code": app_code, "app_id": app_id, "searchtext": destination_input,
"country": country, "gen": gen}
A GET request is then made using the requests library in Python 3.7.3, via
geocoding_data = requests.get(url = geocoding_base_url, params = geocoding_params)
Where geocoding_base_url = "https://geocoder.api.here.com/6.2/geocode.json"
The request gives me three possible locations, listed here in Lat/Lon: (1.30098, 103.77231), (1.29354, 103.77138) & (1.2935, 103.78102).
None of these are the actual coordinates of Kent Ridge MRT station (1.29364, 103.78466), which can be obtained when one types the exact same search terms using Here WeGo.
I am curious to know why such a difference exists and whether there is a way to get what I see in Here WeGo.
What I have tried as of now includes broadening the search field by removing country and gen parameters while keeping searchtext = "Kent Ridge MRT singapore", but to no avail. The results match the three I have gotten above.
The SearchAPI powering HereWeGo and GeocoderAPI are different services with different approaches and goals. The reason why you are not finding your place "Kent Ridge MRT"with GeocoderAPI is because GeocoderAPI does not support places.
The good news: both are unified as OpenSearch in the HERE Open Location Platform:
https://developer.here.com/products/open-location-platform
Check the Open Location Platform documentation at
https://openlocation.here.com/resources/documentation
I would like to find the nearest highway (latitude and longitude) of a given position using 'rest'? Is this possible?
The idea is that the user can enter (select) a 'passthrough' waypoint for a route. If the route is from Belgium to France the waypoint would be in Luxemburg to avoid the toll on the French highways. However, the route should use the highways around the waypoint (if possible) instead of passing through the exact coordinate.
I already tried to set the 'TransitRadius' to 5000, but the route is still calculated on the exact waypoint.
This is my complete call:
In the image, I displayed the route around the waypoint. The thin red line is the proposed route passing at the waypoint (gray marker), the thick blue line is the route that I want (without detour).
Map image
Thx in advance
Please check output for the below rest call,
toll cost 18.2 EUR, travelTime 17:24 h, distance 942 km
http://fleet.api.here.com/2/calculateroute.json?app_id=xxxxx&app_code=xxxxxx&waypoint0=50.86892,2.88533&waypoint1=passThrough!49.6096,6.1034;5000&waypoint2=stopOver!45.7896,4.8656&detail=1&legattributes=none,li,sm¤cy=EUR&tollVehicleType=3&trailerType=2&trailersCount=1&vehicleNumberAxles=2&trailerNumberAxles=3&hybrid=0&emissionType=6&height=4.0m&trailerHeight=4.0m&vehicleWeight=9.5t&limitedWeight=40.0t&heightAbove1stAxle=3.5m&passengersCount=1&tiresCount=12&commercial=1&disabledEquipped=0&minimalPollution=0&width=2.2&length=18&mode=fastest;truck;traffic:disabled&rollups=none,country;tollsys,country,tollsys,total&alternatives=0&metricsystem=metric&transportmodetype=truck&driver_cost=30
please refer fleet telematics API for more information :
developer.here.com/documentation/fleet-telematics/api-reference.html
I'm able to get the fully formatted address from the api,
"1600 Amphitheatre Parkway, Mountain View, CA 94043, USA"
for example.
How do i "breaking to pieces" this formatted address(city, street, country etc)?
code for getting the fully address -
final formattedAddress =decodedResponse['results'][0]['formatted_address']
According to the result from the api(https://developers.google.com/maps/documentation/geocoding/intro#GeocodingResponses)
I can write decodedResponse['results'][0]['address_components'][0]['long_name']
The second [0] indicate the location of the type
i am using the here geocoding and map tiles services.
geocoding search for oran, algeria returns address information in arabic. map tiles for oran, algeria show address information in french. here.com map site for oran, algeria also shows address information in french. i would prefer geocoding information in english. when making my geocoding request i have added "&language=en". information returned in arabic. i have also tried a request but with "&language=fr". information returned in arabic. is it possible to have geocoding information returned in english? and, out of curiosity, since here seems to have the information in french when generating its tiles, is it possible to have geocoding information returned in french?
i notice that for, eg, tokyo, japan, the information is returned in english (or a sort of trans-literated englsh), not japanese. the same is true for, eg, moscow, russia. map information is in english, not cyrillic characters.
the only rule or guidance that i have found in the here documentation regarding language parameters concerns using a language list (&languages= ...)
thanks for any help.
- george ott
When geocoding an address, the language parameter will only alter the exonym for the city and country. Take for example the Grote Markt/Grand Place in the center of Brussels.
If you search for Grand Place - the address is in French
If you search for Grand Place with language=en - the address is in French, the city and country are in English
If you search for Grote Markt - the address is in Dutch
If you search for Grote Markt with language=en - the address is in Dutch, the city and country are in English
If you want to obtain the Dutch name for the French street, you will need to make two requests - firstly a geocoding request to find out the longitude/latitude and then a reverse-geocoding request to find out the local name of a location in the language of your choice.
For example Rue Bouzerki Mohamed/ نهج بوزركي محمد, وهران, الجزائر is a street in Oran:
Geocode the Arabic text to a location like this
Reverse Geocode to get the French name like this
It appears that as a general rule, the primary language is returned by default (for Algeria this is Arabic), but in the cases where a separate script is used an alternative may be returned. For an English language request, the road names in Algeria are returned in French (i.e. the standard 26 letter Roman Alphabet) rather than Arabic script.
The Map Tiler can display bilingual maps as shown below:
lg=FRE&lg2=DUT Map of Brussels at zoom 10
However the roads are only displayed in the primary language
lg=FRE&lg2=DUT Map of Brussels at zoom 17
Presumably this is due to the optimization of the label placements.
For languages with different scripts, both labels are shown
lg=ARA&lg2=FRE Map of Oran at zoom 11
This includes the roads displayed in the secondary language at high zoom
lg=ARA&lg2=FRE Map of Oran at zoom 17
The list of languages available to the lg and lg2 parameters can be found in the Map Tile API Reference. Examples of monolingual and bilingual maps tile can be found in the API Explorer
The lg and lg2 can also be passed to the Maps API For JavaScript as shown:
var mapTileService = platform.getMapTileService({
type: 'base'
}),
bilingualMapLayer = mapTileService.createTileLayer(
'maptile',
'normal.day',
256,
'png8',
{lg: 'ARA', lg2: 'FRE'}
);
map.setBaseLayer(bilingualMapLayer);
Where map is an instance of an H.Map and platform is the
H.service.Platform stub.