diff --git a/build/build.bat b/build/build.bat index 7a2346b..4d39844 100644 --- a/build/build.bat +++ b/build/build.bat @@ -1,6 +1,6 @@ @echo off java -jar ../lib/closure-compiler/compiler.jar ^ ---js ../src/gvector.js ^ +--js ../src/lvector.js ^ --js ../src/core/Util.js ^ --js ../src/core/Class.js ^ --js ../src/layer/Layer.js ^ @@ -12,4 +12,4 @@ java -jar ../lib/closure-compiler/compiler.jar ^ --js ../src/layer/CartoDB.js ^ --js ../src/layer/PRWSF.js ^ --js ../src/layer/GISCloud.js ^ ---js_output_file ../dist/gvector.js \ No newline at end of file +--js_output_file ../dist/lvector.js diff --git a/dist/lvector.js b/dist/lvector.js index 4f75865..4b4432e 100644 --- a/dist/lvector.js +++ b/dist/lvector.js @@ -34,19 +34,19 @@ this._vectors.push(a.features[b]);if(this.options.popupTemplate){var g=this;c=a. [];e=0;for(f=a.coordinates.length;e1){c=[];e=0;for(f=a.paths.length;e1){c=[];e=0;for(f=a.rings.length;e=b[0]&&a<=b[1];this._show()}},options:{where:"1=1",url:null,useEsriOptions:!1},_requiredParams:["url"],_convertEsriOptions:function(a){var b= -{};if(!(a.minScale==void 0||a.maxScale==void 0)){var d=this._scaleToLevel(a.minScale),c=this._scaleToLevel(a.maxScale);c==0&&(c=20);b.scaleRange=[d,c]}if(a.drawingInfo&&a.drawingInfo.renderer)b.symbology=this._renderOptionsToSymbology(a.drawingInfo.renderer);return b},_getEsriOptions:function(){this._makeJsonpRequest(this._originalOptions.url+"?f=json&callback="+this._globalPointer+"._processEsriOptions")},_processEsriOptions:function(a){var b=this._originalOptions;b.esriOptions=a;this.initialize(b)}, -_scaleToLevel:function(a){var b=[5.91657527591555E8,2.95828763795777E8,1.47914381897889E8,7.3957190948944E7,3.6978595474472E7,1.8489297737236E7,9244648.868618,4622324.434309,2311162.217155,1155581.108577,577790.554289,288895.277144,144447.638572,72223.819286,36111.909643,18055.954822,9027.977411,4513.988705,2256.994353,1128.497176,564.248588,282.124294];if(a==0)return 0;for(var d=0,c=0;ce){d=c;break}}return d},_renderOptionsToSymbology:function(a){symbology= -{};switch(a.type){case "simple":symbology.type="single";symbology.vectorOptions=this._parseSymbology(a.symbol);break;case "uniqueValue":symbology.type="unique";symbology.property=a.field1;for(var b=[],d=0;d0?Math.floor(a*255):a},_pad:function(a){return a.length>1?a.toUpperCase():"0"+a.toUpperCase()},_parseAlpha:function(a){return a/255},_getFeatures:function(){this.options.uniqueField||this._clearFeatures();var a=this.options.url+"query?returnGeometry=true&outSR=4326&f=json&outFields="+this.options.fields+"&where="+ -this.options.where+"&callback="+this._globalPointer+"._processFeatures";this.options.showAll||(a+="&inSR=4326&spatialRel=esriSpatialRelIntersects&geometryType=esriGeometryEnvelope&geometry="+this.options.map.getBounds().toBBoxString());this._makeJsonpRequest(a)},_processFeatures:function(a){if(this.options.map){var b=this.options.map.getBounds();if(!this._lastQueriedBounds||!this._lastQueriedBounds.equals(b)||this.options.autoUpdate)if(this._lastQueriedBounds=b,a&&a.features&&a.features.length)for(b= -0;b=b[0]&&a<= +b[1];this._show()}},options:{where:"1=1",url:null,useEsriOptions:!1},_requiredParams:["url"],_convertEsriOptions:function(a){var b={};if(!(a.minScale==void 0||a.maxScale==void 0)){var d=this._scaleToLevel(a.minScale),c=this._scaleToLevel(a.maxScale);c==0&&(c=20);b.scaleRange=[d,c]}if(a.drawingInfo&&a.drawingInfo.renderer)b.symbology=this._renderOptionsToSymbology(a.drawingInfo.renderer);return b},_getEsriOptions:function(){this._makeJsonpRequest(this._originalOptions.url+"?f=json&callback="+this._globalPointer+ +"._processEsriOptions")},_processEsriOptions:function(a){var b=this._originalOptions;b.esriOptions=a;this.initialize(b)},_scaleToLevel:function(a){var b=[5.91657527591555E8,2.95828763795777E8,1.47914381897889E8,7.3957190948944E7,3.6978595474472E7,1.8489297737236E7,9244648.868618,4622324.434309,2311162.217155,1155581.108577,577790.554289,288895.277144,144447.638572,72223.819286,36111.909643,18055.954822,9027.977411,4513.988705,2256.994353,1128.497176,564.248588,282.124294];if(a==0)return 0;for(var d= +0,c=0;ce){d=c;break}}return d},_renderOptionsToSymbology:function(a){symbology={};switch(a.type){case "simple":symbology.type="single";symbology.vectorOptions=this._parseSymbology(a.symbol);break;case "uniqueValue":symbology.type="unique";symbology.property=a.field1;for(var b=[],d=0;d0?Math.floor(a*255):a},_pad:function(a){return a.length>1?a.toUpperCase():"0"+a.toUpperCase()},_parseAlpha:function(a){return a/255},_getFeatures:function(){this.options.uniqueField|| +this._clearFeatures();var a=this.options.url+"query?returnGeometry=true&outSR=4326&f=json&outFields="+this.options.fields+"&where="+this.options.where+"&callback="+this._globalPointer+"._processFeatures";this.options.showAll||(a+="&inSR=4326&spatialRel=esriSpatialRelIntersects&geometryType=esriGeometryEnvelope&geometry="+this.options.map.getBounds().toBBoxString());this._makeJsonpRequest(a)},_processFeatures:function(a){if(this.options.map){var b=this.options.map.getBounds();if(!this._lastQueriedBounds|| +!this._lastQueriedBounds.equals(b)||this.options.autoUpdate){this._lastQueriedBounds=b;if(a&&a.features&&a.features.length)for(b=0;b=b[0]&&a<=b[1];this._show()}if(this.options.autoUpdate&&this.options.esriOptions.editFeedInfo){this._makeJsonpRequest("http://cdn.pubnub.com/pubnub-3.1.min.js"); var c=this;this._pubNubScriptLoaderInterval=setInterval(function(){window.PUBNUB&&c._pubNubScriptLoaded()},200)}},_pubNubScriptLoaded:function(){clearInterval(this._pubNubScriptLoaderInterval);this.pubNub=PUBNUB.init({subscribe_key:this.options.esriOptions.editFeedInfo.pubnubSubscribeKey,ssl:!1,origin:"pubsub.pubnub.com"});var a=this;this.pubNub.subscribe({channel:this.options.esriOptions.editFeedInfo.pubnubChannel,callback:function(){a._getFeatures()},error:function(){}})}});lvector.GeoIQ=lvector.GeoJSONLayer.extend({initialize:function(a){for(var b=0,d=this._requiredParams.length;b=b[0]&&a<=b[1];this._show()}},options:{dataset:null},_requiredParams:["dataset"],_getFeatures:function(){this.options.uniqueField||this._clearFeatures();var a="http://geocommons.com/datasets/"+this.options.dataset+"/features.json?geojson=1&callback="+this._globalPointer+"._processFeatures&limit=999";this.options.showAll||(a+="&bbox="+this.options.map.getBounds().toBBoxString()+"&intersect=full");this._makeJsonpRequest(a)},_processFeatures:function(a){if(this.options.map){var a= diff --git a/src/layer/AGS.js b/src/layer/AGS.js index 6bc53ad..721eb8c 100644 --- a/src/layer/AGS.js +++ b/src/layer/AGS.js @@ -34,6 +34,10 @@ lvector.AGS = lvector.EsriJSONLayer.extend({ // Extend Layer to create AGS lvector.Layer.prototype.initialize.call(this, options); + if (this.options.onload && typeof this.options.onload == 'function') { + this._layerLoaded = this.options.onload; + } + if (this.options.where) { this.options.where = encodeURIComponent(this.options.where); } @@ -387,7 +391,14 @@ lvector.AGS = lvector.EsriJSONLayer.extend({ } } + + if (typeof this._layerLoaded == 'function') { + this._layerLoaded(data); + } - } + }, + _layerLoaded: function(data) { + // do nothing by default + } });