using System;
using System.Configuration;
using ThinkGeo.MapSuite.Core;
using ThinkGeo.MapSuite.WebEdition;
namespace CSSamples
{
public partial class UseDraggableMarkers : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
Map1.CurrentExtent = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962);
Map1.MapTools.PanZoomBar.Enabled = true;
Map1.MapTools.MouseCoordinate.Enabled = true;
Map1.MapUnit = GeographyUnit.Meter;
GoogleOverlay google = new GoogleOverlay("Google Map");
google.JavaScriptLibraryUri = new Uri(ConfigurationManager.AppSettings["GoogleUriV3"]);
google.GoogleMapType = GoogleMapType.Normal;
Map1.CustomOverlays.Add(google);
InMemoryMarkerOverlay inmemorymarkerOverlay = new InMemoryMarkerOverlay("InMemoryMarkerOverlay");
inmemorymarkerOverlay.Features.Add("1",new Feature(-8922952.93266, 2984101.58384));
inmemorymarkerOverlay.Features.Add("2", new Feature(-10830821.09801, 4539747.98328));
inmemorymarkerOverlay.Features.Add("3", new Feature(-12454955.13517, 4980025.26614));
inmemorymarkerOverlay.Features.Add("4", new Feature(-10772117.52067, 3864656.14956));
inmemorymarkerOverlay.Features.Add("5", new Feature(-13164290.75755, 4035875.09290));
inmemorymarkerOverlay.Features.Add("6", new Feature(-9754587.80028, 5156136.17929));
inmemorymarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageWidth = 21;
inmemorymarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageHeight = 25;
inmemorymarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageOffsetX = -10.5f;
inmemorymarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageOffsetY = -25f;
inmemorymarkerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
Map1.CustomOverlays.Add(inmemorymarkerOverlay);
inMemorymarkerOverlay.Click += new EventHandler<MarkerOverlayClickEventArgs>(inMemorymarkerOverlay_Click);
}
}
}
}
when i click on a fetaure everytime it returns same feature id but i want every feature id then how can we find the feature id.
Then How to add Click event for every Inmemory Makeroverlay Feature.why means i want to show a popup for every feature details.
How to add click event for InMemoryFeaturelayer Features
Hi rajanikanth,
The reason we can’t get the feature id is because we didn’t assign an id for the feature. In the codes, if we want to assign an id for feature, please replace the codes:
inmemorymarkerOverlay.Features.Add("1",new Feature(-8922952.93266, 2984101.58384));
with
inmemorymarkerOverlay.Features.Add("1", new Feature(new Vertex(-8922952.93266, 2984101.58384),"featureid1"));
Then we can catch the feature id in the click event of the inmemorymarkerOverlay. Btw, you may notice the obsolete warning from the Features property, I think we should follow the warning to use FeatureSource.InternalFeatures instead.
As for the second questions, if we want to show the feature details with a popup on the clicked marker, I recommend to use the FeatureSourceMarkerOverlay which is similar with inmemorymarkerOverlay but more powerful on the popup content which can be replace with the feature’s column value. More details please refer the HowDoI sample=>Markers=>AddProjectedMarkers.
More questions, please feel free to let us know.
Best regards,
Johnny