[Users] Problem with the FeatureStore.
Bob Sponge
bob_webmapping at yahoo.com
Fri May 7 19:25:56 CEST 2010
Hi,
I have a problem with the FeatureStore. I try to make the example (http://dev.geoext.org/trunk/geoext/examples/feature-grid.html) but it doesn't work.
I have the map and the grid but without the features and I don't understand why.
This is my code, it's the same as in the example, I just change the links of libraries and put the script in my HTML files. The links are ok and i have the JSON files in the data folder.
<html>
<head>
<title>test_atlas</title>
<script src="ext-3.1.1/adapter/ext/ext-base.js" type="text/javascript"></script>
<script src="ext-3.1.1/ext-all.js" type="text/javascript"></script>
<script src="OpenLayers-2.8/OpenLayers.js" type="text/javascript"></script>
<script src="OpenLayers-2.8/lib/OpenLayers/Lang/fr.js"></script>
<script type="text/javascript" src="GeoExt/script/GeoExt.js"></script>
<link rel="stylesheet" type="text/css" href="ext-3.1.1/resources/css/ext-all.css"></link>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript" >
var mapPanel, store, gridPanel, mainPanel;
Ext.onReady(function() {
// create map instance
var map = new OpenLayers.Map();
var wmsLayer = new OpenLayers.Layer.WMS(
"vmap0",
"http://labs.metacarta.com/wms/vmap0",
{layers: 'basic'}
);
// create vector layer
var vecLayer = new OpenLayers.Layer.Vector("vector");
map.addLayers([wmsLayer, vecLayer]);
// create map panel
mapPanel = new GeoExt.MapPanel({
title: "Map",
region: "center",
height: 400,
width: 600,
map: map,
center: new OpenLayers.LonLat(5, 45),
zoom: 6
});
// create feature store, binding it to the vector layer
store = new GeoExt.data.FeatureStore({
layer: vecLayer,
fields: [
{name: 'name', type: 'string'},
{name: 'elevation', type: 'float'}
],
proxy: new GeoExt.data.ProtocolProxy({
protocol: new OpenLayers.Protocol.HTTP({
url: "data/summits.json",
format: new OpenLayers.Format.GeoJSON()
})
}),
autoLoad: true
});
// create grid panel configured with feature store
gridPanel = new Ext.grid.GridPanel({
title: "Feature Grid",
region: "east",
store: store,
width: 320,
columns: [{
header: "Name",
width: 200,
dataIndex: "name"
}, {
header: "Elevation",
width: 100,
dataIndex: "elevation"
}],
sm: new GeoExt.grid.FeatureSelectionModel()
});
// create a panel and add the map panel and grid panel
// inside it
mainPanel = new Ext.Panel({
renderTo: "mainpanel",
layout: "border",
height: 400,
width: 920,
items: [mapPanel, gridPanel]
});
});
</script>
</head>
<body>
<div id="mainpanel"></div>
</body>
</html>
And even with just a html file containing a copy of the HTML example, changing the two relative links by absolut links, it doesm't work :
<html>
<head>
</head>
<body>
<h1>Grid Panel configured with a GeoExt.data.FeatureStore</h1>
<p>This example shows an Ext grid loaded with features read from a
GeoJSON document (data/summits.json).</p>
<p>Because the layer and the store are bound to each other, the
features loaded into the store are automatically added to the layer. A
GeoExt feature selection model is also used so that selecting rows in
the grid selects features in the layer, and vice-versa.</p>
<p>See <a href=feature-grid.js>feature-grid.js</a>.</p>
<div id="mainpanel"></div>
</body>
</html>
I don't see where is the error, it's may be a little one or a big one :)
Thank you for your help.
Benoit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20100507/542adb5b/attachment.htm
More information about the Users
mailing list