最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to redirect to Google Map? - Stack Overflow

programmeradmin1浏览0评论

I have the following piece of code to display map in my test web page

<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript" src=".4.2/jquery.min.js"></script>
     <script src=";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>

I want to redirect to GOOGLE MAP site with exact address location which i used to display Location in Map IF I CLICK ON MAP LOCATION.Hope you understand my requirement. Is it possible?

I have the following piece of code to display map in my test web page

<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript" src="http://ajax.googleapis./ajax/libs/jquery/1.4.2/jquery.min.js"></script>
     <script src="http://maps.google./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>

I want to redirect to GOOGLE MAP site with exact address location which i used to display Location in Map IF I CLICK ON MAP LOCATION.Hope you understand my requirement. Is it possible?

Share Improve this question edited Aug 6, 2011 at 15:13 mymotherland asked Aug 6, 2011 at 15:02 mymotherlandmymotherland 8,24814 gold badges68 silver badges124 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

you could try something like

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

GEvent.addListener(map,"click", function(overlay, latlng) {
    window.location = returnMapUrl(latlng);
});
发布评论

评论列表(0)

  1. 暂无评论