i am using inmemoryfeaturelayer to bring my sql server data into thinkgeo map and my code is:
InMemoryFeatureLayer myData = new InMemoryFeatureLayer();
myData.ZoomLevelSet.ZoomLevel01.DefaultPointStyle =
PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.Blue, 10);
myData.ZoomLevelSet.ZoomLevel01.DefaultLineStyle =
LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.Green, 6, false);
//Make All Polygons Red with a black outline.
myData.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle =
AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Red, GeoColor.StandardColors.Black);
//Add a Text Style to Label the shapes on the map.
myData.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("Name", "Arial", 10,
DrawingFontStyles.Bold, GeoColor.StandardColors.Black);
myData.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen = new GeoPen(GeoColor.StandardColors.White);
//Apply these styles to all zoom levels
myData.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
return myData;
circle is display in thinkgeo map but now
i wants to create a clickable marker on mydata i try like this
MarkerOverlay markerOverlay = new FeatureSourceMarkerOverlay(myData.ToString());
markerOverlay.Click += btnsave_OnClick;
but it does not working please provide me information about this. thanks in advance
Create marker as clickable
Hi Raja,
Why not choose SimpleMarkerOverlay?
I tested it and it looks work well.
SimpleMarkerOverlay simpleMarkerOverlay = new SimpleMarkerOverlay();
simpleMarkerOverlay.DragMode = MarkerDragMode.None;
Marker marker = new Marker(Map1.CurrentExtent.GetCenterPoint());
simpleMarkerOverlay.Markers.Add(marker);
simpleMarkerOverlay.Click += new EventHandler<MarkerOverlayClickEventArgs>(simpleMarkerOverlay_Click);
void simpleMarkerOverlay_Click(object sender, MarkerOverlayClickEventArgs e)
{
string clickedMarkerId = e.FeatureId;
}
Regards,
Don
hi don,
i tried your given code but there is error on
simpleMarkerOverlay.Click += new EventHandler(simpleMarkerOverlay_Click);
it says pass method argument i passed it like
simpleMarkerOverlay.Click += new EventHandler(simpleMarkerOverlay_Click(this,new MarkerOverlayClickEventArgs()));
it still give me error could you please give me error free example of marker
thanks.
Hi Raja,
As below is the simple test sample, you can also use the code replace the UseDraggableMarkers.aspx.cs in our HowDoISamples, it works well in my machine.
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.MapUnit = GeographyUnit.Meter;
SimpleMarkerOverlay simpleMarkerOverlay = new SimpleMarkerOverlay("MarkerOverlay");
simpleMarkerOverlay.Click += new EventHandler<MarkerOverlayClickEventArgs>(simpleMarkerOverlay_Click);
simpleMarkerOverlay.DragMode = MarkerDragMode.Drag;
simpleMarkerOverlay.Markers.Add(new Marker(-8922952.93266, 2984101.58384, new WebImage(21, 25, -10.5f, -25f)));
simpleMarkerOverlay.Markers.Add(new Marker(-10830821.09801, 4539747.98328, new WebImage(21, 25, -10.5f, -25f)));
simpleMarkerOverlay.Markers.Add(new Marker(-12454955.13517, 4980025.26614, new WebImage(21, 25, -10.5f, -25f)));
simpleMarkerOverlay.Markers.Add(new Marker(-10772117.52067, 3864656.14956, new WebImage(21, 25, -10.5f, -25f)));
simpleMarkerOverlay.Markers.Add(new Marker(-13164290.75755, 4035875.09290, new WebImage(21, 25, -10.5f, -25f)));
simpleMarkerOverlay.Markers.Add(new Marker(-9754587.80028, 5156136.17929, new WebImage(21, 25, -10.5f, -25f)));
Map1.CustomOverlays.Add(simpleMarkerOverlay);
}
}
void simpleMarkerOverlay_Click(object sender, MarkerOverlayClickEventArgs e)
{
string clickedMarkerId = e.FeatureId;
}
}
}
Regards,
Don
hi don thanks very much for your answer and yes code is working fine now . i have one more question can i get click marker coordinate in click event thanks in again.
Hi Raja,
I think you can get position like this:
void simpleMarkerOverlay_Click(object sender, MarkerOverlayClickEventArgs e)
{
string clickedMarkerId = e.FeatureId;
SimpleMarkerOverlay simpleMarkerOverlay = Map1.CustomOverlays[0] as SimpleMarkerOverlay;
Marker clickedMarker = simpleMarkerOverlay.Markers[clickedMarkerId];
PointShape position = clickedMarker.Position;
}
Regards,
Don
thanks it is very kind thank you very much
Raja,
If any other questions, don’t hesitate to let us know.
Tanks,
Troy