my problem is i want to show my registered site user on to google map but dont know how to locate the user, means i dont know the latitude and longitude of every user . I am a newbie in google map so plz help
Thanks a ton
What location data do you have for your users? Cities, states, countries?
You might want to have a look at Google's Geocoding APIs.
there are two possible ways of doing this.
Ask the user to search a google map and place themselves on it. Look here for an idea on how to do this http://www.designing4u.de/2008/08/google-maps-jquery-and-xml-saving-markers-with-user-input/
Use an IP to Location database to find out the location based on their IP. Look here for how to do this http://www.ip2nation.com/ip2nation
There is no way to reliably locate a user using their IP address. However if you are developing for a mobile device it may be possible to acquire their GPS coordinates. Or you could require them to enter an address and place a point on the map from that address with geocoding.
If you are collecting the address of each registered user, you can get the latitude and longitude on the server-side through the Google Maps HTTP Geocoding Service.
You would use the following HTTP request:
http://maps.google.com/maps/geo?q=Oxford+Street,+London&output=csv&sensor=false
Simply change the q parameter with your user's address.
Related
Hi I have implemented google analytics on to my website. However it only shows the location of visitors on the country, state and city level. How do I get it to show the visitors location drilling down to suburb level?
Is it a special code I need on my website or some settings I need to do on my account or something I have to pay for ?
Thanks so much for the help!
Google Analytics' accuracy will very often be the best you can get.
There is HTML5 Geolocation (more detailed introduction here) which can be more accurate, down to several feet if the user's machine has a GPS device. However, this kind of geolocation requires the user's explicit permission.
I have a list of addresses in database. I can show google from these addresses in my website but I want to make a link from these addresses. When user clicks on address It will open google map in a new tab.
Just done this for a client. If you take the following php generated link:
<?php echo 'http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q='.$placestring.'&aq=&sll=&sspn=&vpsrc=0&ie=UTF8&hq=&hnear='.$near.'&t=h&z=12'; ?>
$placestring in my code is simply the address, put through a htmlentities() routine to ensure it is a safe url. The $near variable can be used to avoid doubt if your addresses are all within a certain area - i.e. if all of the addresses are in London, you could use London as the $near variable. This helps google to provide a better match. If you have postcodes (in the UK) or a lat/long then this will massively help.
Hi I have a database with a list of contacts in which I am displaying onto a page in a list.
As part of this result set I have a post code, is it possible to generate a google map from that postcode and display it as part of the result?
If it is can any one help me get started?
You can use the post code as the location for your map and google will usually be able to find it.
For example, using the static maps API, the following url will give you a map for the zip code 92117 (which is in San Diego, CA):
http://maps.googleapis.com/maps/api/staticmap?center=92117&size=400x400&sensor=false
You can also do something along the lines of what primehunter326 was suggesting and reverse geocode using the javascript API. Which approach is best depends on what you are trying to do.
Start here for info on how to use the various Google Maps APIs:
http://code.google.com/apis/maps/index.html
Yes it is possible. The basic idea is that you use geocode to get longitude and latitude coordinates for the address. You can then use javascript to display a map on your page with all the points as markers. I'll try to find a link with that goes over it in more detail.
Here is a link which goes over geocoding
You'll need an API key in order to use their services, here
For an online ordering system, we figured that we would take the entered address and city, calculate the distance between it and each entry in a database of addresses using the Google Maps API.
However the client was told by his previous designer that he needs to use geotargeting for more accuracy. As far as I know, geotargetting is only accurate in getting the user's country, but definitely not precise location.
Is there a problem with the address+city method? And is there any truth to the geotargetting method?
Geo-targeting will provide you with the precise location (coordinates) of the user, if they choose to share it.
You can use the coordinates with Google Maps API to then calculate the distance in the same manner you planned with address of the user or the restaurant. (Google converts any address to a coordinates in it's calculations.)
There is no problem with your address+city method, but it may be easier for users to just share their current location... and not have to enter a current address+city.
Address+city would need to be a fallback if the user is not willing to 'share their current location' via geo-targeting.
I have been looking through the documentation for the API and not sure if it is possible to list multiple select stores near the submitted address.
Ultimately something like the following website: http://www.evolutionofsmooth.com/locator/
It seems like they have each location stored in a db but I can't see it that likely since it would be pretty huge to do something like that.
Any ideas?
They probably did store all the shops in a database. They saved the latitude and longitude of each shop. Then they load, via AJAX, all the shops into the google map. Google maps has a tutorial for creating a storelocator.
Google maps api v3 has a function called ClientLocation this can, on base of the IP-address, return the current position of the user viewing the google map. This way the closest shops can be highlighted or put on top of the list.
Hopes this will help!