2014-01-21 1 views
3

회전 할 수있는 open layers 3 개의지도를 만들었습니다.자바 스크립트로 OpenLayers3지도 회전 - onload 및 via 함수

로드시 또는 자바 스크립트를 사용하여지도의 각도를 변경하려면 어떻게해야하나요? 어떤 경우에는지도를 남쪽에서로드 (180)하거나 자바 스크립트 함수를 통해지도의 각도를 변경하고 싶습니다. 지도를 초기화

현재 작업 this fiddle

var map = new ol.Map({ 
interactions: ol.interaction.defaults().extend([ 
new ol.interaction.DragRotateAndZoom()]), 
layers: [ 
new ol.layer.Tile({ 
    source: new ol.source.TileJSON({ 
     url: 'http://api.tiles.mapbox.com/v3/mapbox.blue-marble-topo-jul.jsonp', 
     crossOrigin: 'anonymous' 
    }) 
})], 
renderers: ol.RendererHints.createFromQueryData(), 
target: 'map', 
view: new ol.View2D({ 
    center: ol.proj.transform([-120.0469, 45.6782], 'EPSG:4326', 'EPSG:3857'), 
    zoom: 4 
}) 

})에서 아래 또는이다;

답변

2

난 당신이

var view2D = map.getView().getView2D(); 
//get the current radians of the map's angle 
var currentRadians=map.getView().getView2D().getRotation();  
//add .5 radians to the map's current getRotation() value 
view2D.setRotation(currentRad.+1.5); 
와지도의 회전을 업데이트 할 수있는 부하에 setRotation()

를 사용하여 알아 냈