javascript
  • angularjs
  • google-maps
  • ng-map
  • 2017-08-16 136 views 0 likes 
    0

    谷歌地圖灰色不工作,只工作,如果我調整瀏覽器,我使用AngularJS 1.6.4谷歌地圖灰色的顏色不工作

    enter image description here

    HTML

    <ng-map zoom="8" center="{{h.latitude}},{{h.longitude}}" class="col s12 m12" scale-control="true" map-type-control="true" map-type-control-options='{position:"top_right", style:"dropdown_menu", mapTypeIds:["HYBRID","ROADMAP","SATELLITE","TERRAIN"]}' id="map" 
        style="height:auto;"> 
        <marker position="{{h.latitude}},{{h.longitude}}" icon="https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png"> 
        </marker> 
    </ng-map> 
    

    INI .js

    //home feed 
    var app = angular.module('homephotos', ['ngMap']); 
    app.controller('home', function($scope, $http, $timeout, NgMap) { 
        $http.get("http://xxx") 
        .then(function(response) { 
         $scope.home_feed = response.data.results; 
        }); 
    
        //Init maps 
        $scope.iniMap = function() { 
        NgMap.getMap().then(function(map) { 
         var center = map.getCenter(); 
         google.maps.event.trigger(map, 'resize'); 
         map.setCenter(center); 
         console.log(map); 
        }); 
        } 
    }); 
    
    +0

    您的意思是說,只有在調整瀏覽器大小時,纔會看到灰色區域而不是地圖? –

    +0

    @Mosh Feu是的先生這是我的問題 –

    +0

    看看[這](https://stackoverflow.com/q/19003291/863110)答案可以幫助你.. –

    回答

    0

    只需要在clik上逐一調用,例如在每個off off後whe n點擊查看更多選項inigeocode

     $scope.init_geocode = function() { 
    
         console.log('init_geocode'); 
    
         geocoder = new google.maps.Geocoder(); 
         latlng = new google.maps.LatLng(attrs.lat, attrs.lng); 
    
          geocoder.geocode({ 'latLng': latlng }, function (results, status) { 
    
          if (status == google.maps.GeocoderStatus.OK) { 
           if (results[1]) { 
            var city = results[1].formatted_address; 
            element.text(city); 
           } 
           else { 
            element.text('Location not found'); 
           } 
          } 
           else if (status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT) { 
           setTimeout(function() { 
            $scope.init_geocode(); 
            element.text('Geocoder failed due to: ' + status); 
           }, 1000); 
    
          } 
           else { 
            element.text('Geocoder failed due to: ' + status); 
           } 
    
          }); 
         } 
    
    相關問題