Mappoint batch import pushpin Method

Source: Internet
Author: User

In mappoint, the general method for inserting pushpin is:
Mappoint. pushpin PII = map. addpushpin (LOC, "name1 ");
If (balloonstate = 0)
Pii. balloonstate = geoballoonstate. geodisplayballoon;
Else if (balloonstate = 1)
Pii. balloonstate = geoballoonstate. geodisplayname;
Else
Pii. balloonstate = geoballoonstate. geodisplaynone;
Pii. symbol = symbol;
Pii. Highlight = highlight;
Pii. Note = "info1 ";
However, it takes about 9 minutes to insert a large number of tags in this way.
The machine configuration is Pentium (r) d CPU 2.80 GHz, GB memory.

I asked a question at the Microsoft mappoint forum and replied that using VC to write a plug-in to insert pushpin in batches can avoid the packaging time loss of COM/InterOP and the speed will be faster.
But in that case, the client layout is troublesome.
Therefore, I tried to speed up in the following ways.
If you do not need to highlight or balloonstate, the speed is faster, in about 5 seconds.

Read data from the database and generate the following format string,
Where, name is the name of pushpin, info is the prompt field, and latitude and longlatitude are the longitude and latitude coordinates of the point.

Name info latitude longpolling
Name1 info1 39.9456 75.0861
Nam2 info2 39.9625 75.0875

Write another function to import pushpin. You can also set the pushpin symbol to indicate whether the pushpin is highlighted.

Protected   Bool Importdata ( String Content, Int Balloonstate, Bool Highlight, Short Symbol)
{

Construct the fields Array # Region Construct the fields Array
Object [,] Ary =   New   Object [ 5 , 2 ];

Ary [ 0 , 0 ] =   " Name " ;
Ary [ 0 , 1 ] = Geofieldtype. geofieldname;

Ary [ 1 , 0 ] =   " Name " ;
Ary [ 1 , 1 ] = Geofieldtype. geofielddata;

Ary [ 2 , 0 ] =   " Info " ;
Ary [ 2 , 1 ] = Geofieldtype. geofieldinformation;

Ary [ 3 , 0 ] =   " Latitude " ;
Ary [ 3 , 1 ] = Geofieldtype. geofieldlatitude | Geofieldtype. geofieldskipped;

Ary [ 4 , 0 ] =   " Longpolling " ;
Ary [ 4 , 1 ] = Geofieldtype. geofieldlong.pdf | Geofieldtype. geofieldskipped;
# Endregion

write Temp File # RegionWrite Temp File
StringTempfile=Path. gettempfilename ();
Streamwriter SW= NewStreamwriter (tempfile );
Sw. Write (content );
Sw. Flush ();
Sw. Close ();
# Endregion

Import data and set pushpin features # Region Import data and set pushpin features
Try
{
Dataset DS = Map. datasets. importdata (tempfile, ary,
Geocountry. geocountryunitedstates,
Geodelimiter. geodelimitertab,
Geoimportflags. geoimportfirstrowisheadings );
If (DS ! =   Null )
{
DS. Symbol = Symbol;

Geoballoonstate bstate = Geoballoonstate. geodisplaynone;
If (Highlight | Balloonstate ! =   2 )
{
If (Balloonstate =   0 )
Bstate = Geoballoonstate. geodisplayballoon;
Else   If (Balloonstate =   1 )
Bstate = Geoballoonstate. geodisplayname;

Recordset rs = DS. queryallrecords ();
//
Rs. movefirst ();
While ( ! Rs. EOF)
{
If (Rs. pushpin ! =   Null )
{< br> Rs. pushpin. balloonstate = bstate;
If (highlight)
Rs. pushpin. highlight = highlight;
}
Rs. movenext ();
}
}
}

Return   True ;
}
Catch {Return False;}
# Endregion

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.