MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




How do I loop my dataset of Lat/Long into a map using C#?

This is a discussion on How do I loop my dataset of Lat/Long into a map using C#? within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Using C# & MP2K4, I already have a dataset that contains my Lat/Long values that I want to plot onto ...


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

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-09-2005
Junior Member
White Belt
 
Join Date: Dec 2005
Posts: 3
How do I loop my dataset of Lat/Long into a map using C#?

Using C# & MP2K4, I already have a dataset that contains my Lat/Long values that I want to plot onto a map but I don't know the correct syntax inside my foreach loop. PLEASE HELP!!!!

I don't need to use GetLocation since I already have the coordinates. I just want to shove them onto a map and display them.

//populate my dataset
System.Data.DataSet myDataSet = new System.Data.DataSet();
myDataAdp.Fill(myDataSet,"myTable");

//display a map
MapPoint.Map myMap = axMappointControl1.NewMap(MapPoint.GeoMapRegion.ge oMapNorthAmerica);
MapPoint.DataSet myMapDS = myMap.DataSets.AddPushpinSet("New PushPins");

foreach(DataRow DR in myDataSet.Tables["myTable"].Rows)
{
??????????
}
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 12-09-2005
Senior Member
Green Belt
 
Join Date: Sep 2003
Posts: 103
You need to look at the GetLocation method

I dont know about doing this in C# but in VB .Net it would be something along the lines of


Code:
Dim objLoc as mappoint.location
Dim objMap as Mappoint.map

ObjLoc = GetLocation(50.333,-1.222, 100)


objMap.AddPushpin(objLoc)
Getlocation(Lat,Lon,Altitude)

Note this is completely untested but I have done it before and i seem to remember its something along these lines, unfortunatly i'm not near somewhere I could test it at the moment.
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 12-09-2005
Senior Member
Green Belt
 
Join Date: Sep 2003
Posts: 103
Sorry I didn't read your previous post properly, you said you dont need to use getlocation but perhaps you do.

Again in VB

Code:
Dim dr as datarow

For each Dr in myDataSet.Tables["myTable"].Rows


ObjLoc = GetLocation(dr("Lat"),dr("Lon"), 100) 


objMap.AddPushpin(objLoc)


Next
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 12-09-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
Hi,

For best results make the Altitude argumen 1 instead of 100. Many mappoint calculations get inapropriate if you view it to high If you want to shoot someone you also want to be close to not miss the target
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 12-09-2005
Junior Member
White Belt
 
Join Date: Dec 2005
Posts: 3
Thanks for responding so quickly, but I don't want to use GETLOCATION as I already know where it is since I have long/lat in my dataset.

Anybody else have a suggestion.? I highly appreciate it if someone can help in c# please.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 12-10-2005
Senior Member
Green Belt
 
Join Date: Sep 2003
Posts: 103
What wilfred said about the altitude makes sense, I just put 100 in as an example.

trinity as I understand it your saying you dont want to use GetLocation because you already have the lat/lon but I think your missing the purpose of GetLocation.

Getlocation isn't used to return a set of coordinates but to return a location object on a set of coordinates that you pass it, as my code shows. As you already know the coordinates your working with you can put this in the GetLocation method to return a location object, once you have the location object you can place a pushpin or do whatever else it is that you need to do.

Perhaps i'm misunderstanding your question but this seems the logical answer to me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 12-10-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
Quote:
Originally Posted by trinity
GETLOCATION
Please dont use capitals. It is like you shout If you wants to emphrase a word use _ or use single / double quotes or make it bold text. This is very common use in news / forums / email.

thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 12-12-2005
Junior Member
White Belt
 
Join Date: Dec 2005
Posts: 3
You were right, I did misunderstand GetLocation, this is what I am using now. Thank you everybody!

MapPoint.Location mapLoc;
double dblLon;
double dblLat;

foreach (DataRow dataRow in myDataSet.Tables["myTable"].Rows)
{
dblLat = Convert.ToDouble(dataRow["Latitude"]);
dblLon = Convert.ToDouble(dataRow["Longitude"]);

mapLoc = myMap.GetLocation(dblLat, dblLon, 100);
myMap.AddPushpin(mapLoc, "PP");
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 12-12-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
Hi,

Glad it works now for you

Code:
 mapLoc = myMap.GetLocation(dblLat, dblLon, 100);
Please set altitude to 1 !!! Some methods will have a high dillusion of precision if you go so hight.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10 (permalink)  
Old 12-13-2005
Senior Member
Green Belt
 
Join Date: Sep 2003
Posts: 103
Glad we could help, the Mappoint help is actually suprisingly good at explaining a lot of its methods and properties if you continue to have problems. Of course this forum is also fantastic, its helped me a lot in the past !
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

Tags
dataset, lat or long, loop, map


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
Creating New Dataset Yazzy MapPoint 2006/2009 Discussion 4 08-23-2005 08:20 AM
Importing Lat and Long directly to Pushpin Dataset? Anonymous MapPoint 2006/2009 Discussion 1 12-21-2004 09:00 PM
How do you loop through the stops on a route? petemarkham MapPoint 2006/2009 Discussion 1 11-11-2003 12:06 PM
DataSet Modifications ? Anonymous MapPoint 2006/2009 Discussion 1 09-12-2003 03:44 AM
Need help: return to loop and continue processing David Kachuck MapPoint 2006/2009 Discussion 1 11-13-2002 11:38 PM


All times are GMT -5. The time now is 07:50 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


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 52 53 54