How to get Latitude and Longitude from Country or city using PHP


 


 
How to get latitude and longitude from address in php
 
You can use country name for get Latitude and Longitude and also use full address instead of city or country

$address = 'india';

Or also you can use CIty name for get Latitude and Longitude

$address = 'Junagadh';

Or you can also use city, state and Country togther.

$address = 'Junagadh+Gujarat+India';

There are two method for get Latitude and Longitude

First is :

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

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $details_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = json_decode(curl_exec($ch), true);

// If Status Code is ZERO_RESULTS, OVER_QUERY_LIMIT, REQUEST_DENIED or INVALID_REQUEST
if ($response['status'] != 'OK') {
	return null;
}

//print_r($response);
//print_r($response['results'][0]['geometry']['location']);

$latLng = $response['results'][0]['geometry']['location'];

$lat = $latLng['lat'];
$lng = $latLng['lng'];	

OR
Second method is:

$geocode_stats = file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?address=india&sensor=false");

$output_deals = json_decode($geocode_stats);

$latLng = $output_deals->results[0]->geometry->location;

$lat = $latLng->lat;
$lng = $latLng->lng;	

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

How to apply lightbox in tt_content images


 

To open the tt_content images with lightbox you have to set the below typoscript in your TS template.
Before the you must have to install “perfactlightbox” extension and include in template.

tt_content.image.20.1.imageLinkWrap >
tt_content.image.20.1.imageLinkWrap = 1
tt_content.image.20.1.imageLinkWrap {
	enable.override = 1
	# Add new typolink wrapping code
	typolink {
		target =
		title.field = imagecaption
		parameter.cObject = IMG_RESOURCE
		parameter.cObject.file.import.data = TSFE:lastImageInfo|origFile
		parameter.cObject.file.maxW = 800
		parameter.cObject.file.maxH = 600
		# Add the “rel” attribute needed to activate the lightbox effect.
		# This assumes you want slimbox to be navigable
		ATagParams = rel=”lightbox[sb{field:uid}]” class=”lightbox”
		ATagParams.insertData = 1
	}
}

After set this typoscript. you can go to content element and check the checkbox of “Enlarge on Click” and “Lightbox”.
Then after it will work fine.

If you have any query then feel free to contact me at Jainish Senjaliya