簡體   English   中英

將Google地圖標記超鏈接到坐標

[英]Hyperlink Google Maps Marker to Coordinates

有沒有一種方法可以將Google Maps標記上的自定義標記超鏈接到其在Google Maps自身上的坐標? 在這種情況下,請鏈接到LatLng。 另外,有沒有辦法使用target =“ _ blank”或javascript在新標簽頁中打開它,效果相同?

      function initialize() {
            var mapOptions = {
                zoom: 14,
                center: new google.maps.LatLng(-29.528000, 31.194881)
            }
            var map = new google.maps.Map(document.getElementById('ContactMap'),
                                          mapOptions);

            var image = '/Assets/Images/Pages/Marker.png';
            var myLatLng = new google.maps.LatLng(-29.528000, 31.194881);
            var beachMarker = new google.maps.Marker({
                position: myLatLng,
                map: map,
                icon: image
            });
        }

        google.maps.event.addDomListener(window, 'load', initialize);

真正的超鏈接是不可能的,但是您當然可以設置單擊偵聽器以實現類似的行為:

        google.maps.event.addListener(beachMarker,'click',function(){
          window.open('https://maps.google.com/maps?q=' +
                       this.getPosition().toUrlValue() +
                       '&z='+this.getMap().getZoom(),'google');
        });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM