ThinkGeo.com    |     Documentation    |     Premium Support

Merging polygons at the server side in a customized MsSql2008FeatureLayer

i have already customized MsSql2008FeatureLayer, that allows the value of a field is updated on the fly. This feature Layer is corresponding to one sql table with spatial data and also other non-spatial attributes.

I know when the map bounding box changes, the featureLayer retrieves spatial features again.

In my case, for example, for a zipcode layer, i know which zipcode polygons should merge into one big one. How can i tell the FeatureLayer these merged polygons with attributes/styles to draw on map?

These merging information do not need to persist in the database. Users can change which zip code polygons to merge from other interface by choosing zip codes, for example.

thanks,

Hi Guangming,

It looks you want to dynamic create polygons and render them.

I think if you cannot build a special table for saved them and render them, maybe you don’t want to show them as MsSql2008FeatureLayer, you can query them back and put them into inmemoryfeaturelayer, then do anything you want to do.

Regards,

Don

Thanks, Don. I will try that.

Hi Guangming,

Any question please let us know.

Regards,

Don

an inMemoryLayer seems not preferred.

Can i try this method?

  1. catch this event: OnDrawingFeatures
  2. modify FeaturesToDraw of the arg DrawingFeaturesEventArgs (basically, with the information i know, i will merge multiple polygons into one on the fly)

however, this method, will trigger merging operation any time, for example, when zooming, panning, …

The ideal method is to create these merged features when the layer is created, made these features available for the future. Is there any way (or is the API flexible enough) to do this?

Thanks,

Guangming

Hi Guangming,

The problem is if you zoom or pan out of current extent, the layer will read new feature from database, which means the “first time” render the new features. When the layer is created, it won’t read all features from database, it only read the features which will be rendered in current extent.

So I think the solution should be like these:

  1. Merge the features in Database
  2. Follow your logic, adjust all the features which will be rendered in current extent, modify them on the event. You cannot avoid pan/zoom, they should handle the features also.
  3. I don’t know why the inmemory layer don’t works, but I think when layer created, read all features from database and insert them into inmemory layer should be easier.

Regards,

Don