PDA

View Full Version : Layer and Selection Question



Kevin_Williams
12-05-2006, 01:40 PM
Hi,
I got two questions for programming with map point

1) is there a way to programmatically change the layer?
i'm using map point 2006 and i'm trying to make a button click that will change the layer from "Road Map" -> "Road and Data Map" and back

2) is there a way to tell if a "drawn object" (like a drawn rectangle) is selected?
my program has a "delete" button, but it is only used to delete drawn objects. so i was hoping to have the delete button disabled if nothing was selected and enabled if something was selected.

thank so much

Wilfried
12-05-2006, 02:37 PM
Hi,

You can use SelectionChange event for yoiu second question. As for you first question, there is no layers in mappoint.

Kevin_Williams
12-05-2006, 03:46 PM
Oh! To change the map style, it's


axMappointControl.ActiveMap.MapStyle = MapPoint.GeoMapStyle.geoMapStyle____;


I used the SelectionChange to catch the selection change
I also used axMappointControl.ActiveMap.Selection to let me know if something was selected or not.
However, I'm not able to tell if the selection is a drawn object (which I want) or a selection of a label (City, State, landmark, etc...)

Wilfried
12-07-2006, 11:23 AM
Hi,

You can check if the NewSelection argument is a Direction, Location, Pushpin, Shape, or Waypoint object. In your case you can take acton when it is a Shape object.

Kevin_Williams
12-07-2006, 12:54 PM
Sorry I have to ask this, but how to get get to the NewSelection argument?

I'm not sure what to call get the type of the selected object
axMappointControl.ActiveMap.Selection only gives me a System.__ComObject

Wilfried
12-07-2006, 01:13 PM
Hi,

No problem. What is the programming language you do it ?

Kevin_Williams
12-07-2006, 01:34 PM
I'm using C#
This is what I have so far (it's not much)


private void axMappointControl_SelectionChange(object sender, AxMapPoint._IMappointCtrlEvents_SelectionChangeEve nt e)
{
if (axMappointControl.ActiveMap.Selection == null)
{
// disable control
}
else
{
// enable control
}
}

Wilfried
12-08-2006, 03:06 PM
Hi,


Shape shape = e.pNewSelection as Shape
if (shape == null)
return;
does this help ?

Kevin_Williams
12-20-2006, 01:15 PM
Thanks Wilfried
The snippet worked

I have the following:


private void axMappointControl_SelectionChange(object sender, AxMapPoint._IMappointCtrlEvents_SelectionChangeEve nt e)
{
MapPoint.Shape shape = e.pNewSelection as MapPoint.Shape;
if (shape == null)
{
// disable control
}
else
{
// enable control
}
}