Angular-google-Maps标记InfoWindow没有显示

时间:2015-04-18 00:24:22

标签: javascript angularjs google-maps-api-3 google-maps-markers angular-google-maps

有人可以帮助我并告诉我为什么showWindow布尔值没有改变onclick或mouseover?或者我没有正确设置infowindow?我正在使用http://angular-ui.github.io/angular-google-maps/。一切似乎都在工作,但是当我点击标记时,我希望信息窗口出现。

.controller('marker',['$scope', 'companies', function($scope, companies) {
$scope.map = {
        center: {
            latitude: 37,
            longitude: -122
        },
        zoom: 4,
        options: {
            streetViewControl: false,
            panControl: false,
            maxZoom: 20,
            minZoom: 3
        },
        dragging: false,
        bounds: {},

        randomMarkers: [],
        doClusterRandomMarkers: true,
        currentClusterType: 'standard',
        clusterOptions: {
            title: 'Hi I am a Cluster!', gridSize: 60, ignoreHidden: true, minimumClusterSize: 2
        }

    };

$scope.map.markersEvents = {
        mouseover: function (marker, eventName, model, args) {
          model.options.labelContent = model.title;
          newmarker.showWindow = true;
          $scope.$apply();
        },
        mouseout: function (marker, eventName, model, args) {
           model.options.labelContent = " ";
           newmarker.showWindow = false;
           $scope.$apply();
        },
        click: function (marker, eventName, model, args) {
            model.options.labelContent = model.title;
             model.showWindow = true;
            $scope.$apply();
        }
    };

companies.success(function(data) {
     var markers = [];

    data.forEach(function (item){
        var newMarker = {
            id: item.id,
            latitude: item.latitude,
            longitude: item.longitude,
            content: item.address,
            title: item.name,
            showWindow: false,
            options: {
                labelContent: ' ',
                labelAnchor: "22 0",
                labelClass: "marker-labels",
                draggable: false
            }
    };

        markers.push(newMarker);

    });

    $scope.markers = markers;
})
}]);

这是html:

<div ng-controller="marker">

<ui-gmap-google-map center="map.center" zoom="map.zoom"  dragging="map.dragging" bounds="map.bounds"
                events="map.events"  options="map.options" pan="true" control="map.control">


            <ui-gmap-markers models="markers" coords="'self'" icon="'icon'"
                doCluster="map.doClusterRandomMarkers" clusterOptions="map.clusterOptions" modelsbyref="true"
                events="map.markersEvents" options="'options'"
                >


                <ui-gmap-windows show="showWindow">
                <div>
                    <p>This is an info window</p>
                </div>
            </ui-gmap-windows>


            </ui-gmap-markers>

        </ui-gmap-google-map>
</div>

0 个答案:

没有答案