GeoExt是一款结合openlayers和Extjs的gis前端框架。目前支持openlayers2.10和Ext3.2.
下载地址:http://geoext.org/index.html
下面是用GeoExt改写的一个小的例子:
js代码:
/**
* Copyright (c) 2008-2010 The Open Source Geospatial Foundation
*
* Published under the BSD license.
* See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
* of the license.
*/
/** api: example[mappanel-div]
* Map Panel
* ---------
* Render a map panel in any block level page element.
*/
var mapPanel,map;
Ext.onReady(function() {
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
var bounds = new OpenLayers.Bounds(113.235,23.04,113.416,23.12);
map = new OpenLayers.Map();
var layer = new OpenLayers.Layer.WMS(
"Global Imagery",
"http://maps.opengeo.org/geowebcache/service/wms",
{layers: "bluemarble"}
);
map.addLayer(layer);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new OpenLayers.Control.MousePosition({
element : $('location')
}));
map.addControl(new OpenLayers.Control.OverviewMap());
map.addControl(new OpenLayers.Control.ScaleLine());
var simple = new Ext.FormPanel({
labelWidth: 60, // label settings here cascade unless overridden
url:'save-form.php',
frame:true,
title: '',
bodyStyle:'padding:5px 5px 0',
width: 350,
defaults: {width: 230},
defaultType: 'textfield',
items: [{
fieldLabel: '演示速度',
name: 'first',
width:50,
allowBlank:true
},{
fieldLabel: '轨迹速度',
width:50,
name: 'last'
}
],
buttons: [{
text: '确定',
handler:function(){win.hide();}
},{
text: '取消',
handler:function(){win.hide();}
}]
});
win = new Ext.Window({
layout:'fit',
width:200,
height:150,
title:'速度设置',
draggable:false,
resizable : false,
closeAction:'hide',
plain: true,
items: [simple]
});
mapPanel = new GeoExt.MapPanel({
title: "GeoExt MapPanel",
renderTo: "mappanel",
stateId: "mappanel",
height: 600,
width: 1000,
map: map,
center: new OpenLayers.LonLat(113.31898,23.08618),//two
zoom: 18,
//extent: bounds,//one
// getState and applyState are overloaded so panel size
// can be stored and restored
items:[{
xtype: 'button',
id: 'basic-button',
style :'position: absolute; z-index: 1000; right: 15px; top: 5px; left: auto;',
text: '设置',
handler:function (b){
win.x=b.el.dom.offsetParent.offsetWidth+b.el.dom.offsetParent.offsetLeft-230;
win.y=b.el.dom.offsetParent.offsetTop+30;
if(!win.isVisible()){
win.show();
}else{
win.hide();
}
}
}],
getState: function() {
var state = GeoExt.MapPanel.prototype.getState.apply(this);
state.width = this.getSize().width;
state.height = this.getSize().height;
return state;
},
applyState: function(state) {
GeoExt.MapPanel.prototype.applyState.apply(this, arguments);
this.width = state.width;
this.height = state.height;
}
});
});
// functions for resizing the map panel
function mapSizeUp() {
var size = mapPanel.getSize();
size.width += 40;
size.height += 40;
mapPanel.setSize(size);
map.setCenter(new OpenLayers.LonLat(113.31898,23.08618), 0);
}
function mapSizeDown() {
var size = mapPanel.getSize();
size.width -= 40;
size.height -= 40;
mapPanel.setSize(size);
}
var selectControl,vectors;
function mapAddLayer(){
var v_style = new OpenLayers.StyleMap({
"default": {
strokeOpacity: 1,
strokeWidth: 1,
pointRadius: 6,
fillOpacity:1
},
"select": {
cursor: "pointer",
strokeColor: "blue",
fillColor: "blue"
}
});
vectors = new OpenLayers.Layer.Vector(
"layer1",
{
visibility : true,
styleMap: v_style
}
);
map.addLayer(vectors);
selectControl= new OpenLayers.Control.SelectFeature(
vectors, {clickout: true, toggle: false,
multiple: false, hover: false});
map.addControl(selectControl);
selectControl.activate();
var pointFeature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(113.31898,23.0861));//
var pFeature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(113.32898,23.0861));//
vectors.addFeatures([pointFeature,pFeature]);
// create popup on "featureselected"
vectors.events.on({
featureselected: function(e) {
createPopup(e.feature);
},
featureunselected :function(e){
popup.destroy();
popup = null;
}
});
}
var bogusMarkup = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.";
function createPopup(feature) {
popup = new GeoExt.Popup({
title: 'My Popup',
location: feature,
width:200,
html: bogusMarkup,
maximizable: true,
unpinnable: false,
collapsible: true
});
// unselect feature when the popup
// is closed
popup.on({
close: function() {
selectControl.unselect(feature);
if(OpenLayers.Util.indexOf(vectors.selectedFeatures,
this.feature) > -1) {
popup = null;
}
}
});
popup.show();
}
html页面代码:
<html>
<head>
<title>GeoExt MapPanel Example</title>
<script type="text/javascript" src="http://extjs.cachefly.net/ext-3.2.1/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="http://extjs.cachefly.net/ext-3.2.1/ext-all.js"></script>
<link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-3.2.1/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-3.2.1/examples/shared/examples.css" />
<script src="http://www.openlayers.org/api/2.10/OpenLayers.js"></script>
<script type="text/javascript" src="../script/GeoExt.js"></script>
<script type="text/javascript" src="mappanel-div.js"></script>
</head>
<body>
<h1>GeoExt.MapPanel with an Existing OpenLayers.Map</h1>
<p>This example shows the how to create a MapPanel with a map that has
already been created. See <a href="mappanel-window.html">mappanel-window.html</a>
for an example that creates the MapPanel without creating the map first.<p>
<p>This example makes use of a <code>CookieProvider</code>. The <code>MapPanel</code>
being a stateful component, if you reload the page the map should be
at the same location as previously. Also the <code>getState</code> and
<code>applyState</code> methods are overloaded so the size of the map
panel is also restored when refreshing the page.</p>
<p>The js is not minified so it is readable. See <a href="mappanel-div.js">mappanel-div.js</a>.</p>
<div id="mappanel"></div>
<input type="button" onclick="mapSizeUp()" value="bigger"></input>
<input type="button" onclick="mapSizeDown()" value="smaller"></input>
<input type="button" onclick="mapAddLayer()" value="addlayer"></input>
</body>
</html>
效果图:
- 大小: 116.3 KB
分享到:
相关推荐
基于java的贝儿米幼儿教育管理系统答辩PPT.pptx
本压缩包资源说明,你现在往下拉可以看到压缩包内容目录 我是批量上传的基于SpringBoot+Vue的项目,所以描述都一样;有源码有数据库脚本,系统都是测试过可运行的,看文件名即可区分项目~ |Java|SpringBoot|Vue|前后端分离| 开发语言:Java 框架:SpringBoot,Vue JDK版本:JDK1.8 数据库:MySQL 5.7+(推荐5.7,8.0也可以) 数据库工具:Navicat 开发软件: idea/eclipse(推荐idea) Maven包:Maven3.3.9+ 系统环境:Windows/Mac
基于java的消防物资存储系统答辩PPT.pptx
项目经过测试均可完美运行! 环境说明: 开发语言:java jdk:jdk1.8 数据库:mysql 5.7+ 数据库工具:Navicat11+ 管理工具:maven 开发工具:idea/eclipse
项目经过测试均可完美运行! 环境说明: 开发语言:java jdk:jdk1.8 数据库:mysql 5.7+ 数据库工具:Navicat11+ 管理工具:maven 开发工具:idea/eclipse
TA_lib库(whl轮子),直接pip install安装即可,下载即用,非常方便,各个python版本对应的都有。 使用方法: 1、下载下来解压; 2、确保有python环境,命令行进入终端,cd到whl存放的目录,直接输入pip install TA_lib-xxxx.whl就可以安装,等待安装成功,即可使用! 优点:无需C++环境编译,下载即用,方便
使用软件自带的basic脚本编辑制作的脚本 低版本软件无法输出Excel报告,可以通过脚本方式实现这一功能
基于java的就业信息管理系统答辩PPT.pptx
25法理学背诵逻辑.apk.1g
基于java的大学生校园兼职系统答辩PPT.pptx
做到代码,和分析的源数据
本压缩包资源说明,你现在往下拉可以看到压缩包内容目录 我是批量上传的基于SpringBoot+Vue的项目,所以描述都一样;有源码有数据库脚本,系统都是测试过可运行的,看文件名即可区分项目~ |Java|SpringBoot|Vue|前后端分离| 开发语言:Java 框架:SpringBoot,Vue JDK版本:JDK1.8 数据库:MySQL 5.7+(推荐5.7,8.0也可以) 数据库工具:Navicat 开发软件: idea/eclipse(推荐idea) Maven包:Maven3.3.9+ 系统环境:Windows/Mac
项目经过测试均可完美运行! 环境说明: 开发语言:java jdk:jdk1.8 数据库:mysql 5.7+ 数据库工具:Navicat11+ 管理工具:maven 开发工具:idea/eclipse
适用于ensp已经入门人群的学习,有一定难度
基于java的数码论坛系统设计与实现答辩PPT.pptx
tornado-6.4.1-cp38-abi3-macosx_10_9_universal2.whl
基于java的医院信管系统答辩PPT.pptx
项目经过测试均可完美运行! 环境说明: 开发语言:java jdk:jdk1.8 数据库:mysql 5.7+ 数据库工具:Navicat11+ 管理工具:maven 开发工具:idea/eclipse
tornado-4.2.tar.gz
链表 合并两个链表,链表基础操作