我一直在使用MapControl创建一个UWP应用程序,但是当我运行应用程序时,我在底部角落出现错误"警告:未指定MapServiceToken".我使用的XAML如下:
<Maps:MapControl x:Name="MapControl1" Loaded="mapLoaded" ZoomLevelChanged="mapZoomChanged" MapServiceToken="AqK9nK0h_LngGSC8pHPzBJvl62yf617zRytgimB3fyYqdJPljcB-EGm3llmUUrlI"/>
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我已经指定了MapServiceToken,并且我也尝试使用C#指定它,但没有运气.
MapService.ServiceToken = "AqK9nK0h_LngGSC8pHPzBJvl62yf617zRytgimB3fyYqdJPljcB-EGm3llmUU...";
MapControl1.MapServiceToken = "AqK9nK0h_LngGSC8pHPzBJvl62yf617zRytgimB3fyYqdJPljcB-EGm3llmU...";
Run Code Online (Sandbox Code Playgroud)
我使用www.bingmapsportal.com获取我的令牌,但我也尝试使用Windows开发人员中心的应用程序ID和身份验证令牌.有任何想法吗?
我想在 Windows 10 UWP 地图控件中添加 3D 对象。
该对象将是“具有高度的多边形”,例如房屋的简单表示 - 长方体或立方体。
插图图片:
我知道我可以添加 Xaml 控件(并在其中添加 3D 对象,例如 Cube),但是此 Cube 不是“地图对象”,仅固定到某个纬度/经度。
知道如何实现这一点吗?
我正在尝试使用 MapControl,显示当前查看位置的 MapIcon。
在我的 XAML 中,我有:
<Maps:MapControl x:Name="MapControl" ZoomLevel="14" Center="{Binding Geopoint, Mode=OneWay}" Margin="-12,0,-12,0" Tapped="directions_Click" Height="200" MapServiceToken="{StaticResource BingMapsKey}" PanInteractionMode="Disabled" RotateInteractionMode="Disabled">
<Maps:MapIcon Location="{Binding Geopoint}" Title="{Binding AttractionName}" />
</Maps:MapControl>
Run Code Online (Sandbox Code Playgroud)
我绑定的项目正在页面上的其他地方使用(例如地图中心在正确的位置),但 MapIcon 没有显示,也没有给出任何关于为什么的提示?
就我从 MSDN 中看到的而言,我应该能够以这种方式进行绑定(尽管专门针对<MapIcon>s的示例是动态添加它们,但它确实显示了直接在 XAML 中绑定的其他 XAML 对象)。我在这里标记了错误的 XAML 吗?
对于个人需要,对于Xamarin.Forms.Map控件,我需要创建一个CustomPin扩展。UWP 部分(PCL 项目)
我创建了一个MapIcon喜欢它:
nativeMap.MapElements.Add(new MapIcon()
{
Title = pin.Name,
Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/Pin/customicon.png")),
Location = new Geopoint(new BasicGeoposition() { Latitude = pin.Position.Latitude, Longitude = pin.Position.Longitude }),
NormalizedAnchorPoint = new Windows.Foundation.Point(0.5, 1.0)
});
Run Code Online (Sandbox Code Playgroud)
但是,通过这种方式,我无法设置Image的大小。
然后我想使用Image我的 PCL 部分中的 ,调整它的大小并将其转换为IRandomAccessStreamReference. 要实现它,我需要将我的Image转换为流,但我找不到使其工作的方法><
所需功能示例:
private IRandomAccessStreamReference ImageToIRandomAccessStreamReference(Image image)
{
//Here I can set the size of my Image
//I convert it into a stream
IRandomAccessStreamReference irasr = RandomAccessStreamReference.CreateFromStream(/* img? …Run Code Online (Sandbox Code Playgroud) 我想通过用一个函数替换硬编码的偏移值来旋转多边形(例如这个箭头),该函数可以传入北向偏移和我希望箭头旋转的度数。
我尝试使用旋转矩阵,但效果不佳。
可能是因为 1 Lat 的距离。!= 1 长。
我想用这个做什么:
箭头必须代表车辆并在车辆前进的方向上旋转。
double centerLatitude = pos.Coordinate.Point.Position.Latitude;
double centerLongitude = pos.Coordinate.Point.Position.Longitude;
MapPolygon mapPolygon = new MapPolygon();
mapPolygon.Path = new Geopath(new List<BasicGeoposition>() {
new BasicGeoposition() {Longitude=centerLongitude, Latitude=centerLatitude},//top of the arrow
new BasicGeoposition() {Longitude=centerLongitude-0.001, Latitude=centerLatitude-0.0010},
new BasicGeoposition() {Longitude=centerLongitude-0.001, Latitude=centerLatitude-0.0030},
new BasicGeoposition() {Longitude=centerLongitude+0.001, Latitude=centerLatitude-0.0030},
new BasicGeoposition() {Longitude=centerLongitude+0.001, Latitude=centerLatitude-0.0010},
});
mapPolygon.ZIndex = 1;
mapPolygon.FillColor = Colors.Orange;
mapPolygon.StrokeColor = Colors.Blue;
mapPolygon.StrokeThickness = 2;
mapPolygon.StrokeDashed = false;
MainMap.MapElements.Add(mapPolygon);
Run Code Online (Sandbox Code Playgroud)
我有一个MapControlUWP:
<maps:MapControl x:Name="BikeMap" ZoomLevel="17" Center="{Binding CenterPoint, Mode=TwoWay}">
<maps:MapItemsControl x:Name="MapItems" ItemsSource="{Binding BikePoints}"
ItemTemplate="{StaticResource BikePointTemplate}"/>
</maps:MapControl>
Run Code Online (Sandbox Code Playgroud)
我正在使用XAML数据模板添加MapElements,我的ItemsSource是一个简单对象列表.
但是,UWP似乎并没有提供一种方式来指定DataType的DataTemplate和MapItemsControl没有设置一个属性DataTemplateSelector.
有谁知道我如何使用MapItemsControl的多个数据模板,并根据ItemsSource中的对象类型选择相关的数据模板?
我有一个在地图上跟踪车辆的应用程序.但是我无法让小小的虫子朝着他们的运动方向旋转.基本上,所有这些都是侧身!啊!
Image vehicleImage = new Image
{
//Set image size and source
};
RenderTransform rotation= new RotateTransform{Angle = X};
vehicleImage.RenderTransfrom = rotation;
_mainMap.Children.Add(vehicleImage);
MapControl.SetLocation(vehicleImage, _position);
Run Code Online (Sandbox Code Playgroud)
放在地图上的图像似乎完全忽略了我尝试应用的任何角度.