View Single Post

  #3 (permalink)  
Old 09-08-2006
masty masty is offline
Junior Member
White Belt
 
Join Date: Sep 2006
Posts: 6
Hi Gianmaria,

I also need to plot a large number of pushpins in a map. I found this solution which increase a lot the speed of drawing pushpins. Anyway I also use the trick suggested by Wilfried.. only plot the points that really need.
The first suggestion is: don't use the AddPushPin method... it's good for a very few number of pushpins... otherways it takes too much time.
Use the ImportData method as shown in the follow example:

I suppose to have a DataTable (dt) with two columns. The first contains the Latitude, the second the Longitude as double data type.
From the DataTable I create first a CSV file, which consists in a list of rows with Latitude and Longitude separated by a semicolon.
Then I create a MapPoint DataSet object with the Method ImportData.
Finally I choose the symbol of the PushPins.

Hope this helps.

Everything can go faster if you use a RamDisk to save/read the CSV.

If you want to know the alghortim I used to decide which and how many points are anough for the users... just ask me.

Code:
 
DataRow dr;
//Write the CSV file.
//Open the file in the application path.
 
TextWriter txtw = new StreamWriter(Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName) +
"\\temp.csv",false);
//Write the Column Header
txtw.WriteLine("Lat;Lon");
for (int k=0;k<dt.Rows.Count; k++)
{
dr = dt.Rows[k];
Lat = (double) dr["Lat"];
Lon =(double) dr["Lon"];
txtw.WriteLine(Lat.ToString()+";"+Lon.ToString());
}
txtw.Close();
MapPoint.DataSet oDS;
//Define field specification
object[,] fieldSpecifications = null;
fieldSpecifications = new object[2,2];
//Specify what fields are geographic and what fields are not
fieldSpecifications[0,0] = "Lat";
fieldSpecifications[0,1] = MapPoint.GeoFieldType.geoFieldLatitude;
fieldSpecifications[1,0] = "Lon";
fieldSpecifications[1,1] = MapPoint.GeoFieldType.geoFieldLongitude;
oDS = map.DataSets.ImportData(Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName) + "\\temp.csv", 
fieldSpecifications, 
MapPoint.GeoCountry.geoCountryItaly,
MapPoint.GeoDelimiter.geoDelimiterSemicolon, 0);
oDS.Symbol = 37;
Reply With Quote