I am building a site that helps people to find restaurants on the net .. so i want for every restaurant to show a small Google Map
Now i'm still building my database, in the table restaurant i have id ,name , phone, website, ....
My question is do i have to add other properities to help me locate the place exactly on Google Maps, what are they?
Please note that this is my first time to work with google maps, and i really dont know what do i need exactly to know about a place to represent it on the map.
Thanks
There are several ways to locate a place. First, you can do it through latitude and longitude. For this you can use Reverse geocoding which can translate the latitude & longitude into an address. You also have the option of using place_id, it is used to uniquely identify a place in Google Maps. See Places IDs. You also have the option of using the address of the place but I do not recommend it; due to the fact that there can be multiple places with the same name.
As for the properties that is available for the place, you may want to look at Place Details of Places API. This will return details like latitude,longitude, place_id, international_phone_number, opening_hours, permanently_closed, price_level, reviews etc.
Hope this will help you. Good luck!
To locate a place in google map, we need latitude and longitude.
for eg. in android ,to mark a location
static final LatLng PERTH = new LatLng(-31.90, 115.86);
Marker perth = mMap.addMarker(new MarkerOptions()
.position(PERTH));
here -31.90 and 115.86 are that places latitude and longitude respectively.
I think the logic may b same in all platforms
Related
I am doing some mapping work and need to find latitude and longitude of villages in india many of which are small and rural. I am having trouble finding the full set of locations with the same name, for example a village named 'Kallanai' (see api links below, note they need appropriate keys for the places API to run on your computer). I can find the one I'm looking for in google maps by entering www.google.co.in/maps/place/Kallanai into the browser however it will not turn up in the geocoder or places api without specifying the associated pin code (analogous to zip-code). Can anyone explain why the basic searches for either the geocode or places API using the village name alone do not return the village with the pincode 625501 in the results?
e.g.
Google places:
https://maps.googleapis.com/maps/api/place/textsearch/json?query=kallanai&sensor=false&key=enter your key
https://maps.googleapis.com/maps/api/place/textsearch/json?query=kallanai+625501&sensor=false&key=enter your key
will post google geocode links in follow up as stackoverflow will not let me include more than 2 links in my post without more points.
In a world where autocomplete is common and almost taken for granted, Google Maps has (long) switched to showing just the one results your most likely looking for.
Places Autocomplete API might get you more of what you're looking for, but it would still be a sub-optimal fit for database-like queries like this. It works best when you have users typing, each of them knowing which Kallanai they want, so they can select the suggestion that matches, and they can add details (e.g. PIN code) to get it if the suggestion doesn't show up at first (max 5 suggestion show each time).
Google does Geocoding in a different way from classic GIS databases. To obtain all cities [with a given name] in a given country, you'd probably need a database like GeoNames or Natural Earth.
I did some research about a question but didn't find any answer. And now, I'm wondering if this is possible to do.
More details : I would like to to create a function that take a city in input and return a location (lat + long) randomly inside the city. The problem is that I don't know anything about the city boundaries.
I'm working on api v3 javascript
Do you have an idea of how i can do ?
Thank you
Just use the geocoding service as shown in this example from the documentation
I think you need to get the longs and lats for each point in the polygon for the city to do this cleanly.
Can you not just sidestep the problem by finding a random address, maybe scrape a list of local post offices and pick one at random, then geo-locate it's postcode with the Google Maps API?
It depends what you mean by random to some extent.
We have a database of addresses that we deliver to. It consists of the following data;
StreetName
NumberFrom
NumberTo
ZipcodeId (points to seperate table with zipcodes, which holds cityName)
StoreId
Would it be possible to highlight all those addrresses on a map like GoogleMaps (preferred), Bing, OpenStreetMap, etc. ?
I know how to add polylines, and have done geocoding in the past for addresses.
A possible issue with the data, is where it covers whole street they practise have been to just set the NumberTo to 9999. If i plot an address into google Earth with 'StreetName 999, City' it will place the point in the middle of the length of the street.
Also tried a random number, and it placed the marker on a building instead of on the street.
I don't know if it's different for GoogleMaps..
Update
I think that the DirectionsService in GoogleMaps API is the way to go, now i only need to figure out if and how i can use it multiple times on a map.
Success!
I was able to iterate over all the addresses, doing a DirectionsService request for each addres, from start of street to end of street. Extract the GeoPoints used by DirectionsDisplay, stored it to the database and is now able to draw Polylines on a map for each road.
I could iterate over the addresseseach time the map is shown (in-house use only). But still this would be a performance issue, and also unsure if how many request Google will handle per day. By storing it in DB i only need Google to calculate it once.
It can, but only in certain areas of the world - e.g. US
But you need to prepare your adresses - lets say in div/spans - then on onload document, you calll the API
I did this using Lat/Lng from a Garmin Edge - the difference is that you need to translate your addresses into lat/lng, before you can position these on the map canvas.
Mike
Yes you can convert the Address to a GeoPoint and then plot the GeoPoints on the Map. Start by looking here
All the methods and examples I can find about the Google maps api is based on a postcode, or coordinates to get the desired location - what if I want to place a marker for a specific business which has been added to google maps, so it shows tel number etc like an embeded map would? Even if I use exact coordinates for the address it doesn't recognise it. Sure I'm missing something really simple here...
Thanks!
The Google Places API, this does what your looking for. I couldn't tell you how to implement as of now because i am trying to put it inside of my Rails application but i will update my answer in the future when i do get it working though.
i had implemented google map API with phoogle.php. Its working fine. But i cant able to view multiple places.
Example: all country,all beaches
Not completely clear from your question what it is that you are trying to do here.
I had a look at the Phoogle documentation and it seems like the framework it provides is pretty limiting.
It exposes some methods for setting a key, displaying a map, configuring a few basic UI characteristics and setting the zoom level. It seems like you can also add addresses to be geocoded to lat,lng and then added to the map as markers.
It won't geocode anything as generic as "all countries" or "all beaches".
I can only suggest (and I am guess wildly here) that you might want to populate a list of countries and then geocode (addAddress) just the country names to place markers on the map for each of those countries.
I can't imagine you wanted to place a marker on "all beaches", but you might want a list of beaches ("palm beach, sydney, australia" for example) and similary geocode those names and mark then on the map.
If you would like to read more about what the Google Maps API is capable of, I suggest you have a look at the API Reference.
If there is something more specific that you wanted to do, please update the question and we would be happy to help.