【问题标题】:Grey Tile after Map Marker applied in Google map in Angularjs在 Angularjs 的 Google 地图中应用地图标记后的灰色瓷砖
【发布时间】:2014-11-15 14:35:24
【问题描述】:

使用 angular-google-maps 1.0.18 地图加载得很好,问题上升了一个标记。包含标记的正方形在地图中变为灰色。我也尝试过使用其他问题中建议的解决方案。但它没有任何区别。有关如何解决此问题的任何线索。

Grey boxes appear in parts of embedded Google Map in modal box

参考代码:

var cities = [
        {
            city : 'Toronto',
            desc : 'This is the best city in the world!',
            lat : 43.7000,
            long : -79.4000
        },
        {
            city : 'New York',
            desc : 'This city is aiiiiite!',
            lat : 40.6700,
            long : -73.9400
        },
        {
            city : 'Chicago',
            desc : 'This is the second best city in the world!',
            lat : 41.8819,
            long : -87.6278
        },
        {
            city : 'Los Angeles',
            desc : 'This city is live!',
            lat : 34.0500,
            long : -118.2500
        },
        {
            city : 'Las Vegas',
            desc : 'Sin City...\'nuff said!',
            lat : 28.65596033103927,
            long : 77.2226215342037
        }
    ];

    var mapOptions = {
        zoom: 4,
        center: new google.maps.LatLng(40.0000, -98.0000),
        mapTypeId: google.maps.MapTypeId.TERRAIN
    }

    $scope.map = new google.maps.Map(document.getElementById('map'), mapOptions);
    console.log($scope.map);

    $scope.markers = [];

    var infoWindow = new google.maps.InfoWindow();

    var createMarker = function (info){

        var marker = new google.maps.Marker({
            map: $scope.map,
            position: new google.maps.LatLng(info.lat, info.long),
            title: info.city
        });
        marker.content = '<div class="infoWindowContent">' + info.desc + '</div>';

        google.maps.event.addListener(marker, 'click', function(){
            infoWindow.setContent('<h2>' + marker.title + '</h2>' + marker.content);
            infoWindow.open($scope.map, marker);
        });

        google.maps.event.trigger($scope.map, 'resize');
        //$scope.map.setCenter(new google.maps.LatLng(22.3605336, -72.6362989));

        $scope.markers.push(marker);

        //google.maps.event.trigger($scope.map, 'resize');

    }  

    for (i = 0; i < cities.length; i++){
        createMarker(cities[i]);
    }

    $scope.openInfoWindow = function(e, selectedMarker){
        e.preventDefault();
        google.maps.event.trigger(selectedMarker, 'click');
    }

HTML:

<div>
    <div id="map"></div>
    <div id="class" ng-repeat="marker in markers | orderBy : 'title'">
         <a href="#" ng-click="openInfoWindow($event, marker)">{{marker.title}}</a>
    </div>
</div>

【问题讨论】:

  • 我遇到了同样的问题。你找到解决办法了吗?
  • 我的回答在你的场景中有效吗?

标签: angularjs google-maps


【解决方案1】:

我们遇到了这个问题,看起来与 OP 的屏幕截图一模一样。

问题在于我们使用了一个名为 dropzone 的 javascript 库,它要求我们将 CSS 样式应用于“画布”,如下所示:

 canvas {
    -moz-box-shadow: 3px 3px 3px 0 #e3e3e3;
    -webkit-box-shadow: 3px 3px 3px 0 #e3e3e3;
    background-color: #f3f3f3;
    border: 1px solid #c3c3c3;
    box-shadow: 3px 3px 3px 0 #e3e3e3;
    height: 100px;
    margin: 6px 0 0 6px;
}

此样式无意中被应用到 Google 地图画布上,导致添加标记时地图上出现“灰色框”。

删除任何适用于所有“画布”元素的样式,并酌情使用类/id 选择器,以免您无意中将样式应用于 Google 地图画布。

【讨论】:

  • 我将页面中的所有 html 元素删除到准系统地图,然后出现灰色方块。这解决了我的问题。
猜你喜欢
  • 1970-01-01
  • 2014-05-22
  • 2013-02-11
  • 2011-02-08
  • 2013-08-01
  • 1970-01-01
  • 2014-06-27
  • 1970-01-01
  • 2013-06-02
相关资源
最近更新 更多