Skip to content

Commit

Permalink
switched to google maps v3
Browse files Browse the repository at this point in the history
  • Loading branch information
robap committed Jun 14, 2011
1 parent ca460d1 commit dc95f8d
Show file tree
Hide file tree
Showing 29 changed files with 137 additions and 594 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
/app/config/config.php
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "app/lib/pillow"]
path = app/lib/pillow
url = git://github.com/robap/pillow.git
1 change: 0 additions & 1 deletion app/config/config.template.php
Expand Up @@ -5,7 +5,6 @@
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
$config = array(
'google_api_key' => '',
'google_tracker_key' => '',
'zillow_api_key' => '',
'pillow_install' => '../pillow/'
Expand Down
16 changes: 5 additions & 11 deletions app/lib/Geocoder.php
Expand Up @@ -6,13 +6,11 @@
*/
class Google_Geocoder
{
private $_key;

private $_addresses = array();

public function __construct( $key )
public function __construct()
{
$this->_key = $key;

}

/**
Expand Down Expand Up @@ -43,13 +41,9 @@ public function geocode( $address )
*/
private function _getUri( $address )
{
$uri = "http://maps.google.com/maps/geo?";
$uri .= "q=" . urlencode($address);
$uri .= "&key=" . $this->_key;
$uri = "http://maps.googleapis.com/maps/api/geocode/json?";
$uri .= "address=" . urlencode($address);
$uri .= "&sensor=false";
$uri .= "&output=json";
return $uri;
}
}

?>
}
67 changes: 44 additions & 23 deletions app/lib/Placemark.php
Expand Up @@ -6,8 +6,6 @@
*/
class Google_Placemark
{
public $id;

public $fullAddress;

public $accuracy;
Expand All @@ -19,6 +17,8 @@ class Google_Placemark
public $county;

public $zip;

public $streetNumber;

public $street;

Expand All @@ -39,27 +39,50 @@ public function __construct( $raw_json )
//The returned string may not be decode-able
if( NULL === $pm ) return;

if( $pm->Status->code != '200') return;

if( FALSE === array_key_exists(0,$pm->Placemark) ) return;

if( $pm->Placemark[0]->AddressDetails->Accuracy < 8 ) return;
if( $pm->status != 'OK') return;

$results = $pm->results;
if(count($results) < 1) return;

$result = $results[0];

if(isset($result->partial_match)) {
return;
}

if( TRUE === array_key_exists(0, $pm->Placemark) )
$this->fullAddress = $result->formatted_address;

foreach($result->address_components as $address_component)
{
$this->id = $pm->Placemark[0]->id;
$this->fullAddress = $pm->Placemark[0]->address;
$this->accuracy = $pm->Placemark[0]->AddressDetails->Accuracy;
$this->state = $pm->Placemark[0]->AddressDetails->Country->AdministrativeArea->AdministrativeAreaName;
$this->city = $pm->Placemark[0]->AddressDetails->Country->AdministrativeArea->SubAdministrativeArea->Locality->LocalityName;
$this->county = $pm->Placemark[0]->AddressDetails->Country->AdministrativeArea->SubAdministrativeArea->SubAdministrativeAreaName;
$this->zip = $pm->Placemark[0]->AddressDetails->Country->AdministrativeArea->SubAdministrativeArea->Locality->PostalCode->PostalCodeNumber;
$this->street = $pm->Placemark[0]->AddressDetails->Country->AdministrativeArea->SubAdministrativeArea->Locality->Thoroughfare->ThoroughfareName;
$this->x = $pm->Placemark[0]->Point->coordinates[0];
$this->y = $pm->Placemark[0]->Point->coordinates[1];

$this->_isValid = TRUE;
if(in_array('street_number', $address_component->types)) {
$this->streetNumber = $address_component->long_name;
}

if(in_array('route', $address_component->types)) {
$this->street = $address_component->long_name;
}

if(in_array('administrative_area_level_3', $address_component->types)) {
$this->city = $address_component->long_name;
}

if(in_array('administrative_area_level_2', $address_component->types)) {
$this->county = $address_component->long_name;
}

if(in_array('administrative_area_level_1', $address_component->types)) {
$this->state = $address_component->long_name;
}

if(in_array('postal_code', $address_component->types)) {
$this->zip = $address_component->long_name;
}
}

$this->x = $result->geometry->location->lat;
$this->y = $result->geometry->location->lng;

$this->_isValid = TRUE;
}

/**
Expand All @@ -79,6 +102,4 @@ public function isValid()
{
return $this->_isValid;
}
}

?>
}
3 changes: 1 addition & 2 deletions app/lib/functions.php
Expand Up @@ -20,5 +20,4 @@ function dump( $var )
echo "<xmp>";
print_r($var);
echo "</xmp>";
}
?>
}
1 change: 1 addition & 0 deletions app/lib/pillow
Submodule pillow added at 6a962f
11 changes: 1 addition & 10 deletions app/views/property_begin.php
Expand Up @@ -12,14 +12,12 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Zillow-Google Masher</title>
<link href="css/custom-theme/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 7]>
<link rel="stylesheet" type="text/css" href="css/style_ie.css" />
<![endif]-->

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/jquery.watermark.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
Expand Down Expand Up @@ -112,12 +110,6 @@
here
</a>
</li>
<li>
Get your Google maps api key
<a href="http://code.google.com/apis/maps/signup.html">
here
</a>
</li>
<li>
In the extracted source, copy the file:
app/config/config.template.php
Expand All @@ -129,13 +121,12 @@
</pre>
</li>
<li>
Add your Zillow and Google keys to app/config/config.php and
Add your Zillow key to app/config/config.php and
add the path to the pillow library.
</li>
<li class="no_style">
<pre>
$config = array(
'google_api_key' => 'place your google api key here',
'zillow_api_key' => 'place your zillow api key here',
'pillow_install' => '/path/to/pillow/'
);
Expand Down
2 changes: 0 additions & 2 deletions app/views/property_no_results.php
Expand Up @@ -11,14 +11,12 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Zillow-Google Masher</title>
<link href="css/custom-theme/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 7]>
<link rel="stylesheet" type="text/css" href="css/style_ie.css" />
<![endif]-->

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/jquery.watermark.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
Expand Down
10 changes: 1 addition & 9 deletions app/views/property_results.php
Expand Up @@ -11,18 +11,16 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Zillow-Google Masher</title>
<link href="css/custom-theme/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 7]>
<link rel="stylesheet" type="text/css" href="css/style_ie.css" />
<![endif]-->

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/jquery.watermark.min.js"></script>
<script type="text/javascript" src="js/latnlng.js"></script>
<script type="text/javascript" src="js/zillgoog.js"></script>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=<?php echo $google_api_key ?>" type="text/javascript"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#address').watermark('Enter Address and Press Enter');
Expand All @@ -33,7 +31,6 @@
//map_initialize( pm );
zg = new zillgoog.map(pm);
zg.addComparables( comps );
zg.enableStreetView( 'dia', 'street_view' );

//Apply a row click effect
$('#comps table tbody tr').each(function(){
Expand All @@ -50,12 +47,7 @@
});
});

})

$(document).unload(function(){
GUnload();
});

</script>
</head>
<body>
Expand Down
Binary file removed css/custom-theme/images/ui-bg_flat_0_aaaaaa_40x100.png
Binary file not shown.
Binary file removed css/custom-theme/images/ui-bg_flat_55_0f1ed0_40x100.png
Binary file not shown.
Binary file removed css/custom-theme/images/ui-bg_flat_55_fbec88_40x100.png
Binary file not shown.
Binary file removed css/custom-theme/images/ui-bg_glass_75_d0e5f5_1x400.png
Binary file not shown.
Binary file removed css/custom-theme/images/ui-bg_glass_85_dfeffc_1x400.png
Binary file not shown.
Binary file removed css/custom-theme/images/ui-bg_glass_95_fef1ec_1x400.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed css/custom-theme/images/ui-icons_217bc0_256x240.png
Binary file not shown.
Binary file removed css/custom-theme/images/ui-icons_2e83ff_256x240.png
Binary file not shown.
Binary file removed css/custom-theme/images/ui-icons_469bdd_256x240.png
Binary file not shown.
Binary file removed css/custom-theme/images/ui-icons_6da8d5_256x240.png
Binary file not shown.
Binary file removed css/custom-theme/images/ui-icons_cd0a0a_256x240.png
Binary file not shown.
Binary file removed css/custom-theme/images/ui-icons_d8e7f3_256x240.png
Binary file not shown.
Binary file removed css/custom-theme/images/ui-icons_f9bd01_256x240.png
Binary file not shown.

0 comments on commit dc95f8d

Please sign in to comment.