├── dlls
├── Npgsql.dll
└── Mono.Security.dll
├── BaseMap
├── image
│ ├── 010.png
│ ├── pin.png
│ ├── cancel.png
│ ├── comp4.png
│ ├── force1.png
│ ├── flag.blue.png
│ ├── flag.red.png
│ ├── vehicle.png
│ ├── MinIcons_013.png
│ ├── MinIcons_015.png
│ └── MinIcons_023.png
├── Properties
│ ├── AppManifest.xml
│ └── AssemblyInfo.cs
├── App.xaml
├── testmap.xaml.cs
├── Control
│ ├── ToolBarPanel.xaml
│ ├── DynamicPushpin.xaml
│ ├── ToolBarPanel.xaml.cs
│ ├── ToolBarItem.xaml.cs
│ ├── DynamicPushpin.xaml.cs
│ └── ToolBarItem.xaml
├── testmap.xaml
├── Service References
│ └── RoutingServiceReference
│ │ ├── BaseMap.RoutingServiceReference.GetLastRoadResponse.datasource
│ │ ├── BaseMap.RoutingServiceReference.GetRoutingResponse.datasource
│ │ ├── BaseMap.RoutingServiceReference.HelloWorldResponse.datasource
│ │ ├── BaseMap.RoutingServiceReference.GetBeginRoadResponse.datasource
│ │ ├── BaseMap.RoutingServiceReference.GetBarrierRoadResponse.datasource
│ │ ├── BaseMap.RoutingServiceReference.QueryRealRoadsResponse.datasource
│ │ ├── RoutingWebService.disco
│ │ ├── configuration.svcinfo
│ │ └── Reference.svcmap
├── ServiceReferences.ClientConfig
├── CustomPushpin.xaml
├── App.xaml.cs
├── MainPage.xaml
├── Class
│ ├── PushpinTools.cs
│ ├── DraggablePushpin.cs
│ └── CustomIconSpecification.cs
├── LoadingSpin.xaml.cs
└── CustomPushpin.xaml.cs
├── BaseMap.Web
├── RoutingWebService.asmx
├── IRoutingService.cs
├── Web.config
├── Properties
│ └── AssemblyInfo.cs
├── Web.Debug.config
├── Web.Release.config
├── BaseMap.Web.Publish.xml
├── RoutingWebService.asmx.cs
├── BaseMapTestPage.html
├── BaseMapTestPage.aspx
├── BaseMap.Web.csproj
├── Silverlight.js
└── postgisHelper.cs
├── TobbyBingMaps.MapGeometry
├── IScalable.cs
├── IClipable.cs
├── BalloonEventArgs.cs
├── IReduceable.cs
├── MapLayerObject.cs
├── IClusterable.cs
├── Commands.cs
├── Properties
│ └── AssemblyInfo.cs
├── ClusterCountComparer.cs
├── EnhancedMapPolyline.cs
├── EnhancedMapPolygon.cs
├── InfoGeometry.cs
├── EnhancedMapShapeBase.cs
├── BaseGeometry.cs
├── SelectGeometry.cs
├── TobbyBingMaps.MapGeometry.csproj
└── Themes
│ └── generic.xaml
├── generic
├── Class1.cs
├── Properties
│ └── AssemblyInfo.cs
└── generic.csproj
├── TobbyBingMaps.Common
├── Entities
│ ├── IEnhancedLayer.cs
│ ├── VectorLayerData.cs
│ ├── LayerObjectAttributeDefinition.cs
│ ├── DateRange.cs
│ └── LayerDefinition.cs
├── Enums.cs
├── Constants.cs
├── Properties
│ └── AssemblyInfo.cs
├── Commanding
│ ├── CanExecuteEventArgs.cs
│ ├── ExecutedEventArgs.cs
│ ├── Command.cs
│ ├── CommandService.cs
│ └── CommandSubscription.cs
├── Converters
│ └── CoordinateConvertor.cs
├── TobbyBingMaps.Common.csproj
└── TileSystem.cs
├── .gitattributes
├── .gitignore
└── BaseMap.sln
/dlls/Npgsql.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tommy2gis/AGS-PgRouting/HEAD/dlls/Npgsql.dll
--------------------------------------------------------------------------------
/BaseMap/image/010.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tommy2gis/AGS-PgRouting/HEAD/BaseMap/image/010.png
--------------------------------------------------------------------------------
/BaseMap/image/pin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tommy2gis/AGS-PgRouting/HEAD/BaseMap/image/pin.png
--------------------------------------------------------------------------------
/dlls/Mono.Security.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tommy2gis/AGS-PgRouting/HEAD/dlls/Mono.Security.dll
--------------------------------------------------------------------------------
/BaseMap/image/cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tommy2gis/AGS-PgRouting/HEAD/BaseMap/image/cancel.png
--------------------------------------------------------------------------------
/BaseMap/image/comp4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tommy2gis/AGS-PgRouting/HEAD/BaseMap/image/comp4.png
--------------------------------------------------------------------------------
/BaseMap/image/force1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tommy2gis/AGS-PgRouting/HEAD/BaseMap/image/force1.png
--------------------------------------------------------------------------------
/BaseMap/image/flag.blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tommy2gis/AGS-PgRouting/HEAD/BaseMap/image/flag.blue.png
--------------------------------------------------------------------------------
/BaseMap/image/flag.red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tommy2gis/AGS-PgRouting/HEAD/BaseMap/image/flag.red.png
--------------------------------------------------------------------------------
/BaseMap/image/vehicle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tommy2gis/AGS-PgRouting/HEAD/BaseMap/image/vehicle.png
--------------------------------------------------------------------------------
/BaseMap/image/MinIcons_013.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tommy2gis/AGS-PgRouting/HEAD/BaseMap/image/MinIcons_013.png
--------------------------------------------------------------------------------
/BaseMap/image/MinIcons_015.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tommy2gis/AGS-PgRouting/HEAD/BaseMap/image/MinIcons_015.png
--------------------------------------------------------------------------------
/BaseMap/image/MinIcons_023.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tommy2gis/AGS-PgRouting/HEAD/BaseMap/image/MinIcons_023.png
--------------------------------------------------------------------------------
/BaseMap.Web/RoutingWebService.asmx:
--------------------------------------------------------------------------------
1 | <%@ WebService Language="C#" CodeBehind="RoutingWebService.asmx.cs" Class="BaseMap.Web.RoutingWebService" %>
2 |
--------------------------------------------------------------------------------
/TobbyBingMaps.MapGeometry/IScalable.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 | namespace TobbyBingMaps.MapGeometry
4 | {
5 | public interface IScalable
6 | {
7 | double Scale { get; set; }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/generic/Class1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace generic
7 | {
8 | public class Class1
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/TobbyBingMaps.MapGeometry/IClipable.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Maps.MapControl;
2 |
3 | namespace TobbyBingMaps.MapGeometry
4 | {
5 | public interface IClipable
6 | {
7 | LocationRect MBR { get; set; }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/BaseMap/Properties/AppManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/TobbyBingMaps.Common/Entities/IEnhancedLayer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 |
4 | namespace TobbyBingMaps.Common.Entities
5 | {
6 | public interface IEnhancedLayer : IDisposable
7 | {
8 | string ID { get; set; }
9 | int ZIndex { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/TobbyBingMaps.MapGeometry/BalloonEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 |
4 | namespace TobbyBingMaps.MapGeometry
5 | {
6 | public class BalloonEventArgs : EventArgs
7 | {
8 | public string LayerID { get; set; }
9 | public string ItemID { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/BaseMap/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/TobbyBingMaps.Common/Enums.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 |
4 | namespace TobbyBingMaps.Common
5 | {
6 | [Flags]
7 | public enum GeometryType : ulong
8 | {
9 | None = 0,
10 | Point = 1,
11 | LineString = 2,
12 | Polygon = 4,
13 | MultiPoint = 8,
14 | MultiLineString = 16,
15 | MultiPolygon = 32,
16 | GeometryCollection = 64
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/TobbyBingMaps.Common/Entities/VectorLayerData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 |
4 | namespace TobbyBingMaps.Common.Entities
5 | {
6 | public class VectorLayerData
7 | {
8 | public byte[] Geo { get; set; }
9 | public string ID { get; set; }
10 |
11 | public string Label { get; set; }
12 | public string Style { get; set; }
13 | public DateTime TimeStamp { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/BaseMap.Web/IRoutingService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.Serialization;
5 | using System.ServiceModel;
6 | using System.Text;
7 |
8 | namespace BaseMap.Web
9 | {
10 | // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的接口名“IRoutingService”。
11 | [ServiceContract]
12 | public interface IRoutingService
13 | {
14 | [OperationContract]
15 | void DoWork();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/TobbyBingMaps.MapGeometry/IReduceable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.Maps.MapControl;
4 |
5 | namespace TobbyBingMaps.MapGeometry
6 | {
7 | public interface IReduceable
8 | {
9 | event EventHandler ReductionComplete;
10 |
11 | LocationCollection Original { get; set; }
12 | Dictionary Reduced { get; set; }
13 | int CurrentDisplayed { get; set; }
14 | bool Initalized { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/TobbyBingMaps.MapGeometry/MapLayerObject.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using Microsoft.Maps.MapControl;
3 |
4 | namespace TobbyBingMaps.MapGeometry
5 | {
6 | public class MapLayerObject
7 | {
8 | public UIElement Element { get; set; }
9 | public Location Location { get; set; }
10 | public bool InUse { get; set; }
11 | public bool ToBeRendered { get; set; }
12 | public bool InMapView { get; set; }
13 | public LocationRect MBR { get; set; }
14 | public bool Visible { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/BaseMap/testmap.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Animation;
11 | using System.Windows.Shapes;
12 |
13 | namespace BaseMap
14 | {
15 | public partial class testmap : UserControl
16 | {
17 | public testmap()
18 | {
19 | InitializeComponent();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/BaseMap/Control/ToolBarPanel.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/TobbyBingMaps.MapGeometry/IClusterable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Windows;
4 | using Microsoft.Maps.MapControl;
5 |
6 | namespace TobbyBingMaps.MapGeometry
7 | {
8 | public interface IClusterable
9 | {
10 | event EventHandler ProjectionComplete;
11 |
12 | Location Location { get; set; }
13 | bool Initalized { get; set; }
14 | Dictionary ProjectedPoints { get; set; }
15 | List ClusteredElements { get; set; }
16 | bool IsCluster { get; set; }
17 | bool IsClustered { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/BaseMap/testmap.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/BaseMap/Service References/RoutingServiceReference/BaseMap.RoutingServiceReference.GetLastRoadResponse.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | BaseMap.RoutingServiceReference.GetLastRoadResponse, Service References.RoutingServiceReference.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/BaseMap/Service References/RoutingServiceReference/BaseMap.RoutingServiceReference.GetRoutingResponse.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | BaseMap.RoutingServiceReference.GetRoutingResponse, Service References.RoutingServiceReference.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/BaseMap/Service References/RoutingServiceReference/BaseMap.RoutingServiceReference.HelloWorldResponse.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | BaseMap.RoutingServiceReference.HelloWorldResponse, Service References.RoutingServiceReference.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/BaseMap/Service References/RoutingServiceReference/BaseMap.RoutingServiceReference.GetBeginRoadResponse.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | BaseMap.RoutingServiceReference.GetBeginRoadResponse, Service References.RoutingServiceReference.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/BaseMap/ServiceReferences.ClientConfig:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/BaseMap/Service References/RoutingServiceReference/BaseMap.RoutingServiceReference.GetBarrierRoadResponse.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | BaseMap.RoutingServiceReference.GetBarrierRoadResponse, Service References.RoutingServiceReference.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/BaseMap/Service References/RoutingServiceReference/BaseMap.RoutingServiceReference.QueryRealRoadsResponse.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | BaseMap.RoutingServiceReference.QueryRealRoadsResponse, Service References.RoutingServiceReference.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/BaseMap/Service References/RoutingServiceReference/RoutingWebService.disco:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/BaseMap.Web/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/BaseMap/CustomPushpin.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/TobbyBingMaps.Common/Entities/LayerObjectAttributeDefinition.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 | using System.Windows;
4 | using System.Windows.Controls;
5 | using System.Windows.Documents;
6 | using System.Windows.Ink;
7 | using System.Windows.Input;
8 | using System.Windows.Media;
9 | using System.Windows.Media.Animation;
10 | using System.Windows.Shapes;
11 |
12 | namespace TobbyBingMaps.Common.Entities
13 | {
14 | public enum AttributeType
15 | {
16 | KeyValuePair = 0,
17 | Chart = 1,
18 | Gauge = 2
19 | }
20 |
21 | public class LayerObjectAttributeDefinition
22 | {
23 | public string ObjectAttributeID { get; set; }
24 | public string ObjectAttributeTemplate { get; set; }
25 | public AttributeType ObjectAttributeType { get; set; }
26 |
27 | #if SILVERLIGHT
28 |
29 | #else
30 | //not public
31 | public string ObjectAttributeURI { get; set; }
32 | public string Description { get; set; }
33 | public string ConnectionString { get; set; }
34 | public int DisplayOrder { get; set; }
35 | #endif
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/BaseMap/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("BaseMap")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("BaseMap")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 可使此程序集中的类型
18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则以下 GUID 用作类型库的 ID
23 | [assembly: Guid("3bce84cb-5175-459a-93ce-85bf3fae0f90")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 内部版本号
30 | // 修订号
31 | //
32 | // 您可以指定所有这些值,也可以使用“修订号”和“内部版本号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/TobbyBingMaps.MapGeometry/Commands.cs:
--------------------------------------------------------------------------------
1 | using TobbyBingMaps.Common.Commanding;
2 |
3 | namespace TobbyBingMaps.MapGeometry
4 | {
5 | public static class Commands
6 | {
7 | static Commands()
8 | {
9 | ClosePopupCommand = new Command("ClosePopup");
10 | StopDrawingCommand = new Command("StopDrawing");
11 | EditVectorCommand = new Command("EditVectorCommand");
12 | LoadBalloonDataCommand = new Command("LoadBalloonDataCommand");
13 | ItemSelectedCommand = new Command("ItemSelectedCommand");
14 | PollTileLayerCommand = new Command("PollTileLayerCommand");
15 | }
16 |
17 | public static Command ClosePopupCommand { get; private set; }
18 | public static Command StopDrawingCommand { get; private set; }
19 | public static Command EditVectorCommand { get; private set; }
20 | public static Command LoadBalloonDataCommand { get; private set; }
21 | public static Command ItemSelectedCommand { get; private set; }
22 | public static Command PollTileLayerCommand { get; private set; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/TobbyBingMaps.Common/Constants.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TobbyBingMaps.Common
4 | {
5 | public static class Constants
6 | {
7 |
8 | public const int AutoPanTolleranceToEdge = 20;
9 | public const int AutoPanAmount = 200;
10 |
11 | //See http://en.wikipedia.org/wiki/Geographic_coordinate_system.
12 | public const double EarthMinLatitude = -85.05112878D;
13 | public const double EarthMaxLatitude = 85.05112878D;
14 | public const double EarthMinLongitude = -180D;
15 | public const double EarthMaxLongitude = 180D;
16 | public const double EarthCircumference = EarthRadius * 2 * Math.PI;
17 | public const double HalfEarthCircumference = EarthCircumference / 2;
18 | public const double EarthRadius = 6378137;
19 |
20 | public const double ProjectionOffset = EarthCircumference * 0.5;
21 |
22 | public const double INCH_TO_METER = 0.0254D;
23 | public const double METER_TO_INCH = 39.3700787D;
24 | public const double METER_TO_MILE = 0.000621371192D;
25 | public const double MILE_TO_METER = 1609.344D;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/BaseMap.Web/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下特性集
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("BaseMap.Web")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("BaseMap.Web")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("4917b460-0193-4ae9-821a-1447fc24067f")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 内部版本号
30 | // 修订号
31 | //
32 | // 您可以指定所有这些值,也可以使用“修订号”和“内部版本号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/BaseMap.Web/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/generic/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("generic")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("微软中国")]
12 | [assembly: AssemblyProduct("generic")]
13 | [assembly: AssemblyCopyright("Copyright © 微软中国 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 使此程序集中的类型
18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("292e2955-ebbd-4f8e-bff2-b7e8c1e5ee31")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 内部版本号
30 | // 修订号
31 | //
32 | // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/TobbyBingMaps.Common/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("TobbyBingMaps.Common")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("TobbyBingMaps.Common")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 可使此程序集中的类型
18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则以下 GUID 用作类型库的 ID
23 | [assembly: Guid("72a7f469-5dad-4e8b-89d7-5b8323a61837")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 内部版本号
30 | // 修订号
31 | //
32 | // 您可以指定所有这些值,也可以使用“修订号”和“内部版本号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/TobbyBingMaps.MapGeometry/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("TobbyBingMaps.MapGeometry")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("TobbyBingMaps.MapGeometry")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 可使此程序集中的类型
18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则以下 GUID 用作类型库的 ID
23 | [assembly: Guid("8206041e-a5a2-45d0-883a-126017fa6970")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 内部版本号
30 | // 修订号
31 | //
32 | // 您可以指定所有这些值,也可以使用“修订号”和“内部版本号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/BaseMap.Web/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/BaseMap.Web/BaseMap.Web.Publish.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/TobbyBingMaps.Common/Entities/DateRange.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 |
4 | namespace TobbyBingMaps.Common.Entities
5 | {
6 | public class DateRange : INotifyPropertyChanged
7 | {
8 | private DateTime valueLow;
9 | public DateTime ValueLow
10 | {
11 | get { return valueLow; }
12 | set
13 | {
14 | valueLow = value;
15 | UpdateProperty("ValueLow");
16 | }
17 | }
18 |
19 | private DateTime valueHigh;
20 | public DateTime ValueHigh
21 | {
22 | get { return valueHigh; }
23 | set
24 | {
25 | valueHigh = value;
26 | UpdateProperty("ValueHigh");
27 | }
28 | }
29 |
30 | #region INotifyPropertyChanged Members
31 |
32 | public event PropertyChangedEventHandler PropertyChanged;
33 |
34 | #endregion
35 |
36 | public void UpdateProperty(string propertyName)
37 | {
38 | if (PropertyChanged != null)
39 | {
40 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
41 | }
42 | }
43 |
44 | public DateRange Clone()
45 | {
46 | return new DateRange { ValueHigh = ValueHigh, ValueLow = ValueLow };
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/TobbyBingMaps.MapGeometry/ClusterCountComparer.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace TobbyBingMaps.MapGeometry
4 | {
5 | public class ClusterCountComparer : IComparer
6 | {
7 | #region IComparer Members
8 |
9 | int IComparer.Compare(IClusterable x, IClusterable y)
10 | {
11 | if (x == null)
12 | {
13 | if (y == null)
14 | {
15 | // If x is Nothing and y is Nothing, they're
16 | // equal.
17 | return 0;
18 | }
19 | // If x is Nothing and y is not Nothing, y
20 | // is greater.
21 | return 1;
22 | }
23 | // If x is not Nothing...
24 | if (y == null)
25 | {
26 | // ...and y is Nothing, x is greater.
27 | return -1;
28 | }
29 | // ...and y is not Nothing, compare the
30 | // x values
31 |
32 |
33 | if (x.ClusteredElements.Count > y.ClusteredElements.Count)
34 | {
35 | //x is greater
36 | return -1;
37 | }
38 | if (x.ClusteredElements.Count == y.ClusteredElements.Count)
39 | {
40 | //they're equal.
41 | return 0;
42 | }
43 | //y is greater
44 | return 1;
45 | }
46 |
47 | #endregion
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/BaseMap/Service References/RoutingServiceReference/configuration.svcinfo:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/TobbyBingMaps.MapGeometry/EnhancedMapPolyline.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Browser;
2 | using System.Windows.Media;
3 | using System.Windows.Shapes;
4 | using TobbyBingMaps.Common;
5 | using TobbyBingMaps.Common.Entities;
6 |
7 | namespace TobbyBingMaps.MapGeometry
8 | {
9 | public class EnhancedMapPolyline : EnhancedMapShapeBase
10 | {
11 | public EnhancedMapPolyline()
12 | : base(new Polyline())
13 | {
14 | }
15 |
16 | // Properties
17 | [ScriptableMember]
18 | public FillRule FillRule
19 | {
20 | get
21 | {
22 | return (FillRule)EncapsulatedShape.GetValue(Polyline.FillRuleProperty);
23 | }
24 | set
25 | {
26 | EncapsulatedShape.SetValue(Polyline.FillRuleProperty, value);
27 | }
28 | }
29 |
30 | protected override PointCollection ProjectedPoints
31 | {
32 | get
33 | {
34 | return ((Polyline)EncapsulatedShape).Points;
35 | }
36 | set
37 | {
38 | ((Polyline)EncapsulatedShape).Points = value;
39 | }
40 | }
41 |
42 | private StyleSpecification geometryStyle;
43 | public StyleSpecification GeometryStyle
44 | {
45 | get { return geometryStyle; }
46 | set
47 | {
48 | geometryStyle = value;
49 | Stroke = new SolidColorBrush(Utilities.ColorFromHexString(geometryStyle.LineColour));
50 | StrokeThickness = geometryStyle.LineWidth;
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/BaseMap/Control/DynamicPushpin.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/BaseMap/Service References/RoutingServiceReference/Reference.svcmap:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 | true
6 |
7 | false
8 | false
9 | false
10 |
11 |
12 |
13 |
14 | false
15 | Auto
16 | true
17 | true
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/TobbyBingMaps.Common/Commanding/CanExecuteEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 |
4 | namespace TobbyBingMaps.Common.Commanding
5 | {
6 | ///
7 | /// Provides data for the System.Windows.Input.CommandBinding.CanExecute and System.Windows.Input.CommandManager.PreviewCanExecute routed events.
8 | ///
9 | public class CanExecuteEventArgs : EventArgs
10 | {
11 | #region Constructors
12 |
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | /// The command.
17 | /// The parameter.
18 | internal CanExecuteEventArgs(Command command, object parameter)
19 | {
20 | Command = command;
21 | Parameter = parameter;
22 | }
23 |
24 | #endregion Constructors
25 |
26 | #region Properties
27 |
28 | ///
29 | /// Gets or sets a value indicating whether the System.Windows.Input.RoutedCommand
30 | /// associated with this event can be executed on the command target.
31 | ///
32 | ///
33 | /// true if the event can be executed on the command target; otherwise, false.
34 | /// The default value is false.
35 | ///
36 | public bool CanExecute
37 | {
38 | get;
39 | set;
40 | }
41 |
42 | ///
43 | /// Gets the command associated with this event.
44 | ///
45 | /// The command. Unless the command is a custom command, this is generally a System.Windows.Input.RoutedCommand. There is no default value.
46 | public Command Command
47 | {
48 | get;
49 | private set;
50 | }
51 |
52 | ///
53 | /// Gets the command specific data.
54 | ///
55 | /// The command data. The default value is null.
56 | public object Parameter
57 | {
58 | get;
59 | private set;
60 | }
61 |
62 | #endregion Properties
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/TobbyBingMaps.MapGeometry/EnhancedMapPolygon.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Browser;
2 | using System.Windows.Media;
3 | using System.Windows.Shapes;
4 | using TobbyBingMaps.Common;
5 | using TobbyBingMaps.Common.Entities;
6 |
7 | namespace TobbyBingMaps.MapGeometry
8 | {
9 | public class EnhancedMapPolygon : EnhancedMapShapeBase
10 | {
11 | // Methods
12 | public EnhancedMapPolygon()
13 | : base(new Polygon())
14 | {
15 | }
16 |
17 | // Properties
18 | [ScriptableMember]
19 | public FillRule FillRule
20 | {
21 | get
22 | {
23 | return (FillRule)EncapsulatedShape.GetValue(Polygon.FillRuleProperty);
24 | }
25 | set
26 | {
27 | EncapsulatedShape.SetValue(Polygon.FillRuleProperty, value);
28 | }
29 | }
30 |
31 | protected override PointCollection ProjectedPoints
32 | {
33 | get
34 | {
35 | return ((Polygon)EncapsulatedShape).Points;
36 | }
37 | set
38 | {
39 | ((Polygon)EncapsulatedShape).Points = value;
40 | }
41 | }
42 |
43 | private StyleSpecification geometryStyle;
44 | public StyleSpecification GeometryStyle
45 | {
46 | get { return geometryStyle; }
47 | set
48 | {
49 | geometryStyle = value;
50 | Fill =
51 | geometryStyle.ShowFill
52 | ? new SolidColorBrush(Utilities.ColorFromHexString(geometryStyle.PolyFillColour))
53 | : new SolidColorBrush(Colors.Transparent);
54 | if (geometryStyle.ShowLine)
55 | {
56 | Stroke = new SolidColorBrush(Utilities.ColorFromHexString(geometryStyle.PolygonLineColour));
57 | StrokeThickness = geometryStyle.PolygonLineWidth;
58 | }
59 | else
60 | {
61 | Stroke = new SolidColorBrush(Colors.Transparent);
62 | StrokeThickness = 0;
63 | }
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/BaseMap/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Animation;
11 | using System.Windows.Shapes;
12 |
13 | namespace BaseMap
14 | {
15 | public partial class App : Application
16 | {
17 |
18 | public App()
19 | {
20 | this.Startup += this.Application_Startup;
21 | this.Exit += this.Application_Exit;
22 | this.UnhandledException += this.Application_UnhandledException;
23 |
24 | InitializeComponent();
25 | }
26 |
27 | private void Application_Startup(object sender, StartupEventArgs e)
28 | {
29 | this.RootVisual = new ArcgisMap();
30 | }
31 |
32 | private void Application_Exit(object sender, EventArgs e)
33 | {
34 |
35 | }
36 |
37 | private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
38 | {
39 | // 如果应用程序是在调试器外运行的,则使用浏览器的
40 | // 异常机制报告该异常。在 IE 上,将在状态栏中用一个
41 | // 黄色警报图标来显示该异常,而 Firefox 则会显示一个脚本错误。
42 | if (!System.Diagnostics.Debugger.IsAttached)
43 | {
44 |
45 | // 注意: 这使应用程序可以在已引发异常但尚未处理该异常的情况下
46 | // 继续运行。
47 | // 对于生产应用程序,此错误处理应替换为向网站报告错误
48 | // 并停止应用程序。
49 | e.Handled = true;
50 | Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
51 | }
52 | }
53 |
54 | private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
55 | {
56 | try
57 | {
58 | string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
59 | errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");
60 |
61 | System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");");
62 | }
63 | catch (Exception)
64 | {
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/TobbyBingMaps.Common/Commanding/ExecutedEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TobbyBingMaps.Common.Commanding
4 | {
5 | ///
6 | /// Provides data for the System.Windows.Input.CommandManager.Executed and System.Windows.Input.CommandManager.PreviewExecuted routed events.
7 | ///
8 | public class ExecutedEventArgs : EventArgs
9 | {
10 | #region Constructors
11 |
12 | ///
13 | /// Initializes a new instance of the class.
14 | ///
15 | /// The command.
16 | /// The parameter.
17 | internal ExecutedEventArgs(Command command, object parameter)
18 | : this(command, parameter, null)
19 | {
20 | }
21 |
22 | ///
23 | /// Initializes a new instance of the class.
24 | ///
25 | /// The command.
26 | /// The parameter.
27 | /// The event source.
28 | internal ExecutedEventArgs(Command command, object parameter, object source)
29 | {
30 | Command = command;
31 | Parameter = parameter;
32 | Source = source;
33 | }
34 |
35 | #endregion Constructors
36 |
37 | #region Properties
38 |
39 | ///
40 | /// Gets the command that was invoked.
41 | ///
42 | /// The command associated with this event.
43 | public Command Command
44 | {
45 | get;
46 | private set;
47 | }
48 |
49 | ///
50 | /// Gets data parameter of the command.
51 | ///
52 | /// The command data. The default value is null.
53 | public object Parameter
54 | {
55 | get;
56 | private set;
57 | }
58 |
59 | ///
60 | /// Gets the element that raises the event.
61 | ///
62 | /// The event source.
63 | public object Source
64 | {
65 | get;
66 | private set;
67 | }
68 |
69 | #endregion Properties
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/generic/generic.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | 292e2955-ebbd-4f8e-bff2-b7e8c1e5ee31
9 | Library
10 | Properties
11 | generic
12 | generic
13 | v4.0
14 | 512
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
54 |
--------------------------------------------------------------------------------
/BaseMap/Control/ToolBarPanel.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Animation;
11 | using System.Windows.Shapes;
12 |
13 | namespace BaseMap.Control
14 | {
15 | public partial class ToolBarPanel : UserControl
16 | {
17 | public event Click ToolBarItemClick;
18 | public ToolBarPanel()
19 | {
20 | InitializeComponent();
21 | this.Loaded += new RoutedEventHandler(ToolBarPanel_Loaded);
22 | }
23 |
24 | void ToolBarPanel_Loaded(object sender, RoutedEventArgs e)
25 | {
26 | this.CreateClickEvent();
27 | }
28 |
29 | public static DependencyProperty ToolBarItemsProperty = DependencyProperty.Register("ToolBarItems",
30 | typeof(PresentationFrameworkCollection),
31 | typeof(ToolBarPanel),
32 | new PropertyMetadata(null));
33 | public UIElementCollection ToolBarItems
34 | {
35 | get
36 | {
37 | return ItemHolder.Children;
38 | }
39 | }
40 |
41 | public static DependencyProperty ToolBarItemsOrientation = DependencyProperty.Register("Orientation",
42 | typeof(Orientation),
43 | typeof(ToolBarPanel),
44 | new PropertyMetadata(null));
45 | public Orientation Orientation
46 | {
47 | get { return (ItemHolder.Orientation); }
48 | set { ItemHolder.Orientation = value; }
49 | }
50 | public override void OnApplyTemplate()
51 | {
52 | base.OnApplyTemplate();
53 | ItemHolder.DataContext = this;
54 | }
55 |
56 | private void CreateClickEvent()
57 | {
58 | foreach (UIElement elem in ItemHolder.Children)
59 | {
60 | ToolBarItem item = elem as ToolBarItem;
61 | if (item != null)
62 | item.ToolBarItemClick += new Click(item_ToolBarItemClick);
63 | }
64 | }
65 |
66 | void item_ToolBarItemClick(object sender, string key)
67 | {
68 | if (ToolBarItemClick != null)
69 | this.ToolBarItemClick(sender, ((ToolBarItem)sender).ToolBarItemKey);
70 | }
71 |
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/BaseMap/Control/ToolBarItem.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Animation;
11 | using System.Windows.Shapes;
12 |
13 | namespace BaseMap.Control
14 | {
15 | public delegate void Click(object sender, string key);
16 | public partial class ToolBarItem : Button
17 | {
18 | public event Click ToolBarItemClick;
19 | public ToolBarItem()
20 | {
21 | InitializeComponent();
22 | this.Click += new RoutedEventHandler(ToolBarItem_Click);
23 | }
24 |
25 | void ToolBarItem_Click(object sender, RoutedEventArgs e)
26 | {
27 | if (ToolBarItemClick != null)
28 | this.ToolBarItemClick(sender, (string)GetValue(ToolBarItemKeyProperty));
29 | }
30 |
31 | public static DependencyProperty ToolBarItemImageProperty = DependencyProperty.Register("ToolBarItemImage",
32 | typeof(ImageSource),
33 | typeof(ToolBarItem),
34 | new PropertyMetadata(null));
35 | public ImageSource ToolBarItemImage
36 | {
37 | get { return (ImageSource)GetValue(ToolBarItemImageProperty); }
38 | set { SetValue(ToolBarItemImageProperty, value); }
39 | }
40 |
41 | public static DependencyProperty ToolBarItemKeyProperty = DependencyProperty.Register("ToolBarItemKey",
42 | typeof(String),
43 | typeof(ToolBarItem),
44 | new PropertyMetadata(null));
45 | public string ToolBarItemKey
46 | {
47 | get { return (string)GetValue(ToolBarItemKeyProperty); }
48 | set { SetValue(ToolBarItemKeyProperty, value); }
49 | }
50 |
51 | public override void OnApplyTemplate()
52 | {
53 | base.OnApplyTemplate();
54 | SetDataContext();
55 | }
56 | private void SetDataContext()
57 | {
58 | Border border = GetTemplateChild("imgBorder") as Border;
59 | border.DataContext = this;
60 | TextBlock txtCaption = GetTemplateChild("caption") as TextBlock;
61 | txtCaption.DataContext = this;
62 |
63 | if (this.Content == null)
64 | {
65 | txtCaption.Margin = new Thickness(0);
66 | border.Margin = new Thickness(3);
67 | }
68 | else
69 | {
70 | txtCaption.Margin = new Thickness(3);
71 | }
72 | }
73 |
74 |
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/BaseMap.Web/RoutingWebService.asmx.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using System.Web.Services;
6 | using System.Collections.Generic;
7 |
8 |
9 | namespace BaseMap.Web
10 | {
11 | ///
12 | /// RoutingWebService 的摘要说明
13 | ///
14 | [WebService(Namespace = "http://tempuri.org/")]
15 | [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
16 | [System.ComponentModel.ToolboxItem(false)]
17 | // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
18 | // [System.Web.Script.Services.ScriptService]
19 | public class RoutingWebService : System.Web.Services.WebService
20 | {
21 |
22 | [WebMethod]
23 | public string HelloWorld()
24 | {
25 | return "Hello World";
26 | }
27 |
28 | [WebMethod]
29 | public List GetRouting(string layer,int begin,int last)
30 | {
31 | var records = postgisHelper.GetAllTableFeatures(layer,begin,last);
32 | return records;
33 | }
34 |
35 | [WebMethod]
36 | public List GetBeginRoad(double lg, double lt, double ditMini)
37 | {
38 | var records = postgisHelper.GetClosetRoad(lg, lt, ditMini);
39 | return records;
40 | }
41 |
42 | [WebMethod]
43 | public List GetLastRoad(double lg, double lt, double ditMini)
44 | {
45 | var records = postgisHelper.GetClosetRoad(lg, lt, ditMini);
46 | return records;
47 | }
48 |
49 | [WebMethod]
50 | public List GetBarrierRoad(double lg, double lt, double ditMini)
51 | {
52 | var records = postgisHelper.GetClosetRoad(lg, lt, ditMini);
53 | return records;
54 | }
55 |
56 | [WebMethod]
57 | public void UpdatePassable(int source, int target, int passable)
58 | {
59 |
60 | postgisHelper.updatePassable(source,target, passable);
61 |
62 | }
63 | [WebMethod]
64 | public List QueryRealRoads(string layer, string leve)
65 | {
66 |
67 | var records = postgisHelper.GetRealRoads(layer, leve);
68 | return records;
69 | }
70 |
71 | [WebMethod]
72 | public void updateLength()
73 | {
74 |
75 | postgisHelper.updateLength();
76 |
77 | }
78 |
79 | [WebMethod]
80 | public void updatePassableToT()
81 | {
82 |
83 | postgisHelper.updatePassableToT();
84 |
85 | }
86 |
87 |
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/BaseMap/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## Eclipse
3 | #################
4 |
5 | *.pydevproject
6 | .project
7 | .metadata
8 | bin/
9 | tmp/
10 | *.tmp
11 | *.bak
12 | *.swp
13 | *~.nib
14 | local.properties
15 | .classpath
16 | .settings/
17 | .loadpath
18 |
19 | # External tool builders
20 | .externalToolBuilders/
21 |
22 | # Locally stored "Eclipse launch configurations"
23 | *.launch
24 |
25 | # CDT-specific
26 | .cproject
27 |
28 | # PDT-specific
29 | .buildpath
30 |
31 |
32 | #################
33 | ## Visual Studio
34 | #################
35 |
36 | ## Ignore Visual Studio temporary files, build results, and
37 | ## files generated by popular Visual Studio add-ons.
38 |
39 | # User-specific files
40 | *.suo
41 | *.user
42 | *.sln.docstates
43 |
44 | # Build results
45 | [Dd]ebug/
46 | [Rr]elease/
47 | *_i.c
48 | *_p.c
49 | *.ilk
50 | *.meta
51 | *.obj
52 | *.pch
53 | *.pdb
54 | *.pgc
55 | *.pgd
56 | *.rsp
57 | *.sbr
58 | *.tlb
59 | *.tli
60 | *.tlh
61 | *.tmp
62 | *.vspscc
63 | .builds
64 | *.dotCover
65 |
66 | ## TODO: If you have NuGet Package Restore enabled, uncomment this
67 | #packages/
68 |
69 | # Visual C++ cache files
70 | ipch/
71 | *.aps
72 | *.ncb
73 | *.opensdf
74 | *.sdf
75 |
76 | # Visual Studio profiler
77 | *.psess
78 | *.vsp
79 |
80 | # ReSharper is a .NET coding add-in
81 | _ReSharper*
82 |
83 | # Installshield output folder
84 | [Ee]xpress
85 |
86 | # DocProject is a documentation generator add-in
87 | DocProject/buildhelp/
88 | DocProject/Help/*.HxT
89 | DocProject/Help/*.HxC
90 | DocProject/Help/*.hhc
91 | DocProject/Help/*.hhk
92 | DocProject/Help/*.hhp
93 | DocProject/Help/Html2
94 | DocProject/Help/html
95 |
96 | # Click-Once directory
97 | publish
98 |
99 | # Others
100 | [Bb]in
101 | [Oo]bj
102 | sql
103 | TestResults
104 | *.Cache
105 | ClientBin
106 | stylecop.*
107 | ~$*
108 | *.dbmdl
109 | Generated_Code #added for RIA/Silverlight projects
110 |
111 | # Backup & report files from converting an old project file to a newer
112 | # Visual Studio version. Backup files are not needed, because we have git ;-)
113 | _UpgradeReport_Files/
114 | Backup*/
115 | UpgradeLog*.XML
116 |
117 |
118 |
119 | ############
120 | ## Windows
121 | ############
122 |
123 | # Windows image file caches
124 | Thumbs.db
125 |
126 | # Folder config file
127 | Desktop.ini
128 |
129 |
130 | #############
131 | ## Python
132 | #############
133 |
134 | *.py[co]
135 |
136 | # Packages
137 | *.egg
138 | *.egg-info
139 | dist
140 | build
141 | eggs
142 | parts
143 | bin
144 | var
145 | sdist
146 | develop-eggs
147 | .installed.cfg
148 |
149 | # Installer logs
150 | pip-log.txt
151 |
152 | # Unit test / coverage reports
153 | .coverage
154 | .tox
155 |
156 | #Translations
157 | *.mo
158 |
159 | #Mr Developer
160 | .mr.developer.cfg
161 |
162 | # Mac crap
163 | .DS_Store
164 |
--------------------------------------------------------------------------------
/BaseMap/Class/PushpinTools.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 | using System.Windows;
4 | using System.Windows.Controls;
5 | using System.Windows.Documents;
6 | using System.Windows.Ink;
7 | using System.Windows.Input;
8 | using System.Windows.Media;
9 | using System.Windows.Media.Animation;
10 | using System.Windows.Shapes;
11 | using System.Windows.Media.Imaging;
12 |
13 | namespace BaseMap
14 | {
15 | public static class PushpinTools
16 | {
17 | ///
18 | /// Creates an Image pushpin
19 | ///
20 | /// Uri of the image to use for the pushpin icon
21 | /// Width of the pushpin
22 | /// Height of the pushpin
23 | /// Offset distance for the pushpin so that the point of the
24 | /// pin is aligned with the associated coordinate.
25 | ///
26 | public static UIElement CreateImagePushpin(Uri imageUri, double width, double height, int rotateTr, Point offset, PlaneProjection planeProjection)
27 | {
28 |
29 | //Source.RenderTransform.r
30 | //TransformGroup
31 | RotateTransform RotateTr = new RotateTransform();
32 | RotateTr.Angle = rotateTr;
33 |
34 |
35 |
36 | return new Image()
37 | {
38 | Source = new BitmapImage(imageUri),
39 | //RenderTransform = RotateTr,
40 | Width = width,
41 | Height = height,
42 | //Stretch = System.Windows.Media.Stretch.Uniform,
43 | //VerticalAlignment = VerticalAlignment.Center,
44 | //HorizontalAlignment = HorizontalAlignment.Center,
45 | Margin = new Thickness(offset.X, offset.Y, 0, 0),
46 | Projection = planeProjection,
47 |
48 | };
49 | }
50 |
51 | ///
52 | /// Creates a Circle UIElement
53 | ///
54 | /// Radius of the circle to create
55 | /// The fill color of the circle
56 | /// The stroke color of the circle.
57 | /// This is used to create a border around the circle
58 | ///
59 | public static UIElement CreateCirclePushpin(double radius, Brush fillColor, Brush strokeColor)
60 | {
61 | return new Ellipse()
62 | {
63 | Width = radius + radius,
64 | Height = radius + radius,
65 | Fill = fillColor,
66 | Stroke = strokeColor,
67 | StrokeThickness = 2,
68 | Margin = new Thickness(-radius, -radius, 0, 0)
69 | };
70 | }
71 |
72 |
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/TobbyBingMaps.Common/Converters/CoordinateConvertor.cs:
--------------------------------------------------------------------------------
1 | using GeoAPI.Geometries;
2 | using GisSharpBlog.NetTopologySuite.Geometries;
3 | using Microsoft.Maps.MapControl;
4 | using ProjNet.CoordinateSystems.Transformations;
5 | using Location = Microsoft.Maps.MapControl.Location;
6 |
7 | namespace TobbyBingMaps.Common.Converters
8 | {
9 | public static class CoordinateConvertor
10 | {
11 | public static ICoordinate Convert(Location location)
12 | {
13 | return new Coordinate { Y = location.Latitude, X = location.Longitude };
14 | }
15 |
16 | public static Location ConvertBack(ICoordinate location)
17 | {
18 | return new Location { Latitude = location.Y, Longitude = location.X };
19 | }
20 |
21 | public static LocationCollection CoordinatesToLocationCollection(ICoordinate[] coordinates)
22 | {
23 | var locations = new LocationCollection();
24 | foreach (var coordinate in coordinates)
25 | {
26 | locations.Add(ConvertBack(coordinate));
27 | }
28 | return locations;
29 | }
30 |
31 | public static ICoordinate[] LocationCollectionToCoordinates(LocationCollection locations)
32 | {
33 | var coordinates = new Coordinate[locations.Count];
34 | for (var x = 0; x < locations.Count; x++)
35 | {
36 | coordinates[x] = (Coordinate)Convert(locations[x]);
37 | }
38 | return (ICoordinate[])coordinates;
39 | }
40 |
41 | public static Coordinate ConvertDegreesToUTM(ICoordinate coordinate)
42 | {
43 | var ctfac = new CoordinateTransformationFactory();
44 | ProjNet.CoordinateSystems.ICoordinateSystem wgs84geo = ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84;
45 | int zone = (int)System.Math.Ceiling((coordinate.X + 180) / 6);
46 | ProjNet.CoordinateSystems.ICoordinateSystem utm = ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WGS84_UTM(zone, coordinate.Y > 0);
47 | var trans = ctfac.CreateFromCoordinateSystems(wgs84geo, utm);
48 |
49 | double[] pUtm = trans.MathTransform.Transform(new[] { coordinate.X, coordinate.Y });
50 |
51 | return new Coordinate
52 | {
53 | X = pUtm[0],
54 | Y = pUtm[1],
55 | };
56 | }
57 |
58 | public static LocationCollection LocationRectToLocationCollection(LocationRect locationRect)
59 | {
60 | var locations = new LocationCollection
61 | {
62 | locationRect.Northwest,
63 | locationRect.Southwest,
64 | locationRect.Southeast,
65 | locationRect.Northeast,
66 | locationRect.Northwest
67 | };
68 | return locations;
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/BaseMap.Web/BaseMapTestPage.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | BaseMap
6 |
20 |
21 |
57 |
58 |
59 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/BaseMap.Web/BaseMapTestPage.aspx:
--------------------------------------------------------------------------------
1 | <%@ Page Language="C#" AutoEventWireup="true" %>
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | BaseMap
10 |
24 |
25 |
61 |
62 |
63 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/BaseMap.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaseMap", "BaseMap\BaseMap.csproj", "{4B266542-73EC-4594-A330-9E9048718283}"
5 | ProjectSection(ProjectDependencies) = postProject
6 | {66BE2647-5A4D-4149-8F30-C291AF176C1C} = {66BE2647-5A4D-4149-8F30-C291AF176C1C}
7 | EndProjectSection
8 | EndProject
9 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaseMap.Web", "BaseMap.Web\BaseMap.Web.csproj", "{66BE2647-5A4D-4149-8F30-C291AF176C1C}"
10 | EndProject
11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TobbyBingMaps.Common", "TobbyBingMaps.Common\TobbyBingMaps.Common.csproj", "{DD23CC44-6A41-4599-A55A-8D2F11CC86D9}"
12 | EndProject
13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TobbyBingMaps.MapGeometry", "TobbyBingMaps.MapGeometry\TobbyBingMaps.MapGeometry.csproj", "{6D766A3E-65BD-4F81-AA87-7AE567D3E854}"
14 | EndProject
15 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamicTileLayer", "C:\Documents and Settings\Administrator\桌面\SourceCode\demo_20101215_HugeAmountPointsInClientAPI\DynamicTileLayer\DynamicTileLayer.csproj", "{B0EC9FF8-B93E-477E-8DEB-1A7B56B77462}"
16 | EndProject
17 | Global
18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
19 | Debug|Any CPU = Debug|Any CPU
20 | Release|Any CPU = Release|Any CPU
21 | EndGlobalSection
22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
23 | {4B266542-73EC-4594-A330-9E9048718283}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24 | {4B266542-73EC-4594-A330-9E9048718283}.Debug|Any CPU.Build.0 = Debug|Any CPU
25 | {4B266542-73EC-4594-A330-9E9048718283}.Release|Any CPU.ActiveCfg = Release|Any CPU
26 | {4B266542-73EC-4594-A330-9E9048718283}.Release|Any CPU.Build.0 = Release|Any CPU
27 | {66BE2647-5A4D-4149-8F30-C291AF176C1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28 | {66BE2647-5A4D-4149-8F30-C291AF176C1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
29 | {66BE2647-5A4D-4149-8F30-C291AF176C1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
30 | {66BE2647-5A4D-4149-8F30-C291AF176C1C}.Release|Any CPU.Build.0 = Release|Any CPU
31 | {DD23CC44-6A41-4599-A55A-8D2F11CC86D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32 | {DD23CC44-6A41-4599-A55A-8D2F11CC86D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
33 | {DD23CC44-6A41-4599-A55A-8D2F11CC86D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
34 | {DD23CC44-6A41-4599-A55A-8D2F11CC86D9}.Release|Any CPU.Build.0 = Release|Any CPU
35 | {6D766A3E-65BD-4F81-AA87-7AE567D3E854}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36 | {6D766A3E-65BD-4F81-AA87-7AE567D3E854}.Debug|Any CPU.Build.0 = Debug|Any CPU
37 | {6D766A3E-65BD-4F81-AA87-7AE567D3E854}.Release|Any CPU.ActiveCfg = Release|Any CPU
38 | {6D766A3E-65BD-4F81-AA87-7AE567D3E854}.Release|Any CPU.Build.0 = Release|Any CPU
39 | {B0EC9FF8-B93E-477E-8DEB-1A7B56B77462}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40 | {B0EC9FF8-B93E-477E-8DEB-1A7B56B77462}.Debug|Any CPU.Build.0 = Debug|Any CPU
41 | {B0EC9FF8-B93E-477E-8DEB-1A7B56B77462}.Release|Any CPU.ActiveCfg = Release|Any CPU
42 | {B0EC9FF8-B93E-477E-8DEB-1A7B56B77462}.Release|Any CPU.Build.0 = Release|Any CPU
43 | EndGlobalSection
44 | GlobalSection(SolutionProperties) = preSolution
45 | HideSolutionNode = FALSE
46 | EndGlobalSection
47 | EndGlobal
48 |
--------------------------------------------------------------------------------
/BaseMap/Class/DraggablePushpin.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 | using System.Windows;
4 | using System.Windows.Controls;
5 | using System.Windows.Documents;
6 | using System.Windows.Ink;
7 | using System.Windows.Input;
8 | using System.Windows.Media;
9 | using System.Windows.Media.Animation;
10 | using System.Windows.Shapes;
11 | using Microsoft.Maps.MapControl;
12 |
13 | namespace BaseMap.Class
14 | {
15 | public class DraggablePushpin : Microsoft.Maps.MapControl.Pushpin
16 | {
17 | ///
18 | /// 是否正在拖放
19 | ///
20 | private bool IsDragging = false;
21 | ///
22 | /// 鼠标拖放
23 | ///
24 | private EventHandler MapMouseDragHandler;
25 | ///
26 | /// 鼠标左键弹起
27 | ///
28 | private MouseButtonEventHandler MapMouseLeftButtonUpHandler;
29 | ///
30 | /// 鼠标移动
31 | ///
32 | private MouseEventHandler MapMouseMoveHandler;
33 |
34 | protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
35 | {
36 | //因为图钉是添加在MapLayer上的
37 | var parentLayer = this.Parent as MapLayer;
38 | if (parentLayer != null)
39 | {
40 | //MapLayer是Map的一个子对象
41 | var parentMap = parentLayer.ParentMap;
42 | if (parentMap != null)
43 | {
44 | if (this.MapMouseDragHandler == null)
45 | {
46 | this.MapMouseDragHandler = new EventHandler(ParnetMap_MousePan);
47 | parentMap.MousePan += this.MapMouseDragHandler;
48 | }
49 |
50 | if (this.MapMouseLeftButtonUpHandler == null)
51 | {
52 | this.MapMouseLeftButtonUpHandler = new MouseButtonEventHandler(PrentMap_MouseLeftButtonUp);
53 | parentMap.MouseLeftButtonUp += this.MapMouseLeftButtonUpHandler;
54 | }
55 |
56 | if (this.MapMouseMoveHandler == null)
57 | {
58 | this.MapMouseMoveHandler = new MouseEventHandler(PrentMap_MouseMove);
59 | parentMap.MouseMove += this.MapMouseMoveHandler;
60 | }
61 | }
62 | }
63 | this.IsDragging = true;
64 |
65 | base.OnMouseLeftButtonDown(e);
66 | }
67 |
68 | private void ParnetMap_MousePan(object sender, MapMouseDragEventArgs e)
69 | {
70 | if (this.IsDragging)
71 | {
72 | e.Handled = true;
73 | }
74 | }
75 |
76 | private void PrentMap_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
77 | {
78 | this.IsDragging = false;
79 | }
80 |
81 | private void PrentMap_MouseMove(object sender, MouseEventArgs e)
82 | {
83 | var map = sender as Map;
84 | if (this.IsDragging)
85 | {
86 | var mousePosition = e.GetPosition(map);
87 | var geoPosition = map.ViewportPointToLocation(mousePosition);
88 | //重新定位图钉位置
89 | this.Location = geoPosition;
90 | }
91 | }
92 | }
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/BaseMap/LoadingSpin.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Animation;
11 | using System.Windows.Shapes;
12 |
13 | namespace BaseMap
14 | {
15 | public partial class LoadingSpin : UserControl
16 | {
17 | private Storyboard intervalTimer;
18 | private List animations;
19 | private int nextAnimation;
20 | public event EventHandler ExitCurrentProcess;
21 | public string StopMuemCaption { get; set; }
22 | public Visibility StopMuemVisibility { get; set; }
23 | public LoadingSpin()
24 | {
25 | InitializeComponent();
26 | this.FlashText.Begin();
27 | this.intervalTimer = new Storyboard()
28 | {
29 | Duration = new Duration(TimeSpan.FromMilliseconds(100))
30 | };
31 | this.intervalTimer.Completed += new EventHandler(this.OnIntervalTimerCompleted);
32 |
33 | this.animations = new List()
34 | {
35 | CycleAnimation0,
36 | CycleAnimation1,
37 | CycleAnimation2,
38 | CycleAnimation3,
39 | CycleAnimation4,
40 | CycleAnimation5,
41 | CycleAnimation6,
42 | CycleAnimation7,
43 | CycleAnimation8,
44 | CycleAnimation9
45 | };
46 | this.Loaded += new RoutedEventHandler(LoadingSpin_Loaded);
47 | }
48 |
49 | void LoadingSpin_Loaded(object sender, RoutedEventArgs e)
50 | {
51 | //this.StopCurrent.Visibility = StopMuemVisibility;
52 | //this.StopCurrent.Header = StopMuemCaption;
53 | }
54 |
55 | ///
56 | /// Start the animation.
57 | ///
58 | public void Begin()
59 | {
60 | this.Visibility = Visibility.Visible;
61 | AppearAnimation.Begin();
62 | this.intervalTimer.Begin();
63 | }
64 |
65 | ///
66 | /// Start the animation.
67 | ///
68 | public void Begin(string strMsg)
69 | {
70 | this.Visibility = Visibility.Visible;
71 | waitingText.Text = strMsg;
72 | AppearAnimation.Begin();
73 | this.intervalTimer.Begin();
74 | }
75 |
76 | ///
77 | /// Stop the animation.
78 | ///
79 | public void Stop()
80 | {
81 | this.Visibility = Visibility.Collapsed;
82 | AppearAnimation.Stop();
83 | this.nextAnimation = 0;
84 | this.intervalTimer.Stop();
85 | foreach (var item in this.animations)
86 | {
87 | item.Stop();
88 | }
89 | }
90 |
91 | private void OnIntervalTimerCompleted(object sender, EventArgs e)
92 | {
93 | this.animations[nextAnimation].Begin();
94 |
95 | // Cycle:
96 | this.nextAnimation = this.nextAnimation > 8 ? 0 : this.nextAnimation + 1;
97 |
98 | this.intervalTimer.Begin();
99 | }
100 |
101 | private void MenuItem_Click(object sender, RoutedEventArgs e)
102 | {
103 |
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/TobbyBingMaps.MapGeometry/InfoGeometry.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 | using TobbyBingMaps.Common.Entities;
4 | using GeoAPI.Geometries;
5 | using Microsoft.Maps.MapControl.Core;
6 |
7 |
8 | namespace TobbyBingMaps.MapGeometry
9 | {
10 | public delegate void BalloonEventHandler(object sender, BalloonEventArgs args);
11 |
12 | ///
13 | /// Adds a label and a ballon popup to a selectable geometry
14 | /// Requires at lease one EnhancedMapPoint is created to launch the balloon
15 | /// All EnhancedMapPoints show the label.
16 | ///
17 | public class InfoGeometry : SelectGeometry
18 | {
19 | private readonly EnhancedMapPoint mainPoint;
20 |
21 | public InfoGeometry(IGeometry geometry, StyleSpecification styleSpecification, MapCore map, EnhancedMapLayer layer)
22 | : base(geometry, styleSpecification, map, layer)
23 | {
24 | //must have at least one EnhancedMapPoint to show label and launch balloon.
25 | foreach (var mapObject in mapObjects)
26 | {
27 | if (mapObject is EnhancedMapPoint)
28 | {
29 | var mapPoint = (EnhancedMapPoint)mapObject;
30 | if (mainPoint == null)
31 | {
32 | mainPoint = mapPoint;
33 | }
34 | mapPoint.Balloon += (o, e) => Balloon(this, new BalloonEventArgs { LayerID = layer.ID, ItemID = ItemID });
35 | }
36 | }
37 | if (mainPoint == null)
38 | {
39 | //TODO: create one, invisible at centre of first object
40 | var point = geometry.Centroid;
41 | mainPoint = createPoint(point, layer);
42 | mainPoint.Balloon += (o, e) => Balloon(this, new BalloonEventArgs { LayerID = layer.ID, ItemID = ItemID });
43 | }
44 | Selected += InfoGeometry_Selected;
45 | }
46 |
47 | void InfoGeometry_Selected(object sender, System.EventArgs args)
48 | {
49 | mainPoint.ShowBalloon();
50 | }
51 |
52 | public bool EnableBalloon
53 | {
54 | get { return mainPoint.EnableBalloon; }
55 | set
56 | {
57 | foreach (var mapObject in mapObjects)
58 | {
59 | if (mapObject is EnhancedMapPoint)
60 | {
61 | ((EnhancedMapPoint)mapObject).EnableBalloon = value;
62 |
63 | }
64 | }
65 | }
66 | }
67 |
68 | public Visibility LabelVisibility
69 | {
70 | get { return mainPoint.LabelVisibility; }
71 | set
72 | {
73 | foreach (var mapObject in mapObjects)
74 | {
75 | if (mapObject is EnhancedMapPoint)
76 | {
77 | ((EnhancedMapPoint)mapObject).LabelVisibility = value;
78 |
79 | }
80 | }
81 | }
82 | }
83 |
84 | public string Label
85 | {
86 | get { return mainPoint.Label; }
87 | set
88 | {
89 | foreach (var mapObject in mapObjects)
90 | {
91 | if (mapObject is EnhancedMapPoint)
92 | {
93 | ((EnhancedMapPoint)mapObject).Label = value;
94 |
95 | }
96 | }
97 | }
98 | }
99 |
100 | public event BalloonEventHandler Balloon;
101 |
102 | public UIElementCollection BalloonData
103 | {
104 | get { return mainPoint.BalloonData; }
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/BaseMap/Control/DynamicPushpin.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Animation;
11 | using System.Windows.Shapes;
12 |
13 | namespace BaseMap.Control
14 | {
15 | public partial class DynamicPushpin : UserControl
16 | {
17 | public bool HasAnimated { get; set; }
18 | public bool IsAnimating { get; set; }
19 | System.Threading.Timer StopTimer;
20 |
21 | public DynamicPushpin()
22 | {
23 | InitializeComponent();
24 | this.HasAnimated = false;
25 | this.IsAnimating = false;
26 | timer.Duration = new TimeSpan(0, 0, 0, 5);
27 | timer.Stop();
28 | }
29 |
30 | public void pulseStoryboard_Completed(object sender, EventArgs e)
31 | {
32 | this.IsAnimating = false;
33 |
34 | }
35 | //动画开始
36 | public void BeginAnimation()
37 | {
38 | this.pulseStoryboard.Begin();
39 | this.HasAnimated = true;
40 | }
41 |
42 | //动画开始
43 | public void BeginAnimation(int iTimeCout, Action CallBack)
44 | {
45 | this.pulseStoryboard.Begin();
46 | this.HasAnimated = true;
47 | timer.Duration = new TimeSpan(0, 0, 0, iTimeCout);
48 | timer.Begin();
49 | timer.Completed += (os, en) =>
50 | {
51 | StopAnimation();
52 | if (CallBack != null)
53 | {
54 | CallBack(true);
55 | }
56 | };
57 |
58 | }
59 | public void timerCall(object obj)
60 | {
61 |
62 |
63 | }
64 | //动画结束
65 | public void StopAnimation()
66 | {
67 | this.pulseStoryboard.Stop();
68 | this.HasAnimated = false;
69 | timer.Stop();
70 | }
71 | //设定中心点大小及动画时长
72 | public double Magnitude
73 | {
74 | get
75 | {
76 | return (double)base.GetValue(MagnitudeProperty);
77 | }
78 | set
79 | {
80 | base.SetValue(MagnitudeProperty, value);
81 | int seconds = 0;
82 | double num2 = 0.127;
83 | if (this.Magnitude <= 2.5)
84 | {
85 | seconds = 1;
86 | num2 = 0.05;
87 | }
88 | else if (this.Magnitude <= 3.5)
89 | {
90 | seconds = 3;
91 | num2 = 0.08;
92 | }
93 | else if (this.Magnitude <= 4.5)
94 | {
95 | seconds = 4;
96 | num2 = 0.1;
97 | }
98 | else if (this.Magnitude <= 5.5)
99 | {
100 | seconds = 6;
101 | num2 = 0.127;
102 | }
103 | else if (this.Magnitude <= 6.5)
104 | {
105 | seconds = 8;
106 | num2 = 0.15;
107 | }
108 | else if (this.Magnitude <= 7.5)
109 | {
110 | seconds = 10;
111 | num2 = 0.3;
112 | }
113 | else if (this.Magnitude <= 8.5)
114 | {
115 | seconds = 12;
116 | num2 = 0.4;
117 | }
118 | else if (this.Magnitude > 8.5)
119 | {
120 | seconds = 14;
121 | num2 = 0.6;
122 | }
123 | TimeSpan span = new TimeSpan(0, 0, 0, seconds);
124 | this.pulseAnim.Duration = (Duration)span;
125 | this.pulseColour.Duration = (Duration)span;
126 | this.pulseStoryboard.Duration = (Duration)span.Add(new TimeSpan(0, 0, 0, 1));
127 | this.ImpactSite.Offset = num2;
128 | this.PulseRing.Offset = num2 + 0.2;
129 | }
130 |
131 | }
132 | public static readonly DependencyProperty MagnitudeProperty = DependencyProperty.Register("Magnitude", typeof(double), typeof(DynamicPushpin), new PropertyMetadata(2.5));
133 |
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/TobbyBingMaps.Common/Commanding/Command.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Windows;
4 |
5 | namespace TobbyBingMaps.Common.Commanding
6 | {
7 | ///
8 | /// Command pattern implementation
9 | ///
10 | public class Command
11 | {
12 | #region Constructors
13 |
14 | ///
15 | /// Static constructor. Initialize static properties
16 | ///
17 | static Command()
18 | {
19 | CommandCache = new Dictionary();
20 | }
21 |
22 | ///
23 | /// Initializes a new instance of the class.
24 | ///
25 | /// The command name used for retreiving command in Xaml.
26 | public Command(string commandName)
27 | {
28 | if (CommandCache.ContainsKey(commandName))
29 | {
30 | // Not throwing exception to prevent error in blend
31 | return;
32 | //throw new ArgumentException(Resource.CommandNameAlreadyRegistered, commandName);
33 | }
34 |
35 | Name = commandName;
36 | CommandCache.Add(commandName, this);
37 | }
38 |
39 | #endregion Constructors
40 |
41 | #region Events
42 |
43 | ///
44 | /// Check if the specified command can be executed.
45 | ///
46 | public event EventHandler CanExecute;
47 |
48 | ///
49 | /// Occurs when the command is executed.
50 | ///
51 | public event EventHandler Executed;
52 |
53 | #endregion Events
54 |
55 | #region Properties
56 |
57 | ///
58 | /// Gets the command cache.
59 | ///
60 | /// The command cache.
61 | public static Dictionary CommandCache
62 | {
63 | get;
64 | private set;
65 | }
66 |
67 | ///
68 | /// Gets the name of the command.
69 | ///
70 | /// the name of the command.
71 | public string Name
72 | {
73 | get;
74 | private set;
75 | }
76 |
77 | #endregion Properties
78 |
79 | #region Methods
80 |
81 | public virtual CommandSubscription CreateCommandSubscription(FrameworkElement element, string commandName)
82 | {
83 | return new CommandSubscription(element, commandName);
84 | }
85 |
86 | ///
87 | /// Executes the command
88 | ///
89 | public virtual void Execute()
90 | {
91 | Execute(null);
92 | }
93 |
94 | ///
95 | /// Executes the command
96 | ///
97 | /// The parameter.
98 | public virtual void Execute(object parameter)
99 | {
100 | if (RaiseCanExecute(parameter))
101 | {
102 | if (Executed != null)
103 | {
104 | var e = new ExecutedEventArgs(this, parameter);
105 | Executed(this, e);
106 | }
107 | }
108 | }
109 |
110 | ///
111 | /// Executes the command
112 | ///
113 | /// The parameter.
114 | /// The event source.
115 | public virtual void Execute(object parameter, object source)
116 | {
117 | if (RaiseCanExecute(parameter))
118 | {
119 | if (Executed != null)
120 | {
121 | var e = new ExecutedEventArgs(this, parameter, source);
122 | Executed(this, e);
123 | }
124 | }
125 | }
126 |
127 | ///
128 | /// Raises the can execute event.
129 | ///
130 | /// The parameter.
131 | /// returns true if the command can be executed, otherwise false.
132 | public virtual bool RaiseCanExecute(object parameter)
133 | {
134 | if (CanExecute != null)
135 | {
136 | var e = new CanExecuteEventArgs(this, parameter);
137 | CanExecute(this, e);
138 | return e.CanExecute;
139 | }
140 |
141 | return true;
142 | }
143 |
144 | #endregion Methods
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/TobbyBingMaps.MapGeometry/EnhancedMapShapeBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Windows.Shapes;
5 | using TobbyBingMaps.Common.Converters;
6 | using GisSharpBlog.NetTopologySuite.Simplify;
7 | using Microsoft.Maps.MapControl;
8 | using Microsoft.Maps.MapControl.Core;
9 |
10 | namespace TobbyBingMaps.MapGeometry
11 | {
12 | public abstract class EnhancedMapShapeBase : MapShapeBase, IDisposable, IScalable, IReduceable, IClipable
13 | {
14 | private double scale;
15 | private double strokeThickness;
16 | private readonly BackgroundWorker reductionWorker = new BackgroundWorker();
17 |
18 | public event EventHandler ReductionComplete;
19 |
20 | protected EnhancedMapShapeBase(Shape shape)
21 | : base(shape)
22 | {
23 | Scale = 1;
24 | Reduced = new Dictionary();
25 | reductionWorker.WorkerSupportsCancellation = true;
26 | reductionWorker.DoWork += reductionWorkerDoWork;
27 | reductionWorker.RunWorkerCompleted += reductionWorkerOnCompleted;
28 | }
29 |
30 | private void reductionWorkerDoWork(object sender, DoWorkEventArgs args)
31 | {
32 | var worker = sender as BackgroundWorker;
33 | var lineSimplify = new DouglasPeuckerLineSimplifier(CoordinateConvertor.LocationCollectionToCoordinates(Original));
34 | for (int i = 21; i > 0; i--)
35 | {
36 |
37 | if (worker != null && worker.CancellationPending)
38 | {
39 | args.Cancel = true;
40 | break;
41 | }
42 |
43 | var simplificationDistance = (1 / (Math.Pow(2, i - 1)));
44 | lineSimplify.DistanceTolerance = simplificationDistance;
45 | Reduced.Add(i, CoordinateConvertor.CoordinatesToLocationCollection(lineSimplify.Simplify()));
46 | }
47 |
48 | Initalized = true;
49 | }
50 |
51 | private void startReductionWorker()
52 | {
53 | //only be running once instance, if already running we cancel and wait.
54 | if (reductionWorker.WorkerSupportsCancellation && reductionWorker.IsBusy)
55 | {
56 | reductionWorker.CancelAsync();
57 | }
58 | else
59 | {
60 | reductionWorker.RunWorkerAsync();
61 | }
62 | }
63 |
64 | private void reductionWorkerOnCompleted(object sender, RunWorkerCompletedEventArgs e)
65 | {
66 | if (e.Cancelled)
67 | {
68 | startReductionWorker();
69 | }
70 | else if (ReductionComplete != null)
71 | {
72 | ReductionComplete(this, new EventArgs());
73 | }
74 | }
75 |
76 | public new LocationCollection Locations
77 | {
78 | get { return base.Locations; }
79 | set
80 | {
81 | Original = value;
82 | MBR = new LocationRect(value);
83 | base.Locations = new LocationCollection { new Location(0, 0) };
84 | Initalized = false;
85 | Reduced.Clear();
86 | startReductionWorker();
87 | }
88 | }
89 |
90 | public new double StrokeThickness
91 | {
92 | get { return strokeThickness; }
93 | set
94 | {
95 | strokeThickness = value;
96 | updateThickness();
97 | }
98 | }
99 |
100 | #region IDisposable Members
101 |
102 | public void Dispose()
103 | {
104 | reductionWorker.RunWorkerCompleted -= reductionWorkerOnCompleted;
105 | if (reductionWorker.WorkerSupportsCancellation && reductionWorker.IsBusy)
106 | {
107 | reductionWorker.CancelAsync();
108 | }
109 | Reduced.Clear();
110 | Reduced = null;
111 | }
112 |
113 | #endregion
114 |
115 | #region IScalable Members
116 |
117 | public double Scale
118 | {
119 | get { return scale; }
120 | set
121 | {
122 | scale = value;
123 | updateThickness();
124 | }
125 | }
126 |
127 | #endregion
128 |
129 | private void updateThickness()
130 | {
131 | base.StrokeThickness = StrokeThickness * Scale;
132 | }
133 |
134 | public LocationCollection Original { get; set; }
135 | public Dictionary Reduced { get; set; }
136 | public int CurrentDisplayed { get; set; }
137 | public bool Initalized { get; set; }
138 | public LocationRect MBR { get; set; }
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/BaseMap/Control/ToolBarItem.xaml:
--------------------------------------------------------------------------------
1 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/BaseMap.Web/BaseMap.Web.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 |
7 |
8 | 2.0
9 | {66BE2647-5A4D-4149-8F30-C291AF176C1C}
10 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
11 | Library
12 | Properties
13 | BaseMap.Web
14 | BaseMap.Web
15 | v4.0
16 | {4B266542-73EC-4594-A330-9E9048718283}|..\BaseMap\BaseMap.csproj|ClientBin|False
17 |
18 |
19 | true
20 | full
21 | false
22 | bin\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | pdbonly
29 | true
30 | bin\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 | ..\dlls\Npgsql.dll
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | Designer
66 |
67 |
68 | Web.config
69 |
70 |
71 | Web.config
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | RoutingWebService.asmx
80 | Component
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 | False
91 | True
92 | 2478
93 | /
94 |
95 |
96 | False
97 | False
98 |
99 |
100 | False
101 |
102 |
103 |
104 |
105 |
112 |
--------------------------------------------------------------------------------
/TobbyBingMaps.MapGeometry/BaseGeometry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.ObjectModel;
3 | using System.Windows;
4 | using System.Windows.Controls;
5 | using TobbyBingMaps.Common.Converters;
6 | using TobbyBingMaps.Common.Entities;
7 | using GeoAPI.Geometries;
8 | using Microsoft.Maps.MapControl;
9 | using Microsoft.Maps.MapControl.Core;
10 |
11 | namespace TobbyBingMaps.MapGeometry
12 | {
13 | ///
14 | /// A geometry object on the map.
15 | /// Creates and manages a collection of points, lines and polygons (mapObjects) based on the IGeometry type.
16 | /// Provides a common object to apply style and metadata onto.
17 | ///
18 | public class BaseGeometry : IDisposable
19 | {
20 | private Visibility visibility;
21 | private readonly MapCore mapInstance;
22 | private readonly EnhancedMapLayer mapLayer;
23 |
24 | public BaseGeometry(IGeometry geometry, StyleSpecification styleSpecification, MapCore map, EnhancedMapLayer layer)
25 | {
26 | Geometry = geometry;
27 | StyleSpecification = styleSpecification;
28 | mapInstance = map;
29 | mapLayer = layer;
30 | mapObjects = new ObservableCollection();
31 | if (mapLayer != null)
32 | {
33 | createGeometry(mapLayer, Geometry);
34 | }
35 | }
36 |
37 | internal ObservableCollection mapObjects { get; set; }
38 |
39 | public string ItemID { get; set; }
40 |
41 | public EnhancedMapLayer MapLayer { get { return mapLayer; } }
42 |
43 | public IGeometry Geometry { get; set; }
44 |
45 | public StyleSpecification StyleSpecification { get; set; }
46 |
47 | public DateTime TimeStamp { get; set; }
48 |
49 | public Visibility Visibility
50 | {
51 | get { return visibility; }
52 | set
53 | {
54 | if (visibility != value)
55 | {
56 | visibility = value;
57 | foreach (var mapObject in mapObjects)
58 | {
59 | mapObject.Visibility = visibility;
60 | }
61 | }
62 | }
63 | }
64 |
65 | #region IDisposable Members
66 |
67 | public void Dispose()
68 | {
69 | removeGeometry();
70 | }
71 |
72 | #endregion
73 |
74 | private void removeGeometry()
75 | {
76 | foreach (var mapObject in mapObjects)
77 | {
78 | mapLayer.Remove(mapObject);
79 | }
80 | mapObjects.Clear();
81 | }
82 |
83 | protected void createGeometry(MapLayerBase layer, IGeometry geo)
84 | {
85 | if (geo is IPoint)
86 | {
87 | var point = (IPoint)geo;
88 | createPoint(point, layer);
89 | }
90 | if (geo is ILineString)
91 | {
92 | var lineString = (ILineString)geo;
93 | createPolyLine(lineString, layer);
94 | }
95 | if (geo is IPolygon)
96 | {
97 | var polygon = (IPolygon)geo;
98 | createPolygon(polygon, layer);
99 | }
100 | if (geo is IGeometryCollection)
101 | {
102 | var geometryCollection = (IGeometryCollection)geo;
103 | foreach (IGeometry subgeometry in geometryCollection.Geometries)
104 | {
105 | createGeometry(layer, subgeometry);
106 | }
107 | }
108 | }
109 |
110 | protected EnhancedMapPoint createPoint(IGeometry point, MapLayerBase layer)
111 | {
112 | var location = CoordinateConvertor.ConvertBack(point.Coordinate);
113 | var mapPoint = new EnhancedMapPoint(location, mapInstance) { GeometryStyle = StyleSpecification };
114 | layer.AddChild(mapPoint, location);
115 | mapObjects.Add(mapPoint);
116 | mapPoint.Visibility = Visibility;
117 | return mapPoint;
118 | }
119 |
120 | protected EnhancedMapPolyline createPolyLine(IGeometry lineString, MapLayerBase layer)
121 | {
122 | var line = new EnhancedMapPolyline
123 | {
124 | Locations = CoordinateConvertor.CoordinatesToLocationCollection(lineString.Coordinates),
125 | GeometryStyle = StyleSpecification,
126 | Visibility = Visibility
127 | };
128 | layer.AddChild(line, CoordinateConvertor.ConvertBack(lineString.Centroid.Coordinate));
129 | mapObjects.Add(line);
130 | return line;
131 | }
132 |
133 | protected EnhancedMapPolygon createPolygon(IGeometry polygon, MapLayerBase layer)
134 | {
135 | var poly = new EnhancedMapPolygon
136 | {
137 | Locations = CoordinateConvertor.CoordinatesToLocationCollection(polygon.Coordinates),
138 | GeometryStyle = StyleSpecification,
139 | Visibility = Visibility
140 | };
141 | layer.AddChild(poly, CoordinateConvertor.ConvertBack(polygon.Centroid.Coordinate));
142 | mapObjects.Add(poly);
143 | return poly;
144 | }
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/TobbyBingMaps.MapGeometry/SelectGeometry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Specialized;
3 | using System.Windows.Controls;
4 | using System.Windows.Input;
5 | using TobbyBingMaps.Common;
6 | using TobbyBingMaps.Common.Entities;
7 | using GeoAPI.Geometries;
8 | using Microsoft.Maps.MapControl.Core;
9 |
10 |
11 | namespace TobbyBingMaps.MapGeometry
12 | {
13 | public delegate void SelectedEventHandler(object sender, EventArgs args);
14 |
15 | ///
16 | /// Geometry with mouse over effect a common selected event handler.
17 | ///
18 | public class SelectGeometry : BaseGeometry
19 | {
20 | public SelectGeometry(IGeometry geometry, StyleSpecification styleSpecification, MapCore map,
21 | EnhancedMapLayer layer)
22 | : base(geometry, styleSpecification, map, layer)
23 | {
24 | //default is the inverse of the style colours + 50% larger icon.
25 | SelectedSpecification = styleSpecification.Clone();
26 | SelectedSpecification.IconScale = styleSpecification.IconScale * 1.5;
27 | SelectedSpecification.LineColour = Utilities.InvertColorFromHexString(styleSpecification.LineColour);
28 | SelectedSpecification.PolyFillColour = Utilities.InvertColorFromHexString(styleSpecification.PolyFillColour);
29 |
30 | foreach (Control mapObject in mapObjects)
31 | {
32 | mapObject.MouseLeftButtonDown += SelectGeometry_MouseLeftButtonDown;
33 | mapObject.MouseEnter += SelectGeometry_MouseEnter;
34 | mapObject.MouseLeave += SelectGeometry_MouseLeave;
35 | }
36 |
37 | mapObjects.CollectionChanged += mapObjects_CollectionChanged;
38 |
39 | EnableSelection = true;
40 | }
41 |
42 | public StyleSpecification SelectedSpecification { get; set; }
43 | public bool EnableSelection { get; set; }
44 |
45 | private void mapObjects_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
46 | {
47 | if (e.OldItems != null)
48 | {
49 | foreach (Control oldItem in e.OldItems)
50 | {
51 | oldItem.MouseLeftButtonDown -= SelectGeometry_MouseLeftButtonDown;
52 | oldItem.MouseEnter -= SelectGeometry_MouseEnter;
53 | oldItem.MouseLeave -= SelectGeometry_MouseLeave;
54 | }
55 | }
56 | if (e.NewItems != null)
57 | {
58 | foreach (Control newItem in e.NewItems)
59 | {
60 | newItem.MouseLeftButtonDown += SelectGeometry_MouseLeftButtonDown;
61 | newItem.MouseEnter += SelectGeometry_MouseEnter;
62 | newItem.MouseLeave += SelectGeometry_MouseLeave;
63 | }
64 | }
65 | }
66 |
67 | public event SelectedEventHandler Selected;
68 |
69 | protected virtual void OnSelected(EventArgs e)
70 | {
71 | if (Selected != null)
72 | Selected(this, e);
73 | }
74 |
75 |
76 | private void SelectGeometry_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
77 | {
78 | if (EnableSelection)
79 | {
80 | OnSelected(new EventArgs());
81 | }
82 | }
83 |
84 | private void SelectGeometry_MouseLeave(object sender, MouseEventArgs e)
85 | {
86 | Restore();
87 | }
88 |
89 |
90 | private void SelectGeometry_MouseEnter(object sender, MouseEventArgs e)
91 | {
92 | Select();
93 | }
94 |
95 | public void Select()
96 | {
97 | if (EnableSelection && SelectedSpecification != null)
98 | {
99 | setStyleOnMapObjects(SelectedSpecification);
100 | }
101 | }
102 |
103 | public void Restore()
104 | {
105 | setStyleOnMapObjects(StyleSpecification);
106 | }
107 |
108 | private void setStyleOnMapObjects(StyleSpecification styleSpecification)
109 | {
110 | foreach (Control mapObject in mapObjects)
111 | {
112 | if (mapObject is EnhancedMapPoint)
113 | {
114 | ((EnhancedMapPoint)mapObject).GeometryStyle = styleSpecification;
115 | }
116 | if (mapObject is EnhancedMapPolyline)
117 | {
118 | ((EnhancedMapPolyline)mapObject).GeometryStyle = styleSpecification;
119 | }
120 | if (mapObject is EnhancedMapPolygon)
121 | {
122 | ((EnhancedMapPolygon)mapObject).GeometryStyle = styleSpecification;
123 | }
124 | }
125 | }
126 |
127 | private void removeGeometry()
128 | {
129 | foreach (Control mapObject in mapObjects)
130 | {
131 | mapObject.MouseLeftButtonDown -= SelectGeometry_MouseLeftButtonDown;
132 | mapObject.MouseEnter -= SelectGeometry_MouseEnter;
133 | mapObject.MouseLeave -= SelectGeometry_MouseLeave;
134 | }
135 | }
136 |
137 | public new void Dispose()
138 | {
139 | removeGeometry();
140 | base.Dispose();
141 | }
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/TobbyBingMaps.Common/TobbyBingMaps.Common.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.50727
7 | 2.0
8 | {DD23CC44-6A41-4599-A55A-8D2F11CC86D9}
9 | {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
10 | Library
11 | Properties
12 | TobbyBingMaps.Common
13 | TobbyBingMaps.Common
14 | Silverlight
15 | v4.0
16 | $(TargetFrameworkVersion)
17 | false
18 | true
19 | true
20 |
21 |
24 |
25 | v3.5
26 |
27 |
28 | true
29 | full
30 | false
31 | Bin\Debug
32 | DEBUG;TRACE;SILVERLIGHT
33 | true
34 | true
35 | prompt
36 | 4
37 |
38 |
39 | pdbonly
40 | true
41 | Bin\Release
42 | TRACE;SILVERLIGHT
43 | true
44 | true
45 | prompt
46 | 4
47 |
48 |
49 |
50 | D:\SL4\Libraries\GeoAPI\Bin\Debug\GeoAPI.dll
51 |
52 |
53 | D:\SL4\Toolkit\Client\DeepEarth.BingMapsToolkit.Client.MapGeometry\Bin\Debug\Microsoft.Maps.MapControl.dll
54 |
55 |
56 | D:\SL4\Toolkit\Client\DeepEarth.BingMapsToolkit.Client.MapGeometry\Bin\Debug\Microsoft.Maps.MapControl.Common.dll
57 |
58 |
59 |
60 | D:\SL4\Libraries\NetTopologySuite\Bin\Debug\NetTopologySuite.dll
61 |
62 |
63 | D:\SL4\Toolkit\Client\DeepEarth.BingMapsToolkit.Client.MapGeometry\Bin\Debug\ProjNet.Silverlight.dll
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
108 |
--------------------------------------------------------------------------------
/TobbyBingMaps.MapGeometry/TobbyBingMaps.MapGeometry.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.50727
7 | 2.0
8 | {6D766A3E-65BD-4F81-AA87-7AE567D3E854}
9 | {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
10 | Library
11 | Properties
12 | TobbyBingMaps.MapGeometry
13 | TobbyBingMaps.MapGeometry
14 | Silverlight
15 | v4.0
16 | $(TargetFrameworkVersion)
17 | false
18 | true
19 | true
20 |
21 |
24 |
25 | v3.5
26 |
27 |
28 | true
29 | full
30 | false
31 | Bin\Debug
32 | DEBUG;TRACE;SILVERLIGHT
33 | true
34 | true
35 | prompt
36 | 4
37 |
38 |
39 | pdbonly
40 | true
41 | Bin\Release
42 | TRACE;SILVERLIGHT
43 | true
44 | true
45 | prompt
46 | 4
47 |
48 |
49 |
50 | D:\SL4\Libraries\GeoAPI\Bin\Debug\GeoAPI.dll
51 |
52 |
53 | D:\SL4\Toolkit\Client\DeepEarth.BingMapsToolkit.Client.MapGeometry\Bin\Debug\Microsoft.Maps.MapControl.dll
54 |
55 |
56 | D:\SL4\Toolkit\Client\DeepEarth.BingMapsToolkit.Client.MapGeometry\Bin\Debug\Microsoft.Maps.MapControl.Common.dll
57 |
58 |
59 |
60 | D:\SL4\Toolkit\Client\DeepEarth.BingMapsToolkit.Client.MapGeometry\Bin\Debug\NetTopologySuite.dll
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 | {DD23CC44-6A41-4599-A55A-8D2F11CC86D9}
91 | TobbyBingMaps.Common
92 |
93 |
94 |
95 |
96 | Designer
97 | MSBuild:Compile
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
115 |
--------------------------------------------------------------------------------
/TobbyBingMaps.Common/Commanding/CommandService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 |
5 |
6 | namespace TobbyBingMaps.Common.Commanding
7 | {
8 | ///
9 | /// Service class that provides the system implementation for linking Command
10 | ///
11 | public static class CommandService
12 | {
13 | #region Fields
14 |
15 | ///
16 | /// The DependencyProperty for the CommandParameter property.
17 | ///
18 | public static readonly DependencyProperty CommandParameterProperty =
19 | DependencyProperty.RegisterAttached(
20 | "CommandParameter", // Name
21 | typeof(object), // Type
22 | typeof(CommandService), // Owner
23 | null);
24 |
25 | ///
26 | /// The DependencyProperty for the Command property.
27 | ///
28 | public static readonly DependencyProperty CommandProperty =
29 | DependencyProperty.RegisterAttached(
30 | "Command", // Name
31 | typeof(string), // Type
32 | typeof(CommandService), // Owner
33 | new PropertyMetadata(CommandChanged));
34 |
35 | #endregion Fields
36 |
37 | #region Methods
38 |
39 | ///
40 | /// Finds a command from its name.
41 | ///
42 | /// The command name.
43 | /// returns the command for a given commandName
44 | public static Command FindCommand(string commandName)
45 | {
46 | if (string.IsNullOrEmpty(commandName))
47 | {
48 | return null;
49 | }
50 |
51 | // Check from cache
52 | Command cmd;
53 | if (Command.CommandCache.TryGetValue(commandName, out cmd))
54 | {
55 | return cmd;
56 | }
57 |
58 | return null;
59 | }
60 |
61 | ///
62 | /// Gets the value of the Command property.
63 | ///
64 | /// The object on which to query the property.
65 | /// The value of the property.
66 | public static string GetCommand(DependencyObject element)
67 | {
68 | if (element == null)
69 | {
70 | throw new ArgumentNullException("element");
71 | }
72 |
73 | return (string)element.GetValue(CommandProperty);
74 | }
75 |
76 | ///
77 | /// Gets the value of the CommandParameter property.
78 | ///
79 | /// The object on which to query the property.
80 | /// The value of the property.
81 | public static object GetCommandParameter(DependencyObject element)
82 | {
83 | if (element == null)
84 | {
85 | throw new ArgumentNullException("element");
86 | }
87 |
88 | return element.GetValue(CommandParameterProperty);
89 | }
90 |
91 | ///
92 | /// Sets the value of the Command property.
93 | ///
94 | /// The object on which to set the value.
95 | /// The desired value of the property.
96 | public static void SetCommand(DependencyObject element, string value)
97 | {
98 | if (element == null)
99 | {
100 | throw new ArgumentNullException("element");
101 | }
102 |
103 | element.SetValue(CommandProperty, value);
104 | }
105 |
106 | ///
107 | /// Sets the value of the CommandParameter property.
108 | ///
109 | /// The object on which to set the value.
110 | /// The desired value of the property.
111 | public static void SetCommandParameter(DependencyObject element, object value)
112 | {
113 | if (element == null)
114 | {
115 | throw new ArgumentNullException("element");
116 | }
117 |
118 | element.SetValue(CommandParameterProperty, value);
119 | }
120 |
121 | public static void UnregisterCommands(FrameworkElement obj)
122 | {
123 | CommandSubscription.UnregisterAllSubscriptions(obj);
124 | }
125 |
126 | public static void UnregisterCommandsRecursive(FrameworkElement obj)
127 | {
128 | var pnl = obj as Panel;
129 | if (pnl != null)
130 | {
131 | foreach (var item in pnl.Children)
132 | {
133 | UnregisterCommandsRecursive(item as FrameworkElement);
134 | }
135 | }
136 | CommandSubscription.UnregisterAllSubscriptions(obj);
137 | }
138 |
139 | ///
140 | /// occurs when the command change on a
141 | ///
142 | /// The dependency object.
143 | /// The instance containing the event data.
144 | private static void CommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
145 | {
146 | if (d is FrameworkElement)
147 | {
148 | var elem = (FrameworkElement)d;
149 | var oldCommands = e.OldValue as string;
150 | if (!string.IsNullOrEmpty(oldCommands))
151 | {
152 | foreach (var item in oldCommands.Split(' '))
153 | {
154 | CommandSubscription.UnregisterSubscription(item, elem);
155 | }
156 | }
157 |
158 | var newCommands = e.NewValue as string;
159 | if (!string.IsNullOrEmpty(newCommands))
160 | {
161 | foreach (var item in newCommands.Split(' '))
162 | {
163 | CommandSubscription.RegisterCommand(item, elem);
164 | }
165 | }
166 | }
167 | }
168 |
169 | #endregion Methods
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/TobbyBingMaps.Common/Entities/LayerDefinition.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 |
5 | namespace TobbyBingMaps.Common.Entities
6 | {
7 | //Class must be partial as the server componant has additional properties not required on client.
8 | // ReSharper disable PartialTypeWithSinglePart
9 | public partial class LayerDefinition : INotifyPropertyChanged
10 | // ReSharper restore PartialTypeWithSinglePart
11 | {
12 | private DateTime currentVersion;
13 | private bool isEditable;
14 | private bool labelOn;
15 | private string layerAlias;
16 | private string layerId;
17 | private string layerStyleName;
18 | private int layerTimeout;
19 | private int layerType;
20 | private int maxDisplayLevel;
21 | private byte[] mbr;
22 | private int minDisplayLevel;
23 | private bool permissionToEdit;
24 | private bool selected;
25 | private string tags;
26 | private int zIndex;
27 | private bool temporal;
28 | private string iconUri;
29 | private string layerUri;
30 | private int publishMethod;
31 | private StyleSpecification style;
32 |
33 | public LayerDefinition()
34 | {
35 | ObjectAttributes = new Dictionary();
36 | }
37 |
38 | public string LayerID
39 | {
40 | get { return layerId; }
41 | set
42 | {
43 | layerId = value;
44 | UpdateProperty("LayerID");
45 | }
46 | }
47 |
48 | public string LayerAlias
49 | {
50 | get { return layerAlias; }
51 | set
52 | {
53 | layerAlias = value;
54 | UpdateProperty("LayerAlias");
55 | }
56 | }
57 |
58 | public string Tags
59 | {
60 | get { return tags; }
61 | set
62 | {
63 | tags = value;
64 | UpdateProperty("Tags");
65 | }
66 | }
67 |
68 | public int LayerType
69 | {
70 | get { return layerType; }
71 | set
72 | {
73 | layerType = value;
74 | UpdateProperty("LayerType");
75 | }
76 | }
77 |
78 | public bool IsEditable
79 | {
80 | get { return isEditable; }
81 | set
82 | {
83 | isEditable = value;
84 | UpdateProperty("IsEditable");
85 | }
86 | }
87 |
88 | public bool Selected
89 | {
90 | get { return selected; }
91 | set
92 | {
93 | selected = value;
94 | UpdateProperty("Selected");
95 | }
96 | }
97 |
98 | public bool LabelOn
99 | {
100 | get { return labelOn; }
101 | set
102 | {
103 | labelOn = value;
104 | UpdateProperty("LabelOn");
105 | }
106 | }
107 |
108 | public DateTime CurrentVersion
109 | {
110 | get { return currentVersion; }
111 | set
112 | {
113 | currentVersion = value;
114 | UpdateProperty("CurrentVersion");
115 | }
116 | }
117 |
118 | public int MinDisplayLevel
119 | {
120 | get { return minDisplayLevel; }
121 | set
122 | {
123 | minDisplayLevel = value;
124 | UpdateProperty("MinDisplayLevel");
125 | }
126 | }
127 |
128 | public int MaxDisplayLevel
129 | {
130 | get { return maxDisplayLevel; }
131 | set
132 | {
133 | maxDisplayLevel = value;
134 | UpdateProperty("MaxDisplayLevel");
135 | }
136 | }
137 |
138 | public byte[] MBR
139 | {
140 | get { return mbr; }
141 | set
142 | {
143 | mbr = value;
144 | UpdateProperty("MBR");
145 | }
146 | }
147 |
148 | public string LayerStyleName
149 | {
150 | get { return layerStyleName; }
151 | set
152 | {
153 | layerStyleName = value;
154 | UpdateProperty("LayerStyleName");
155 | }
156 | }
157 |
158 | public int LayerTimeout
159 | {
160 | get { return layerTimeout; }
161 | set
162 | {
163 | layerTimeout = value;
164 | UpdateProperty("LayerTimeout");
165 | }
166 | }
167 |
168 | public int ZIndex
169 | {
170 | get { return zIndex; }
171 | set
172 | {
173 | zIndex = value;
174 | UpdateProperty("ZIndex");
175 | }
176 | }
177 |
178 | public bool PermissionToEdit
179 | {
180 | get { return permissionToEdit; }
181 | set
182 | {
183 | permissionToEdit = value;
184 | UpdateProperty("PermissionToEdit");
185 | }
186 | }
187 |
188 | public bool Temporal
189 | {
190 | get { return temporal; }
191 | set
192 | {
193 | temporal = value;
194 | UpdateProperty("Temporal");
195 | }
196 | }
197 |
198 | public string IconURI
199 | {
200 | get { return iconUri; }
201 | set
202 | {
203 | iconUri = value;
204 | UpdateProperty("IconURI");
205 | }
206 | }
207 |
208 | public string LayerURI
209 | {
210 | get { return layerUri; }
211 | set
212 | {
213 | layerUri = value;
214 | UpdateProperty("LayerURI");
215 | }
216 | }
217 |
218 | public int PublishMethod
219 | {
220 | get { return publishMethod; }
221 | set
222 | {
223 | publishMethod = value;
224 | UpdateProperty("PublishMethod");
225 | }
226 | }
227 |
228 | public StyleSpecification Style
229 | {
230 | get { return style; }
231 | set
232 | {
233 | style = value;
234 | UpdateProperty("Style");
235 | }
236 | }
237 |
238 | public Dictionary ObjectAttributes { get; set; }
239 |
240 | #region INotifyPropertyChanged Members
241 |
242 | public event PropertyChangedEventHandler PropertyChanged;
243 |
244 | #endregion
245 |
246 | public void UpdateProperty(string propertyName)
247 | {
248 | if (PropertyChanged != null)
249 | {
250 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
251 | }
252 | }
253 | }
254 | }
255 |
--------------------------------------------------------------------------------
/BaseMap.Web/Silverlight.js:
--------------------------------------------------------------------------------
1 | //v2.0.30511.0
2 | if(!window.Silverlight)window.Silverlight={};Silverlight._silverlightCount=0;Silverlight.__onSilverlightInstalledCalled=false;Silverlight.fwlinkRoot="http://go2.microsoft.com/fwlink/?LinkID=";Silverlight.__installationEventFired=false;Silverlight.onGetSilverlight=null;Silverlight.onSilverlightInstalled=function(){window.location.reload(false)};Silverlight.isInstalled=function(b){if(b==undefined)b=null;var a=false,m=null;try{var i=null,j=false;if(window.ActiveXObject)try{i=new ActiveXObject("AgControl.AgControl");if(b===null)a=true;else if(i.IsVersionSupported(b))a=true;i=null}catch(l){j=true}else j=true;if(j){var k=navigator.plugins["Silverlight Plug-In"];if(k)if(b===null)a=true;else{var h=k.description;if(h==="1.0.30226.2")h="2.0.30226.2";var c=h.split(".");while(c.length>3)c.pop();while(c.length<4)c.push(0);var e=b.split(".");while(e.length>4)e.pop();var d,g,f=0;do{d=parseInt(e[f]);g=parseInt(c[f]);f++}while(f");delete a.id;delete a.width;delete a.height;for(var c in a)if(a[c])b.push('');b.push("");return b.join("")};Silverlight.createObjectEx=function(b){var a=b,c=Silverlight.createObject(a.source,a.parentElement,a.id,a.properties,a.events,a.initParams,a.context);if(a.parentElement==null)return c};Silverlight.buildPromptHTML=function(b){var a="",d=Silverlight.fwlinkRoot,c=b.version;if(b.alt)a=b.alt;else{if(!c)c="";a="
";a=a.replace("{1}",c);a=a.replace("{2}",d+"108181")}return a};Silverlight.getSilverlight=function(e){if(Silverlight.onGetSilverlight)Silverlight.onGetSilverlight();var b="",a=String(e).split(".");if(a.length>1){var c=parseInt(a[0]);if(isNaN(c)||c<2)b="1.0";else b=a[0]+"."+a[1]}var d="";if(b.match(/^\d+\056\d+$/))d="&v="+b;Silverlight.followFWLink("149156"+d)};Silverlight.followFWLink=function(a){top.location=Silverlight.fwlinkRoot+String(a)};Silverlight.HtmlAttributeEncode=function(c){var a,b="";if(c==null)return null;for(var d=0;d96&&a<123||a>64&&a<91||a>43&&a<58&&a!=47||a==95)b=b+String.fromCharCode(a);else b=b+""+a+";"}return b};Silverlight.default_error_handler=function(e,b){var d,c=b.ErrorType;d=b.ErrorCode;var a="\nSilverlight error message \n";a+="ErrorCode: "+d+"\n";a+="ErrorType: "+c+" \n";a+="Message: "+b.ErrorMessage+" \n";if(c=="ParserError"){a+="XamlFile: "+b.xamlFile+" \n";a+="Line: "+b.lineNumber+" \n";a+="Position: "+b.charPosition+" \n"}else if(c=="RuntimeError"){if(b.lineNumber!=0){a+="Line: "+b.lineNumber+" \n";a+="Position: "+b.charPosition+" \n"}a+="MethodName: "+b.methodName+" \n"}alert(a)};Silverlight.__cleanup=function(){for(var a=Silverlight._silverlightCount-1;a>=0;a--)window["__slEvent"+a]=null;Silverlight._silverlightCount=0;if(window.removeEventListener)window.removeEventListener("unload",Silverlight.__cleanup,false);else window.detachEvent("onunload",Silverlight.__cleanup)};Silverlight.__getHandlerName=function(b){var a="";if(typeof b=="string")a=b;else if(typeof b=="function"){if(Silverlight._silverlightCount==0)if(window.addEventListener)window.addEventListener("onunload",Silverlight.__cleanup,false);else window.attachEvent("onunload",Silverlight.__cleanup);var c=Silverlight._silverlightCount++;a="__slEvent"+c;window[a]=b}else a=null;return a};Silverlight.onRequiredVersionAvailable=function(){};Silverlight.onRestartRequired=function(){};Silverlight.onUpgradeRequired=function(){};Silverlight.onInstallRequired=function(){};Silverlight.IsVersionAvailableOnError=function(d,a){var b=false;try{if(a.ErrorCode==8001&&!Silverlight.__installationEventFired){Silverlight.onUpgradeRequired();Silverlight.__installationEventFired=true}else if(a.ErrorCode==8002&&!Silverlight.__installationEventFired){Silverlight.onRestartRequired();Silverlight.__installationEventFired=true}else if(a.ErrorCode==5014||a.ErrorCode==2106){if(Silverlight.__verifySilverlight2UpgradeSuccess(a.getHost()))b=true}else b=true}catch(c){}return b};Silverlight.IsVersionAvailableOnLoad=function(b){var a=false;try{if(Silverlight.__verifySilverlight2UpgradeSuccess(b.getHost()))a=true}catch(c){}return a};Silverlight.__verifySilverlight2UpgradeSuccess=function(d){var c=false,b="2.0.31005",a=null;try{if(d.IsVersionSupported(b+".99")){a=Silverlight.onRequiredVersionAvailable;c=true}else if(d.IsVersionSupported(b+".0"))a=Silverlight.onRestartRequired;else a=Silverlight.onUpgradeRequired;if(a&&!Silverlight.__installationEventFired){a();Silverlight.__installationEventFired=true}}catch(e){}return c}
--------------------------------------------------------------------------------
/BaseMap/Class/CustomIconSpecification.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 | using System.Windows;
4 | using System.Windows.Controls;
5 | using System.Windows.Documents;
6 | using System.Windows.Ink;
7 | using System.Windows.Input;
8 | using System.Windows.Media;
9 | using System.Windows.Media.Animation;
10 | using System.Windows.Shapes;
11 | using System.ComponentModel;
12 | using Microsoft.Maps.MapControl;
13 |
14 | namespace BaseMap.Class
15 | {
16 |
17 | public static class CustomPushPinExtensions
18 | {
19 | ///
20 | /// Allows a custom pushpin to be added to a MapLayer
21 | ///
22 | /// MapLayer to add custom pushpin to
23 | /// Custom Pushpin to add to layer
24 | public static void AddChild(this MapLayer layer, CustomPushpin pushpin)
25 | {
26 | layer.AddChild(pushpin, pushpin.Location);
27 | }
28 | public static void RemoveChild(this MapLayer layer, CustomPushpin pushpin)
29 | {
30 | layer.Children.Remove(pushpin);
31 | }
32 |
33 | }
34 | public class CustomIconSpecification : INotifyPropertyChanged
35 | {
36 | #region Private Variables
37 |
38 | //Default properties
39 | private double width = 30;
40 | private double height = 30;
41 | private int rotateTr = 0;
42 | private Brush textColor = new SolidColorBrush(Colors.Black);
43 | private double fontSize = 10;
44 | private Point iconOffset = new Point(0, 0);
45 | private Point textOffset = new Point(0, 0);
46 | private PlaneProjection planeProjection = new PlaneProjection();
47 |
48 | public PlaneProjection PlaneProjection
49 | {
50 | get { return planeProjection; }
51 | set
52 | {
53 | planeProjection = value;
54 | NotifyPropertyChanged("PlaneProjection");
55 | }
56 | }
57 |
58 | #endregion
59 |
60 | #region Public Properties
61 |
62 | ///
63 | /// A user can use a UIElement as a pushpin icon
64 | ///
65 | private UIElement _Icon;
66 | public UIElement Icon
67 | {
68 | get
69 | {
70 | return _Icon;
71 | }
72 | set
73 | {
74 | _Icon = value;
75 | NotifyPropertyChanged("Icon");
76 | }
77 | }
78 |
79 | ///
80 | /// If a uri is specified for an icon and image will be created. This is only used if the Icon property is null.
81 | ///
82 | private Uri _IconUri;
83 | public Uri IconUri
84 | {
85 | get
86 | {
87 | return _IconUri;
88 | }
89 | set
90 | {
91 | _IconUri = value;
92 | NotifyPropertyChanged("IconUri");
93 | }
94 | }
95 |
96 | ///
97 | /// Offset used for positioning icon so that pin point is anchored to coordinate
98 | ///
99 | private Point _IconOffsett;
100 | public Point IconOffset
101 | {
102 | get
103 | {
104 | return _IconOffsett;
105 | }
106 | set
107 | {
108 | _IconOffsett = value;
109 | NotifyPropertyChanged("IconOffset");
110 | }
111 | }
112 |
113 | ///
114 | /// Height of the pushpin. This is used for positioning Text and for sizing the icon image
115 | ///
116 | private double _Height;
117 | public double Height
118 | {
119 | get
120 | {
121 | return _Height;
122 | }
123 | set
124 | {
125 | _Height = value;
126 | NotifyPropertyChanged("Height");
127 | }
128 | }
129 |
130 | ///
131 | /// Width of the pushpin. This is used for positioning Text and for sizing the icon image
132 | ///
133 | private double _Width;
134 | public double Width
135 | {
136 | get
137 | {
138 | return _Width;
139 | }
140 | set
141 | {
142 | _Width = value;
143 | NotifyPropertyChanged("Width");
144 | }
145 | }
146 |
147 | ///
148 | /// Width of the pushpin. This is used for positioning Text and for sizing the icon image
149 | ///
150 | private int _RotateTr;
151 | public int RotateTr
152 | {
153 | get
154 | {
155 | return _RotateTr;
156 | }
157 | set
158 | {
159 | _RotateTr = value;
160 | NotifyPropertyChanged("RotateTr");
161 | }
162 | }
163 |
164 | ///
165 | /// Custom text to be displayed above the pushpin.
166 | ///
167 | private string _TextContent;
168 | public string TextContent
169 | {
170 | get
171 | {
172 | return _TextContent;
173 | }
174 | set
175 | {
176 | _TextContent = value;
177 | NotifyPropertyChanged("TextContent");
178 | }
179 | }
180 |
181 | ///
182 | /// Color of the custom Text
183 | ///
184 | private Brush _TextColor;
185 | public Brush TextColor
186 | {
187 | get
188 | {
189 | return _TextColor;
190 | }
191 | set
192 | {
193 | _TextColor = value;
194 | NotifyPropertyChanged("TextColor");
195 | }
196 | }
197 |
198 |
199 | ///
200 | /// Size of the custom Text
201 | ///
202 | private double _FontSize;
203 | public double FontSize
204 | {
205 | get
206 | {
207 | return _FontSize;
208 | }
209 | set
210 | {
211 | _FontSize = value;
212 | NotifyPropertyChanged("FontSize");
213 | }
214 | }
215 |
216 | ///
217 | /// Offset used for positioning Text so that it is centered over the right part of the pushpin
218 | ///
219 | private Point _TextOffet;
220 | public Point TextOffet
221 | {
222 | get
223 | {
224 | return _TextOffet;
225 | }
226 | set
227 | {
228 | _TextOffet = value;
229 | NotifyPropertyChanged("TextOffet");
230 | }
231 | }
232 | #endregion
233 |
234 | #region INotifyPropertyChanged
235 | public event PropertyChangedEventHandler PropertyChanged;
236 |
237 | private void NotifyPropertyChanged(String info)
238 | {
239 | if (PropertyChanged != null)
240 | {
241 | PropertyChanged(this, new PropertyChangedEventArgs(info));
242 | }
243 | }
244 | #endregion
245 | }
246 | }
247 |
--------------------------------------------------------------------------------
/TobbyBingMaps.MapGeometry/Themes/generic.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
56 |
57 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/BaseMap/CustomPushpin.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Animation;
11 | using System.Windows.Shapes;
12 | using Microsoft.Maps.MapControl;
13 | using System.ComponentModel;
14 | using BaseMap.Class;
15 |
16 | namespace BaseMap
17 | {
18 | public partial class CustomPushpin : UserControl
19 | {
20 | public CustomPushpin()
21 | {
22 | InitializeComponent();
23 | this.Loaded += new RoutedEventHandler(CustomPushpin_Loaded);
24 | }
25 |
26 | void CustomPushpin_Loaded(object sender, RoutedEventArgs e)
27 | {
28 |
29 | }
30 |
31 |
32 | private string _Id;
33 | public string Id
34 | {
35 | get
36 | {
37 | return _Id;
38 | }
39 | set
40 | {
41 | _Id = value;
42 | NotifyPropertyChanged("Id");
43 | }
44 | }
45 |
46 |
47 |
48 | private string _Describe;
49 | public string Describe
50 | {
51 | get
52 | {
53 | return _Describe;
54 | }
55 | set
56 | {
57 | _Describe = value;
58 | NotifyPropertyChanged("Describe");
59 | }
60 | }
61 |
62 |
63 | private string _carName;
64 | public string carName
65 | {
66 | get
67 | {
68 | return _carName;
69 | }
70 | set
71 | {
72 | _carName = value;
73 | NotifyPropertyChanged("carName");
74 | }
75 | }
76 |
77 | private string _carStatus;
78 | public string carStatus
79 | {
80 | get
81 | {
82 | return _carStatus;
83 | }
84 | set
85 | {
86 | _carStatus = value;
87 | NotifyPropertyChanged("carStatus");
88 | }
89 | }
90 |
91 |
92 | private DateTime _GpsDate;
93 | public DateTime GpsDate
94 | {
95 | get
96 | {
97 | return _GpsDate;
98 | }
99 | set
100 | {
101 | _GpsDate = value;
102 | NotifyPropertyChanged("GpsDate");
103 | }
104 | }
105 |
106 |
107 |
108 | #region Public Properties
109 |
110 | ///
111 | /// Specification to create the custom pushpin
112 | ///
113 | private CustomIconSpecification _iconSpec;
114 | public CustomIconSpecification IconSpecification
115 | {
116 | get
117 | {
118 | return _iconSpec;
119 | }
120 | set
121 | {
122 | _iconSpec = value;
123 |
124 | PushpinBase.Children.Clear();
125 |
126 | if (value.Icon != null)
127 | {
128 | PushpinBase.Children.Add(value.Icon);
129 | }
130 | else if (value.IconUri != null)
131 | {
132 | PushpinBase.Children.Add(PushpinTools.CreateImagePushpin(value.IconUri, value.Width, value.Height, value.RotateTr, value.IconOffset, value.PlaneProjection));
133 | }
134 | RotateTransform.Angle = value.RotateTr;
135 | if (!string.IsNullOrEmpty(value.TextContent))
136 | {
137 | lblCarName.Children.Clear();
138 | TextBlock text = new TextBlock();
139 | text.Width = value.Width;
140 | text.Text = value.TextContent;
141 | text.TextAlignment = TextAlignment.Center;
142 | text.HorizontalAlignment = HorizontalAlignment.Center;
143 | text.VerticalAlignment = VerticalAlignment.Center;
144 | text.Foreground = value.TextColor;
145 | text.FontSize = value.FontSize;
146 | text.TextWrapping = TextWrapping.Wrap;
147 | text.Margin = new Thickness(value.TextOffet.X, value.TextOffet.Y, 0, 0);
148 | if (text.Width > value.Width)
149 | lblCarName.Width = value.Width;
150 | lblCarName.Children.Add(text);
151 | }
152 | NotifyPropertyChanged("IconSpecification");
153 | }
154 | }
155 |
156 |
157 |
158 |
159 |
160 | ///
161 | /// The Location in which to display the pushpin
162 | ///
163 | private Location _Location;
164 | public Location Location
165 | {
166 | get
167 | {
168 | return _Location;
169 | }
170 | set
171 | {
172 | _Location = value;
173 | NotifyPropertyChanged("Location");
174 | }
175 | }
176 |
177 |
178 | private bool _isVisiable;
179 | public bool isVisiable
180 | {
181 | get
182 | {
183 | return _isVisiable;
184 | }
185 | set
186 | {
187 | _isVisiable = value;
188 | NotifyPropertyChanged("isVisiable");
189 | }
190 | }
191 |
192 |
193 | private Map _map;
194 | public Map MapInstance
195 | {
196 | get
197 | {
198 | return _map;
199 | }
200 | set
201 | {
202 | _map = value;
203 | _map.ViewChangeOnFrame += MapViewChangeOnFrame;
204 | ApplyPowerLawScaling(_map.ZoomLevel);
205 | NotifyPropertyChanged("MapInstance");
206 | }
207 | }
208 |
209 |
210 |
211 | void MapViewChangeOnFrame(object sender, MapEventArgs e)
212 | {
213 | ApplyPowerLawScaling(MapInstance.ZoomLevel);
214 | }
215 |
216 | private void ApplyPowerLawScaling(double currentZoomLevel)
217 | {
218 | double scale = Math.Pow(0.05 * (currentZoomLevel + 1), 2) + 0.01;
219 | if (scale > 1) scale = 1;
220 | if (scale < 0.125) scale = 0.125;
221 |
222 | PinScaleTransform.ScaleX = scale;
223 | PinScaleTransform.ScaleY = scale;
224 | }
225 |
226 |
227 |
228 | ///
229 | /// Optional metadata that can be used to store data for a pushpin
230 | ///
231 | private object _MetaData;
232 | public object MetaData
233 | {
234 | get
235 | {
236 | return _MetaData;
237 | }
238 | set
239 | {
240 | _MetaData = value;
241 | NotifyPropertyChanged("MetaData");
242 | }
243 | }
244 |
245 | #endregion
246 |
247 | #region INotifyPropertyChanged
248 | public event PropertyChangedEventHandler PropertyChanged;
249 |
250 | private void NotifyPropertyChanged(String info)
251 | {
252 | if (PropertyChanged != null)
253 | {
254 | PropertyChanged(this, new PropertyChangedEventArgs(info));
255 | }
256 | }
257 | #endregion
258 | }
259 |
260 | }
261 |
--------------------------------------------------------------------------------
/TobbyBingMaps.Common/Commanding/CommandSubscription.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Windows;
4 | using System.Windows.Controls;
5 | using System.Windows.Controls.Primitives;
6 | using System.Windows.Input;
7 |
8 | namespace TobbyBingMaps.Common.Commanding
9 | {
10 | ///
11 | /// Handles command subscription of a FrameworkElement
12 | ///
13 | public class CommandSubscription
14 | {
15 | #region Fields
16 |
17 | ///
18 | /// CommandSubscription depedency property.
19 | ///
20 | public static readonly DependencyProperty CommandSubscriptionProperty =
21 | DependencyProperty.RegisterAttached(
22 | "CommandSubscription",
23 | typeof(Dictionary),
24 | typeof(CommandSubscription),
25 | null);
26 |
27 | #endregion Fields
28 |
29 | #region Constructors
30 |
31 | ///
32 | /// Initializes a new instance of the class.
33 | ///
34 | /// The element attached to the command.
35 | /// Name of the command.
36 | public CommandSubscription(FrameworkElement element, string commandName)
37 | {
38 | Element = element;
39 | CommandName = commandName;
40 | }
41 |
42 | #endregion Constructors
43 |
44 | #region Properties
45 |
46 | ///
47 | /// Gets the Command name
48 | ///
49 | /// The name of the command.
50 | public string CommandName
51 | {
52 | get;
53 | private set;
54 | }
55 |
56 | ///
57 | /// Gets the element attached to the command
58 | ///
59 | /// The element.
60 | public FrameworkElement Element
61 | {
62 | get;
63 | private set;
64 | }
65 |
66 | #endregion Properties
67 |
68 | #region Methods
69 |
70 | ///
71 | /// Registers the command.
72 | ///
73 | /// The command name.
74 | /// The element.
75 | internal static void RegisterCommand(string commandName, FrameworkElement element)
76 | {
77 | var cmd = CommandService.FindCommand(commandName);
78 | if (cmd != null)
79 | {
80 | var subscription = cmd.CreateCommandSubscription(element, commandName);
81 |
82 | var elementSubscriptions = element.GetValue(CommandSubscriptionProperty) as Dictionary;
83 | if (elementSubscriptions == null)
84 | {
85 | elementSubscriptions = new Dictionary();
86 | element.SetValue(CommandSubscriptionProperty, elementSubscriptions);
87 | }
88 |
89 | subscription.HookEvents();
90 | elementSubscriptions[commandName] = subscription;
91 | }
92 | }
93 |
94 | internal static void UnregisterAllSubscriptions(FrameworkElement element)
95 | {
96 | var elementSubscriptions = element.GetValue(CommandSubscriptionProperty) as Dictionary;
97 | if (elementSubscriptions == null)
98 | return;
99 |
100 | foreach (var item in new List(elementSubscriptions.Values))
101 | {
102 | item.Unregister();
103 | }
104 | }
105 |
106 | ///
107 | /// Unregister a command from an element
108 | ///
109 | /// The command name to remove
110 | /// The element to be detached
111 | internal static void UnregisterSubscription(string commandName, FrameworkElement element)
112 | {
113 | var elementSubscriptions = element.GetValue(CommandSubscriptionProperty) as Dictionary;
114 | if (elementSubscriptions == null)
115 | {
116 | return;
117 | }
118 |
119 | CommandSubscription currentSubscription;
120 | if (!elementSubscriptions.TryGetValue(commandName, out currentSubscription))
121 | {
122 | return;
123 | }
124 |
125 | currentSubscription.Unregister();
126 | }
127 |
128 | ///
129 | /// Executes the command
130 | ///
131 | /// The command sender
132 | protected virtual void ExecuteCommand(object sender)
133 | {
134 | var ctrl = sender as Control;
135 | if (ctrl != null)
136 | {
137 | if (!ctrl.IsEnabled)
138 | return;
139 | }
140 | string commandName = CommandService.GetCommand(Element);
141 | Command cmd = CommandService.FindCommand(commandName);
142 | object parameter = CommandService.GetCommandParameter(Element);
143 | parameter = PreProcessParameter(parameter);
144 | cmd.Execute(parameter, sender);
145 | }
146 |
147 | protected virtual void HookEvents()
148 | {
149 | FrameworkElement element = Element;
150 |
151 | if (element is ButtonBase)
152 | {
153 | ((ButtonBase)element).Click += CommandService_Click;
154 | }
155 | else if (element is TextBox)
156 | {
157 | (element).KeyDown += CommandService_KeyDown;
158 | }
159 | else
160 | {
161 | element.MouseLeftButtonUp += CommandService_Click;
162 | }
163 | }
164 |
165 | protected virtual object PreProcessParameter(object parameter)
166 | {
167 | return parameter;
168 | }
169 |
170 | protected virtual void UnhookEvents()
171 | {
172 | FrameworkElement element = Element;
173 |
174 | if (element is ButtonBase)
175 | {
176 | ((ButtonBase)element).Click -= CommandService_Click;
177 | }
178 | else if (element is TextBox)
179 | {
180 | (element).KeyDown -= CommandService_KeyDown;
181 | }
182 | else
183 | {
184 | element.MouseLeftButtonUp -= CommandService_Click;
185 | }
186 | }
187 |
188 | ///
189 | /// Unregister the current CommandSubscription
190 | ///
191 | protected virtual void Unregister()
192 | {
193 | UnhookEvents();
194 |
195 | var elementSubscriptions = Element.GetValue(CommandSubscriptionProperty) as Dictionary;
196 | if (elementSubscriptions == null)
197 | {
198 | return;
199 | }
200 |
201 | elementSubscriptions.Remove(CommandName);
202 | }
203 |
204 | ///
205 | /// Handles the Click event of the CommandService control.
206 | ///
207 | /// The source of the event.
208 | /// The instance containing the event data.
209 | private void CommandService_Click(object sender, EventArgs e)
210 | {
211 | ExecuteCommand(sender);
212 | }
213 |
214 | ///
215 | /// Handles the KeyDown event of the CommandService control.
216 | ///
217 | /// The source of the event.
218 | /// The instance containing the event data.
219 | private void CommandService_KeyDown(object sender, KeyEventArgs e)
220 | {
221 | if (e.Key == Key.Enter)
222 | {
223 | ExecuteCommand(sender);
224 | }
225 | }
226 |
227 | #endregion Methods
228 | }
229 | }
230 |
--------------------------------------------------------------------------------
/TobbyBingMaps.Common/TileSystem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 |
4 | namespace TobbyBingMaps.Common
5 | {
6 | public static class TileSystem
7 | {
8 | private const double EarthRadius = 6378137;
9 | private const double MinLatitude = -85.05112878;
10 | private const double MaxLatitude = 85.05112878;
11 | private const double MinLongitude = -180;
12 | private const double MaxLongitude = 180;
13 |
14 |
15 | ///
16 | /// Clips a number to the specified minimum and maximum values.
17 | ///
18 | /// The number to clip.
19 | /// Minimum allowable value.
20 | /// Maximum allowable value.
21 | /// The clipped value.
22 | private static double Clip(double n, double minValue, double maxValue)
23 | {
24 | return Math.Min(Math.Max(n, minValue), maxValue);
25 | }
26 |
27 | ///
28 | /// Determines the map width and height (in pixels) at a specified level
29 | /// of detail.
30 | ///
31 | /// Level of detail, from 1 (lowest detail)
32 | /// to 23 (highest detail).
33 | /// The map width and height in pixels.
34 | public static uint MapSize(int levelOfDetail)
35 | {
36 | return (uint)256 << levelOfDetail;
37 | }
38 |
39 | ///
40 | /// Determines the ground resolution (in meters per pixel) at a specified
41 | /// latitude and level of detail.
42 | ///
43 | /// Latitude (in degrees) at which to measure the
44 | /// ground resolution.
45 | /// Level of detail, from 1 (lowest detail)
46 | /// to 23 (highest detail).
47 | /// The ground resolution, in meters per pixel.
48 | public static double GroundResolution(double latitude, int levelOfDetail)
49 | {
50 | latitude = Clip(latitude, MinLatitude, MaxLatitude);
51 | return Math.Cos(latitude * Math.PI / 180) * 2 * Math.PI * EarthRadius / MapSize(levelOfDetail);
52 | }
53 |
54 | ///
55 | /// Determines the map scale at a specified latitude, level of detail,
56 | /// and screen resolution.
57 | ///
58 | /// Latitude (in degrees) at which to measure the
59 | /// map scale.
60 | /// Level of detail, from 1 (lowest detail)
61 | /// to 23 (highest detail).
62 | /// Resolution of the screen, in dots per inch.
63 | /// The map scale, expressed as the denominator N of the ratio 1 : N.
64 | public static double MapScale(double latitude, int levelOfDetail, int screenDpi)
65 | {
66 | return GroundResolution(latitude, levelOfDetail) * screenDpi / 0.0254;
67 | }
68 |
69 | ///
70 | /// Converts a point from latitude/longitude WGS-84 coordinates (in degrees)
71 | /// into pixel XY coordinates at a specified level of detail.
72 | ///
73 | /// Latitude of the point, in degrees.
74 | /// Longitude of the point, in degrees.
75 | /// Level of detail, from 1 (lowest detail)
76 | /// to 23 (highest detail).
77 | /// Output parameter receiving the X coordinate in pixels.
78 | /// Output parameter receiving the Y coordinate in pixels.
79 | public static void LatLongToPixelXY(double latitude, double longitude, int levelOfDetail, out int pixelX, out int pixelY)
80 | {
81 | latitude = Clip(latitude, MinLatitude, MaxLatitude);
82 | longitude = Clip(longitude, MinLongitude, MaxLongitude);
83 |
84 | double x = (longitude + 180) / 360;
85 | double sinLatitude = Math.Sin(latitude * Math.PI / 180);
86 | double y = 0.5 - Math.Log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI);
87 |
88 | uint mapSize = MapSize(levelOfDetail);
89 | pixelX = (int)Clip(x * mapSize + 0.5, 0, mapSize - 1);
90 | pixelY = (int)Clip(y * mapSize + 0.5, 0, mapSize - 1);
91 | }
92 |
93 | ///
94 | /// Converts a pixel from pixel XY coordinates at a specified level of detail
95 | /// into latitude/longitude WGS-84 coordinates (in degrees).
96 | ///
97 | /// X coordinate of the point, in pixels.
98 | /// Y coordinates of the point, in pixels.
99 | /// Level of detail, from 1 (lowest detail)
100 | /// to 23 (highest detail).
101 | /// Output parameter receiving the latitude in degrees.
102 | /// Output parameter receiving the longitude in degrees.
103 | public static void PixelXYToLatLong(int pixelX, int pixelY, int levelOfDetail, out double latitude, out double longitude)
104 | {
105 | double mapSize = MapSize(levelOfDetail);
106 | double x = (Clip(pixelX, 0, mapSize - 1) / mapSize) - 0.5;
107 | double y = 0.5 - (Clip(pixelY, 0, mapSize - 1) / mapSize);
108 |
109 | latitude = 90 - 360 * Math.Atan(Math.Exp(-y * 2 * Math.PI)) / Math.PI;
110 | longitude = 360 * x;
111 | }
112 |
113 | ///
114 | /// Converts pixel XY coordinates into tile XY coordinates of the tile containing
115 | /// the specified pixel.
116 | ///
117 | /// Pixel X coordinate.
118 | /// Pixel Y coordinate.
119 | /// Output parameter receiving the tile X coordinate.
120 | /// Output parameter receiving the tile Y coordinate.
121 | public static void PixelXYToTileXY(int pixelX, int pixelY, out int tileX, out int tileY)
122 | {
123 | tileX = pixelX / 256;
124 | tileY = pixelY / 256;
125 | }
126 |
127 | ///
128 | /// Converts tile XY coordinates into pixel XY coordinates of the upper-left pixel
129 | /// of the specified tile.
130 | ///
131 | /// Tile X coordinate.
132 | /// Tile Y coordinate.
133 | /// Output parameter receiving the pixel X coordinate.
134 | /// Output parameter receiving the pixel Y coordinate.
135 | public static void TileXYToPixelXY(int tileX, int tileY, out int pixelX, out int pixelY)
136 | {
137 | pixelX = tileX * 256;
138 | pixelY = tileY * 256;
139 | }
140 |
141 | ///
142 | /// Converts tile XY coordinates into a QuadKey at a specified level of detail.
143 | ///
144 | /// Tile X coordinate.
145 | /// Tile Y coordinate.
146 | /// Level of detail, from 1 (lowest detail)
147 | /// to 23 (highest detail).
148 | /// A string containing the QuadKey.
149 | public static string TileXYToQuadKey(int tileX, int tileY, int levelOfDetail)
150 | {
151 | StringBuilder quadKey = new StringBuilder();
152 | for (int i = levelOfDetail; i > 0; i--)
153 | {
154 | char digit = '0';
155 | int mask = 1 << (i - 1);
156 | if ((tileX & mask) != 0)
157 | {
158 | digit++;
159 | }
160 | if ((tileY & mask) != 0)
161 | {
162 | digit++;
163 | digit++;
164 | }
165 | quadKey.Append(digit);
166 | }
167 | return quadKey.ToString();
168 | }
169 |
170 | ///
171 | /// Converts a QuadKey into tile XY coordinates.
172 | ///
173 | /// QuadKey of the tile.
174 | /// Output parameter receiving the tile X coordinate.
175 | /// Output parameter receiving the tile Y coordinate.
176 | /// Output parameter receiving the level of detail.
177 | public static void QuadKeyToTileXY(string quadKey, out int tileX, out int tileY, out int levelOfDetail)
178 | {
179 | tileX = tileY = 0;
180 | levelOfDetail = quadKey.Length;
181 | for (int i = levelOfDetail; i > 0; i--)
182 | {
183 | int mask = 1 << (i - 1);
184 | switch (quadKey[levelOfDetail - i])
185 | {
186 | case '0':
187 | break;
188 |
189 | case '1':
190 | tileX |= mask;
191 | break;
192 |
193 | case '2':
194 | tileY |= mask;
195 | break;
196 |
197 | case '3':
198 | tileX |= mask;
199 | tileY |= mask;
200 | break;
201 |
202 | default:
203 | throw new ArgumentException("Invalid QuadKey digit sequence.");
204 | }
205 | }
206 | }
207 |
208 | //Helper
209 | public static string LatLongToQuadKey(double latitude, double longitude, int levelOfDetail)
210 | {
211 |
212 | int pixelX;
213 | int pixelY;
214 |
215 | LatLongToPixelXY(latitude, longitude, levelOfDetail, out pixelX, out pixelY);
216 |
217 | return PixelXYToQuadKey(pixelX, pixelY, levelOfDetail);
218 |
219 | }
220 |
221 | //Helper
222 | public static string PixelXYToQuadKey(int pixelX, int pixelY, int levelOfDetail)
223 | {
224 | int tileX;
225 | int tileY;
226 |
227 | PixelXYToTileXY(pixelX, pixelY, out tileX, out tileY);
228 |
229 | return TileXYToQuadKey(tileX, tileY, levelOfDetail);
230 | }
231 | }
232 | }
233 |
--------------------------------------------------------------------------------
/BaseMap.Web/postgisHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using Npgsql;
6 | using System.Text;
7 | using System.Text.RegularExpressions;
8 |
9 | namespace BaseMap.Web
10 | {
11 | public class postgisHelper
12 | {
13 |
14 |
15 |
16 | public static List GetClosetRoad(double lg, double lt, double ditMini)
17 | {
18 | var records = new List();
19 | var pg = new PostGIS();
20 | string strSQL = string.Format(@"select source ,target,st_astext(pointgeom) as pointgeom from ch10.realroad
21 | WHERE
22 | ST_DWithin(the_geom ,GeometryFromText('point({0} {1})',4326), {2})
23 | order by ST_Distance(the_geom,GeometryFromText('point({0} {1})',4326)) limit 1", lt, lg, ditMini);
24 | records = pg.QueryAdd("mini", strSQL);
25 | return records;
26 | }
27 |
28 | public static void updateLength()
29 | {
30 |
31 | var pg = new PostGIS();
32 | string strSQL = "update ch10.realtimeroad set length1=random()*40";
33 | pg.SQLExcute(strSQL);
34 | }
35 |
36 |
37 |
38 | public static void updatePassable(int source ,int target,int passable)
39 | {
40 | PostGIS pg = new PostGIS();
41 | string strSQL = string.Format(@" update ch10.realtimeroad set passable={2}
42 | WHERE realtimeroad.source={0} and realtimeroad.target={1}", source, target, passable);
43 | pg.SQLExcute(strSQL);
44 | }
45 |
46 | public static void updatePassableToT()
47 | {
48 | var pg = new PostGIS();
49 | string strSQL = "update ch10.realtimeroad set passable=1";
50 |
51 | pg.SQLExcute(strSQL);
52 | }
53 |
54 | public static List GetAllTableFeatures(string layer,int begin,int last)
55 | {
56 | var pg = new PostGIS();
57 | string sql = " set search_path = public, ch10;"+
58 |
59 | "SELECT NAME,source,target,st_astext(pointgeom) as pointgeom, st_astext(the_geom) as geom FROM shortest_path('select st_astext(the_geom),gid as id,source::int4,target::int4,length::double precision as cost "
60 |
61 | + "from realtimeroad where passable <>0 '," + begin + "," + last + ",false,false) as sp ,realtimeroad as tc "
62 |
63 | +"where sp.edge_id=tc.gid; ";
64 |
65 | var records = pg.Query(layer, sql);
66 | return records;
67 | }
68 |
69 | public static List GetRealRoads(string layer,string leve)
70 | {
71 | var pg = new PostGIS();
72 | string sql = " set search_path = public, ch10;" +
73 | "select sroadid,st_astext(the_geom) as geom,accessleve from fourleveroads";
74 |
75 | var records = pg.QueryRealRoads(layer, sql);
76 | return records;
77 | }
78 | }
79 |
80 |
81 | public class PostGIS
82 | {
83 | NpgsqlConnection conn;
84 | private string _layer;
85 | private string _bbox;
86 | private string _table;
87 | readonly string _connStr;
88 | public PostGIS()
89 | {
90 | this._connStr = "server=localhost;uid=postgres;pwd=123456;database=postgis;port=5432";
91 | }
92 | public void SQLExcute(string SQLCmd)
93 | {
94 | NpgsqlConnection Conn = new NpgsqlConnection(_connStr);
95 |
96 | try
97 | {
98 |
99 | Conn.Open();
100 |
101 | NpgsqlCommand Cmd = new NpgsqlCommand();
102 |
103 | Cmd.Connection = Conn;
104 |
105 | Cmd.CommandTimeout = 150;
106 |
107 | Cmd.CommandType = System.Data.CommandType.Text;
108 |
109 | Cmd.CommandText = SQLCmd;
110 |
111 | Cmd.ExecuteNonQuery();
112 |
113 |
114 | }
115 | catch
116 | {
117 |
118 |
119 | }
120 |
121 | Conn.Close();
122 |
123 | }
124 |
125 |
126 |
127 | public void UpdateData(string sql)
128 | {
129 | string connStr = _connStr;
130 | if (conn == null)
131 | {
132 | conn = new NpgsqlConnection(connStr);
133 | }
134 | conn.Open();
135 |
136 | var command = new NpgsqlCommand(sql, conn) {CommandTimeout = 120};
137 |
138 | conn.Close();
139 | }
140 |
141 | public List QueryAdd(string _layer, string sql)
142 | {
143 | StringBuilder sb;
144 | string[] fields;
145 | var records = new List();
146 | string connStr = _connStr;
147 | if (conn == null)
148 | {
149 | conn = new NpgsqlConnection(connStr);
150 | }
151 | conn.Open();
152 | try
153 | {
154 | var command = new NpgsqlCommand(sql, conn) {CommandTimeout = 120};
155 | NpgsqlDataReader rdr = command.ExecuteReader();
156 | while (rdr.Read())
157 | {
158 | sb = new StringBuilder();
159 | if (!string.IsNullOrEmpty(_layer))
160 | sb = new StringBuilder(_layer + ";");
161 | for (int i = 0; i < rdr.FieldCount - 1; i++)
162 | {
163 | sb.Append(rdr[i].ToString() + ";");
164 | }
165 | fields = Regex.Split(rdr["pointgeom"].ToString(), @"\(+(.*?)\)+");
166 | if (fields[0].Equals("MULTIPOINT"))
167 | {
168 |
169 | string[] pts = fields[1].Split(',');
170 | for (int i = 0; i < pts.Length; i++)
171 | {
172 | if (i > 0) sb.Append(",");
173 | sb.Append((pts[i].Split(' '))[1]);//latitude
174 | sb.Append(" " + (pts[i].Split(' '))[0]);//longitude
175 | }
176 |
177 | }
178 | records.Add(sb.ToString());
179 |
180 |
181 | }
182 | rdr.Close();
183 | }
184 | catch
185 | {
186 |
187 | }
188 |
189 |
190 | conn.Close();
191 | return records;
192 | }
193 |
194 | public List QueryRealRoads(string _layer, string sql)
195 | {
196 | StringBuilder sb;
197 | string[] fields;
198 | var records = new List();
199 | string connStr = _connStr;
200 | if (conn == null)
201 | {
202 | conn = new NpgsqlConnection(connStr);
203 | }
204 | conn.Open();
205 | try
206 | {
207 | var command = new NpgsqlCommand(sql, conn) { CommandTimeout = 120 };
208 | NpgsqlDataReader rdr = command.ExecuteReader();
209 | while (rdr.Read())
210 | {
211 |
212 | sb = new StringBuilder();
213 | if (!string.IsNullOrEmpty(_layer))
214 | sb = new StringBuilder(_layer + ";");
215 | for (int i = 0; i < rdr.FieldCount - 2; i++)
216 | {
217 | sb.Append(rdr[i].ToString() + ";");
218 | }
219 | fields = Regex.Split(rdr["geom"].ToString(), @"\(+(.*?)\)+");
220 | if (fields[0].Equals("LINESTRING"))
221 | {
222 |
223 | string[] pts = fields[1].Split(',');
224 | for (int i = 0; i < pts.Length; i++)
225 | {
226 | if (i > 0) sb.Append(",");
227 | sb.Append((pts[i].Split(' '))[1]);//latitude
228 | sb.Append(" " + (pts[i].Split(' '))[0]);//longitude
229 | }
230 |
231 | }
232 | records.Add(sb.ToString());
233 | }
234 | rdr.Close();
235 | }
236 | catch
237 | {
238 |
239 | }
240 |
241 |
242 | conn.Close();
243 | return records;
244 | }
245 |
246 | public List Query(string _layer, string sql)
247 | {
248 | StringBuilder sb;
249 | List records = new List();
250 | string[] fields;
251 | string[] pointsfields;
252 | string geomType;
253 | string[] names;
254 | string[] Locations;
255 | string[] OrderIds;
256 | string connStr = _connStr;
257 | if (conn == null)
258 | {
259 | conn = new NpgsqlConnection(connStr);
260 | }
261 |
262 | conn.Open();
263 |
264 | var command = new NpgsqlCommand(sql, conn);
265 | command.CommandTimeout = 120;
266 | int index = 0;
267 | try
268 | {
269 | NpgsqlDataReader rdr = command.ExecuteReader();
270 | while (rdr.Read())
271 | {
272 | // if (index == 500)
273 | // {
274 | // break;
275 | // }
276 | // index++;
277 | sb = new StringBuilder();
278 | if (!string.IsNullOrEmpty(_layer))
279 | sb = new StringBuilder(_layer + ";");
280 | for (int i = 0; i < rdr.FieldCount - 2; i++)
281 | {
282 | sb.Append(rdr[i].ToString() + ";");
283 | }
284 | fields = Regex.Split(rdr["geom"].ToString(), @"\(+(.*?)\)+");
285 | pointsfields = Regex.Split(rdr["pointgeom"].ToString(), @"\(+(.*?)\)+");
286 | names = Regex.Split(rdr["name"].ToString(), @"\(+(.*?)\)+");
287 | geomType = fields[0];
288 |
289 | if (pointsfields[0].Equals("MULTIPOINT"))
290 | {
291 | string[] mpts = pointsfields[1].Split(',');
292 | for (int i = 0; i < mpts.Length; i++)
293 | {
294 | if (i > 0) sb.Append(",");
295 | sb.Append((mpts[i].Split(' '))[1]);//latitude
296 | sb.Append(" " + (mpts[i].Split(' '))[0]);//longitude
297 | }
298 | }
299 |
300 | if (geomType.Equals("MULTILINESTRING"))
301 | {
302 | sb.Append(";");
303 | string[] pts = fields[1].Split(',');
304 | for (int i = 0; i < pts.Length; i++)
305 | {
306 | if (i > 0) sb.Append(",");
307 | sb.Append((pts[i].Split(' '))[1]);//latitude
308 | sb.Append(" " + (pts[i].Split(' '))[0]);//longitude
309 | }
310 |
311 | }
312 |
313 |
314 |
315 |
316 | records.Add(sb.ToString());
317 | }
318 | rdr.Close();
319 | }
320 | catch (Exception e)
321 | {
322 | records.Add(e.Message);
323 | }
324 | conn.Close();
325 | return records;
326 | }
327 | }
328 | }
--------------------------------------------------------------------------------