Bing map development tutorial 3: Custom Translation

Source: Internet
Author: User

 

For the translation function, the first thing to note is that Bing map's Chinese API cannot be accurately translated to a map area centered on a longitude and latitude. According to relevant documents of China, all electronic maps must go through the vector offset. Therefore, the position obtained by directly inputting the latitude and longitude is somewhat different from the actual position. This article will show three translation modes: direct translation by longitude and latitude, manual translation, and continuous translation. First, let's take a look at the direct translation of longitude and latitude. We define a translation function: Function panlatlong (c)
{
VaR lat = Document. getelementbyid ('txtmaplat'). value;
VaR Lon = Document. getelementbyid ('txtmaplon '). value;
Map. pantolatlong (New velatlong (Lat, Lon ));
}
The longitude and latitude of the translation are obtained from the input box. Therefore, you must add two input boxes in the HTML body. The corresponding IDs are TxtmaplatAnd Txtmaplon: <Div>
Dimension: <input id = 'txtmaplat' style = 'width: 30px 'Type = 'text' value = '36'/>
Longitude: <input id = 'txtmaplon 'style = 'width: 30px 'Type = 'text' value = '000000'/>
<Input type = 'button 'value = 'latitude and longitude translation 'onclick = 'panlatlong (); '/>
</Div>
The second function is manual translation. The user inputs the size of the current map as the center translation volume. Similarly, we need to define a function: Function panxy ()
{
VaR x = Document. getelementbyid ('txtmapx'). value;
Var y = Document. getelementbyid ('txtmapy'). value;
Map. Pan (x, y );
}

We add two input boxes in the HTML body field to allow users to enter the translation quantity. The IDS are txtmapx and txtmapy: <Div>
X: <input id = 'txtmapx' style = 'width: 30px 'Type = 'text' value = '1'/>
Y: <input id = 'txtmapy' style = 'width: 30px 'Type = 'text' value = '1'/>
<Input type = 'button 'value = 'manual translation 'onclick = 'panxy ();'/>
</Div>
Next, let's take a look at the implementation of continuous translation. Continuous translation can be applied in many places, such as online travel. When displaying users' travel routes, you can use continuous translation to visually display users' footprints. Here we need to define two functions: Start translation and End translation: Function startcontinuous ()
{
VaR x = Document. getelementbyid ('txtmapxspeed'). value;
Var y = Document. getelementbyid ('txtmapyspeed'). value;
Map. startcontinuouspan (x, y );
}

Function endcontinuous ()
{
Map. endcontinuouspan ();
}
Then, we add two buttons in the HTML body field, corresponding to start translation and End translation. An input box is provided to allow users to enter the continuous translation speed: <Div>
X (speed): <input id = 'txtmapxspeed' style = 'width: 30px 'type = 'text' value = '1'/>
Y (speed): <input id = 'txtmapyspeed' style = 'width: 30px 'type = 'text' value = '1'/>
<Input type = 'button 'value = 'Start continuous translation 'onclick = 'startcontinuous ();'/>
<Input type = 'button 'value = 'End continuous translation 'onclick = 'endcontinuous ();'/>
</Div>
The code of the above three methods can be pasted together in the display map code described in the first lecture, or you can add a method separately. I will not write the complete code to avoid the article being too long and affecting the reader's patience. If you need it, please contact my mailbox: acnchen@hotmail.com

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.