Friday 20 November 2015

geoserver - Cannot populate a Ext GridPanel through GeoExt WMSCapabilitiesStore


I've been working through a few tutorial/starter map samples on the OpenGeo and GeoExt websites and have come upon a problem I cannot solve. I'm trying to load a list of layers from my GeoServer into a GridPanel using GeoExt.data.WMSCapabilitiesStore. No matter what I try, I cannot get anything to show in the GridPanel. I thought I had cross domain issues at first, but the problem persists even when the webpage and the GeoServer data are on the same server.


Here's a link to my very barren looking web map: http://24.105.210.45/OpenGeoGeoExtMap1.html.


Here's the JavaScript that's supposed to access the wms and load the layer list:


    Ext.onReady(function() {
var grid = new Ext.grid.GridPanel({
title: "Available WMS Layers",
region: "north",
height: 150,
viewConfig: {forceFit: true},

store: new GeoExt.data.WMSCapabilitiesStore({
url: "http://24.105.210.45:8080/geoserver/wms?service=wms&version=1.1.1&request=GetCapabilities",
autoLoad: true
}),
columns: [
{header: "Name", dataIndex: "name", sortable: true},
{header: "Title", dataIndex: "title", sortable: true},
{header: "Abstract", dataIndex: "abstract"}
],


Any help with this, or just ideas of where to look next would be greatly appreciated.



Answer



Different port numbers are considered as different domains - even if the rest of the URL is the same. So if your main site is running on:


http://24.105.210.45:80

You would need a proxy to access:


http://24.105.210.45:8080/geoserver/wms?service=wms&version=1.1.1&request=GetCapabilities

So the proxy FAQ below applies in your case:


http://trac.osgeo.org/openlayers/wiki/FrequentlyAskedQuestions#ProxyHost



Why can't you run both your web application and Geoserver on the same port?


Update:


You can also get around the same domain policy using YQL - http://geographika.co.uk/accessing-cross-domain-data-with-yql


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...