I'm coding a Telegram Bot with Python and I'm using Google Maps Geolocation API to find different addresses. I have JSON Object with a formatted_address field, which contains the exact address of the location correctly formated, for example: 100 Green Hwy, Mattapan, MA 02122, USA.
I'd like to send the location to a chat conversation, something like this:
Or at least, generate a google maps link which points to the location, so the other people in the chat can open the link using google maps or the browser.
So just to make it clear, I want to send the location message to a Telegram chat conversation given 100 Green Hwy, Mattapan, MA 02122, USA or its coordinates (if it's possible to find them), or at least send a link which would look similiar to this one: https://maps.google.com/location/100+Green+Hwy+Mattapan+MA (note that I just made it up, and this won't work).
I finally was able to do it using the Geolocation API. I made this requests
https://maps.googleapis.com/maps/api/geocode/json?address=HERE_THE_FULL_ADDRESS_AND_CITY&key=MY_API_KEY
I got a JSON response (which contained the Latitude and Longitude inside the Geometry key. Then, I used the sendLocation function of the Telegram Bot API, to send the coords.
Related
I want to write an application that gives me the exact route of a subway.
When you use Google Maps it just connects two stops linearly, but not the actual way.
Is there a way to move a route anywhere on a map without being bound to roads?
If there's any solution (doesn't have to be with the Google Maps API) please let me know.
Edit:
Example
Google shows the train route like the brown line, but the train actually drives the blue line. What I would like to do is get the blue line so that I can get the coordinates of the route and calculate the curves and elevation.
I know that I could add like 50 waypoint and get get a "fake" route with them, but I would like to have it automatic and not done by hand.
To show the transit directions (subway, bus, tram, etc.) Google Maps uses the data provided by transit agencies in the form of GTFS feeds. This is a responsibility of the agency to provide a detailed shape of the route for the transport according to the GTFS specification. You can have a look at GTFS documentation to figure out how does it work:
https://developers.google.com/transit/gtfs/
https://developers.google.com/transit/gtfs/reference/#general_transit_feed_specification_reference
I hope this helps.
I'm developing an asp.net web app and i need to detect the current Geo location and save it to a variable and than show to user its current place name and through this I will guide the user to where he want to go, and than user will in put the destination and I will guide that what the root will be suitable for him and I will provide full detail.
I'm getting its current location but don't how to show to user by displaying on label or in textbox.
I don't know where to start this.
If you are able to access the current geolocation of the user then you need to do the following things-
Get Destination
Now you need to get the destination name from the user using some mode of text input or, speech to text etc.
Geo Code destination
Now you need a good geocoding API to get the coordinate of the destination that user has entered. You can use google's geocoding API. It is available for both client(JavaScript) and server(C#, Java, PHP -etc) side. All you need is an API key.
Find Route
Now you have to find the route between the two coordinates (your current location and destination coordinates). Google provides a direction API for the same. Again you can implement this both on the client or, server side (I will prefer client side to reduce the load on the server end). This API returns a long polyline string which can be decoded into a list of coordinates to plot the route on the map. It also returns a list of maneuver data containing the direction info and road names etc. This maneuver info will help you to direct your user to the destination at the time of navigation.
Plotting the route
Now is the time to add a map canvas to your application and then plot the route to it. You can now use the list of coordinates that you decoded from the polyline to draw a polygon on the map. See this below screenshot from one of my application where I drew the path on the map and also marked all the maneuver points on the path.
Navigation
Well, now you are almost done. Now you can start navigating to the destination. Now use whatever mechanism you use to get the user location periodically and then update it as a marker (you can use a car's icon) on the map and then whenever you reach (calculate the distance) a maneuver point show user the maneuver message like "Turn right"/"Turn left"/"Continue straight for 100 meter" -etc.
If you are stuck with getting the current user's location then you can use HTML5 to get devices location using the network.
Hope this is helpful for you.
I am trying to make a web app based on google map api.I want to put image icon at different position of street in map.
how wiil i get these street coordinate from google map api?
Please give your useful suggestion.
Thanks.
Google have a service called Geocoding - you send a request including an address, a google.maps.latLng, or a Place_ID and it returns an array with all three of them. they explain all about this here.
I am new to Google Maps API and I have a requirement to integrate Google Maps API with an ASP.Net application. Is there a Google service where in I can input a UK postcode and radius as input parameters and get results only, without the map.
For example if I search for solicitors in a particular area like Z1 1XY (not real post code) with a radius of 5 mi, can I get the results of all solicitors with the postcodes 5 mile radius? Is there any service that would return the result set only? I know GeoCoding does something similar but can I provide radius as one of the input parameter and get results.
Any help would be appreciated. Thanks in advance.
Seaton
The Geocoding API may only be used in conjunction with a Google map; geocoding results without displaying them on a map is prohibited. For complete details on allowed usage, consult the Maps API Terms of Service License Restrictions.
Source: https://developers.google.com/maps/documentation/geocoding/#Limits
yes, you can use the Google Geocoding API to do address lookups (in this case postcodes). The response contains lat/lon co-ordinates which you can then subsequently use as the epicenter of your search to find items within a radius. Have a look at this blog post on how to use the DbGeography in .NET to perform radius queries based on lat/lon co-ordinates.
Has anyone got sample code/file which they could share as i am trying to plot foursquare venues on a Google map. For example: Given the Long and Lat of i.e. London. i would like to show restaurants within a 3 miles radius.
Is this possible without having to pass the client ID when using the API?
Your help would be greatly appreciated
Kamran
Do not have a direct sample you can copy paste, but it is not that complicated to do:
Foursquare wise: You must register as a consumer here, this gives you a Client ID + Secret.
You do not need to have your users go through the authentication to just display the venue information around a specific lat/lng, you can use the Venue Platform for that, specifically search for venues and (if required) get the venue details.
According to your specific example, show restaurants in a 3 mile (~5000 meters) radius, you will want to call search with intent=browse, radius=5000, ll={your search location}, limit=50 (the max) and categoryId=4d4b7105d754a06374d81259 (it is the food category, see here on how to get the category id listing)
So searching will produce a json array of foursquare locations, from there you can take what data you need and display it on google map via the maps api.
For Maps v3 you will probably want to drop a marker for each venue returned.
Also check out this answer for how to drop pins on google maps: Google Maps API - Drop a new pin