This topic is locked

UK Post Code Search

8/19/2018 8:12:44 AM
PHPRunner General questions
S
swanside author

Hi All

I am looking for a way I can add this into my sites table, so when we add a new site address, we can use a post code lookup
Would anybody have any idea where I can insert this to pick up the Postcode form my table please?
Thanks

Paul.

$('#submit').click(function(){
//Get Postcode

var number = $('#number').val();

var postcode = $('#postcode').val().toUpperCase();;
//Get latitude & longitude

$.getJSON('http://maps.googleapis.com/maps/api/geocode/json?address='; + postcode + '&sensor=false', function(data) {
var lat = data.results[0].geometry.location.lat;

var lng = data.results[0].geometry.location.lng;
//Get address

$.getJSON('http://maps.googleapis.com/maps/api/geocode/json?latlng='; + lat + ',' + lng + '&sensor=false', function(data) {

var address = data.results[0].address_components;

var street = address[1].long_name;

var town = address[2].long_name;

var county = address[3].long_name;
//Insert

$('#text').text(number + ', ' + street + ', ' + town + ', ' + county + ', ' + postcode);
});

});

});
T
thudsen 8/20/2018



Hi All

I am looking for a way I can add this into my sites table, so when we add a new site address, we can use a post code lookup
Would anybody have any idea where I can insert this to pick up the Postcode form my table please?
Thanks

Paul.

$('#submit').click(function(){
//Get Postcode

var number = $('#number').val();

var postcode = $('#postcode').val().toUpperCase();;
//Get latitude & longitude

$.getJSON('http://maps.googleapis.com/maps/api/geocode/json?address='; + postcode + '&sensor=false', function(data) {
var lat = data.results[0].geometry.location.lat;

var lng = data.results[0].geometry.location.lng;
//Get address

$.getJSON('http://maps.googleapis.com/maps/api/geocode/json?latlng='; + lat + ',' + lng + '&sensor=false', function(data) {

var address = data.results[0].address_components;

var street = address[1].long_name;

var town = address[2].long_name;

var county = address[3].long_name;
//Insert

$('#text').text(number + ', ' + street + ', ' + town + ', ' + county + ', ' + postcode);
});

});

});



It's a big datable but free from this site
https://www.freemaptools.com/download-uk-postcode-lat-lng.htm

S
swanside author 8/25/2018

Thnaks Pal.

But I want something that works like other webpages, when you start to enter a Postcode, it will come up with suggestions until the correct address is selected.



It's a big datable but free from this site
https://www.freemaptools.com/download-uk-postcode-lat-lng.htm

C
cristi 8/25/2018

There is a discussion HERE