| | trinity 12-09-2005, 12:43 AM 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)
{
??????????
} Dazzer 12-09-2005, 08:33 AM 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
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. Dazzer 12-09-2005, 08:36 AM Sorry I didn't read your previous post properly, you said you dont need to use getlocation but perhaps you do.
Again in VB
Dim dr as datarow
For each Dr in myDataSet.Tables["myTable"].Rows
ObjLoc = GetLocation(dr("Lat"),dr("Lon"), 100)
objMap.AddPushpin(objLoc)
Next Wilfried 12-09-2005, 01:08 PM 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 :) trinity 12-09-2005, 03:40 PM 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. Dazzer 12-10-2005, 06:36 AM 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. Wilfried 12-10-2005, 01:03 PM 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 :) trinity 12-12-2005, 12:44 PM 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");
} Wilfried 12-12-2005, 12:58 PM Hi,
Glad it works now for you :)
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. Dazzer 12-13-2005, 04:18 AM 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 :D ! | |