使用XAML地图控件基于OpenStreetMap的从C#VS2013 WPF在地图上添加一层热图 [英] using XAML Map Control to add a heatmap layer on a map based on OpenStreetMap from C# VS2013 WPF

查看:1503
本文介绍了使用XAML地图控件基于OpenStreetMap的从C#VS2013 WPF在地图上添加一层热图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用XAML MAP控制( https://xamlmapcontrol.codeplex.com/ )至基于OpenStreetMap的从C#VS2013 WPF在地图上添加热图层。

I am trying to use XAML MAP control (https://xamlmapcontrol.codeplex.com/) to add a heatmap layer on a map based on OpenStreetMap from C# VS2013 WPF.

我已经通过设置北,南,东,西经/纬度在MainWindow.xaml增加了热图图像地图。

I have added the heatmap image to the map by setting north, south, east and west latitude/longitude in MainWindow.xaml.

但是,我需要在热图的位置,以在与地图相同的纬度和经度的正确位置被示出,因为它们是从输入文件创建不只是图像粘贴到地图上。

But, I need the locations in the heatmap to be shown in the correct locations with same latitude and longitude in the map as they are created from the input file not just pasting the image to the map.

为例,给定输入为:

   Logitude,    latitude,    value
       -77.85      42.96      9798

有输入文件50万的位置。

There are 0.5 million locations in the input file.

我想显示在地图作为热图点的位置。在上述的例子中,点位于纽约州。我想表明它与那些按照预先指定一个传奇的值赋予某些颜色在地图上。

I would like to show the locations in the map as heatmap points. In the above example, the point is located at New York State. I would like to show it on a map with some colors that are assigned according to the value in a legend specified beforehand.

此外,由于是在地图上显示50万点可能不是一个很好的观点,当缩放级别较大例如15.因此,我希望当我在地图放大,缩小,热图点可以在不同的聚合地缘级合并为一个点。

Also, because 0.5 million points are shown on a map may not be a good view when zoom level is large e.g. 15. So, I hope that when I zoom in the map, the heatmap points can be merged to one point at different aggregated geo-level.

例如,如果有5000分在一个邮政编码区,在缩放水平> 12,我只显​​示在一个邮政编码区域的一个点的邮政编码质心或只是使邮政编码区域进行着色,与只有一种颜色的多边形。

For example, if there 5000 points in one zip code area, at zoom level > 12, I only show one point in one zip code area at the zip-code centroid or just make the zipcode area to be colored as a polygon with only one color.

当在8 LT缩放级别;水平< 12,我只需要在图案与上述相同,显示县级分。

When zoom level at 8 < level < 12, I only need to show county level points in the pattern same as above.

当在3'缩放级别;水平< 5,我只需要出示国家级点的模式与上述相同。

When zoom level at 3 < level < 5, I only need to show state level points in the pattern same as above.

当在水平和LT缩放级别; 3,我只需要在模式上面一样,显示美国国家一级分。

When zoom level at level < 3, I only need to show U.S. country level points in the pattern same as above.

任何帮助,将不胜感激。

Any help would be appreciated.

推荐答案

您可以使用衍生MapImageLayer并覆盖其 UpdateImage 以创建动态热图位图。这当然会只能是一个明智的做法,如果在创建位图不花太多时间

You may use a derived MapImageLayer and override its UpdateImage to create a heatmap bitmap on the fly. This would of course only be a sensible approach, if creating the bitmap doesn't take too much time.

public class HeatmapImage : MapImageLayer
{
    protected override void UpdateImage(
        double west, double east, double south, double north, int width, int height)
    {
        BitmapSource bitmap = ... // create heatmap here
        UpdateImage(west, east, south, north, bitmap);
    }
}

您会则只需添加 HeatmapImage 地图,你就大功告成了:

You would then simply add the HeatmapImage to the map, and you're done:

<map:Map TileLayer="{x:Static map:TileLayer.OpenStreetMapTileLayer}">
    <local:HeatmapImage />
</map:Map>

请注意,在该位图的地图图像将不得不使用网络墨卡托投影

Note that the map image in the bitmap would have to be created using the Web Mercator projection.

编辑:为了给你一个想法MapImage如何工作,看看在XAML地图控件示例应用程序下面的XAML代码片段。它显示给定的纬度/经度范围作为地图控件重叠的图像。实际的图像是一个虚像瓷砖从谷歌地图复制:

To give you an idea how a MapImage works, take a look at the following XAML snippet from the sample application in XAML Map Control. It displays an image with the given lat/lon bounds as an overlay in the map control. The actual image is a aerial image tile copied from Google Maps:

<map:MapImage South="53.54031" North="53.74871" West="8.08594" East="8.43750"
              Source="10_535_330.jpg"/>

这篇关于使用XAML地图控件基于OpenStreetMap的从C#VS2013 WPF在地图上添加一层热图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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