如何创建自动scalling图像趴在WP8地图 [英] How to create auto-scalling image lying on WP8 maps

查看:179
本文介绍了如何创建自动scalling图像趴在WP8地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想多个图钉添加到地图,当你缩小不够,使图钉那么一点的消失,它们不再呈现。

I am trying to add multiple pushpins to the map, that disappear when you zoom out enough, to make the pushpins so little, that they are not rendered anymore.

我设法实现与下面的代码这样的效果:

I managed to achieve this effect with the following code:

MapPolygon shape = new MapPolygon();
GeoCoordinateCollection boundingLocations = CreateCircle(geoCoordinate, 0.1);
shape.Path = boundingLocations;
shape.FillColor = Color.FromArgb(0x55, 0xFF, 0xFF, 0x00);
shape.StrokeColor = Color.FromArgb(0xFF, 0xFF, 0x00, 0xFF);
shape.StrokeThickness = 4;
mapToDrawOn.MapElements.Add(shape);



但我真正想要做的是填充自定义图像多边形。图像具有被放置在地图的特定点,并涉及其大小以缩放水平。 (就像上面的例子),这是我试图用代码:

But what I really want to do is fill the polygon with a custom image. The image has to be placed in the specific point of the map, and relate its size to the level of zoom. (just as in the above example) This is the code that I tried to use:

MapLayer layer = new MapLayer();
MapOverlay overlay = new MapOverlay();
Polygon polygon = new Polygon();
polygon.Points.Add(new Point(0, 0));
polygon.Points.Add(new Point(0, 75));
polygon.Points.Add(new Point(25, 0)); 
BitmapImage arrImg = 
    new BitmapImage(new Uri("/Images/arrow.png", UriKind.RelativeOrAbsolute));
ImageBrush imgBrush = new ImageBrush();
imgBrush.ImageSource = arrImg;
polygon.Fill = imgBrush;
overlay.Content = polygon;
//geoCoordinate is the argument of a method
overlay.GeoCoordinate = geoCoordinate;
layer.Add(overlay);
mapToDrawOn.Layers.Add(layer);



这是行不通的。形象出现在世人面前的具体点,但是当我缩小,图像保留其大小。我相信这个问题是通过限制多边形缺乏一些矩形造成的,但我找不到任何下手。请帮助。

It doesn't work. The image appears in the specific point of the world, but when I zoom out, image keeps its size. I believe that the problem is caused by the lack of some Rectangle restricting the polygon, but I can't find anything to start with. Please help.

推荐答案

这不是WP8地图的支持功能。我们的想法是,一旦项目被添加到Map.Layers它不与放大,以便创建一个一致的外观&放大器重新缩放;感觉。有些项目做调整,如Map.MapElements折线和地标,但这些不会为图像的工作。

That's not a supported feature of WP8 Maps. The idea is that once an item is added to Map.Layers it doesn't rescale with zoom in order to create a consistent look & feel. Some items do resize such as Map.MapElements Polylines and Landmarks, but those won't work for an Image.

如果你希望你的项目规模,你必须登录为Map.ZoomLevelChanged和编程方式更改您的项目的比例。

If you want your items to scale you'll have to sign-up for Map.ZoomLevelChanged and change the scaling of your items programmatically.

如果你有兴趣在未来的版本中看到这个,请填写的 wpdev UserVoice的建议你用例,为什么你有兴趣这样做。

If you're interested in seeing this in future releases please fill in a wpdev uservoice suggestion with your usecase and why you're interested in doing that.

这篇关于如何创建自动scalling图像趴在WP8地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆