Designing a WPF map control

前端 未结 10 1937
梦如初夏
梦如初夏 2021-02-01 08:55

I\'m thinking about making a simple map control in WPF, and am thinking about the design of the basic map interface and am wondering if anyone has some good advice for this.

相关标签:
10条回答
  • 2021-02-01 09:25

    The main question is how you store and access the items you are going to put in the map (assuming this isn't just a picture display). Lookup scenegraph for some ideas.

    Also if you want it to be more than a toy image viewer the lat long to XY scaling can get 'interesting'

    0 讨论(0)
  • 2021-02-01 09:30

    Don't know if you use ESRI software, but I hear there developing a Silverlight API for there stack so you might want to hold off.

    0 讨论(0)
  • 2021-02-01 09:32

    It does not fall on my field of work at all, but you may have a look at MapWindow GIS, which has an Open Source ActiveX object that provides a lot of mapping and GIS features. Here is a post explaining how to embed it on WPF applications:

    http://www.mapwindow.org/phorum/read.php?13,13484

    0 讨论(0)
  • 2021-02-01 09:35

    It is probably a roundabout way of going about it, but you might find some useful stuff in the javascript and XAML from SilverlightEarth.com which a Silverlight 1.0-based map-tile-client. It can load VE, Google, Yahoo (there is a DeepZoom version that can load OpenStreetMap, Moon and Mars too; but since it uses MSI it doesn't really help on the WPF 3/3.5 front).

    Although the javascript is a little untidy, you can clearly see it is creating a Silverlight 1.0 Xaml (dynamically sized) Canvas, filling it with tiles (Image controls) and handling zoom in/out and pan requests. You would need to make sense of all the javascript and convert it to C# - the XAML should mostly come into WPF unaltered. I have tested this Silverlight 1.0 with a Deep Zoom tile pyramid (and here) so the concepts are applicable (ie. not just for maps).

    I know this works because I have done it myself to build the map viewer in Geoquery2008.com (screenshot) which is WPF/c#. Unfortunately the Geoquery2008 assemblies are obfuscated, but you might still glean some ideas or useful code via DASM/Reflector. It is still a beta so I wouldn't claim it is 100% done. I hadn't really thought of factoring out the map code into a separate control but may I will look into that if another one doesn't appear...

    Incidentally I also started off with the ScrollViewer, but am planning to ditch it and mimic the javascript more closely so it's easier to re-use Image objects when panning/zooming (by gaining more control over the process than ScrollViewer provides).

    These MSDN pages on the Virtual Earth tile system and the Deep Zoom file format and related links is probably also a useful reference.

    Finally - I guess you've seen since this post that DeepZoom/MultiScaleImage is likely to be in .NET 4.0/Studio 2010.

    0 讨论(0)
  • 2021-02-01 09:36

    Download Bing Maps WPF Control sdk(Microsoft.Maps.MapControl.WPF.dll).Add as dll as referance,then change the XAML as below

    **

    <Window x:Class="WPFTestApplication.InsertPushpin"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"
        Width="1024" Height="768">
        <Grid x:Name="LayoutRoot" Background="White">
            <m:Map CredentialsProvider="INSERT_YOUR_BING_MAPS_KEY" 
                   Center="47.620574,-122.34942" ZoomLevel="12">
                <m:Pushpin Location="47.620574,-122.34942"/>
            </m:Map>
        </Grid>
    </Window>
    

    **

    0 讨论(0)
  • 2021-02-01 09:39

    If you're looking for a good start, you can use the foundation of code supplied by the SharpMap project and build out from there. If I recall there were a few people already working on a WPF renderer for SharpMap, so you may also have some code to begin with.

    I've personally used SharpMap in a C# 2.0 application that combined GIS data with real time GPS data, and it was very successful. SharpMap provided me the transformation suite to handle GIS data, along with the mathematical foundation to work with altering GIS information. It should be relatively straightforward to use the non-rendering code with a WPF frontend, as they already have presentation separated from the data.

    (EDIT: added more details about how I used SharpMap)

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