PHP Results and Google Maps - php

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

Related

Geocode address, using Google (not geocoder)

Can you use Google's map search (not geocoder)? For instance, if I type in google maps: 1249 Cedar Rd. 101 Chesapeake VA 23322. It will return the right location, but when I do a geocoding of this address it doesn't show the right location (wrong lat/long). What I was hoping is to just use https://maps.google.com/maps?q=1249+Cedar+Rd.+101+Chesapeake+VA+23322&ie=UTF-8&hq=&hnear=0x89baa4d9ad5e3b8b:0x844028b651d3e0cb,1249+Cedar+Rd,+Chesapeake,+VA+23322&gl=us&ei=IWJAUs_PHonV2AWoz4GwBw&ved=0CCwQ8gEwAA
If you click on that link, it will show the correct location. Is there a way to use PHP/JSON use the above URL?
Or, is there a way to pair Google Maps/Places, to return the right address? I'm trying to figure out a way to get the correct address. Search that works fine in google, but not when geocoding. It's really annoying....
That Google Map (click on "more" then "Zoom here" on your link to get the link above) gives me 36.716054,-76.284857
The Google Maps Javascript API v3 geocoder returns:
1249 Cedar Road, Las Gaviotas Shopping Center, Chesapeake, VA 23322, USA (36.716055, -76.28485490000003)
Which looks pretty close to me...
I get the same(ish) coordinates from the Geocoding API as I do from the map: http://maps.googleapis.com/maps/api/geocode/json?address=1249%20Cedar%20Rd.%20101%20Chesapeake%20VA%2023322&sensor=false gives
"lat" : 36.7174039802915,
"lng" : -76.2835059197085
Which match (with very small differences) in what I get when I right click on the marker and choose What's here which is possibly what you mean by geocoding from the map? :
36.717567,
-76.283689
This puts the point right beside the location selected by Google maps. This shows that Google's internal look-up is using slightly different (better?) data then the Geocoding API but all three points show the same address. Am I missing something in how you are getting the incorrect address?
Ahhh, I figured out what was going wrong. I wasn't properly encoding the address when I put it into Google, so it was returning a different address. I switched to using the php urlencode() function and it seems to be working.
Thanks though!

Want to add a google maps button to customer address form

I'm looking for a way to add a google maps button to a customer contact form that pulls the customers address from MySQL
So basically I want to have a google maps button on the customer contact form that takes the address for that customer stored in MySQL and when the button is pressed it navigates to google maps and displays that customers address.
Try this https://gis.stackexchange.com/questions/52370/how-to-geocode-addresses-from-mysql-and-add-them-like-markers-to-the-google-map I don't think it is exactly what you want but it should get you going in the right direction.
Here's how I did it!
The original question was exactly what I was trying to find out...for hours and hours! Everything I found is for a much more complex implementation.
I just wanted a button that would take the address returned from the database and give the end-user the option to go to Google Maps. Couldn't find the solution anywhere.
Assuming my database has returned values to these fields:
'$loaded_street'
'$loaded_city'
'$loaded_state'
'$loaded_zip'
Go to Map
I did a property search at Google Maps, hit their "Send" button, which launched my email client and included a link to that address.
I took the address out and added the php for each field on my form and it worked!
I'm sure there's a cleaner approach, but I'm not a programmer so I was happy to get it to work since finding such a simple answer was so difficult.
No script, no map API, geocodes, longtitude and lat. Just a link with the right variables.
Here is a scenario for you.
First of all you must know that you will have to use javascript with google maps api.
As Jason suggested you must use geocode.
Geocode is a service of google maps, that gives you the ability to give the api an address, so it can return you something that you can use for the map, like latitude and longtitude.
What you can do is use ajax to request from your server the address, then you use the api as I mentioned and after that is easy. If you don't want to just place a marker, just don't. When you have the location in a way that is useful to your map, you can do whatever you want. From what I understand, you want an infowindow with the address in it.
Some examples that might help you
Geocoding example
Jquery ajax post
How to add an infowindow to your marker
Live example for infowindow
UPDATE
I believe that, if you take the first example and change it a little bit it will do the work. In the example it takes the address from the input. What you will do, is when the user presses the button, then you make an ajax post (or get) to your server and receive the address. When you receive the address you use geocode as the example where you add an infowindow to your marker displaying what you want.

Is it possible to mail google maps using php

I have code for finding source and destination in google map. Is it possible to mail that map to a specific mail id using php code . please help me
thanks in advance
It is possible to mail a link to a Google Map - just put the link into the E-Mail.
Other than that, I don't think you will be lucky. Google Maps uses extensive scripting. Scripting is not supported in E-Mails.
Google Maps has a static maps API that creates images, but I don't think they do directions on that - and distributing the generated images via E-Mail would probably violate their terms and conditions.
Google maps can be built from their URL. The maps page takes certain variables form the url and uses them to calculate the entire directions. All you have to substitute your locations and way points and any other more advanced options (avoid motorways etc.) and mail that link.
example (guess the location :p ):
http://maps.google.co.uk/maps?hl=en&q=edinburgh+to+london&bav=on.2,or.r_gc.r_pw.&biw=1148&bih=766&um=1&ie=UTF-8&sa=N&tab=wl
Edit: P.S Lat and Lng Values also work in URL

Google Maps API Business Search

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!

Google Map with php mysql

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.

Categories