My google map code

1setGoogleMapCommunity('Country Hills, Calgary, alberta');
2setGoogleMapLocations('Country Hills, Calgary, alberta');
3setGoogleMapLocations('# 133 728 Country Hills RD NW');

above is data.html

<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">  
  
<head>    
  
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>    
  
<title>Google Maps JavaScript API Example</title>    
  
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA0fjp2tHrrQJwoaRp8r_sYxR9fR65Vek3QPwU0sVxyfrqv-3SrxSOi2QPW6Z4SZY2sm8l2ZDVezrplA" type="text/javascript"></script>   
  
<script type="text/javascript">    
   
var map;
   
var geocoder;
   
function initialize() 
   
{      
     
if (GBrowserIsCompatible()) 
     
{
          map 
= new GMap2(document.getElementById("map_canvas"));
          geocoder 
= new GClientGeocoder();
          map.addControl(
new GSmallMapControl());
          map.addControl(
new GMapTypeControl());
          map.setCenter(
new GLatLng('51.053726''-114.062477'), 10);
      }

   }

   
   
var request=false;
   
try
   
{
     request 
= new XMLHttpRequest();//Firefox
   }

   
catch(trymicrosoft)
   
{
     
try 
       
{
          request 
= new ActiveXObject("Msxml2.XMLHTTP.5.0");//New IE
       }
 
       
catch(othermicrosoft)
       
{
          
try 
        
{
              request 
= new ActiveXObject("Microsoft.XMLHTTP");//Old IE
        }
 
        
catch(failed)
        
{
              request 
= false;//Unknown browser
        }

      }

   }

   
function sendRequest()
   
{
       map.clearOverlays();
       url
=escape("data.html")+"?random=" + Math.random();//use a random number to avoid cache
       request.open("Get",url,true);//connection method
       request.onreadystatechange=showProcess;//show Process method
       request.setRequestHeader('Content-Type''application/x-www-form-urlencoded; charset=utf-8');
       
var queryString="";
       request.send(
"queryString="+escape(queryString));
   }

   
function showProcess() 
   
{
       
if(request.readyState == 4)//finished
       {
          
if(request.status == 200)//normal
          {
             eval(request.responseText);
//insert script to add locations to google map
          }

       }

   }

   
function setGoogleMapCommunity(address)
   
{
       
if(geocoder)
       
{
          geocoder.getLatLng
          (
            address,
            
function(point)
            
{
              
var marker;
              
if(point)
              
{
                map.setCenter(point, 
10);
              }

            }

          );
       }

   }

   
function setGoogleMapLocations(address)
   
{
       
if(geocoder)
       
{
          geocoder.getLatLng
          (
            address,
            
function(point)
            
{
              
var marker;
              
if(point)
              
{
                marker 
= new GMarker(point);
                map.addOverlay(marker);
                GEvent.addListener
                (
                  marker, 
                  
"click"
                  
function() 
                  
{
                    marker.openInfoWindowHtml
                    (
                      
'<img src="http://www2.creb.com/28/C3293828_1.jpg" style="margin-right: 5px;" align="left" width="90" height="65" /><b><a href="http://www.jimsparrow.com/calgary-mls/details/1/C3293828" target="_blank">MLS # C3293828</a></b><br /><b>Listing Price:</b> $379,900<br /><b>Bedrooms:</b> 5<br /><b>Bathrooms:</b> 4<br />'
                    );
                  }

                );
              }

            }

          );
       }

   }

  
</script>  
  
</head>  
  
<body onload="initialize()" onunload="GUnload()">    
  
<div id="map_canvas" style="width: 500px; height: 300px"></div>  
  
<div id="button">
   
<href="javascript:void(0);" onclick="sendRequest();">
   
<img id="buttonImage" src="http://cafe24-board.cafe24.com/board/img/search-button.gif" style="border: none;" />
   
</a>
  
</div>
  
</body>
</html>

above is final.html
posted @ 2008-01-16 04:23  N/A2011  阅读(601)  评论(0编辑  收藏  举报