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

后端 未结 1 796
旧时难觅i
旧时难觅i 2021-01-28 08:39

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.

I have added the h

1条回答
  •  闹比i
    闹比i (楼主)
    2021-01-28 09:08

    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:

    
        
    
    

    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:

    
    

    0 讨论(0)
提交回复
热议问题