[OpenLayers-Users] Proxy problem in GetFeatureInfo -nosolution??
Arnd Wippermann
arnd.wippermann at web.de
Tue Mar 30 15:36:39 EDT 2010
Hi,
Instead <div id="nodelist">
It has to be <div id="nodeList">
and
instead OpenLayers.loadUrl(url, '', this, setHTML);
It has to be OpenLayers.loadURL(url, '', this, setHTML);
Also to get your source running, I have set the script into the init2()
function. All works as expected with my WMS layers.
You can also use a relative url for your WMS, then you don't need a proxy
script:
layer1 = new OpenLayers.Layer.WMS("OpenLayers WMS",
"/mapserver/mapserv.exe?...
But only if your WMS and your html page runs from the same domain.
Arnd
-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von sunny74
Gesendet: Dienstag, 30. März 2010 07:58
An: users at openlayers.org
Betreff: Re: [OpenLayers-Users] Proxy problem in GetFeatureInfo
-nosolution??
Hi Barend,
I got my mapfile corrected and my map is displaying fine.
My mapfile is like this:
# Map file created from QGIS project file D:/QGIS/newwr.qgs # Edit this file
to customize for your map interface # (Created with PyQgis MapServer Export
plugin) MAP
NAME newwr.map
# Map image size
SIZE 600 600
UNITS dd
EXTENT 67.440106 17.379867 78.390250 25.122977
FONTSET "fonts.txt"
PROJECTION
'proj=longlat'
'ellps=WGS84'
'datum=WGS84'
'no_defs'
''
END
# Background color for the map canvas -- change as desired
IMAGECOLOR 192 192 192
IMAGEQUALITY 95
IMAGETYPE gif
OUTPUTFORMAT
NAME GIF
DRIVER 'GD/gif'
MIMETYPE 'image/gif'
#IMAGEMODE PC256
EXTENSION 'gif'
END
# Legend
LEGEND
IMAGECOLOR 255 255 255
STATUS ON
KEYSIZE 18 12
LABEL
TYPE BITMAP
SIZE MEDIUM
COLOR 0 0 89
END
END
# Web interface definition. Only the template parameter
# is required to display a map. See MapServer documentation
WEB
# Set IMAGEPATH to the path where MapServer should
# write its output.
IMAGEPATH '/tmp/'
# Set IMAGEURL to the url that points to IMAGEPATH
# as defined in your web server configuration
IMAGEURL '/tmp/'
# WMS server settings
METADATA
'wms_title' 'newwr.map'
'wms_feature_mime_type' 'text/html'
'wms_onlineresource'
'http://172.16.0.144:9000/cgi-bin/mapserv?map=d:\ms4w\apache\htdocs\Shape\ne
wwr1rec.map&'
'wms_srs' 'EPSG:4326'
'queryable' 'true'
'wms_proxy_auth_type' 'ntlm'
'wms_proxy_host' '172.16.0.144'
'wms_proxy_port' '9000'
'wms_proxy_type' 'http'
'wms_proxy_username' 'subhranilr'
'wms_proxy_password' 'subh123$'
'gml_include_items' 'all'
END
#Scale range at which web interface will operate
# Template and header/footer settings
HEADER ../templates/Demo_header.html
TEMPLATE ../templates/Demo_query_body.html
FOOTER ../templates/Demo_footer.html
# Only the template parameter is required to display a map. See
MapServer documentation
END
LAYER
NAME 'STATE'
TYPE POLYGON
DATA 'D:\ms4w\Apache\htdocs\Shape\STATE.shp'
METADATA
'wms_title' 'STATE'
END
STATUS DEFAULT
HEADER ../templates/Demo_header.html
TEMPLATE ../templates/Demo_query_body.html
FOOTER ../templates/Demo_footer.html
DUMP TRUE
TRANSPARENCY 100
PROJECTION
'proj=longlat'
'ellps=WGS84'
'datum=WGS84'
'no_defs'
''
END
CLASS
NAME 'STATE'
STYLE
SYMBOL 0
SIZE 2
OUTLINECOLOR 0 0 0
COLOR 255 255 127
END
END
END
LAYER
NAME 'RailwayStations'
TYPE POINT
DATA 'D:\ms4w\Apache\htdocs\Shape\RailwayStations.shp'
LABELITEM 'S_NAME'
METADATA
'wms_title' 'RailwayStations'
END
STATUS ON
HEADER ../templates/Demo_header.html
TEMPLATE ../templates/Demo_query_body.html
FOOTER ../templates/Demo_footer.html
DUMP TRUE
TRANSPARENCY 100
PROJECTION
'proj=longlat'
'ellps=WGS84'
'datum=WGS84'
'no_defs'
''
END
CLASS
NAME 'RailwayStations'
STYLE
SYMBOL 'CIRCLE'
SIZE 8
OUTLINECOLOR 0 0 0
COLOR 255 0 0
END
LABEL
COLOR 132 31 31
SHADOWCOLOR 218 218 218
SHADOWSIZE 2 2
TYPE TRUETYPE
FONT comic_sans-bold
SIZE 6
ANTIALIAS TRUE
POSITION AUTO
FORCE TRUE
PARTIALS FALSE
MINDISTANCE 300
BUFFER 4
END # end of label
END
END
#Circle symbol
SYMBOL
NAME 'CIRCLE'
TYPE ellipse
FILLED true
POINTS
1 1
END
END
END
Problem is Openlayers.loadUrl(url, '', this, setHTML) does not work.
It is saying Jscript runtime does not support this Object or property.
My script for calling GetFeatureInfo is as below:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script type="text/javascript"
src="OL28/OL28/lib/OpenLayers.js"></script>
<script type="text/javascript">
var mapview, layer, layer1, map;
function init2() {
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="map" runat="server" style="width:600px;height:600px">
<script defer="defer" type="text/javascript">
OpenLayers.ProxyHost =
"http://172.16.0.144:9000/cgi-bin/proxy.cgi?url=";
//alert('here');
var lon = 73.25;
var lat = 20.35;
var zoom = 6;
map = new OpenLayers.Map('<%=map.ClientID%>');
// layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
// "http://localhost:9000/cgi-bin/mapserv.exe?", {
map: '../htdocs/Shape/newwr1rec.map', layers: 'STATE', format: 'png' });
// layer1 = new OpenLayers.Layer.WMS("Rstations",
// "http://localhost:9000/cgi-bin/mapserv.exe?", {
map: '../htdocs/Shape/newwr1rec.map', transparent: true, layers:
'RailwayStations', format: 'png' });
//alert(map);
layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
"http://172.16.0.144:9000/cgi-bin/mapserv.exe?map=d:/ms4w/apache/htdocs/Shap
e/newwr1rec.map",
{ 'layers': 'STATE', transparent: false, format: "image/png" });
layer1 = new OpenLayers.Layer.WMS("OpenLayers WMS",
"http://172.16.0.144:9000/cgi-bin/mapserv.exe?map=d:/ms4w/apache/htdocs/Shap
e/newwr1rec.map",
{ 'layers': 'RailwayStations', transparent: true, format: "image/png" });
//alert(layer);
map.addLayers([layer, layer1]);
//layer = new OpenLayers.Layer.WFS("OpenLayers WFS",
"http://127.0.0.1:9000/cgi-bin/mapserv.exe?map=d:/ms4w/apache/htdocs/Shape/n
ewwr1.map",
{ typename: 'STATE', maxfeatures: 6 }, { featureClass:
OpenLayers.Feature.WFS });
///map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
map.addControl(new OpenLayers.Control.LayerSwitcher());
//map.zoomToMaxExtent();
map.events.register('click', map, function(e) {
//alert('clicked');
OpenLayers.Util.getElement('nodeList').innerHTML = "Loading...
please wait...";
var url = layer1.getFullRequestString({
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: layer1.map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/html',
QUERY_LAYERS: layer1.params.LAYERS,
FEATURE_COUNT: 1,
WIDTH: map.size.w,
HEIGHT: map.size.h
});
// var msg = document.getElementById('urlmsg');
// msg.value = url;
alert(url, "getfeatureinfo",
"location=0,status=0,scrollbars=1,width=800,height=400");
//window.open(url, '', this, setHTML, setHTML);
OpenLayers.loadUrl(url, '', this, setHTML);
OpenLayers.Event.stop(e);
});
function setHTML(response) {
OpenLayers.Util.getElement('nodeList').innerHTML =
response.responseText;
}
</script>
</div>
<div id="nodelist">
</div>
</form>
</body>
</html>
I think it has something to do with proxy.I am showing map on a aspx page
using IIS.Could you pls try it yourself and let me know if it works for you.
thanks.
--
View this message in context:
http://n2.nabble.com/Proxy-problem-in-GetFeatureInfo-no-solution-tp4802810p4
822912.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
More information about the Users
mailing list