OpenLayers 3 ol.View范围未设置

时间:2016-04-05 01:30:55

标签: openlayers-3

我正在尝试设置地图视图的范围。这是我的代码:

var viewOpts = {
    extent: [-2750000, -900000, 3600000, 4630000]
}

myMap.setView( new ol.View( viewOpts ) );

视图范围以未定义的形式返回。关于如何让这个工作的任何想法。使用v3.15.0。

1 个答案:

答案 0 :(得分:0)

如果您extent ol.View extent center属性,var extent = [-2750000, -900000, 3600000, 4630000]; var center = ol.extent.getCenter(extent); map.setView(new ol.View({ extent: extent, center: center })); 约束long millis = 0; Date eventOneBegin = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2016-4-06 06:00:00"); Date eventOneEnd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2016-4-06 09:00:00"); Date eventTwoBegin = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2016-4-06 08:00:00"); Date eventTwoEnd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2016-4-06 11:00:00"); if (eventOneEnd.getTime()>eventTwoBegin.getTime()) { System.out.println("there is a overlap time"); millis = eventOneEnd.getTime()-eventTwoBegin.getTime(); }else{ System.out.println("there is NO overlap time...."); } String lapse=String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(millis), TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)), // The change is in this line TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis))); System.out.println("Time overlap is: "+lapse); ,则中心不能超出范围。所以只需添加一个位于范围内的中心属性。 OL3为处理扩展区提供了一些read about

lst = [['A','B'],['C','D']]