2011-08-06 13 views
2

私は私のテストのWebページにGoogleマップへのリダイレクト方法

<html> 
    <head> 
     <title></title> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAvY_htg5RzYE1oj2BL4bFvxSRc9RmgUY0ng1PT46gfsZ_uuISzxROX5ZCo6sw1juxfGN03mgyAPAIoA" type="text/javascript"></script> 

    <script type="text/javascript"> 

    function initialize() { 
     if (GBrowserIsCompatible()) { 
     var map = new GMap2(document.getElementById("map_canvas")); 
     map.setCenter(new GLatLng(xxx,xxx), 13); 

     var marker = new GMarker(map.getCenter()); 
     GEvent.addListener(marker, "click", function() { 
      marker.openInfoWindowHtml("xxxxxxxxxxxx"); 
     }); 
     map.addOverlay(marker); 
     } 
    } 

    </script> 
    </head> 
    <body onLoad="initialize()"> 
     <div id="map_canvas" style="width: 300px; height: 250px; margin:auto;"></div> 
    </body> 
</html> 

をマップを表示するには、次のコードを持っている私は、私は地図上の位置をクリックした場合、私は地図で場所を表示するために使用される正確なアドレス位置をGoogleマップのサイトへリダイレクトしますあなたが私の要求を理解してくれることを願います。出来ますか?

答えて

3

あなたは

function returnMapUrl(GLatLngObj){ 
    var point= GLatLngObj || map.getCenter(); 
    return "http://maps.google.com/?ll="+point.lat+','+point.lng; 
} 

GEvent.addListener(map,"click", function(overlay, latlng) { 
    window.location = returnMapUrl(latlng); 
}); 
+0

ような何かを試みることができるおかげで、今、私のポストを更新...私は地図上の位置をクリックしたときに – mymotherland

+0

がclick.see更新にリダイレクトを追加リダイレクトする必要があります。 –

+0

"map is not defined" JSエラー – mymotherland

関連する問題