Skip navigation

Category Archives: PHP

OK, this is a simple way to get your postcode/ address location returned and displayed via the Google Maps API on your own website. I’ll cover the ‘nearest store locator’ scenario in another post where you want places with a certain radius of an inputted postcode/ town returned.

First of all we need to retrieve our results which should already be stored with a geocoded result using the previous tutorial here. remember that in order for this to work you need an API key from google – again check the previous tutorial for more info on this.

Google Maps API part 2: Retrieving Postcodes from your database

Ok so you want to upload a file to your webspace. Easy enough you just need some sort of server-side language. In this case it’s PHP, this tutorial should work with versions 4 upwards.

So we’ll build just 1 file to handle the upload, display status and the form.

Im going to call this upload0r.php (you can call it whatever you want)

First of all make a folder in your webspace/server called uploads, by default it should have read, write and execute permissions (chmod 777) if it doesn’t you can use something like Filezilla FTP client to alter this.

More here: Upload a File Using PHP

Why would you need to do this? Well for instance if you were using 3rd party AJAX APIs and you wanted to capture the data from them perhaps, or maybe you just have a complex form.

Or you could use this for form validation to return errors from the server without refreshing the browser, for example, if the data already exists in a database you could let the user know.

Either way its pretty simple. Basically we just use javascript to post the form object over http to a serverside page – e.g. PHP, JSP, ASP etc…

More here: Using Javascript/ AJAX to post HTML form data

Recently I had to build a system that would take an address, pass it to google and return latitude and longitude values. The result is then stored for later use and display on Google maps.

However, firstly I found that the default XML geocoding service provided by Google that allows you to do bulk geocoding on a data source and the geocoding provided by their maps API/ AJAX library (GClientGeocoder) had huge differences in results. Most postal codes passed to googles XML geocoding service were miles out or just not recognised. Yet when using the same postcode in the maps API when calculated on the fly the results were more or less spot on.

More here:Google Maps API part 1: Accurate Geocoding for UK Postcodes

Follow

Get every new post delivered to your Inbox.