get coordinates from address using google maps api in javascript

get coordinates from address using google maps api in javascript

http://maps.googleapis.com/maps/api/js?sensor=false

Advertisements

get coordinates from address using google maps api in php loop

get coordinates from address using google maps api in php loop

 

function getCoordinates($address){

$address = str_replace(" ", "+", $address); // replace all the white space with "+" sign to match with google search pattern

$url = "http://maps.google.com/maps/api/geocode/json?sensor=false&address=$address";

$response = file_get_contents($url);

$json = json_decode($response,TRUE); //generate array object from the response from the web

return ($json['results'][0]['geometry']['location']['lat'].",".$json['results'][0]['geometry']['location']['lng']);

}


echo getCoordinates('740 Story Rd San Jose CA 95122');

set cookie, get cookie, delete cookie in javascript

set cookie in javascript
function setCookie(key, value) {
var expires = new Date();
expires.setTime(expires.getTime() + (1 * 24 * 60 * 60 * 1000));
document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();
}

get cookie in javascript
function getCookie(key) {
var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
return keyValue ? keyValue[2] : null;
}

delete cookie in javascript
function delete_cookie(name) {
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}