I have a problem with my GetFeatureInfo, because I can not get the values back at me as if they were variables. Anyone know any way?

I researched and what I have seen is Geoserver modify the template (Content.ftl etc ...) But I would like to eliminate this as it has very little customization.

Or if someone could help to customize these by javascript or another language with more options.

I use the example from OpenLayers3 :

map.on('singleclick', function(evt) {
  document.getElementById('info').innerHTML = '';
  var viewResolution = /** @type {number} */ (view.getResolution());
  var url = Rustica.getGetFeatureInfoUrl(
      evt.coordinate, viewResolution, 'EPSG:3857',
      {'INFO_FORMAT': 'application/json'});
  if (url) {
    document.getElementById('info').innerHTML =
        '<iframe seamless src="' + url + '"></iframe>';

map.on('pointermove', function(evt) {
  if (evt.dragging) {
  var pixel = map.getEventPixel(evt.originalEvent);
  var hit = map.forEachLayerAtPixel(pixel, function(layer) {
    return true;
  map.getTargetElement().style.cursor = hit ? 'pointer' : '';

And I recibe this JSON:


My aim would be to get each of these values separately to put them in an HTML form.


You are making a GetFeatureInfo request with a application/json as INFO_FORMAT parameter, so a JSON is what your are going to obtain. Not sure about your expectations here.

If you need to get the properties of the json to make something with it, as show it in your html templates, just parse the json response.


If you are using geoserver, it has a vendor parameter, propertyName, that allows specify the properties that should be returned by the server

  • I'm using geoserver, and returns a json me, but what I would like to achieve is to get the json in an array and be able to take the values I want and modify them and put them on a form. The problem I have is that I can not access that data is in a <iframe> and if I remove just get the url.
    – Sergio_Az
    Sep 18 '15 at 12:11

If your problem is communicating with the iframe you create, try to use

otherWindow.postMessage(message, targetOrigin, [transfer]); 

It's a nice way to communicate between windows or frames.

Here is the doc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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