MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




AddPolyLine dilemma - is it GetLocation here that's problematic ?

This is a discussion on AddPolyLine dilemma - is it GetLocation here that's problematic ? within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hi folks Using VB6 and the MapPointControl here I'll paste code as I find searching these boards, I've learned a ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  6 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 11-01-2007
Member
Yellow Belt
 
Join Date: Feb 2005
Posts: 48
AddPolyLine dilemma - is it GetLocation here that's problematic ?

Hi folks

Using VB6 and the MapPointControl here

I'll paste code as I find searching these boards, I've learned a good bit from the code examples from peoples problems.

I have a custom poly approach where I build an array of Location objects (zero based). I trap when CTRL is pressed to know when to add the point, as I want users to still have normal mouse function with the MapPoint ActiveX Map control - I THEN assign this to a final Shape Object for the current workspace using the .AddPolyLine

example:
Set oCurrentShapeFinal = MappointControl1.ActiveMap.Shapes.AddPolyline(oLoc ations)

This works great. I of course require them to Close the polygon using right click exposure to Close - but that's not issue.

I allow the user to SAVE this polygon, I figured gee, I should be able to comprise the users poly data with lat, lon and a verticeIndex to keep the order right.

Because I let the user have multiple poly's on the MP control, I use a generic NAME property for current poly being edited with NewPoly. So just understand the outer loop is to isolate the shape I want.


Dim dLat As Double
Dim dLon As Double
Dim oloc As MapPoint.Location
lCnt = 0

Dim objShape As MapPoint.Shape

For Each objShape In MappointControl1.ActiveMap.Shapes

If objShape.Name = "NewPoly" Then

For iVertices = 0 To UBound(objShape.Vertices)
ReDim Preserve dCurrentShapeLongitude(0 To lCnt)
ReDim Preserve dCurrentShapeLatitude(0 To lCnt)

CalcPos frmMapRef.MappointControl1.ActiveMap, objShape.Vertices(iVertices).Location, dLat, dLon
dCurrentShapeLongitude(lCnt) = dLon
dCurrentShapeLatitude(lCnt) = dLat
lCnt = lCnt + 1
Next
End If

Next



All is well - any new users here, CalcPos can be found throughout this board. It's an outside function to get Lat Lon from XY on the MP Control. (Funny there is more ingenuity from this forum seemingly than inhouse at MS - no comment).



Well, all was well until I went to let the user LOAD the shape back in.

I thought, ok, I'll call the MP .GetLocation that allows me to create a new Location object (I need to rebuild an arrayed Location Object to feed to .AddPolyLine) from lat lon. I pulled ors - my recordset object ordered by verticeIndex from my 3 field table - ok 4 with key, but 3 fields used are lat, lon and vertice index on key.

I use ltemp as a counter here - just a generic long (VB6 compiler actually performs better with longs, SIDE issue heh - strange but true)

While Not ors.EOF

ReDim Preserve oLocations(0 To lTemp)

ReDim Preserve dCurrentShapeLongitude(0 To lTemp)
ReDim Preserve dCurrentShapeLatitude(0 To lTemp)

dCurrentShapeLongitude(lTemp) = ors.Fields("latitude")
dCurrentShapeLatitude(lTemp) = ors.Fields("longitude")

Set oLocations(lTemp) = MappointControl1.ActiveMap.GetLocation(dCurrentSha peLatitude(lTemp), dCurrentShapeLongitude(lTemp))
lTemp = lTemp + 1
ors.MoveNext

Wend


Set oCurrentShapeFinal = MappointControl1.ActiveMap.Shapes.AddPolyline(oLoc ations)



Well - no poly showed up. Where oCurrentShapeFinal works just fine when creating it as the user creates their poly ?
Nothing here. No show. It shows fine when I feed it my arrayed Location Object using XY but apparantly ? my location object using GetLocation ? I'm just not sure, am I not getting the exact same arrayed location object rebuilding it thinking that lat lon would be enough to reconstruct it ?

It is identical to my assignment of oCurrentShapeFinal that CLEARLY works in creating the polygons.

Yet ?

To my dismay - NO custom shape appeared on the MapPoint Control on passing my ressurected Location Object array to feed to the Shape object I sought to populate using AddPolyLine


so here I am wondering, gee, what's going wrong here.

Is it my Location object array ? that's not identical ?

When the user creates the custom poly, I use

Set oLocations(lPointMaxCnt) = MappointControl1.ActiveMap.XYToLocation(X, Y)

I'm always impressed at the organization of the MP Object Model, but.

Is a location object a location object a location object etc ?

I mean, Whether I assign a location object using .XYToLocation OR .GetLocation ?

isn't it the same result ?

Either way, I THINK and FEEL that my arrayed location object is fine - reconstituting it from lat lon ordered by verticeIndex in a table.

And I expect to be able to pass this arrayed location object to a shape object using .AddPolyLine(myLocationObjectHere)

this works in creating the initial poly, but when I go to recreate 'as if' a user did this ? to give them the experience of 'Loading' a custom poly ?

Nothing.

Nothing shows.

So, I ask the community here, any insights ?

thanks in advance.

It's gonna be Eric, Winwaed, or Wilfried, prolly Wilfried ! ok ok - really, anyone who has any insights, please do share.

Thanks.

I do hope the code I posted helps someone who may in some way be trying to even get to first base here !

I'm just going for a triple (I really am not fan of baseball, but the allegory seems right)

Not sure what the Homerun is with MP ! heh. Probably getting multiple control instances to not conflict with multiple app instances - did read that article on how to prevent that jittery window flux when doing that ! heh.

Tim Miltz

Last edited by tfmiltz; 11-01-2007 at 01:16 AM. Reason: correction
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 11-01-2007
Member
Yellow Belt
 
Join Date: Feb 2005
Posts: 48
Re: AddPolyLine dilemma - is it GetLocation here that's problematic ?

Just to condense my point.

I have a successful use of .AddPolyline on a shape object - passing it an arrayed Location Object (zero based).

I use the .vertices(index).Location property to pass off to the CalcPos function to get me lat/lon + the index to store in a table.

This is used to recreate the polygon.

Yet ?

When I go to recreate my array of location objects (same arrayed var actually that works in edit mode) ? I use the .GetLocation method because I can pass it lat/lon, which I figured would be enough data to recreate each vertice of the polygon.

Yet ? After I repopulate my Location Object array ?

and pass IT off - just like I do successfully when user creates the poly ?

to the final Shape object using .AddPolyLine (my_arrayed_location_object_here) ?

no shape on the mappoint control.

yet same methodology SHORT - only difference I can see is how I create my location object.

When I get a successful .AddPolyLine method fired off on a shape object ? I'm creating the Location object using XY, and latter case I create it using GetLocation using the Lat/Lon I store.

I'm guessing it has something to do with my Location Object and how I'm creating it.

But I'd think a location object is a location object is a location object whether I create it from lat/lon OR XY - for - .GetLocation works using lat lon, and XY works by XY.

I made sure I set .Line.Forecolor just in case to vbBlack -

This is just an unexpected hurdle in closing this poly issue ! pun intended !

Thanks Wilfried in advance ! Cause I just know you're going to probably have some insight here.

If I actually MADE any money, I'd forward you some. ! heh

Tim Miltz
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 11-01-2007
Member
Yellow Belt
 
Join Date: Feb 2005
Posts: 48
Re: AddPolyLine dilemma - is it GetLocation here that's problematic ?

JEebus

X Y holds true

I would NOT expect X Y to hold relative, er, absolute values to where I sought Lat Lon to state what is objecively REAL.

Just tried X Y vals over lat lon - and got MOST of my shape back.

I'll continue onward but this is sketchy to me- that MP won't let me feed it an array of lat/lon to create an arrayed location object and then feed IT to a shape object to fire off .AddPolyLine.

Any insights welcome.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 11-01-2007
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 787
Blog Entries: 5
Re: AddPolyLine dilemma - is it GetLocation here that's problematic ?

Try modifying your GetLocation call to include an altitude.
Some of the documentation marks this as optional, but some does not. Try a dummy value of 100.

Otherwise it must involve the control or be something subtle with what you are doing - I frequently create polygon shapes using lists of coordinates, albeit using the Application object (both GridImp and MPSuperShape do this under the hood). No problems.

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 11-02-2007
Member
Yellow Belt
 
Join Date: Feb 2005
Posts: 48
Smile Re: AddPolyLine dilemma - is it GetLocation here that's problematic ?

Go figure

I didn't think through that the lat lon pairs I saved ? I didn't save start point as last point

well - I still won't do that for economy - BUT

runtime I do now - outside of my loop assigning the arrayed location object ? - assign ONE MORE location - heh - no doubt assigning it to the start lat / lon to close the poly.

This worked in the end.

Thanks WinWaed -

not only do you make MY day- you make the entire community's day here !

Thanks

Tim Miltz

Last edited by tfmiltz; 11-02-2007 at 02:40 AM. Reason: name error
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/addpolyline-dilemma-getlocation-here-thats-problematic-6669.html

Posted By For Type Date
MapPoint Download - MP2K Magazine This thread Refback 11-06-2007 11:52 AM
Apple Blog » Blog Archive » AddPolyLine dilemma - is it GetLocation here that’s problematic ? This thread Pingback 11-05-2007 04:57 PM
Create 3D Map Video - Win a Free Zune from Microsoft - MapPoint News - MP2K Magazine This thread Refback 11-05-2007 06:48 AM
Merging Multiple Routes - MapPoint Articles - MP2K Magazine This thread Refback 11-04-2007 04:15 PM
Programming MapPoint via .NET - MapPoint Articles - MP2K Magazine This thread Refback 11-02-2007 07:37 AM
Determing Whether A Point Is Located Inside Polygon - MapPoint Articles - MP2K Magazine This thread Refback 11-02-2007 07:28 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Addpolyline from a dataset micheln MapPoint 2006/2009 Discussion 3 05-04-2007 06:49 AM
Shapes.AddPolyline is very slow tdaffin MapPoint 2006/2009 Discussion 4 01-27-2006 07:08 AM
Speeding up Getlocation queries? Help! Solo4357 MapPoint Web Service and Virtual Earth 0 10-13-2005 02:34 PM
Getlocation in VB .net wallacech MapPoint 2006/2009 Discussion 1 12-11-2003 02:27 PM
addpolyline Anonymous Wish List 2 04-25-2003 03:50 PM


All times are GMT -5. The time now is 10:24 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map

Andorra Ski Holidays
Andorra ski holidays offer tax-free shopping and a range of great après-ski activities when you have finished on the slopes. Book online today.

City Break Holidays
Top 10 City Breaks Holidays. Based on holidays booked this year, these are the most popular City Breaks Holidays for 2006

Thailand Holiday
A Thailand Holiday has much to offer with historic culture, lively arts, beautiful beaches, a good nightlife, friendly and hospitable people and one of the best cuisines in the world.

Nile Cruises
Nile cruises are one of the best ways to discover the riches of Egypt. See ancient ruins and lush verdure from the River Nile. Book today!

Turkey
Before booking a holiday to Turkey check out the ULookUBook travel guide. Find out about the rich culture in Turkey before you go there to help you to make the most of your holiday.

Compare Holidays
Compare holidays online where you can see all the amazing possibilities at Travel.co.uk

Cheap Holidays in Florida
Legendary weather! Visit On The Beach for info on cheap holidays in Florida.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51