angularjs - 如何禁用谷歌地图中的卫星和街景选项

标签 angularjs cordova ionic-framework

我正在开发一个 ionic 应用程序,我需要在其中显示谷歌地图以显示位置。我需要禁用 map 中的卫星和街景选项,但没有得到任何合适的方法。
map 也产生了问题,有时它会显示在屏幕上,有时却没有。

这是我在 Controller 中尝试的代码

  $scope.addLoc = function(){ 
   $cordovaGeolocation.getCurrentPosition(options).then(function(position){
       $scope.lat  = position.coords.latitude;
       $scope.long = position.coords.longitude;
       var url = "http://maps.googleapis.com/maps/api/geocode/json?latlng="+$scope.lat+","+$scope.long+"&sensor=true";
       $http.get(url)
         .then(function(res) {

           $rootScope.address = res.data.results[0].formatted_address; 
           console.log($rootScope.address);
          }, function(error) {
             console.log( error);
         });
     console.log(position);
     var latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);

     var mapOptions = {
       center: latLng,
       zoom: 4,
       mapTypeId: google.maps.MapTypeId.ROADMAP
     };

     $scope.map = new google.maps.Map(document.getElementById("map"), mapOptions);
     $scope.marker = new google.maps.Marker({
       position: new google.maps.LatLng($scope.lat, $scope.long),
       map: $scope.map,
       title: 'Drag me!'
   }, function(err) {
       console.err(err);
   });
   }, function(error){
     console.log("Could not get location");
   });


 }

最佳答案

你可以试试这个

var mapOptions = {
    center: latLng,
    zoom: 4,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    streetViewControl: false,
    disableDefaultUI: true
};
Doc: https://developers.google.com/maps/documentation/javascript/controls#DefaultUI

关于angularjs - 如何禁用谷歌地图中的卫星和街景选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41374432/

相关文章:

javascript - 在移动键盘(iOS)上点击返回时如何取消选择输入字段

angularjs - 如何使用不污染全局范围的 TypeScript 类定义 AngularJS 服务?

javascript - 为什么 AngularJS 建议将服务、指令和过滤器放在单独的模块中?

javascript - 如何继续实现混合移动应用理念?

cordova - Azure 通知中心向 APNS 推送通知有一半时间失败

javascript - 用于尝试返回 json 数据的 ionic Angular 闭合

javascript - 在 ng-repeat 中将项目添加到数组后保持滚动位置

Angularjs 简单的日期选择器使用 Controller 而不是 $scope

ios - 将 Phonegap 插件添加到 Xcode - 错误 : Plugin 'PayPalPlugin' not found, 或不是 CDVPlugin

html - ion-navbar 背景图像未出现 - 仅显示白色 - Ionic 3