Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created a WMS layer in GIS Cloud app. I use GIS Cloud because they provide prepared app to transfer data from mobile to layer. The URL of WMS layer: The name of layer:138865:mobile_fleet. I'm working on thesis and I have to create a web mapping app.

I decided to use OpenLayers library but I'm newbie, I have never been programming and I don't have much time to understand all aspects. Nevertheless I tried to follow examples on the web of OpenLayers and decided to use example Feature Info Example as template and then I tried to change parameters of functions and objects. I was successful with creating map viewer and adding WMS layer and moreover I added a WFS layer. I wasn't successful with picking a feature's attributes of WMS layer. The code:

    <!DOCTYPE html>
function init(){
// Map is in mercator this time, so over-ride the default
// options that assume lat/lon.
var options = {
  projection: new OpenLayers.Projection("EPSG:900913"),
  displayProjection: new OpenLayers.Projection("EPSG:4326"),
  units: "m",
  numZoomLevels: 10,
  maxResolution: 156543.0339,
  maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
                                          20037508, 20037508.34)};
    // Create the map object
 map = new OpenLayers.Map('map', options);
         // create Google Maps layer
var gmap = new OpenLayers.Layer.Google(
      "Google Streets", // the default
      {'sphericalMercator': true, numZoomLevels: 20}

// create Google Satellite layer
var gsat = new OpenLayers.Layer.Google(
    "Google Satellite",
    {type: G_SATELLITE_MAP, 'sphericalMercator': true, numZoomLevels: 20}

var wmslayer = new OpenLayers.Layer.WMS(
    "Canadian Data",
        version: "1.1.1",
        layers: "138865:mobile_fleet",
        srs: "EPSG:4326",
        transparent: "TRUE",

    { isBaseLayer: false }

var wfs = new OpenLayers.Layer.Vector(
     "Stavros Features",
        strategies: [new OpenLayers.Strategy.Fixed()]
        , projection: new OpenLayers.Projection("EPSG:4326")
        , protocol: new OpenLayers.Protocol.WFS({
            version: "1.1.0",
            url: "",
            featurePrefix: 'Fleet', //geoserver worspace name
            featureType: "vzorek_WGS84", //geoserver Layer Name
            featureNS: "", // Edit Workspace Namespace URI
            geometryName: "the_geom" // field in Feature Type details with type "Geometry"    

highlightLayer = new OpenLayers.Layer.Vector("Highlighted Features", {
    displayInLayerSwitcher: false, 
    isBaseLayer: false 

    infoControls = {
        click: new OpenLayers.Control.WMSGetFeatureInfo({
            url: '', 
            title: 'Identify features by clicking',
            infoFormat: "text/plain",
            layers: [wmslayer],
            queryVisible: true
        hover: new OpenLayers.Control.WMSGetFeatureInfo({
            url: '', 
            title: 'Identify features by clicking',
            layers: [wmslayer],
            hover: true,
            // defining a custom format options here
            formatOptions: {
                typeName: 'water_bodies', 
                featureNS: ''
            queryVisible: true

    map.addLayers([gmap, gsat,wfs,wmslayer, highlightLayer]); 
    for (var i in infoControls) { 
        infoControls[i].events.register("getfeatureinfo", this, showInfo);

    map.addControl(new OpenLayers.Control.LayerSwitcher());;

function showInfo(evt) {
    if (evt.features && evt.features.length) {
    } else {
        $('responseText').innerHTML = evt.text;

function toggleControl(element) {
    for (var key in infoControls) {
        var control = infoControls[key];
        if (element.value == key && element.checked) {
        } else {

function toggleFormat(element) {
    for (var key in infoControls) {
        var control = infoControls[key];
        control.infoFormat = element.value;

function toggleLayers(element) {
    for (var key in infoControls) {
        var control = infoControls[key];
        if (element.value == 'Specified') {
            control.layers = [water];
        } else {
            control.layers = null;

// function toggle(key

You can see this app: When I click on some feature of WMS layer (the red points on the map) I see in Firebug that the response is bad.

After s few hours I have found solution. For information: I'm using OpenGeo product deployed on AWS EC2. Geoserver has already implemented proxy so you don't need copy file proxy.cgi from openlayers. All you have to do is open webUI (dashboard), click on proxy and then add a hostname (in my case and in some case mimetype too. That is all.

share|improve this question

This is a classic case of "same origin policy" preventing the request being made. You need to add a proxy to your GeoServer instance so that it can resend the requests to the remote map server. See Help Setting up GeoServer Proxy with OpenLayers and related questions for more help on this process.

share|improve this answer
Yes, thanks for information. – Zola Horvi May 16 '12 at 11:44
Hello! Thank you! Now I see that respond is allright. But I have another problem - <ServiceException code="LayerNotQueryable">. I'm not administring WMS server of GIS Cloud so I assume that I can't solve this problem or is there possibility to make this layer queryable? – Zola Horvi May 16 '12 at 12:11
Zola Horvi: if the solution did help you, make sure to accept the answer, so that people will help you in the future – atlefren May 16 '12 at 12:14
No - the querability of a layer is entirely with in the control of the server (otherwise you could steal my secret information by clicking on it). – iant May 16 '12 at 12:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.