Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- OpenLayers.Control.ArcGisRestIdentify = OpenLayers.Class(OpenLayers.Control, {
- layerid:null,
- eventListeners:null,
- url:null,
- EVENT_TYPES: ["resultarrived"],
- defaultHandlerOptions: {
- 'single': true,
- 'double': false,
- 'pixelTolerance': 0,
- 'stopSingle': false,
- 'stopDouble': false,
- 'sr' : 4326
- },
- initialize: function(options) {
- this.EVENT_TYPES =
- OpenLayers.Control.ArcGisRestIdentify .prototype.EVENT_TYPES.concat(
- OpenLayers.Control.prototype.EVENT_TYPES
- );
- this.handlerOptions = OpenLayers.Util.extend(
- {}, this.defaultHandlerOptions
- );
- OpenLayers.Control.prototype.initialize.apply(
- this, arguments
- );
- var callbacks = {};
- callbacks['click'] = this.doQuery;
- this.handler = new OpenLayers.Handler.Click(
- this, callbacks, this.handlerOptions
- );
- },
- activate: function () {
- if (!this.active) {
- this.handler.activate();
- }
- return OpenLayers.Control.prototype.activate.apply(
- this, arguments
- );
- },
- deactivate: function () {
- return OpenLayers.Control.prototype.deactivate.apply(
- this, arguments
- );
- },
- /*trigger: function(e) {
- var lonlat = map.getLonLatFromViewPortPx(e.xy);
- alert("You clicked near " + lonlat.lat + " N, " +
- + lonlat.lon + " E");*/
- buildOptions: function(clickPosition,url){
- evtlonlat = this.map.getLonLatFromPixel(clickPosition);
- var queryoptions = {
- geometry:evtlonlat.lon+","+evtlonlat.lat,
- geometryType:"esriGeometryPoint",
- sr:this.sr,
- tolerance:3,
- imageDisplay:this.map.getSize().w+","+this.map.getSize().h+",96",
- mapExtent:this.map.getExtent().toBBOX(null,false),
- layers:"visible:"+this.layerid,
- spatialRel:"esriSpatialRelIntersects",
- f:"json",
- returnGeometry:"false"};
- var query = {
- url:url,
- params:queryoptions,
- callback: function(request){
- this.handleresult(request,clickPosition);
- },
- scope: this
- };
- return query
- },
- handleresult: function(result,xy){
- this.events.triggerEvent("resultarrived",{
- text:result.responseText,
- xy:xy
- });
- },
- request: function(clickPosition){
- queryOptions = this.buildOptions(clickPosition,this.url);
- var request = OpenLayers.Request.GET(queryOptions);
- },
- doQuery: function(e){
- this.request(e.xy);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement