search lat/log from Adress using GMMap in Delphi - delphi

I wanted just and simply hit a normal full address in edit box and get it's position (lat/log) and mark it in the map. I don't have any clue about getting latitude and longitude from adress , I was searching in GMMap properties , I could not see it at all. Could you please a help on that ?
Thanks

To obtain a lat/lng from an address, you need to geocode it. To do that, put a TGMGeocode component, link it with the TGMMap and call Geocode method with the address.
A geocodification can return 1 or more results (until 10 with standard Google access). For example, if you geocode "Andorra" you will get 2 results, Andorra a country and Andorra a city from Spain. For this reason, the result of geocodification is an array (GeoResult). You can iterate it with Count property.
To know the lat/lng from a GeoResult, you need to read TGMGeocode[i].Geometry.Location property or TGMGeocode.GeoResult[i].Geometry.Location property (is the same)

Related

How can I get Only Health related Data from Google API?

I want to get only results that are related to health and for that I used below api.
https://maps.googleapis.com/maps/api/place/search/json?location=23.0225,72.5714&radius=500&types=hospital&sensor=false&key="API_KEY"
Above API gives me the results related to Health but I don't want to pass location lat long Parameter.
Actually I want to search it with "input" Param like below.
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Ahmedabad&types=hospital&radius=500&key="API_KEY"
But above give me error like below
{
"predictions" : [],
"status" : "INVALID_REQUEST"
}
How can I get this type of results?
Thanks in Advance.
The places autocomplete request from your question has several issues.
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Ahmedabad&types=hospital&radius=500&key=API_KEY
If you remove the location parameter, you should remove the radius parameter as well. It doesn't make sense without location.
hospital is not allowed value in types filter of autocomplete. If you check the documentation, you will see that the only possible values are:
geocode
address
establishment
(regions)
(cities)
Place autocomplete might return only 5 suggestions. I think you are looking for something different.
Also, be aware that radar search mentioned in the comments is now deprecated and will stop working in June 2018.
https://maps-apis.googleblog.com/2017/06/announcing-deprecation-of-place-add.html
I would suggest having a look at Places API text search. Your query with Places API text search might be
https://maps.googleapis.com/maps/api/place/textsearch/json?query=Ahmedabad&type=hospital&key=YOUR_API_KEY
The text search can return up to 60 results divided into pages of 20 results. For your particular example, I got the following output
Hope this helps!

Get random address/coordinates in a specified town

Is there any way to give Google Maps API or a similar API a town name and have it return a random address inside the town? I was hoping to be able to get the data as a JSON so I could parse it with SwiftyJSON in XCode and use it, but I can't seem to find any way to get the address in the first place. If coordinates would be easier to get, then those would work too, as long as its random and inside the town borders.
You can try to use Google Places API Web Service. It allows you to query for place information on a variety of categories, such as: establishments, prominent points of interest, geographic locations, and more. You can search for places either by proximity or a text string. A Place Search returns a list of places along with summary information about each place.
A Nearby Search lets you search for places within a specified area. You can refine your search request by supplying keywords or specifying the type of place you are searching for.
A Nearby Search request is an HTTP URL of the following form:
https://maps.googleapis.com/maps/api/place/nearbysearch/output?parameters
where output may be either xml or JSON values.
And if you want either address or coordinates, you can use Geocoding for it. Here i found a tutorial on how to use Geocoding in IOS.

Map search results show in a table

I am working on a school project and I can't figure out how to have someone search for a location and then have the results show in a table view.
Ive searched everywhere for some way to do this but found nothing.
There are (with the Apple's API, at least) two types of searches:
CLGeocoder lets you search for an address, or do a reverse search on the basis of the coordinates (e.g. to get the address of the selected coordinates). For example:
If you want to search for an address within a region use geocodeAddressString(_:in:completionHandler:) (passing it the map's region);
If you want to search the world for a given address string, use geocodeAddressString(_:completionHandler:);
If you want to perform reverse geocode lookup of a particular coordinate, use reverseGeocodeLocation(_:completionHandler:).
MKLocalSearch lets you search within a particular MKRegion (e.g. the visible portion of the current map) for points of interest. To do that, you:
Create a MKLocalSearch.Request, setting its region (presumably to your map’s region) and naturalLanguageQuery; and
And then instantiate a MKLocalSearch and then start the search with start(completionHandler:).
If your goal is to show completions for an address as a user types it, you can use MKLocalSearchCompleter.
I assume you're looking for the MKLocalSearch, but these are the basic kinds of searches you can do.

Can i get geocoding information from Google Geocoding API passing only the city?

I just need to fetch some geo data for a given city, i'm not interested (and i don't know) the address. Sending a request like this:
http://maps.googleapis.com/maps/api/geocode/xml?address=fake,%20USA&sensor=false
will match a street with whe word fake in it, somewhere in USA. How can i match only cities and get ZERO_RESULTS response if there is no city with that name?
You can't do this with the Geocoding API unfortunately, from the docs page:
Geocoding is the process of converting addresses (like "1600 Amphitheatre Parkway, Mountain View, CA") into geographic coordinates (like latitude 37.423021 and longitude -122.083739)
The API will always look for a specific address and if it can't find an exact match from the string you provide it will always make a 'best effort' guess as to what you meant to try and find one. Only if it can't make this reasonable guess wil it return ZERO_RESULTS.
I also just explore the API.how about using link like below
http://maps.googleapis.com/maps/api/geocode/xml?components=locality:fake|country:US
locality equal to City and stated the country as US.It will return zero result.But if using this
http://maps.googleapis.com/maps/api/geocode/xml?components=locality:fake|country:Nigeria
This will return the result.

City By GPS Location Latitude/Longitude

I've got a latitude/longitude value.... How can I search and get the city?
If you're looking for free (as freedom) sources, you can use Geonames API findNearbyPlaceName.
For example the following returns nearest Placename:
http://api.geonames.org/findNearbyPlaceName?lat=47.3&lng=9&username=demo
More information is available here
http://www.geonames.org/export/web-services.html#findNearbyPlaceName
Another option is getting data from Freebase. Instead of single point it takes bounded box:
http://api.freebase.com/api/service/geosearch?location=[30.2,50.4,30.6,50.8]&location_type=/location/citytown&inside=true&indent=1
Using the google maps api, here is an example to get the address in XML format.
http://maps.google.com/maps/api/geocode/xml?latlng={latlng}&sensor={sensor}&region={region}
Where latlng = 0,0 sensor = false, and region = country code, so for my old address it would be
http://maps.google.com/maps/api/geocode/xml?latlng=-43.893792,171.7592620&sensor=false&region=nz
Then you can use that XML to get whatever details you need, including the City

Resources