Open google map from my website - php

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.

Related

Address validation in Laravel

I am trying to validate addresses input from users, where they give their street name, zip code, house number etc ...
The question is, how can I validate weather the address is valid?
The even better question would be, how can I check using the IP of the user, weather the input match the current country of the user or not, according to those informations I am gonna flash some validation errors.
Can I implement this in a Google Map for example?
Thanks
You can't.
There are simply too many edge cases, where addresses might seem wrongful, but are correct. Where I live some companies get their own zip code, also some roads do and some addresses does not have a town name.
If you want to be as precise as possible, you should ask the user to enter their address through a Google Maps auto complete field, as Google Maps knows a lot of the edge cases.
That being said, It's not accurate to check whether the users inputted address matches their origin country, as they can be behind a VPN. Also some IP addresses maps to another country than the user is actually in.

Remove unwanted email address from URL

I'm running a site that has google adsense advertisements on it, and they recently notified me that I'm passing PII (Personally Identifiable Information) to them. This came as a surprise, since I intentionally designed the site to avoid doing that and have come to find out that some users are not following the directions on the website for referring traffic and are inputting their EMAIL ADDRESSES instead of their referral numbers.
For example, they should be using http://www.scratch4satoshis.com/?r=2127
but instead are using http://www.scratch4satoshis.com/?r=redacted#sample.com and so, the traffic they send there are shown google ads and if they click them, pass that PII along to google and now they're threatening to close my adsense account.
The site is written in PHP; I'm wondering if there is a way to modify the information being passed to Google Adsense?
Try to filter get parameter as integer values:
$r = intval($_GET['r']);

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.

Geotargetting for "Nearest Restaurant Locator"

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.

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