Community of VE/MapPoint Users and Developers
This is a discussion on Polygonsearch with C# within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Can anyone please help me with some C#-code on how to get a working polygon-search method...?...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
|
Hi, can you explain what you exacly means by "polygon-search method" ?
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
|
I want to draw a polygon on the map with the freeform tool. The metod should for instance return all the pushpins in the area that the polygon encloses. I want to be able to do a search within the polygon only, not the whole map. |
| |||
|
Hi, Yu have to make triangles from out of the polygon (not a real problme of course but not coded in 5 minutes
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
|
I found this code in VB.NET. It should do the trick. Code: Dim a As MapPoint.Shape
Dim objDataSet As MapPoint.DataSet
Dim objRecordset As MapPoint.Recordset
ListBoxValdaKunder.Items.Clear()
If Karta.ActiveMap.Shapes.Count > 0 Then
objDataSet = Karta.ActiveMap.DataSets("sbg031_2003")
Cursor.Current = Cursors.WaitCursor
a = Karta.ActiveMap.Shapes(Karta.ActiveMap.Shapes.Count)
objRecordset = objDataSet.QueryShape(a)
If objRecordset.EOF = False Then
Do Until objRecordset.EOF
ListBoxValdaKunder.Items.Add(objRecordset.Pushpin.Name)
objRecordset.MoveNext()
Loop
End If
End If
Code: objDataSet = Karta.ActiveMap.DataSets("sbg031_2003")
|
| |||
|
Hi, QueryShape returns all records within a shape (learned again something new). So when you add the pushpins to the map you add them as whell into a dataset. And itis _that_ dataset you have to use.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
|
Hi, I had a moment of free time so I did a little experiment, as I did not knew the answer for your problem eather. It seems that pushpins are always added to a "default" dataset. I assume it is always the first one in the collection. This is what I tryed: Code: uint Count = 10;
Location Loc;
Pushpin PP;
Double Lat = 50;
Double Lon = -3;
Double Alt = 1000;
while (Count-- > 0) {
Lon += 0.5;
Loc = MP.ActiveMap.GetLocation(Lat, Lon, Alt);
PP = MP.ActiveMap.AddPushpin(Loc, "Kieken");
PP.Symbol = 1;
}
MP.ActiveMap.DataSets.ZoomTo();
Code: Loc = MP.ActiveMap.GetLocation(Lat, Lon, Alt);
Shape s = MP.ActiveMap.Shapes.AddShape(GeoAutoShapeType.geoShapeRadius, Loc, 100, 100);
s.Line.Weight = 0;
s.Select();
object o = 1;
Recordset rs = MP.ActiveMap.DataSets.get_Item(ref o).QueryShape(s);
rs.MoveFirst();
while (!rs.EOF) {
Console.WriteLine(rs.Pushpin.Name.ToString());
rs.MoveNext();
}
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
|
Hi, I did a litte additional research and tought to put it here as it can benefit you and others. First of all this dataset where pushpins are added has the name 'My Pushpins". I found this like this: Code: MapPoint.DataSets ds = MP.ActiveMap.DataSets;
foreach (MapPoint.DataSet d in ds)
Console.WriteLine(d.Name);
Code: o = "My Pushpins";
rs = MP.ActiveMap.DataSets.get_Item(ref o).QueryShape(s);
rs.MoveFirst();
while (!rs.EOF) {
rs.MoveNext();
}
Code: MapPoint.DataSet InCircle = MP.ActiveMap.DataSets.AddPushpinSet("In circle");
rs.MoveFirst();
while (!rs.EOF) {
rs.Pushpin.MoveTo(InCircle);
rs.MoveNext();
}
o = "In circle";
rs = MP.ActiveMap.DataSets.get_Item(ref o).QueryShape(s);
rs.MoveFirst();
while (!rs.EOF) {
rs.MoveNext();
}
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| Tags |
| polygonsearch |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Flight to Tenerife
Don't check in before you check out Holiday Hypermarket. Book a low cost flight to Tenerife and soak up some Canary Island sun.
Independent Travel Agent
Travel Counsellors is a completely Independent Travel Agent. Our travel agents are free to help with your travel plans.
Cuba Holiday
A Cuba Holiday has so much to offer with numerous different cultures affecting the sights, sounds and tastes. Visit this fascinating country with dealchecker.co.uk.
Holidays to Mauritius
Visit the paradise island in your holidays to Mauritius. Enjoy the friendliness of the locals, the warm of the sun and the beauty of the views!
Cyprus
Before visiting Cyprus, make sure you are well informed to make the most of your holiday. Online at ulookubook.com you check out our useful travel guides. Find out all about the Cyprus nightlife, shopping, eating and customs.
Travel Deals
Find the very best travel deals on your prime comparison site, Travel.co.uk
Holidays to Florida
Sun and sea! Get info on holidays to Florida, only at On The Beach.