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
分享到:
相关推荐
前端项目-geoext,geoext将openlayers的地理空间知识与精通ext-js的用户界面结合在一起,帮助您使用javascript在Web上构建强大的桌面风格的GIS应用程序。
GeoExt 3 用于Rich Web Mapping应用程序JavaScript工具包。 GeoExt是开放源代码,可通过Web构建类似于桌面的GIS应用程序。 它是一个JavaScript框架,结合了OpenLayers的GIS功能和Sencha提供的ExtJS库的用户界面。 ...
GeoExt-release-0.6.zip地理信息地图处理客户端开发工具包,纯JAVAScipt。
OpenLayers ext前台框架,支持WMS服务发布,非常实用的工具栏等
基于GeoExt的应用程序的高级组件。_JavaScript_HTML_下载.zip
为了显示基于GeoExt 3的面板,在添加了一个新条目: { text: 'GeoExt 3', view: 'geo.MapPanel', leaf: true, iconCls: 'x-fa fa-globe', routeId: 'map' }测试要在本地测试应用程序,可以使用以下命令运行本地...
BasiGX是一个ExtJS软件包,用于基于ExtJS 6,GeoExt3和OpenLayers> 3创建现代的GIS应用程序。它包含多个组件,可帮助开发人员快速组合定制的应用程序。 发展要求 Node.js 10.13.0或更高版本 npm 6.8.0或更高版本 ...
GeoExt 2.0.3 GeoExt是用于Web制图应用程序的丰富工具包,为OpenLayers数据结构添加了ExtJS组件。 它是ExtJS和OpenLayers之间的结合点。 DeftJS DeftJS在ExtJS中添加了一个IoC容器,该容器是GXC.App类的基础。 注册...
如果您安装了Python,则可以运行一个简单的HTTP服务器并从您的计算机( http:// localhost:8000 )开始使用Heron。 见苍鹭/startheron。* 对于开发人员 要构建一个版本,请转到heron / build并在那里阅读说明,...
GeoExt集成google map ,地图偏移 21 用JavaScript为OpenLayers.Marker的加上单击显示详细信息的功能 21 改良OpenLayers的MousePostion 25 使用OpenLayers实现一个在鼠标点击处添加标记的效果 27 openlayers 利用...
哥伦比亚多用途地籍的观众该地图查看器是在哥伦比亚多用途地籍试验项目的背景下开发的,其主要目的是通过多用途方法建立农村和城市地籍运作... 该查看器是使用JavaScript库OpenLayers 4 , ExtJS 6.2.0和GeoExt 3.1开发
在不来梅举行的FOSS4G-Europe 2014上的演讲内容“ OpenLayers 3 –迈向3.0.0最终版本”,马克·詹森(Marc Jansen) “ GeoExt2 –过去,现在和未来”,马克·詹森(Marc Jansen) “ GDA Wasser –实际中的SHOGun的...
扩展QGIS Web客户端(EQWC) 这是官方QGIS Web Client I的修改和扩展版本。它将QGIS项目转换为带有查看,导航,搜索和打印数据的工具的Web和Mobile GIS应用程序。 最重要的是,还有一个PostgreSQL管理数据库,用于...