Hi i try to find if the google maps or the HERE nokia maps have a static segmentation of the roads and an associated id and where i can find this information. I try to rich information by Rest api from both maps type but i don't find it. Instead with the javascript api i see that i can edit the maps or create, but what i want is to query a server or a database's maps in the way that i can use the latitude and longitude information as key for research (or the address string) and i will get the information from where is the location (so address or lat/long) and in what segment/polyline of the street the location is.
Thanks all!
I think you will need to look at a RESTful API rather than JavaScript:
For the HERE Platform:
To get an address for a Lat/Lng or vice-versa use the Geocoder API
To get an road shapes for a Lat/Lng use the Enterprise Routing API
You will need to register to get access to the documentation, but you can see the APIs in action using the API Explorer e.g. Geocoder Routing
The getlinkinfo endpoint of the Enterprise Routing API could be useful. For example, the URL below ( replace YOUR_APP_ID and YOUR_TOKEN of course)
http://route.st.nlp.nokia.com/routing/6.2/getlinkinfo.json?app_idYOUR_APP_ID&app_code=YOUR_APP_CODEg&waypoint=52.53086,13.3846&linkattributes=shape
Returns the following link info about a line segment:
{
"Response":
{
"MetaInfo":
{
"MapVersion":"2013Q2",
"ModuleVersion":"0.2",
"InterfaceVersion":"4.2",
"Timestamp":"2013-12-12T12:45:47.035Z"
},
"Link":[
{
"_type":"PrivateTransportLinkType",
"LinkId":"+931447247",
"Shape":[
"52.5309486,13.38447",
"52.5310516,13.38482"
],
"SpeedLimit":13.89,
"DynamicSpeedInfo":
{
"TrafficSpeed":6.94,
"TrafficTime":3.7,
"BaseSpeed":13.89,
"BaseTime":1.9
},
"Address":
{
"Label":"Invalidenstraße",
"Country":"DE",
"State":"Berlin",
"County":"Berlin",
"City":"Berlin",
"District":"Mitte",
"Street":"Invalidenstraße"
}
}
]
}
}
Related
I would like to fetch Sports Complexes/ Fields and even apartments, how can I get that?
Currently I get very few results in the Auto-Complete.
Package Name: react-native-google-places-autocomplete .
API: GooglePlacesAutocomplete
<GooglePlacesAutocomplete
query={{
// available options: https://developers.google.com/places/web-service/autocomplete
key: ,
language: "en", // language of the results
types: "address" // default: 'geocode'
}}
nearbyPlacesAPI="GooglePlacesSearch" // Which API to use: GoogleReverseGeocoding or GooglePlacesSearch
GoogleReverseGeocodingQuery={
{
// available options for GoogleReverseGeocoding API : https://developers.google.com/maps/documentation/geocoding/intro
}
}
GooglePlacesSearchQuery={{
// available options for GooglePlacesSearch API : https://developers.google.com/places/web-service/search
rankby: "distance"
}}
filterReverseGeocodingByTypes={[
"locality",
"administrative_area_level_3"
]} // filter the reverse geocoding results by types - ['locality', 'administrative_area_level_3'] if you want to display only cities
// predefinedPlaces={[homePlace, workPlace]}
debounce={200} // debounce the requests in ms. Set to 0 to remove debounce. By default 0ms.
/>
filterReverseGeocodingByTypes is something I should be taking care of but I'm not sure how to get all the Sport Complexes, Fields and Apartments.
If I can get all the result, like we get in Google Maps, it would be fine as well.
example City, Locality, Schools and everything.
Unfortunately this isn't accessible with the current API. The list of currently support types can be found here.
However, you could add
GooglePlacesSearchQuery={{
// available options for GooglePlacesSearch API : https://developers.google.com/places/web-service/search
rankby: 'distance',
type: 'stadium'
}}
Specifying the type as stadium is the closest you'll get to fetching Sports Complexes and Fields however the results will not be 100% accurate.
It appears the type "sports_complex" are not yet currently supported. However, if you really need this feature to be added in our API, you can file a Feature Request in our Google Public Issue Tracker.
Issue Tracker is a tool used internally at Google to track bugs and feature requests during product development. It is available outside of Google for use by external public and partner users who need to collaborate with Google teams on specific projects.
Thank you very much!
Is Google Map street view available in Flutter? I know there is a plugin of Google Map but I couldn't find out if I can use Street view functionality.
I am the owner of flutter_google_street_view.
Flutter plugin flutter_google_street_view provides street view and support web, Android and iOS.
Try it! The usage steps shown below.
Usage Steps:
Get an API key at https://cloud.google.com/maps-platform/.
Specify your API key to your code.(Web, Android, iOS)
Create FlutterGoogleStreetView widget and the sample code show below.
StreetViewController? streetViewController;
FlutterGoogleStreetView(
initPos: LatLng(25.0780892, 121.5753234),
onStreetViewCreated: (StreetViewController controller) async {
//save controller for late using
streetViewController = controller;
//change position by controller
controller.setPosition(position: LatLng(37.769263, -122.450727))
}
)
Done and control FlutterGoogleStreetView by streetViewController.
I am using google maps to provide directions to multiple locations within a website. Users are in Japan, but are non-Japanese, so results should be in English.
In certain examples, even when the name is in the query parameter, a link like this location, returns an alternate Japanese place name (主教座聖堂牧師館), instead of "St. Andrew's Tokyo."
This link is dynamically generated, so I can change the parameters if need be, but I can't figure out how to force results that look more like this, without hardcoding the entire link. Here is what builds the URL:
//handle directions links; send to Apple Maps (iOS), or Google Maps (everything else)
var iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
$body.on('click', 'a.tsml-directions', function(e){
e.preventDefault();
var directions = (iOS ? 'maps://?' : 'https://maps.google.com/?') + $.param({
daddr: $(this).attr('data-latitude') + ',' + $(this).attr('data-longitude'),
saddr: 'Current Location',
q: $(this).attr('data-location')
});
window.open(directions);
});
I've had a look at your sample URL https://www.google.com/maps?daddr=35.6603676,139.7444553&saddr=Yotsuya,%20Shinjuku,%20Tokyo%20160-0004&q=St.%20Andrew%27s%20Tokyo.
I understand that your intention is getting a directions on Google Maps. In the aforementioned URL you specify parameters for origin saddr and destination daddr, the q parameter shouldn't affect directions in this case. So, the destination address is just coordinate 35.6603676,139.7444553. When I reverse geocode this coordinate I get the 'Japan, 〒105-0011 Tōkyō-to, Minato-ku, Shibakōen, 3 Chome−6−18 主教座聖堂牧師館' address as shown in Geocoder tool:
https://google-developers.appspot.com/maps/documentation/utils/geocoder/#q%3D35.660368%252C139.744455
The 主教座聖堂牧師館 corresponds to premise address component and I suspect it is not translated to English in Google database, because web service call with language set to English returns this component in original language as well
https://maps.googleapis.com/maps/api/geocode/json?latlng=35.6603676%2C139.7444553&language=en&key=YOUR_API_KEY
If your destination should be St. Andrew's, use it as a destination parameter.
And the most important part: Google has Google Maps URLs as an official, recommended and documented method to construct URLs. I would suggest using this API in order to create your directions URLs. These URLs are cross-platform, so there is no need to create different URLs for iOS, Android or web browser.
Your example will convert into
https://www.google.com/maps/dir/?api=1&origin=Yotsuya,%20Shinjuku,%20Tokyo%20160-0004&destination=St.%20Andrew%27s%20Tokyo&travelmode=driving
The result is shown in the screenshot
Your code might be something like
$body.on('click', 'a.tsml-directions', function(e){
e.preventDefault();
var directions = 'https://www.google.com/maps/dir/?' + $.param({
api: "1",
destination: $(this).attr('data-location'),
travelmode: "driving"
});
window.open(directions);
});
Note I don't specify origin parameter as it is optional and in this case it should be interpreted as my current location.
I hope this helps!
We are calling the google directions api to calculate round trip values. In general it works perfectly. I have however come across a use case where it fails to come up with any route. However when we use the js google.maps.DirectionsService version with the same origin, destination, waypoints, and travelMode it works.
The failing call is:
https://maps.googleapis.com/maps/api/directions/json?origin=-33.92873,18.458879&destination=-33.92873,18.458879&waypoints=via:-33.9403,18.666731&mode=driving&key=
The response is
{
"geocoded_waypoints" : [ {}, {}, {} ],
"routes" : [],
"status" : "ZERO_RESULTS"
}
When you use via: prefix (no stopover), it adds some additional restrictions. Particularly the U-turn maneuver is not allowed, the route must go straight forward through waypoint. If this is impossible the Directions service will return ZERO_RESULTS.
To check this hypothesis I created exactly the same request, but with stopover (without via: prefix). You can see the result in the Directions calculator:
https://directionsdebug.firebaseapp.com/?origin=-33.92873%2C18.458879&destination=-33.92873%2C18.458879&waypoints=-33.9403%2C18.666731
Indeed, you should do the U-Turn in -33.9403,18.666731 (marker B) and this is the reason for ZERO_RESULTS when you try to create a route without stopovers.
This is also confirmed in the official documentation:
Caution: Using the via: prefix to avoid stopovers results in directions that are very strict in their interpretation of the waypoint. This may result in severe detours on the route or ZERO_RESULTS in the response status code if the Google Maps Directions API is unable to create directions through that point.
https://developers.google.com/maps/documentation/directions/intro#Waypoints
I hope this explains your doubt!
Suppose I have a route defined from one town to another. From the Google Maps API I can recover a route between the two. However, the route returned from Google is a driving route that includes geo-coordinates only at places where there is another step in a leg (for example, where I have to turn from one highway to another).
What I need is geo-locations (lat/long) along the entire route, at specific intervals (for example, every 1/4 mile or 100m).
Is there a way to accomplish this via the Google Maps API / web services?
Or would the OpenStreetMap database be the way to do it?
Kind regards,
Madeleine.
OSRM gives you routes with road geometries as they are in the OpenStreetMap database. For example, you can get the route as GPX (and post-process this file if you want). This would look like the following:
GET http://router.project-osrm.org/viaroute?hl=en&loc=47.064970,15.458470&loc=47.071100,15.476760&output=gpx
Read more: OSRM API docs.
Since the accepted answer is outdated and does not work anymore, here is how all nodes along a road can be queried using the route service from Project OSRM.
Given an arbitrary number of lon,lat pairs.
For Instance the following three (in Berlin):
13.388860,52.517037
13.397634,52.529407
13.428555,52.523219
The route-service calculates the fastest route between these points and its possible to return all nodes along the road using the following query:
http://router.project-osrm.org/route/v1/driving/13.388860,52.517037;13.397634,52.529407;13.428555,52.523219?alternatives=false&annotations=nodes
This returns a json response containing node IDs of all the nodes along the route. The result should look something like this:
{
"routes": [
{
...
"legs": [
{
"annotation": {
"nodes": [
2264199819,
2045820592,
21487242,
...
]
}
To receive the lat,lon coordinates of the nodes OverpassAPI can be used.
[out:json];
(
node(264199819);
node(...);
node(...);
...
);
(._;>;);
out;
Here is a sample request using overpass-turbo: http://overpass-turbo.eu/s/toe
It's simply google.maps.DirectionsService().route() method. You need to pass the service request and then a callback which executes upon completion of the service request.
https://developers.google.com/maps/documentation/javascript/directions
While not used as API, here: https://www.nmeagen.org/ one can create "Multi-point line", set the distance between points and download route (coordinates) as CSV.
Adding to the Marlio's answer.
You can use Google Maps Directions API itself.
For a given origin and destination, in the JSON output, look for following:
"polyline" : {
"points" : ""
}
You can use a decoder to get the coordinates from the polyline.:
https://github.com/emcconville/google-map-polyline-encoding-tool
Or. you can use the googleway package in R to decode the same.
https://cran.r-project.org/web/packages/googleway/googleway.pdf
I am not sure how to set the resolution to your desired level though.But the resolution in the API output is really good.