• 大小: 85KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-16
  • 语言: C#
  • 标签: C#  WEBGIS  程序案例  

资源简介

使用C#开发,通过VS可以打开该系统,该系统实现了地图的漫游,放大缩小等基本功能。 可以用作课程设计,也可以作为自己研究的参考。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using BingMapsClient.TileSources;
using BingMapsClient.Events;

/**
 * Beniao Microsoft MVP(Silverlight)
 * 技术博客:http://beniao.cnblogs.com 
 * 微软Bing Maps开发群:75662563
 **/
namespace BingMapsClient
{
    public partial class MainPage : UserControl
    {
        private double _zoom = 1;
        private Point currentPosition;
        private Point dragOffset;
        private Point lastMousePos;
        private bool mouseButtonPressed;
        private bool mouseIsDragging;

        public MainPage()
        {
            InitializeComponent();

            msi.Source = new BingMapsRoadTileSource();

            MouseMove += delegate(object sender MouseEventArgs e)
            {
                if (mouseButtonPressed)
                {
                    mouseIsDragging = true;
                }
                lastMousePos = e.GetPosition(msi);
            };

            MouseLeftButtonDown += delegate(object sender MouseButtonEventArgs e)
            {
                mouseButtonPressed = true;
                mouseIsDragging = false;
                dragOffset = e.GetPosition(this);
                currentPosition = msi.ViewportOrigin;
            };

            msi.MouseLeave += delegate { mouseIsDragging = false; };

            MouseLeftButtonUp += delegate
            {
                mouseButtonPressed = false;
                if (mouseIsDragging == false)
                {
                    bool shiftDown = (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift;

                    ZoomFactor = 2.0;
                    if (shiftDown) ZoomFactor = 0.5;
                    Zoom(ZoomFactor lastMousePos);
                }
                mouseIsDragging = false;
            };

            MouseMove += delegate(object sender MouseEventArgs e)
            {
                if (mouseIsDragging)
                {
                    var newOrigin = new Point();
                    newOrigin.X = currentPosition.X -
                                  (((e.GetPosition(msi).X - dragOffset.X) / msi.ActualWidth) * msi.ViewportWidth);
                    newOrigin.Y = currentPosition.Y -
                                  (((e.GetPosition(msi).Y - dragOffset.Y) / msi.ActualHeight) * msi.ViewportWidth);
                    msi.ViewportOrigin = newOrigin;
                }
            };
            new MouseWheelHelper(this).Moved += delegate(object sender BingMapsClient.Events.MouseWheelEventArgs e)
            {
                e.Handled = true;
                if (e.Delta > 0)
                    ZoomFactor = 1.2;
                else
                    ZoomF

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        297  2010-05-21 00:07  BingMapsClient\BingMapsClient\App.xaml

     文件        365  2010-05-21 01:35  BingMapsClient\BingMapsClient\Bin\Debug\AppManifest.xaml

     文件      17920  2011-01-11 18:52  BingMapsClient\BingMapsClient\Bin\Debug\BingMapsClient.dll

     文件      44544  2011-01-11 18:52  BingMapsClient\BingMapsClient\Bin\Debug\BingMapsClient.pdb

     文件       8195  2011-01-11 18:52  BingMapsClient\BingMapsClient\Bin\Debug\BingMapsClient.xap

     文件       2852  2011-01-11 18:52  BingMapsClient\BingMapsClient\Bin\Debug\BingMapsClientTestPage.html

     文件       5108  2011-01-11 18:51  BingMapsClient\BingMapsClient\BingMapsClient.csproj

     文件       1142  2011-01-11 18:51  BingMapsClient\BingMapsClient\BingMapsClient.csproj.user

     文件       2573  2010-05-21 00:25  BingMapsClient\BingMapsClient\Events\MouseWheelHelper.cs

     文件        938  2011-01-11 18:51  BingMapsClient\BingMapsClient\MainPage.xaml

     文件       3930  2011-01-11 19:45  BingMapsClient\BingMapsClient\MainPage.xaml.cs

     文件       1804  2010-05-21 00:07  BingMapsClient\BingMapsClient\obj\Debug\App.g.cs

     文件       1804  2010-05-21 00:07  BingMapsClient\BingMapsClient\obj\Debug\App.g.i.cs

     文件       2128  2011-01-11 18:52  BingMapsClient\BingMapsClient\obj\Debug\BingMapsClient.csproj.FileListAbsolute.txt

     文件      17920  2011-01-11 18:52  BingMapsClient\BingMapsClient\obj\Debug\BingMapsClient.dll

     文件       1493  2011-01-11 18:52  BingMapsClient\BingMapsClient\obj\Debug\BingMapsClient.g.resources

     文件      44544  2011-01-11 18:52  BingMapsClient\BingMapsClient\obj\Debug\BingMapsClient.pdb

     文件      10331  2011-01-11 18:56  BingMapsClient\BingMapsClient\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       5537  2011-01-11 18:52  BingMapsClient\BingMapsClient\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       2320  2011-01-11 18:50  BingMapsClient\BingMapsClient\obj\Debug\MainPage.g.cs

     文件       2320  2011-01-11 18:50  BingMapsClient\BingMapsClient\obj\Debug\MainPage.g.i.cs

     文件        551  2011-01-11 18:52  BingMapsClient\BingMapsClient\obj\Debug\XapCacheFile.xml

     文件        207  2010-05-21 00:07  BingMapsClient\BingMapsClient\Properties\AppManifest.xml

     文件       1417  2010-05-21 00:07  BingMapsClient\BingMapsClient\Properties\AssemblyInfo.cs

     文件        248  2010-05-21 01:11  BingMapsClient\BingMapsClient\TileSources\BingMapsAerialTileSource.cs

     文件        280  2010-05-21 01:10  BingMapsClient\BingMapsClient\TileSources\BingMapsRoadTileSource.cs

     文件       2520  2010-05-21 01:07  BingMapsClient\BingMapsClient\TileSources\BingMapsTileSource.cs

     文件       5435  2011-01-11 19:45  BingMapsClient\BingMapsClient\TileSources\WMSTileSource.cs

     文件       7807  2011-05-09 16:22  BingMapsClient\BingMapsClient\Web.config

     文件       1440  2010-05-21 00:07  BingMapsClient\BingMapsClient.sln

............此处省略34个文件信息

评论

共有 条评论