Google Maps with PHP and Javascript


<?php

class GoogleMaps
{

var $APIKey = “ABQIAAAASTe3RGQOzgfE_7pgalxCWxTxwC-FTRouMUU4URT3KGgoa5PSihROzcGmVudxV_XFjm17uSpKPwoCYw”;

function SetLocation($Location)
{
$this->Location = $Location;
}
function SetWidth($Width)
{
$this->Width = $Width;
}
function SetHeight($Height)
{
$this->Height = $Height;
}
function DisplayGoogleMaps()
{
?>
<script src=”http://maps.google.com/maps?file=api&v=2&sensor=false&key=&lt;?php echo $this->APIKey; ?>” type=”text/javascript”></script>
<script type=”text/javascript”>
//var JobLocationInGoogleMaps = ‘Dhaka, BD’;
var JobLocationInGoogleMaps = ‘<?php echo $this->Location; ?>’;
if (GBrowserIsCompatible())
{
var geocoder = new GClientGeocoder();
geocoder.getLocations(JobLocationInGoogleMaps, function (locations)
{
if (locations.Placemark)
{
var north = locations.Placemark[0].ExtendedData.LatLonBox.north;
var south = locations.Placemark[0].ExtendedData.LatLonBox.south;
var east = locations.Placemark[0].ExtendedData.LatLonBox.east;
var west = locations.Placemark[0].ExtendedData.LatLonBox.west;

var bounds = new GLatLngBounds(new GLatLng(south, west), new GLatLng(north, east));
var map = new GMap2(document.getElementById(“GoogleMapCanvasHere”));
map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
//map.addControl(new GSmallMapControl());
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.addOverlay(new GMarker(bounds.getCenter()));
}
});
}
GUnload();
</script>
<div id=”GoogleMapCanvasHere” style=”width:<?php echo $this->Width; ?>px; height:<?php echo $this->Height; ?>px; background: url(./images/google-maps-loading.gif); background-repeat:no-repeat; background-position:center;”></div>
<?php
}
}

$maps = new GoogleMaps();
$maps->SetLocation(“Khulna,bd”); // Change Location
$maps->SetWidth(500); // Chaneg Map Width
$maps->SetHeight(350); // Change Map Height
$maps->DisplayGoogleMaps();

?>

Advertisements

17 Replies to “Google Maps with PHP and Javascript”

  1. Amazing piece. I was checking constantly this blog and I’m impressed! Very useful info specifically the last part. I care for such information a lot. I was looking for this certain information for a very long time. Thank you and best of luck.

  2. Nice blog. I was checking constantly this blog and I’m impressed! Extremely useful info particularly the last part. I care for such information a lot. I was looking for this particular information for a very long time. Thank you and good luck.

  3. Nice piece. I was checking constantly this blog and I am quite impressed! Very useful info specifically the last part. I care for such info much. I was seeking this particular info for a very long time. Thank you and good luck.

  4. Excellent post. I was checking continuously this blog and I am impressed! Extremely helpful information particularly the last part 🙂 I care for such information a lot. I was looking for this certain info for a long time. Thank you and best of luck.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s