Stuck with a problem.

Overview:

Producing a real estate website using IDX Broker. After a visitor performs a query, they are presented with property results. They click a result, and are taken to a detail page with the property’s specific info.

IDX Broker, only allows me to have one Google map on the page. I wish to add the following data as well: Yelp (local businesses); Streetview; Walkscore.

To do this, I need to first establish the longitude and latitude of the property address. PROBLEM: IDX Broker will not allow me to pass any variables from the source, therefore, I’ve come up with a new way.

I have configured the source output so the Meta Title tag is the Property Address formatted as such: STREET ADDRESS, CITY, STATE, ZIP.

Using PHP, I hope to lookup the current page’s title, and echo this into a script (SoapClient) that geocodes the address. Once I have the Longitude & Latitude, I should be able to to add my scripts to the footer and produce the output I need.

However, I can’t get this to work. I’m using the following code, which I’m sure is not very good, as it doesn’t produce anything. Also important to note, I have the Google API Key javascript in my element, not in the code below.

////////////////////////////////////////////////

<?php $title = ""; if ($fp = @fopen( $_POST['url'], 'r' )) { $cont = ""; // read the contents while( !feof( $fp ) ) { $buf = trim(fgets( $fp, 4096 )) ; $cont .= $buf; } // get tag contents @preg_match( "/([a-z 0-9]*)<\/title>/si", $cont, $match ); // tag contents $title = strip_tags(@$match[ 1 ]); } $client = new SoapClient("http://therentalqueen.com/geocoder.wsdl"); $result = $client->geocode("<?php echo $title;?>");

$latitude = $result[0]->lat;
$longitude = $result[0]->long;
?>

<div id="map" style="width: 400px; height: 300px"></div>
<script type="text/javascript">
//<![CDATA[
var map = new GMap(document.getElementById("map"));
map.centerAndZoom(
new GPoint(<?php echo $longitude;?>, <?php echo $latitude;?>), 3);
var point = 
new GPoint(<?php echo $longitude;?>, <?php echo $latitude;?>);
var marker = new GMarker(point);
map.addOverlay(marker);
//]]>

/////////////////////////////////////////////////////

Any assistance is greatly appreciated. Thanks in advance.

Sponsor our Newsletter | Privacy Policy | Terms of Service