2017-04-07 39 views
-2

我使用angular-openlayers-directive創建自定義地圖。試圖修改this example,使用靜態圖像而不是自定義圖層中的地圖。錯誤發生錯誤。靜態圖像旋轉OpenLayers3和AngularJS

我正在尋找作爲地圖的自定義圖像旋轉的解決方案。你能幫忙嗎?

+2

什麼錯誤?你試圖做出什麼改變?即使有獎金,你也不可能得到迄今爲止提供的信息。 – Claies

+0

你對靜態圖像使用什麼投影?地圖加載了嗎? –

回答

2

沒有看到您的代碼或明知錯誤信息是很難說具體是什麼問題,但這裏的修改,以旋轉靜態圖像的例子:

<!DOCTYPE html> 
 
<html ng-app="demoapp"> 
 

 
<head> 
 
    <script src="https://tombatossals.github.io/angular-openlayers-directive/bower_components/openlayers3/build/ol.js"></script> 
 
    <script src="https://tombatossals.github.io/angular-openlayers-directive/bower_components/angular/angular.js"></script> 
 
    <script src="https://tombatossals.github.io/angular-openlayers-directive/bower_components/angular-sanitize/angular-sanitize.js"></script> 
 
    <script src="https://tombatossals.github.io/angular-openlayers-directive/dist/angular-openlayers-directive.js"></script> 
 
    <link rel="stylesheet" href="https://tombatossals.github.io/angular-openlayers-directive/bower_components/openlayers3/build/ol.css" /> 
 
    <script> 
 
    var app = angular.module('demoapp', ['openlayers-directive']); 
 
    app.controller('DemoController', ['$scope', '$http', 'olData', function($scope, $http, olData) { 
 

 
     angular.extend($scope, { 
 
     degrees: 0, 
 
     center: { 
 
      coord: [900, 600], 
 
      zoom: 3 
 
     }, 
 
     defaults: { 
 
      view: { 
 
      projection: 'pixel', 
 
      extent: [0, 0, 1800, 1200], 
 
      rotation: 0 
 
      } 
 
     }, 
 
     static: { 
 
      source: { 
 
      type: "ImageStatic", 
 
      url: "http://blog.wallpops.com/wp-content/upLoads/2013/05/WPE0624.jpg", 
 
      imageSize: [1800, 1200] 
 
      } 
 
     }, 
 
     view: { 
 
      extent: [0, 0, 1800, 1200], 
 
      rotation: 0 
 
     } 
 

 
     }); 
 

 
     $scope.degreesToRadians = function() { 
 
     $scope.view.rotation = parseFloat($scope.degrees, 10).toFixed(2) * (Math.PI/180); 
 
     }; 
 

 
     $scope.$watch('view.rotation', function(value) { 
 
     $scope.degrees = ($scope.view.rotation * 180/Math.PI).toFixed(2); 
 
     }); 
 
    }]); 
 
    </script> 
 
</head> 
 

 
<body ng-controller="DemoController"> 
 
    <openlayers ol-center="center" ol-defaults="defaults" ol-view="view" custom-layers="true" height="400px"> 
 
    <ol-layer ol-layer-properties="static"></ol-layer> 
 
    </openlayers> 
 
    <h1>View rotation example</h1> 
 
    <p>You can interact with the view rotation of your map.</p> 
 

 
    <p> 
 
    <input type="range" min="-180" max="180" ng-change="degreesToRadians()" ng-model="degrees" /> Degrees: {{ degrees }}</p> 
 
    <pre ng-bind="view | json"></pre> 
 
</body> 
 

 
</html>

而且Plunker中的示例:http://plnkr.co/edit/zw7QUyFfWXqnNE9rkdjZ?p=preview