Development and application of "Silverlight" Bing Maps: Map Management and coordinate control (coordcontr

Source: Internet
Author: User
Tags silverlight

Development and application of "Silverlight" Bing Maps: Map Management and coordinate control (Coordcontrol)

Using the Bing Maps Silverlight control Development, there are many times when you need a real-world mapping feature, which is to add a callout (such as a Pushpin) to the click Point on the current map via a mouse click event, mainly using The Viewportpointtolocation method coordinates the transformation and transforms the physical coordinates of the clicked point of the mouse into geographical coordinates (longitude, latitude), which is defined as follows:

[ScriptableMemberAttribute]
public override Location ViewportPointToLocation (Point viewportPoint)
{}

Clicking on the map will trigger a series of Map mouse events (Mapmouseeventargs), through which event arguments can be directly or get to the physical coordinates of the mouse's current click Point, which is defined as follows:

namespace Microsoft.Maps.MapControl
{
     public class MapMouseEventArgs : MapEventArgs
     {
         public MapMouseEventArgs(Point viewportPoint);

         [ScriptableMember]
         public Point ViewportPoint { get; }
     }
}

Understand the above two key points can be achieved on the map to manage functions, such as we through the mouse click event to handle, when the mouse clicked on the map to achieve the dot, the code is as follows:

protected void map_MouseClick(object sender, MapMouseEventArgs e)
{
     //初始化一个图标
     Pushpin pushpin = new Pushpin();
     //设置图钉对象的定位坐标
     pushpin.Location = map.ViewportPointToLocation(e.ViewportPoint);
     //添加图钉到地图上
     map.Children.Add(pushpin);
}

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.