[OpenLayers-Users] TileCache + GetFeatureinfo(Geoserver1.6.4)?
Xiaoyu Guan
guanxiaoyu at gmail.com
Wed Aug 6 06:29:54 EDT 2008
Dear All.
the problem have been solved. I simply add another WMS layer to map and hide
it. then GetFeatureinfor can request from that WMS layer. please check the
following codes.
var map;
var testlayer;
var tiled;
function setHTML(response) {
document.getElementById('nodelist').innerHTML =
response.responseText;
};
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;
OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;
function init(){
var bounds = new OpenLayers.Bounds(
143.83482400000003, -43.648056,
148.47914100000003, -39.573891
);
var options = {
controls: [],
maxExtent: bounds,
maxResolution: 0.018141863281250004,
projection: "EPSG:4326",
units: 'degrees'
};
map = new OpenLayers.Map('map', options);
// setup tiled layer
tiled = new OpenLayers.Layer.WMS(
"Geoserver layers - Tiled", "
http://127.0.0.1:2010/tilecache/tilecache.py",
{
layers: 'tasmania',
styles: '',
height: '658',
width: '800',
srs: 'EPSG:4326',
format: 'image/png',
tiled: 'true',
tilesOrigin : "143.83482400000003,-43.648056"
},
{buffer: 0}
);
testlayer = new OpenLayers.Layer.WMS(
"Geoserver layers - Untiled", "
http://127.0.0.1:2008/geoserver/wms",
{
layers: 'tasmania',
styles: '',
height: '658',
width: '800',
srs: 'EPSG:4326',
format: 'image/png'
},
{singleTile: true, ratio: 1,displayInLayerSwitcher: false /*
Not show this layer */}
);
map.addLayers([tiled,testlayer]);
// setup controls and initial zooms
map.addControl(new OpenLayers.Control.PanZoomBar());
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.LayerSwitcher());
//map.addControl(new OpenLayers.Control.OverviewMap());
map.zoomToExtent(bounds);
// support GetFeatureInfo
geoserver=map.layers.slice(1); // copy map.layers to a new
object without TileCache layer
map.events.register('click', geoserver, function (e) {
document.getElementById('nodelist').innerHTML = "Loading...
please wait...";
var url = geoserver[0].getFullRequestString(
{
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: geoserver[0].getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/html',
QUERY_LAYERS: geoserver[0].params.LAYERS,
FEATURE_COUNT: 50,
WIDTH: map.size.w,
HEIGHT: map.size.h
},
"http://127.0.0.1:2008/geoserver/wms"
);
OpenLayers.loadURL(url, '', this, setHTML, setHTML);
OpenLayers.Event.stop(e);
});
}
All the best
Xiaoyu
On Thu, Jul 31, 2008 at 2:04 PM, Xiaoyu Guan <guanxiaoyu at gmail.com> wrote:
> Dear All:
> I have a problem on building getFeatureinfo. I have use Geoserver 1.6.4,
> and Tilecache. I pointed my geoserver sample page to my tilecache. then I
> still want getfeatureinfo function of Geoserver. I try to modified it, but
> not success.
>
> var map;
> var testlayer;
> var tiled;
> function setHTML(response) {
> document.getElementById('nodelist').innerHTML = response.responseText;
>
> };
>
>
> OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;
> OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;
>
> function init(){
> var bounds = new OpenLayers.Bounds(
> 143.83482400000003, -43.648056,
>
> 148.47914100000003, -39.573891
> );
> var options = {
> controls: [],
> maxExtent: bounds,
> maxResolution: 0.018141863281250004,
>
> projection: "EPSG:4326",
> units: 'degrees'
> };
> map = new OpenLayers.Map('map', options);
>
>
> // setup tiled layer
>
> tiled = new OpenLayers.Layer.WMS(
> "Geoserver layers - Tiled", "http://127.0.0.1:2010/tilecache/tilecache.py",
>
> {
> layers: 'tasmania',
> styles: '',
> height: '658',
> width: '800',
> srs: 'EPSG:4326',
>
> format: 'image/png',
> tiled: 'true',
> tilesOrigin : "143.83482400000003,-43.648056"
> },
> {buffer: 0}
>
> );
>
>
>
> map.addLayer( tiled);
>
> // setup controls and initial zooms
> map.addControl(new OpenLayers.Control.PanZoomBar());
>
> 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.LayerSwitcher());
> //map.addControl(new OpenLayers.Control.OverviewMap());
> map.zoomToExtent(bounds);
>
> testlayer = new OpenLayers.Layer.WMS(
>
> "Geoserver layers - Untiled", "http://127.0.0.1:2008/geoserver/wms",
> {
> layers: 'tasmania',
>
> styles: '',
> height: '658',
> width: '800',
> srs: 'EPSG:4326',
> format: 'image/png'
>
> },
> {singleTile: true, ratio: 1}
> );
> // here I would like to add stuff like this
> //then geoserver only contain one layer, which is testlayer
> var geoserver = map;
>
> geoserver.addLayer(testlayer);
>
>
> // support GetFeatureInfo
> geoserver.events.register('click', geoserver, function (e) {
> document.getElementById('nodelist').innerHTML = "Loading... please wait...";
>
> var url = geoserver.layers[0].getFullRequestString(
> {
> REQUEST: "GetFeatureInfo",
> EXCEPTIONS: "application/vnd.ogc.se_xml",
>
> BBOX: geoserver.getExtent().toBBOX(),
> X: e.xy.x,
> Y: e.xy.y,
> INFO_FORMAT: 'text/html',
> QUERY_LAYERS: geoserver.layers[0].params.LAYERS,
>
> FEATURE_COUNT: 50,
> WIDTH: geoserver.size.w,
> HEIGHT: geoserver.size.h
> },
> "http://127.0.0.1:2008/geoserver/wms"
>
> );
> OpenLayers.loadURL(url, '', this, setHTML, setHTML);
> OpenLayers.Event.stop(e);
> });
> }
>
>
> b
>
> because I am not a JavaScript expert. it is hard for me to replace the
> layer, such as map.layers[0]. how can use tilecache as base layer, and have
> getFeatureInfo on top of it at same time?
> Much much thanks
>
> all the best
>
> Xiaoyu
> PS, I have already send a copy to Geoserver mailling list
>
> --
> Xiaoyu Guan (Sam)
> Geo-information Science
> Wageningen UR
>
>
--
Xiaoyu Guan (Sam)
Geo-information Science
Wageningen UR
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080806/9dbd5b9d/attachment.html
More information about the Users
mailing list