Community of VE/MapPoint Users and Developers
This is a discussion on Where did I click on that line? within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; On my application I have a list box which displays a journey with time and location gathered from a GPS ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Where did I click on that line? When the user clicks on any journey point in the list box I go to that point on the map so the map display is updated with where he is. What I would like to do also is work the other way. Allow the user to click on the track and reposition the listbox display to the corresponding journey point. This is needed since the journey can consist of thousands of points and there is important other information gathered with the GPS signal. My first thought was to use the map SelectionChange event which fires when the user first clicks on the line. From that determine the what had been selected (the line) from the GetItemType method. But that is going no where! There are no parameters in the event that I can use to determine what part of the line was clicked - the whole line is selected, not a point or a line segment. Any ideas how I can work back to the location nearest to the point I clicked on the line? TIA |
| ||||
|
Hmm, I thought there was somewhere to get at a selected vertex, but I've just had a quick scan through the docs for the event and I can't see anything. If you have "thousands" of vertices it might be a bit slow, but you could try a brute-force search. Get the mouse position immediately after the event fireing. Start at the beginning, compare each location in the track against the mouse position. Do with with a simple "DistanceTo" call. Choose the vertex with the lowest distance. Depending on how complex your track is, there are probably ways to speed it up. Eg. if they tend to approximate straight lines then a simple "binary chop" algorithm will change the search space from N to log2(N). Richard
__________________ Winwaed Software Technology LLC http://www.winwaed.com See http://www.mapping-tools.com for MapPoint Tools Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009 |
| |||
|
Ouch! I was afraid I would have to find a brute strength answer. Unfortunately the tracks can be complex and often parallel (journey to and return). Hence picking out the nearest vertex could often miss the spot by hours. However you have got me thinking If i develop a brute strength scheme which provides alternative hits then I could examine the line equation between vertices and determine mathematically if the point lies on that line. Thanks |
| |||
|
Solved Instead of plotting one long line for the track I split it up into segments no more than 15 minutes journey time long. Each journey segment is assigned a shape name which includes the listbox index of the first vertex on the line. When the user clicks on the track I use the name of the shape selected to work back to the listbox ensure the originating reading is selected and visible. So the user doesn't get to the nearest point on the track but within a reasonable region of the journey (given that reading at most every 30 seconds). It is slower to plot the track for a long journey but 15 minute segments is a good compromise. Thanks |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to add click event for VB.Net ? | Anonymous | MapPoint 2006/2009 Discussion | 2 | 12-31-2003 12:15 AM |
| Double Click on map | Anonymous | MapPoint 2006/2009 Discussion | 0 | 08-08-2003 06:42 PM |
| How can I create a line between two line with VB6 | Anonymous | MapPoint 2006/2009 Discussion | 0 | 04-29-2003 05:44 PM |
| What happens when YOU click on a street? | schuchhardp | MapPoint 2006/2009 Discussion | 5 | 01-03-2003 10:37 AM |
| As I draw a line and then a pushpin on that line, .... | Anonymous | MapPoint 2006/2009 Discussion | 1 | 07-16-2002 08:35 AM |
Ski Holidays France
Ski holidays in France are popular with both beginners and experienced skiers alike. It's easy to see why in light of the huge diversity of slopes and the numerous entertainment options.
Portugal Holidays
Find great Portugal Holidays with Travel Counsellors. A personal Travel Counsellor can help you plan the perfect holiday to Portugal.
Holidays Thailand
Holidays in Thailand are hugely diverse with wonderful luxury resorts and beaches but also some lovely forested mountains with interesting hill tribes. See dealchecker.co.uk.
Holidays in Egypt
A holiday in Egypt will stimulate your mind, captivate your heart and spark your senses. Visit this exceptional country, book today!
Cheap Spain Holidays
Stay well informed when you are searching for cheap holidays online. For useful advice on when to book cheap Spain holidays make sure you look on ulookubook.com
Cheap Travel
Travel.co.uk has some excellent offers on cheap travel. Click here.
Sharm el Sheikh Holidays
Visit Egypt! Get info on Sharm El Sheikh holidays, only at On The Beach.