用于在Google地图中显示地图标记内容的活动

时间:2016-03-24 13:24:32

标签: javascript google-maps ionic-framework

我的离子应用程序中有一个谷歌地图集成。我想在地图出现时显示地图上的标记,但这取决于“点击”事件。我已经变成'闲置',但它甚至没有显示标记的内容。

问题:我应该更改“点击”?

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

1 个答案:

答案 0 :(得分:0)

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