getElementsByTagName('configuration'); $params = $configuration->item(0)->getElementsByTagName('param'); for($i = 0; $i < $params->length; $i++) { $param = $params->item($i); if($param->getAttribute("name") == "max_extent") { $max_extent = $param->firstChild->nodeValue; } } // Take the max_extent and project it to lat/lon $extent = explode(",",$max_extent); $min_extent = ms_newPointObj(); $min_extent->setXY($extent[0],$extent[1]); $min_extent->project($map_proj, $latlon_proj); $max_extent = ms_newPointObj(); $max_extent->setXY($extent[2],$extent[3]); $max_extent->project($map_proj, $latlon_proj); // Create the Google geocode URL $url = "http://maps.google.com/maps/geo?output=xml&key=$googlekey"; $request_url = $url . "&q=" . urlencode($streetaddress); // Response from Google $xml = simplexml_load_file($request_url) or die('

Unable to resolve address.


New Search
'); $status = $xml->Response->Status->code; if (strcmp($status, "200") == 0) { // Successful geocode // Look at the candidate matches, keep those within max_extent $placemarks = $xml->Response->Placemark; foreach($placemarks as $placemark) { $coordinates = $placemark->Point->coordinates; $coordinatesSplit = split(",", $coordinates); // if($coordinatesSplit[0] >= $min_extent->x and $coordinatesSplit[0] <= $max_extent->x and $coordinatesSplit[1] >= $min_extent->y and $coordinatesSplit[1] <= $max_extent->y) { $address = split("!", $placemark->address); $match['address'] = $address[0]; $match['lng'] = $coordinatesSplit[0]; $match['lat'] = $coordinatesSplit[1]; array_push($matches, $match); // } } // Create output for each match if(count($matches) > 0) { $content .= "Possible Address Matche(s):
$resolvedaddress"; foreach($matches as $value) { $content .= "" . $value["address"] . "

"; } } else { $content .= "

Unable to resolve address.

"; } header('Content-type: application/xml'); print ""; print ""; print ""; print "
New Search
'; print "]]>"; print""; print "
"; } else{ header('Content-type: application/xml'); print ""; print ""; print ""; print "

Unable to resolve address.

"; print '
New Search
'; print "]]>"; print""; print "
"; } ?>