Hello,
I know we can set click event on the map control.
Is there anyway to attach/fire the click event in overlays and layers?
Thank you
shwe
Hello,
I know we can set click event on the map control.
Is there anyway to attach/fire the click event in overlays and layers?
Thank you
shwe
shwe,
With the web edition you only have the click event at the Map Level, however if you want you can apply that click to only the layer or overlay of your choice.
Thanks!
Thank you Clint.
Would you please provide a sample code for Web Edition to attach/fire click event in layers and overlays?
Thank you
shwe
Hello,
Here is my code.
private void CreateSalesAreaLayer(LayerOverlay saOverlay, string saName)
{
//This is bottom layer and this layer starts to show only at the zoom level = 12 up to zoom level = 20
//In this layer we show zip codes as text on the feature
InMemoryFeatureLayer saZipsLayer = new InMemoryFeatureLayer();
saZipsLayer.Name = saName + "_ZIPS";
saZipsLayer.Open();
saZipsLayer.Columns.Add(new FeatureSourceColumn("ZIPCODE"));
saZipsLayer.Close();
saZipsLayer.ZoomLevelSet.ZoomLevel12.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(150, GeoColor.StandardColors.CadetBlue));
saZipsLayer.ZoomLevelSet.ZoomLevel12.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
saZipsLayer.ZoomLevelSet.ZoomLevel12.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("ZIPCODE", "Arial", 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3);
saOverlay.Layers.Add(saName + "_ZIPS", saZipsLayer);
//====================================================
//This is top layer and it starts to show only at the time of zoom level = 01 up to zoom level = 11
//SALESAREA is custom column and in this layer, we show the sales area name as text on the feature
InMemoryFeatureLayer saLayer = new InMemoryFeatureLayer();
saLayer.Name = saName;
saLayer.Open();
saLayer.Columns.Add(new FeatureSourceColumn("ZIPCODE"));
saLayer.Close();
saLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(150, GeoColor.StandardColors.CadetBlue));
saLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level11;
saLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("SALESAREA", "Arial", 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3);
saLayer.FeatureSource.CustomColumnFetch += new EventHandler<CustomColumnFetchEventArgs>(CustomColumnFetch_GetSalesArea);
saOverlay.Layers.Add(saName, saLayer);
}
Here we have two layers and we show one layer at a time depending on the zoom level.
So at the time user clicked, would you please tell me if there is any way we can know which layer did user click?
Thank you
shwe
shwe,
Thanks for your reply, there are a couple ways to do this but the easiest if you only have two layers you are dealing with is to check the current scale of the map and then choose the layer you want to apply the click event too.
For example if you had your sales territory layer showing from 1 to 11 and then your zip code layer showing from 11 to 20 then your code to choose the correct layer would look something like this:
if (saZipsLayer.ZoomLevelSet.ZoomLevel12.Scale > Map1.CurrentScale)
{
// Do Query to find feature on Sales Territory Layer
}
else
{
// Do query to find feature on zip code layer
}
You will probably also want to take a look at the "FindTheFeatureTheUserClicked" under the Getting Started section of the How Do I sample apps.
Hope this helps, but please let us know if you have any questions.
Thanks!