using XAML Map Control to add a heatmap layer on a map based on OpenStreetMap from C# VS2013 WPF

萝らか妹 提交于 2019-12-02 09:30:53

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);
    }
}

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.


EDIT: 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"/>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!