[OpenLayers-Users] Re: OL w/ JQuery Mobile - WMSGetFeatureInfo

Ravi Pavuluri ravitheja at ymail.com
Fri Jun 17 10:21:00 EDT 2011


Matt,

Thanks for your reply.

Rich,

Thanks for posting you idea. Since we do not have a complete client side solution at this moment, may be your idea could be the only way out.

-Ravi.


________________________________
From: Richard Greenwood <richard.greenwood at gmail.com>
To: maw269 <maw269 at gmail.com>
Cc: users at openlayers.org
Sent: Thursday, June 16, 2011 7:16 PM
Subject: Re: [OpenLayers-Users] Re: OL w/ JQuery Mobile - WMSGetFeatureInfo

On Thu, Jun 16, 2011 at 5:04 PM, maw269 <maw269 at gmail.com> wrote:
> Nope Ravi, I have not found a solution.
>
> Sorry,
>
> Matt

I don't know if the code below will help. I am putting the results
into a jQuery 'page' rather than a pop-up, and I am querying the
attribute data via a custom php page that returns JSON, but maybe it
will be useful to you none the less.

Best regards,
Rich

OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
  defaultHandlerOptions: {
      'single': true,
      'double': false,
      'pixelTolerance': 0,
      'stopSingle': false,
      'stopDouble': false
  },

  initialize: function(options) {
     
 this.handlerOptions = OpenLayers.Util.extend(
          {}, this.defaultHandlerOptions
      );
      OpenLayers.Control.prototype.initialize.apply(
          this, arguments
      );
      this.handler = new OpenLayers.Handler.Click(
          this, {
              'click': this.trigger
          }, this.handlerOptions
      );
  },

  trigger: function(e) {
    var url;

    // var qlayers = rwg.mapservLayerList.getActiveInfoLayers();
    var qlayers = 'ownership';

    if (qlayers) {
      /* Populate Info Tool via jQuery JSON */
 
     url = rwg.info_url + '?layers=' + qlayers;
      url += '&r='+Math.round(map.getResolution()); // resolution in
feet per pixel

      var p0 = this.map.getLonLatFromViewPortPx(e.xy);
      url += "&p="+Math.round(p0.lon)+','+Math.round(p0.lat);

      $('#infotool').empty();
      $('#infotool').append(rwg.renderInfo(url));

      $.mobile.changePage('infopage');
    }
  }
});

rwg.renderInfo = function(url){
  var content = $('<div>');
  // content.hide();
  // in jQuery 1.4 $.getJSON() will fail silently on invalid JSON data
  $.getJSON(url, function(data) {
    // content.append('<b>' + data.numRows + ' Record(s) Found</b>');
    var infoLength = data.info.length;

    // loop thru the unique info layers
    // a single layer can return multiple records
    for (var i=0; i<infoLength; i++) {
      // content.append('<hr>');
      // Check to see if we have a function registered to display
records of this info type.
      if (typeof(rwg.infoLayers[data.info[i].handler]) === 'function') {
        content.append(rwg.infoLayers[data.info[i].handler](data.info[i].records));
      }
    }
  });
  return content;
}



-- 
Richard Greenwood
richard.greenwood at gmail.com
www.greenwoodmap.com
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110617/46186801/attachment.html


More information about the Users mailing list