null extent for dynamically generated polygon geometry from KMLLayer

1917
14
Jump to solution
04-27-2012 11:26 AM
AndrewMurdoch
Occasional Contributor
I get this error when attempting to use the FeatureLayer selectFeatures method using a dynamically generated polygon geometry:

In "?v=2.8 [dynamic]":
Microsoft JScript runtime error: 'xmin' is null or not an object (Ln 48, Col 41494, Ch 41494)

Ultimately, I want to use the actual geometry in a KML Layer to query another FeatureLayer, rather than use the Extent object of the KML geometries.  I'm trying to create a new geometry object that contains all of the KML Layer geometries.  There may be a better way to do this...

When evaluating breakpoints I can tell that the code fails on this line:
   targetLayer.selectFeatures(query);

Looking closer, I can see that the extent property is null for the new Geometry object after this line:
                           geom.addRing(graphic.geometry);
The graphic.geometry has a valid extent property (and presumably a valid geometry), but the geom object has an invalid extent after this line. 

Any thoughts or suggestions for me?

Thanks for your help!
Andrew




I'm using JavaScript API v2.8

Where kmlLayer = an esri KMLLayer object that contains a polygon for the state of Wyoming (http://dl.dropbox.com/u/2654618/kml/Wyoming.kml) and targetLayer = an esri FeatureLayer object:

function selectByLoadedLayer() {       if (kmlLayer) {         var geom;          var layers = kmlLayer.getLayers();         dojo.forEach(layers, function (lyr) {             if (lyr.graphics && lyr.graphics.length > 0) {                  if (lyr.declaredClass == "esri.layers.FeatureLayer") {                     if (lyr.geometryType == "esriGeometryPoint") {                         geom = new esri.geometry.Multipoint(map.spatialReference);                         dojo.forEach(lyr.graphics, function (graphic) {                             geom.addPoint(graphic.geometry);                         });                      } else if (lyr.geometryType == "esriGeometryPolygon") {                         geom = new esri.geometry.Polygon(map.spatialReference);                         dojo.forEach(lyr.graphics, function (graphic) {                             geom.addRing(graphic.geometry);                         });                      } else if (lyr.geometryType == "esriGeometryPolyline") {                         geom = new esri.geometry.PolyLine(map.spatialReference);                         dojo.forEach(lyr.graphics, function (graphic) {                             geom.addPath(graphic.geometry);                         });                     }                 } else {                     alert("KML layer contains a non-FeatureLayer layer object");                 }              }          });     } else {         alert("Please load an uploaded file or a network link first.");     }      //initialize & execute query     var query = new esri.tasks.Query();     query.geometry = geom;     query.returnGeometry = true;          targetLayer.selectFeatures(query);        }
0 Kudos
14 Replies
AndrewMurdoch
Occasional Contributor
This issue occurs in both IE8 and in Chrome 18.  After I reach about 4400 JSON string length, the selectFeatures method stops returning any features.  In Chrome, I get an error message that I don't get in IE8.  The error says: "Unable to Complete Operation" from the selectFeatures error handler.

Queries below about 4400 length seem to work fine in Chrome and in IE8.

Andrew
0 Kudos
derekswingley1
Frequent Contributor
Let me take a look...I'll get back to you.
0 Kudos
derekswingley1
Frequent Contributor
Here's an example that uses a geometry that comes out to about 7300 characters (make sure you update the URL to your proxy):  http://dl.dropbox.com/u/2654618/fl_select_large_geometry.txt

That works in both Chrome and IE8 for me. Can you test that code and let us know if that works for you?

There could be an issue with the polygon you're using...can you run your polygon through the geometry service's simplify operation and use the result of that to query your feature layer?
0 Kudos
AndrewMurdoch
Occasional Contributor
I tested your polygon file and it works fine for me (through our proxy.ashx file).

However, I've actually been testing with a KML file showing multiple polylines around Redding, CA.  Maybe it is not the length that is the problem but some other measure of complexity?

This JSON object fails (~5500 characters):

{"paths":[[[-13623091.7047,4952116.6667],[-13623055.6302,4952202.6571],[-13623005.3393,4952242.2741],[-13623005.7716,4952578.6665]],[[-13626762.4683,4952154.0091],[-13626787.4059,4952278.5776],[-13626915.6952,4952354.0507]],[[-13626915.6952,4952354.0507],[-13626801.5321,4952342.2127],[-13626584.8925,4952352.9089],[-13626239.1151,4952364.0777],[-13626036.1347,4952343.7974],[-13625742.7069,4952268.7129],[-13625696.9236,4952316.6434],[-13625705.8135,4952416.661],[-13625694.8656,4952642.0433]],[[-13626915.6952,4952354.0507],[-13626923.4555,4952358.6161]],[[-13622801.0314,4952553.642],[-13622765.1197,4952525.6682],[-13622537.595,4952531.6267],[-13622363.5384,4952510.9117],[-13622295.5671,4952578.8661],[-13622196.2117,4952554.3791],[-13622170.7263,4952643.2586],[-13622110.4206,4952673.6161],[-13622106.8734,4952798.1517],[-13622056.7673,4952880.4188],[-13622143.8438,4952948.513],[-13622179.0369,4953023.6609],[-13622161.0658,4953049.6801],[-13622119.286,4953054.04],[-13622027.031,4952976.3265],[-13621994.5406,4952975.6793],[-13621986.2048,4953016.0685],[-13622068.3198,4953107.3722]],[[-13622801.0314,4952553.642],[-13622892.0746,4952633.953]],[[-13622943.8065,4952563.6241],[-13622905.3931,4952601.6147],[-13622857.39,4952553.9138],[-13622801.0314,4952553.642]],[[-13623005.7716,4952578.6665],[-13622932.3513,4952546.5341],[-13622930.8112,4952514.1758],[-13622984.0156,4952499.8745]],[[-13622919.7236,4952596.1494],[-13622892.0746,4952633.953]],[[-13626299.6662,4952619.2813],[-13625757.1305,4952658.6575],[-13625728.7929,4952641.1616],[-13625694.8656,4952642.0433]],[[-13626841.3577,4952626.1773],[-13626841.1133,4952625.9892]],[[-13626841.3577,4952626.1773],[-13626835.6363,4952641.1318],[-13626820.0754,4952649.024]],[[-13626841.3577,4952626.1773],[-13626851.8404,4952598.778],[-13626919.194,4952582.7947],[-13627081.18,4952615.3534],[-13627234.3274,4952621.2911],[-13627624.098,4952734.8192],[-13627660.7249,4952757.9715],[-13627675.9033,4952808.3042]],[[-13622892.0746,4952633.953],[-13623256.2181,4952887.0805],[-13623282.4149,4953110.7174],[-13623267.4928,4953226.1779],[-13623210.4915,4953336.1933],[-13623146.2861,4953401.2073],[-13623119.6452,4953399.9155],[-13623092.7869,4953347.9621],[-13622974.853,4953306.2536],[-13622918.4554,4953230.5041],[-13622762.6091,4953173.4771],[-13622574.046,4953004.0082],[-13622471.145,4952869.3538],[-13622374.3052,4952841.6222],[-13622337.7054,4952805.1904],[-13622296.5864,4952694.1963],[-13622315.8234,4952575.3453]],[[-13625694.8656,4952642.0433],[-13625548.5686,4952645.8452],[-13625519.9542,4952688.1143],[-13625485.4221,4952695.9839],[-13625368.3416,4952649.9745],[-13625333.8332,4952663.0763],[-13625047.9101,4952651.1567],[-13624952.9877,4952587.4101],[-13624906.0636,4952597.088],[-13624814.063,4952566.5612],[-13624540.8321,4952446.6099],[-13624351.6774,4952416.3347],[-13623953.2569,4952425.3857],[-13623820.6735,4952406.0514],[-13623818.6211,4952515.1462],[-13623784.8641,4952550.665],[-13623732.7277,4952549.4774],[-13623692.5647,4952482.3145],[-13623648.1216,4952483.8618],[-13623580.5362,4952445.6444],[-13623478.6949,4952481.209],[-13623360.5824,4952452.4686],[-13623211.0475,4952468.0346],[-13623079.059,4952514.4076],[-13623063.151,4952570.313],[-13623005.7716,4952578.6665]],[[-13626820.0754,4952649.024],[-13626818.5623,4952647.9326]],[[-13626820.0754,4952649.024],[-13626782.6565,4952668.0022],[-13626689.9419,4952629.6976],[-13626631.7656,4952612.0585],[-13626299.6662,4952619.2813]],[[-13625748.0533,4952653.4665],[-13625729.0188,4952750.7748]],[[-13626243.6816,4952741.1797],[-13626299.6662,4952619.2813]],[[-13626876.4558,4952750.2055],[-13626869.1886,4952684.4505],[-13626820.0754,4952649.024]],[[-13626934.563,4952750.5866],[-13626920.9679,4952687.4568],[-13626841.3577,4952626.1773]],[[-13625707.8461,4952757.6262],[-13625690.271,4952736.6315],[-13625694.8656,4952642.0433]],[[-13628330.1969,4952765.5629],[-13628506.1301,4952767.3658],[-13628683.4227,4952831.1658],[-13628721.1656,4952832.1058],[-13628791.0334,4952907.9073],[-13628847.7526,4952930.6969],[-13628824.4002,4952854.2917],[-13628941.7555,4952772.5991],[-13629110.4324,4952730.7254],[-13629286.9521,4952792.6456],[-13629480.2658,4952866.1023],[-13629509.3119,4952906.6181],[-13629739.403,4953041.4038],[-13629948.2039,4953255.8841],[-13629962.0707,4953308.6093],[-13629998.0491,4953319.805],[-13630195.4179,4953549.158],[-13630286.8803,4953770.1635],[-13630319.5835,4953781.3377],[-13630403.8928,4953751.1667],[-13630479.2529,4953717.3473],[-13630409.839,4953490.8137],[-13630350.6416,4953379.193],[-13630109.9142,4953023.1011],[-13629910.0155,4952736.722],[-13629695.1347,4952534.977],[-13629525.1982,4952458.4565],[-13629296.8716,4952444.6433],[-13629150.5517,4952453.1355],[-13629043.4153,4952496.4957],[-13628938.2628,4952496.0504],[-13628541.4208,4952547.1949],[-13628283.7085,4952535.6395],[-13628093.2158,4952495.2792],[-13627592.0384,4952434.2024],[-13627095.8343,4952372.73],[-13626915.6952,4952354.0507]],[[-13627937.4654,4952810.6528],[-13628042.852,4952818.9864],[-13628147.4017,4952759.6782],[-13628330.1969,4952765.5629]],[[-13629028.7897,4953975.2475],[-13629088.3617,4953840.1068],[-13629089.3787,4953742.7548],[-13629062.8852,4953598.0863],[-13628941.9373,4953508.654],[-13628886.9682,4953424.1478],[-13628930.4467,4953201.3433],[-13628859.4143,4953138.072],[-13628763.8208,4953112.6599],[-13628729.0044,4953060.6912],[-13628720.0361,4952983.839],[-13628662.1492,4952954.1411],[-13628642.9296,4952913.8782],[-13628456.1382,4952790.212],[-13628330.1969,4952765.5629]]],"spatialReference":{"wkid":102100}}



This generalized JSON object works (2394 characters):

{"paths":[[[-13623091.7047,4952116.6667],[-13623005.7716,4952578.6665]],[[-13626762.4683,4952154.0091],[-13626923.4555,4952358.6161]],[[-13622801.0314,4952553.642],[-13622892.0746,4952633.953]],[[-13622943.8065,4952563.6241],[-13622537.595,4952531.6267],[-13622295.5671,4952578.8661],[-13622110.4206,4952673.6161],[-13622179.0369,4953023.6609],[-13621994.5406,4952975.6793],[-13622068.3198,4953107.3722]],[[-13623005.7716,4952578.6665],[-13622984.0156,4952499.8745]],[[-13622919.7236,4952596.1494],[-13622892.0746,4952633.953]],[[-13626299.6662,4952619.2813],[-13625728.7929,4952641.1616],[-13625707.159,4952642.362]],[[-13626299.6662,4952619.2813],[-13626689.9419,4952629.6976],[-13627081.18,4952615.3534],[-13627624.098,4952734.8192],[-13627675.9033,4952808.3042]],[[-13622892.0746,4952633.953],[-13623256.2181,4952887.0805],[-13623146.2861,4953401.2073],[-13622374.3052,4952841.6222],[-13622315.8234,4952575.3453]],[[-13625707.159,4952642.362],[-13625705.8135,4952416.661],[-13625742.7069,4952268.7129],[-13626239.1151,4952364.0777],[-13626584.8925,4952352.9089],[-13627095.8343,4952372.73],[-13627592.0384,4952434.2024],[-13628093.2158,4952495.2792],[-13628541.4208,4952547.1949],[-13628938.2628,4952496.0504],[-13629296.8716,4952444.6433],[-13629695.1347,4952534.977],[-13629910.0155,4952736.722],[-13630109.9142,4953023.1011],[-13630350.6416,4953379.193],[-13630403.8928,4953751.1667],[-13630195.4179,4953549.158],[-13629948.2039,4953255.8841],[-13629739.403,4953041.4038],[-13629509.3119,4952906.6181],[-13629286.9521,4952792.6456],[-13628941.7555,4952772.5991],[-13628847.7526,4952930.6969],[-13628683.4227,4952831.1658],[-13628330.1969,4952765.5629]],[[-13625707.159,4952642.362],[-13625333.8332,4952663.0763],[-13624814.063,4952566.5612],[-13624351.6774,4952416.3347],[-13623953.2569,4952425.3857],[-13623784.8641,4952550.665],[-13623478.6949,4952481.209],[-13623005.7716,4952578.6665]],[[-13625748.0533,4952653.4665],[-13625729.0188,4952750.7748]],[[-13626243.6816,4952741.1797],[-13626299.6662,4952619.2813]],[[-13626876.4558,4952750.2055],[-13626818.5623,4952647.9326]],[[-13626934.563,4952750.5866],[-13626841.1133,4952625.9892]],[[-13625707.8461,4952757.6262],[-13625707.159,4952642.362]],[[-13627937.4654,4952810.6528],[-13628330.1969,4952765.5629]],[[-13629028.7897,4953975.2475],[-13628930.4467,4953201.3433],[-13628330.1969,4952765.5629]]],"spatialReference":{"wkid":102100}}


Can you take a look and let me know if you have suggestions for me?
Thanks,
Andrew
0 Kudos
derekswingley1
Frequent Contributor
Here's an example using the first, larger polyline JSON you posted:  http://dl.dropbox.com/u/2654618/fl_select_using_large_polyline.txt

At this point, I'm not sure what to tell you. Can you open an incident with support? That, or post a link to a public page that reproduces the issue.
0 Kudos