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

I have the following piece of code to display map in my test web page<html><head><title&

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);
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745512388a4630828.html

相关推荐

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

    I have the following piece of code to display map in my test web page<html><head><title&

    21小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信