Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2011
    WInchester, Hampshire. UK
    Thanked 0 Times in 0 Posts

    Smile Dynamic Google Map now disappears!

    An old website of mine for an estate agent extracted the postcode for a property and then showed the location for property using Google Maps.

    This still, briefly, shows the location and then the map disappears.

    The site is: http://www.southampton-property.com/

    Select a property type on the left and the click on a property image to get property details (propertydetails.php)

    I used the following code to create the listing and Google Map

    //$searchUrl = "http://web.aspasia.net/pls/marques/aspasia_search.xml?be=1&upw=1467581F8E6F42D1BF0207B0A16964DE";
    $searchUrl = $_SESSION['url'];
    $handle = curl_init();
    curl_setopt($handle, CURLOPT_URL, $searchUrl);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($handle);
    $doc = new DOMDocument();
    $doc->loadXML( $response);
    $searchNode = $doc->getElementsByTagName( "property" );
    echo '<script src="http://maps.google.com/maps?file=api&v=2&key=AIzaSyAXg9xwiHfBXzIylS2ZOEExGyEtmWrkcLY"    type="text/javascript"></script>';
    echo '<script src="http://www.google.com/uds/api?file=uds.js&v=1.0" type="text/javascript"></script>';
    foreach($searchNode as $searchNode)
        $valueID = $searchNode->getAttribute('id');
    	if($imgId == $valueID)
    		$branch = $searchNode->getElementsByTagName("branch");
    		$valueBranch = $branch->item(0)->nodeValue;
    		$postcode = $searchNode->getElementsByTagName("postcode");
    		$valuePostcode = $postcode->item(0)->nodeValue;				
    		$display_address = $searchNode->getElementsByTagName("display_address");
    		$valueDispAddr = $display_address->item(0)->nodeValue;
    		$price_text = $searchNode->getElementsByTagName("price_text");
    		$valuePrice_text = $price_text->item(0)->nodeValue;
    		$beds = $searchNode->getElementsByTagName("beds");
    		$valueBeds = $beds->item(0)->nodeValue;
    		$baths = $searchNode->getElementsByTagName("baths");
    		$valueBaths = $baths->item(0)->nodeValue;
    		$receptions = $searchNode->getElementsByTagName("receptions");
    		$valueReceptions = $receptions->item(0)->nodeValue;
    		$long_description = $searchNode->getElementsByTagName("long_description");
    		$valueLongDesc = $long_description->item(0)->nodeValue;
    		$short_description = $searchNode->getElementsByTagName("short_description");
    		$valueShortDesc = $short_description->item(0)->nodeValue;
    		$prst_code = $searchNode->getElementsByTagName("prst_code");
    		$valuePrst_code = $prst_code->item(0)->nodeValue;
    		$slide_show = $searchNode->getElementsByTagName("slide_show");
    		$valueSlideShow = $slide_show->item(0)->nodeValue;
    		$data = array();
    		foreach($results as $node)
    				foreach($node->childNodes as $child)
    					$data[] = $child->nodeName;					
    		$longitude = $searchNode->getElementsByTagName("longitude");
    		$valueLongitude = $longitude->item(0)->nodeValue;
    		$latitude = $searchNode->getElementsByTagName("latitude");
    		$valueLatitude = $latitude->item(0)->nodeValue;
    		$title = $searchNode->getElementsByTagName("title");
    		$valueTitle = $title->item(0)->nodeValue;
    		$description = $searchNode->getElementsByTagName("description");
    		$valueDescription = $description->item(0)->nodeValue;
    		$image = $searchNode->getElementsByTagName("image");
    		$valueImage = $image->item(0)->nodeValue;
    		echo '<div style="width:1000px;float:left;padding:5px;">';
    			echo '<div style="width:560px;float:left; margin-left:-5px;">';
    				echo '<Iframe src="'.$valueSlideShow.'" width="550" height="650" frameborder="0"></Iframe>';
    			echo '</div>';
    			echo '<div style="float:right;width:395px;margin-bottom:50px;margin-left:-10px;">';
    				echo '<h4>Sale or Let: '.$valueBranch.'</h4>';
                    echo '<h4>Property Type: '.$valuePrst_code.'</h4>';
    				echo '<h4>Price: '.$valuePrice_text.'</h4>';
    				echo '<h4>Beds: '.$valueBeds.'</h4>';
    				echo '<h4>Baths: '.$valueBaths.'</h4>';
    				echo '<h4>Receptions: '.$valueReceptions.'</h4>';
    				echo '<h4>Location: '.$valueDispAddr.'</h4>';
    				echo '<h4>Description:</h4><p>'.$valueLongDesc.'</p>';
    			echo '</div>';
    			echo '<div>';
    			$postcode = $valuePostcode;
    			<script type="text/javascript">
    				var map;
    				var localSearch = new GlocalSearch();
    				var icon = new GIcon();
    				icon.image = "http://www.google.com/mapfiles/marker.png";
    				icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
    				icon.iconSize = new GSize(20, 34);
    				icon.shadowSize = new GSize(37, 34);
    				icon.iconAnchor = new GPoint(10, 34);
    				function usePointFromPostcode(postcode, callbackFunction) {
    						function() {
    							if (localSearch.results[0])
    								var resultLat = localSearch.results[0].lat;
    								var resultLng = localSearch.results[0].lng;
    								var point = new GLatLng(resultLat,resultLng);
    								alert("Postcode not found!");
    					localSearch.execute(postcode + ", UK");
    				function setCenterToPoint(point)
    					map.setCenter(point, 17);
    					var marker = new GMarker(point,icon);
    				function mapLoad() {
    					if (GBrowserIsCompatible()) {
    						map = new GMap2(document.getElementById("map"));
    						map.addControl(new GLargeMapControl());
    						map.addControl(new GMapTypeControl());
    						map.setCenter(new GLatLng(54.622978,-2.592773), 5, G_NORMAL_MAP);
    <!-- This function may not be needed, I haven't tried removing it  -->
    				function addUnLoadEvent(func) {
    					var oldonunload = window.onunload;
    					if (typeof window.onunload != 'function') {
    					  window.onunload = func;
    					} else {
    					  window.onunload = function() {
    <!-- This call may not be necessary, I haven't tried removing it -->
    				 window.onload = function() {
    				 usePointFromPostcode("<?php echo $postcode; ?>", setCenterToPoint);
    			<div id="map" style="width: 400px; height: 400px;float:right; "></div>
    			echo '</div>';
    		echo '</div>';		
    This connects to the following google maps scripts:




    Is this a Google API version problem?

    I am not a coder but managed to cobble the code together from various sites.

    Can anyone help with a simple solution to get the maps appearing again.

  2. #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Thanked 634 Times in 629 Posts
    Is this a Google API version problem?
    Very much so. From the error console on your map page:
    Control is no longer supported in the Google Maps Javascript API v2. Please visit https://developers.google.com/maps/d...ript/v2/v2tov3 to migrate your application to v3. %7Bmain,adsense,geometry,zombie%7D.js:66
    Map.addControl is no longer supported in the Google Maps Javascript API v2. Please visit https://developers.google.com/maps/d...ript/v2/v2tov3 to migrate your application to v3.
    v2 has been deprecated for years now, and google just switched it off (or whatever the proper term is for the final death blow that happens after deprecation).

    You could possibly work around it keep it working on v2, but really the situation is only going to get worse over time as google removes more and more support for the old API.

    So like the message says, time to migrate! If it's any consolation, I had a much more complicated map that I had to change from v2 to 3. It was a moderately harrying couple of hours, but not too complicated if you keep an eye on the error console, refer to the documentation and google anything that you get really stuck on.

    Oh - and keep a backup copy of the original, of course

  3. Users who have thanked xelawho for this post:

    sblatch (01-16-2014)


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts