Hey! Here I am again with more questions =)
The short version first: I want to be able to Click on the Map and then determine if I clicked any of my custom drawn polygons. I want to do this without reloading the map/page.
I added (manually) an OnClick-event in the ASPX-file like this:
<
ContentTemplate>
<cc1:Map ID="Map1" runat="server" Width="100%" Height="100%" OnClick="Map1_Click">
</cc1:Map>
</ContentTemplate>
Then, in the CS-file I added some code like this:
protected
First problem:
Everytime I click the map the page reloads/refreshes. Isnt there some AJAX-way to execute on server and then update the client without reload?
Second problem:
The GetFeaturesTouching-method returns no Features. I cannot understand what the second parameter is (the string[]-thing) so I just made that en empty array.
Further comment:
What Im actually trying to do is to avoid having manually click an "Edit button". Instead, I want the application to understand that a User clicked a Shape and then automatically start editing that shape which is much better than changing mode manually.
I also tried to set Map1.Mode = ModeType.EditShape in the Page_Load but that didnt work at all. I tried this since I realized that the Map actually works fine in that mode at all times. Then you can always modify polygons, you can pan and zoom which is really all I need. However, I want an AJAX-like response to when an Shape is created or changed so that the new shape can be saved in the database and the map/page DOES NOT reload =)
Thanks in advance =)
void Map1_Click(object sender, MapClickedEventArgs e)
{
InMemoryLayer shapeLayer = (InMemoryLayer)Map1.DynamicLayers["shapeLayer"];
Collection<Feature> features = shapeLayer.QueryTools.GetFeaturesTouching(e.Position, new string[0] { });
if (features.Count > 0)
{
Feature feature = features[0];
shapeLayer.Features.Remove(feature.Id);
Map1.EditLayer.Features.Add(feature.Id, feature);
Map1.Mode = ModeType.EditShape;
}
}