Google Maps with PHP and Javascript

Posted: January 31, 2011 in Javascript, PHP5
Tags: ,

<?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
Comments
  1. Spot on with this write-up, I really suppose this website needs far more consideration. I’ll in all probability be again to learn rather more, thanks for that info.

  2. This Blog is going places, the people, the layout, amazing to see such dedication and focus.

  3. 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.

  4. 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.

  5. 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.

  6. i read a lot of blogs specially interesting ones like your blog. ‘”,,*~

  7. 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.

  8. Hi i found your blog when looking for something else on a forum, could you help with a sms php script?

  9. oh i just turned on notifications with this comment so i know if you get back

  10. Hi Amith,

    Nice blog check my site here http://codershelpdesk.com

    you posted a comments on my wordpress blog http://codershelpdesk.wordpress.com/

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s