您的位置:首页 > 运维架构

OpenLayers设置地图缩放最小范围和最大范围

2016-07-29 15:47 435 查看

OpenLayers设置地图缩放最小范围和最大范围

function init()
{
var options=
{
projection: "EPSG:4326",
eventListeners:
{
"moveend": mapEvent,
"zoomend": mapEvent
},
controls:
[
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
//new OpenLayers.Control.LayerSwitcher(),
new OpenLayers.Control.ScaleLine(),
//new OpenLayers.Control.Scale(),
new OpenLayers.Control.MousePosition(),
new OpenLayers.Control.KeyboardDefaults()
],
//numZoomLevels:20
minResolution:"auto",
minExtent:new OpenLayers.Bounds(119.66509,32.23268,121.37895,32.77925),
maxResolution:"auto",
maxExtent:new OpenLayers.Bounds(118.84386,31.93193,122.27159,33.02782)
};
map=new OpenLayers.Map("map_element",options);
var wms=new OpenLayers.Layer.WMS("OpenLayers WMS",
"http://127.0.0.1:8989/geoserver/map/wms",
{
layers:"map:china"
});
//添加wms图层
//map.addLayer(wms);
map.addLayers([wms,test,train]);
selectControl=new OpenLayers.Control.SelectFeature([train,test],
{
onSelect:onFeatureSelect,
onUnselect:onFeatureUnselect
});
map.addControl(selectControl);
selectControl.activate();
map.setCenter(new OpenLayers.LonLat(lon,lat),zoom);
$(".close_btn").hover(function()
{
$(this).css({color:'black'});
},function()
{
$(this).css({color:"#999"});
}).on('click',function()
{
$("#LoginBox").fadeOut("fast");
$("#mask").css({display:'none'});
});
$("#closehostidBtn").hover(function()
{
$(this).css({color:'black'});
},function()
{
$(this).css({color:"#999"});
}).on('click',function()
{
$("#hostidBox").fadeOut("fast");
});
$("#zyxxCloseBtn").hover(function()
{
$(this).css({color:"black"});
},function()
{
$(this).css({color:"#999"});
}).on("click",function()
{
$("#zyxxDiv").fadeOut("fast");
});
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  OpenLayers