C# 如何在C语言中获得点击bing地图的地理位置#
是否有可能获得我在c#中单击bing地图的地点的地理位置?bing地图API使这变得非常简单C# 如何在C语言中获得点击bing地图的地理位置#,c#,bing-maps,C#,Bing Maps,是否有可能获得我在c#中单击bing地图的地点的地理位置?bing地图API使这变得非常简单 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title></title> <me
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
<script type="text/javascript">
var map = null;
function GetMap()
{
// Initialize the map
map = new Microsoft.Maps.Map(document.getElementById("myMap"),
{credentials:"Bing Maps Key"});
//Add handler for the map click event.
Microsoft.Maps.Events.addHandler(map, 'click', displayLatLong);
}
function displayLatLong(e) {
if (e.targetType == "map") {
var point = new Microsoft.Maps.Point(e.getX(), e.getY());
var loc = e.target.tryPixelToLocation(point);
document.getElementById("textBox").value= loc.latitude + ", " + loc.longitude;
}
}
</script>
</head>
<body onload="GetMap();">
<div id='myMap' style="position:relative; width:400px; height:400px;"></div><br>
<b>Click the map to display the coordinate values at that point.</b><br>
Latitude, Longitude:
<input id='textBox' type="text" style="width:250px;"/>
</body>
</html>
var-map=null;
函数GetMap()
{
//初始化映射
map=new Microsoft.Maps.map(document.getElementById(“myMap”),
{凭证:“Bing地图密钥”});
//为映射单击事件添加处理程序。
Microsoft.Maps.Events.addHandler(映射,'click',displayLatLong);
}
函数displayLatLong(e){
如果(如targetType==“映射”){
var point=new Microsoft.Maps.point(e.getX(),e.getY());
var loc=e.目标胰蛋白酶解(点);
document.getElementById(“textBox”).value=loc.latitude+,“+loc.longitude;
}
}
单击地图以显示该点的坐标值。
纬度、经度:
来源:好吧,既然你在C#中的WinRT中,你就在使用Bing Maps Windows应用商店应用程序控件。 将地图添加到XAML标记中:
<Page
x:Class="Win8PublicApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:m="using:Bing.Maps">
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<m:Map Name="MyMap" Credentials="YOURKEY"/>
</Grid>
</Page>
你试过什么?你做过什么调查吗?让人们知道你已经尝试/研究了什么,这样你就更有可能收到你还不知道的信息。c#和winrt而不是Javascript你可以在Windows RT应用程序中使用JS。你的应用程序现在看起来像什么?我不认为它与它的需求有关,因为他要求C#应用程序。
public MainPage()
{
this.InitializeComponent();
this.MyMap.PointerPressedOverride += MyMap_PointerPressedOverride;
}
void MyMap_PointerPressedOverride(object sender, PointerRoutedEventArgs e)
{
Bing.Maps.Location l = new Bing.Maps.Location();
this.MyMap.TryPixelToLocation(e.GetCurrentPoint(this.MyMap).Position, out l);
Bing.Maps.Pushpin pushpin = new Bing.Maps.Pushpin();
pushpin.SetValue(Bing.Maps.MapLayer.PositionProperty, l);
this.MyMap.Children.Add(pushpin);
}