繁体   English   中英

在Google Map中显示地图标记内容的事件

[英]Event for showing map marker content in google map

我在离子应用程序中集成了Google地图。 我希望我的地图上的标记会在地图出现时显示,但是这取决于“点击”事件。 我已更改为“ idle”,但是它甚至没有显示标记的内容。

问题:将“点击”更改为什么?

function getMap(lat, lon, content) {
        var latLng = new google.maps.LatLng(lat, lon);
        var mapOptions = {
          center: latLng,
          zoom: 15,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        $scope.map = new google.maps.Map(document.getElementById("map"), mapOptions);

        //Wait until the map is loaded
        google.maps.event.addListenerOnce($scope.map, 'idle', function () {

          var marker = new google.maps.Marker({
            map: $scope.map,
            animation: google.maps.Animation.DROP,
            position: latLng
          });

          var infoWindow = new google.maps.InfoWindow({
            content: content
          });

          google.maps.event.addListener(marker, 'click', function () {
            infoWindow.open($scope.map, marker);
          });
        });
      }

只需删除google.maps.event.addListener(marker, 'click', function () {})并留下infoWindow.open($scope.map, marker); 单独

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM