Find layer geometry type

4903
13
08-15-2011 04:01 AM
BabbageOcelot
New Contributor
Hello all,

I may just be being dim on a Monday afternoon, but I can't seem to find any way of finding a layer's specified geometry type. This is shown in the REST endpoint as "Geometry Type: esriGeometryPoint"; unfortunately it doesn't seem to be exposed in either the Layer properties, or in the layerInfos object.

What I need to do is create a custom-symbolised featureLayer on the fly, and in order for that to work I need to know the geometry present in this particular layer.

Sadly, I can't use layerDefinitions (which would be far more appropriate).

Any ideas?

- Ben
0 Kudos
13 Replies
HemingZhu
Occasional Contributor III
Hello all,

I may just be being dim on a Monday afternoon, but I can't seem to find any way of finding a layer's specified geometry type. This is shown in the REST endpoint as "Geometry Type: esriGeometryPoint"; unfortunately it doesn't seem to be exposed in either the Layer properties, or in the layerInfos object.

What I need to do is create a custom-symbolised featureLayer on the fly, and in order for that to work I need to know the geometry present in this particular layer.

Sadly, I can't use layerDefinitions (which would be far more appropriate).
Any ideas?

- Ben


FeatureLayer.geometryType.
0 Kudos
BabbageOcelot
New Contributor
FeatureLayer.geometryType.


Hi Heming,

thanks - turns out I am being dim on a Monday. Create the feature layer, *then* find the geometry type, symbolise accordingly.

It is a little strange that the type isn't accessible without first creating a featureLayer; I'd expect that to be in layerInfos[layerId], or similar.

Cheers,

Ben.
0 Kudos
HemingZhu
Occasional Contributor III
Hi Heming,

thanks - turns out I am being dim on a Monday. Create the feature layer, *then* find the geometry type, symbolise accordingly.

It is a little strange that the type isn't accessible without first creating a featureLayer; I'd expect that to be in layerInfos[layerId], or similar.

Cheers,

Ben.



I agreed with you on that.
0 Kudos
MichaelKyffin
New Contributor
I agreed with you on that.


Yes - I think being able to expose the geometry type of the (sub) layers could be useful for many, many reasons. I'm surprised this isn't in layerInfos, actually. It's a little silly to have to create a feature layer just to get at this.
0 Kudos
MarkSmith
New Contributor III
Hi,

Can you help me out please?  I've just been looking at this too but can't work out what I'm getting wrong.  I have the following lines to try and work out what the geometry type of a layer is, but my alert just give me 'undefined', can you please show me the correct way of getting this?

anFeatureLayer = new esri.layers.FeatureLayer("http://server/ArcGIS/rest/services/service/FeatureServer/0", {mode: esri.layers.FeatureLayer.MODE_SELECTION});
    geomType = anFeatureLayer.geometryType
    alert(geomType)

Thank you.
0 Kudos
JayJohnson1
New Contributor
Yes - I think being able to expose the geometry type of the (sub) layers could be useful for many, many reasons. I'm surprised this isn't in layerInfos, actually. It's a little silly to have to create a feature layer just to get at this.


The reason it's not exposed is because not all layers are feature layers. Some layers are rasters.
0 Kudos
MichaelKyffin
New Contributor
The reason it's not exposed is because not all layers are feature layers. Some layers are rasters.


Agreed - but I wouldn't want to use feature layers at all, but rather the index of the "sub"layer inside a map service. Additionally, the geometryType of the feature layer isn't exposed until it's added to the map.
0 Kudos
StephanieSnider
Occasional Contributor III
So what should I do if the geometry type is blank in the map service for a point layer?  I have some point layers that are set to "esriGeometryPoint", but others are just blank.  This causes a problem when trying to work with the ArcGIS Viewer for Silverlight.  I cannot use the layer because the geometry type is "unspecified".  How do I set the geometry type of an unspecified layer?

Here's an example of a point layer with an unspecified geometry type:
http://ndep-emap.nv.gov/ArcGIS/rest/services/eMap/MapServer/17
0 Kudos
HemingZhu
Occasional Contributor III
So what should I do if the geometry type is blank in the map service for a point layer?  I have some point layers that are set to "esriGeometryPoint", but others are just blank.  This causes a problem when trying to work with the ArcGIS Viewer for Silverlight.  I cannot use the layer because the geometry type is "unspecified".  How do I set the geometry type of an unspecified layer?

Here's an example of a point layer with an unspecified geometry type:
http://ndep-emap.nv.gov/ArcGIS/rest/services/eMap/MapServer/17


That is causing your featureLayer's geometry being undefined (I tried featureLayer.graphics[0].geometry.type too). That is interesting!!
0 Kudos