Changing the position of a shape

Last post 8/27/2008 10:45:19 PM by Chris Pietschmann. 1 replies. << Back to Web.Maps.VE v2.0 General
8/21/2008 12:55:06 PM
warnestam

Changing the position of a shape

Hi,

I'm trying to change the position of a shape on the server in the OnClick eventwitouth success. This is my code:

protected void Map1_OnClick(object sender, AsyncMapEventArgs e)

{

if (e.leftMouseButton)

{

if (CurrentUser.SelectedStationID.HasValue)

{

// Change Pushpin on screen

if (Map1.Layers.Count > 0)

{

if (Map1.Layers[0].Shapes.Count > 0)

{

Shape s = Map1.Layers[0].Shapes[0];

s.LatLong.Latitude = e.latlong.Latitude;

s.LatLong.Longitude = e.latlong.Longitude;

}

}

 

8/27/2008 10:45:19 PM
Chris Pietschmann

Re:Changing the position of a shape

Try removing the Shape from the Map, then adding it again after you change it's
location:

Shape s = Map1.Layers[0].Shapes[0];
Map1.Layers[0].Shapes.Remove(s);
s.LatLong.Latitude++;
Map1.Layers[0].Shapes.Add(s);


You can modify the Shapes other properties, like Title, during an Async Postback, but to move the Shape you'll need to remove it and add it again.