Map
Changes
ModelData/BusinessModel/BusinessDataManager.cs 126(+126 -0)
ModelData/BusinessModel/Position.cs 53(+53 -0)
ModelData/BusinessModel/RDFQuery.cs 4(+2 -2)
ModelData/BusinessModel/Settlement.cs 66(+66 -0)
ModelData/ModelData.csproj 8(+7 -1)
ModelData/WebModel/MapPoint.cs 8(+6 -2)
ModelData/WebModel/WebDataManager.cs 74(+74 -0)
web-map.sln 6(+0 -6)
web-map/App_Start/BundleConfig.cs 2(+1 -1)
web-map/Content/Site.css 100(+99 -1)
web-map/Controllers/MapAPIController.cs 42(+42 -0)
web-map/Controllers/MapController.cs 48(+2 -46)
web-map/Scripts/SiteScripts/AjaxQuery.js 71(+71 -0)
web-map/Scripts/SiteScripts/Events.js 55(+55 -0)
web-map/Scripts/SiteScripts/Init.js 140(+140 -0)
web-map/Scripts/SiteScripts/Output.js 16(+16 -0)
web-map/Views/Map/Map.cshtml 48(+41 -7)
web-map/Views/Shared/_Layout.cshtml 14(+12 -2)
web-map/web-map.csproj 13(+12 -1)
Details
ModelData/BusinessModel/BusinessDataManager.cs 126(+126 -0)
diff --git a/ModelData/BusinessModel/BusinessDataManager.cs b/ModelData/BusinessModel/BusinessDataManager.cs
new file mode 100644
index 0000000..586b79e
--- /dev/null
+++ b/ModelData/BusinessModel/BusinessDataManager.cs
@@ -0,0 +1,126 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ModelData.BusinessModel
+{
+ public class BusinessDataManager
+ {
+ #region singl
+
+ private static BusinessDataManager dataManager;
+ public static BusinessDataManager Get()
+ {
+ if (dataManager == null)
+ dataManager = new BusinessDataManager();
+
+ return dataManager;
+ }
+ public static void Destroy()
+ {
+ dataManager = null;
+ }
+
+ private BusinessDataManager()
+ {
+ Init();
+ }
+
+ #endregion
+
+ #region Data
+
+ private List<Settlement> lst_settlements;
+
+ #endregion
+
+ #region Methods
+
+ public Settlement[] GetSettlements()
+ {
+ return lst_settlements.ToArray();
+ }
+
+ public Settlement GetSettlement(string name)
+ {
+ return lst_settlements[FindByName(name)];
+ }
+
+ #region Tools
+
+ private void Init()
+ {
+ lst_settlements = new List<Settlement>();
+
+ lst_settlements.Add(new Settlement
+ (
+ name_: "Саратов",
+ position_: new Position(51.533103, 46.034158),
+ year_: "1590",
+ type_: "Город",
+ description_: "Город на юго-востоке европейской части России, административный центр Саратовской области и Саратовского района," +
+ "в который не входит, являясь городом областного значения, образует муниципальное образование город Саратов со статусом " +
+ "городского округа. Крупный культурный, экономический и образовательный центр Поволжья. Входит в двадцатку крупнейших" +
+ "городов России, не будучи городом-миллионером, одновременно является центром Саратовской агломерации, население которой " +
+ "превышает 1,2 млн человек. Находится на правом берегу Волгоградского водохранилища реки Волги, в 389 км от Волгограда и" +
+ "442 км от Самары, в 858 км к юго-востоку от Москвы."
+ ));
+
+ lst_settlements.Add(new Settlement
+ (
+ name_: "Балаково",
+ position_: new Position(52.02782, 47.8007),
+ year_: "1762",
+ type_: "Город",
+ description_: "Город, находящийся в юго-восточной европейской части России, административный центр Балаковского муниципального района " +
+ "Саратовской области. Образует одноимённое муниципальное образование город Балаково со статусом городского поселения как " +
+ "единственный населённый пункт в его составе. Располагается на левом берегу реки Волга и острове (Жилгородок)."
+ ));
+
+ lst_settlements.Add(new Settlement
+ (
+ name_: "Балашов",
+ position_: new Position(51.5502, 43.1667),
+ year_: "XVIII век",
+ type_: "Город",
+ description_: "Город расположен на восточной окраине Окско-Донской равнины, на реке Хопёр (приток Дона), на пересечении железнодорожных " +
+ "линий Тамбов — Камышин и Поворино — Пенза, в 210 км к западу от Саратова. Через город протекает одна из красивейших рек " +
+ "средней полосы России — Хопёр, которая делит Балашов на две неравные части — частный сектор и центральный, с постройками " +
+ "городского типа. Вблизи города находится военный аэродром Балашов и военный городок Восход (Балашов-13)."
+ ));
+
+ lst_settlements.Add(new Settlement
+ (
+ name_: "Маркс",
+ position_: new Position(51.71111, 46.74861),
+ year_: "1765",
+ type_: "Город",
+ description_: "Город, расположенный на левом берегу Волги, в 60 км к северо-востоку от Саратова, административный центр Марксовского" +
+ "муниципального района Саратовской области. Образует одноимённое муниципальное образование город Маркс со статусом городского поселения " +
+ "как единственный населённый пункт в его составе.",
+ names_: new List<SettlementName> {
+ new SettlementName("Екатериненштадт (Баронск)", "1765", "1915"),
+ new SettlementName("Екатериноград", "1915", "1920"),
+ new SettlementName("Марксшта́дт", "1920", "1942"),
+ new SettlementName("Маркс", "1942")}
+ ));
+
+ }
+ private int FindByName(string name)
+ {
+ for (int i = 0; i < lst_settlements.Count; i++)
+ {
+ if (lst_settlements[i].Name == name)
+ return i;
+ }
+ return -1;
+ }
+
+ #endregion
+
+ #endregion
+
+ }
+}
ModelData/BusinessModel/Position.cs 53(+53 -0)
diff --git a/ModelData/BusinessModel/Position.cs b/ModelData/BusinessModel/Position.cs
new file mode 100644
index 0000000..51bdf27
--- /dev/null
+++ b/ModelData/BusinessModel/Position.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ModelData.BusinessModel
+{
+
+ //!По хорошему сделать структурой а не классом
+
+ public class Position
+ {
+ #region Data
+
+ public double X { set; get; }
+ public double Y { set; get; }
+
+ #endregion
+
+ #region Constructor
+
+ public Position()
+ {
+ X = 0;
+ Y = 0;
+ }
+ public Position(double x, double y)
+ {
+ this.X = x;
+ this.Y = y;
+ }
+ public Position(Position origin)
+ {
+ X = origin.X;
+ Y = origin.Y;
+ }
+
+ #endregion
+
+ #region operator
+ public static Position operator +(Position p1, Position p2)
+ {
+ return new Position
+ {
+ X = p1.X + p2.X,
+ Y = p1.Y + p2.Y
+ };
+ }
+
+ #endregion
+ }
+}
ModelData/BusinessModel/Settlement.cs 66(+66 -0)
diff --git a/ModelData/BusinessModel/Settlement.cs b/ModelData/BusinessModel/Settlement.cs
new file mode 100644
index 0000000..bfa5b24
--- /dev/null
+++ b/ModelData/BusinessModel/Settlement.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ModelData.BusinessModel
+{
+ public class Settlement
+ {
+ public string Name { set; get; }
+ public List<SettlementName> Names { set; get; }
+ public Position position { set; get; }
+
+ public string Year { set; get; }
+ public string Type { set; get; }
+
+ public string Description { set; get; }
+
+ public Settlement(string name_, Position position_, string year_, string type_ = null, string description_ = null, List<SettlementName> names_ = null)
+ {
+ this.Name = name_;
+ this.position = position_;
+ this.Year = year_;
+ this.Type = type_ ?? "";
+ this.Description = description_ ?? "";
+ this.Names = (names_ != null && names_.Count > 0) ? new List<SettlementName>(names_) : null;
+ }
+
+ }
+
+ public class SettlementName
+ {
+ public string Name { set; get; }
+ public TimeInterval Interval { set; get; }
+
+ public SettlementName(){ }
+ public SettlementName(string name_, string start_)
+ {
+ this.Name = name_;
+ this.Interval = new TimeInterval(start_);
+ }
+ public SettlementName(string name_, string start_, string end_)
+ {
+ this.Name = name_;
+ this.Interval = new TimeInterval(start_, end_);
+ }
+ }
+
+ public class TimeInterval
+ {
+ public string Start { set; get; }
+ public string End { set; get; }
+
+ public TimeInterval(){ }
+ public TimeInterval(string start_)
+ {
+ this.Start = start_;
+ }
+ public TimeInterval(string start_, string end_)
+ {
+ this.Start = start_;
+ this.End = end_;
+ }
+ }
+}
ModelData/ModelData.csproj 8(+7 -1)
diff --git a/ModelData/ModelData.csproj b/ModelData/ModelData.csproj
index 0f0583e..177ec6e 100644
--- a/ModelData/ModelData.csproj
+++ b/ModelData/ModelData.csproj
@@ -55,11 +55,17 @@
</Reference>
</ItemGroup>
<ItemGroup>
- <Compile Include="Class1.cs" />
+ <Compile Include="BusinessModel\BusinessDataManager.cs" />
+ <Compile Include="BusinessModel\Position.cs" />
+ <Compile Include="BusinessModel\Settlement.cs" />
+ <Compile Include="BusinessModel\RDFQuery.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="WebModel\MapPoint.cs" />
+ <Compile Include="WebModel\WebDataManager.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
+ <ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
ModelData/WebModel/WebDataManager.cs 74(+74 -0)
diff --git a/ModelData/WebModel/WebDataManager.cs b/ModelData/WebModel/WebDataManager.cs
new file mode 100644
index 0000000..4bb2152
--- /dev/null
+++ b/ModelData/WebModel/WebDataManager.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using ModelData.BusinessModel;
+
+namespace ModelData.WebModel
+{
+ public class WebDataManager
+ {
+ #region singl
+
+ private static WebDataManager dataManager;
+ public static WebDataManager Get()
+ {
+ if (dataManager == null)
+ dataManager = new WebDataManager();
+
+ return dataManager;
+ }
+ public static void Destroy()
+ {
+ dataManager = null;
+ }
+
+ private WebDataManager()
+ {
+ Init();
+ }
+
+ #endregion
+
+ #region Data
+ #endregion
+
+ #region Methods
+
+ public MapPoint[] GetMapPoints()
+ {
+ BusinessDataManager businessData = BusinessDataManager.Get();
+
+ Settlement[] settlements = businessData.GetSettlements();
+ List<MapPoint> mapPoints = new List<MapPoint>(settlements.Length);
+
+ foreach (var elem in settlements)
+ mapPoints.Add(new MapPoint()
+ {
+ Name = elem.Name,
+ Position = elem.position
+ });
+
+ return mapPoints.ToArray();
+ }
+
+ public Settlement GetSettlement(string name)
+ {
+ BusinessDataManager businessData = BusinessDataManager.Get();
+
+ return businessData.GetSettlement(name);
+ }
+
+ #region Tools
+
+ private void Init(int Count = 5)
+ {
+ }
+ #endregion
+
+ #endregion
+
+ }
+}
web-map.sln 6(+0 -6)
diff --git a/web-map.sln b/web-map.sln
index 4bf4f64..47241ed 100644
--- a/web-map.sln
+++ b/web-map.sln
@@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "web-map", "web-map\web-map.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModelData", "ModelData\ModelData.csproj", "{5DB5C021-7C14-4798-9C0D-79E280583112}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModelWEB", "ModelWEB\ModelWEB.csproj", "{CB321371-8885-4FB8-B1CF-5D6370487C7E}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -23,10 +21,6 @@ Global
{5DB5C021-7C14-4798-9C0D-79E280583112}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DB5C021-7C14-4798-9C0D-79E280583112}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5DB5C021-7C14-4798-9C0D-79E280583112}.Release|Any CPU.Build.0 = Release|Any CPU
- {CB321371-8885-4FB8-B1CF-5D6370487C7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {CB321371-8885-4FB8-B1CF-5D6370487C7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {CB321371-8885-4FB8-B1CF-5D6370487C7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {CB321371-8885-4FB8-B1CF-5D6370487C7E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
web-map/App_Start/BundleConfig.cs 2(+1 -1)
diff --git a/web-map/App_Start/BundleConfig.cs b/web-map/App_Start/BundleConfig.cs
index 60796e3..7983687 100644
--- a/web-map/App_Start/BundleConfig.cs
+++ b/web-map/App_Start/BundleConfig.cs
@@ -20,7 +20,7 @@ namespace web_map
"~/Scripts/modernizr-*"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
- "~/Scripts/bootstrap.js"));
+ "~/Scripts/bootstrap.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
web-map/Content/Site.css 100(+99 -1)
diff --git a/web-map/Content/Site.css b/web-map/Content/Site.css
index 6ea5d8f..faa0b70 100644
--- a/web-map/Content/Site.css
+++ b/web-map/Content/Site.css
@@ -20,5 +20,103 @@
input,
select,
textarea {
- max-width: 280px;
+ max-width: 400px;
+}
+
+
+/* ---------------------------------------------------
+ SIDEBAR STYLE
+ ----------------------------------------------------- */
+#sidebar {
+ width: 250px;
+ position: fixed;
+ top: 20px;
+ left: 0px;
+ height: 100vh;
+ z-index: 999;
+ background: #7386D5;
+ color: #fff;
+ transition: all 0.3s;
+}
+
+#sidebar.active {
+ margin-left: -250px;
+}
+
+#sidebar .sidebar-header {
+ padding: 20px;
+ background: #6d7fcc;
+}
+
+#sidebar ul.components {
+ padding: 20px 0;
+ border-bottom: 1px solid #47748b;
+}
+
+#sidebar ul p {
+ color: #fff;
+ padding: 10px;
+}
+
+#sidebar ul li a {
+ padding: 10px;
+ font-size: 1.1em;
+ display: block;
+}
+
+ #sidebar ul li a:hover {
+ color: #7386D5;
+ background: #fff;
+ }
+
+#sidebar ul li.active > a, a[aria-expanded="true"] {
+ color: #fff;
+ background: #6d7fcc;
+}
+
+
+a[data-toggle="collapse"] {
+ position: relative;
+}
+
+a[aria-expanded="false"]::before, a[aria-expanded="true"]::before {
+ content: '\e259';
+ display: block;
+ position: absolute;
+ right: 20px;
+ font-family: 'Glyphicons Halflings';
+ font-size: 0.6em;
+}
+
+a[aria-expanded="true"]::before {
+ content: '\e260';
+}
+
+
+ul ul a {
+ font-size: 0.9em !important;
+ padding-left: 30px !important;
+ background: #6d7fcc;
+}
+
+ul.CTAs {
+ padding: 20px;
+}
+
+ ul.CTAs a {
+ text-align: center;
+ font-size: 0.9em !important;
+ display: block;
+ border-radius: 5px;
+ margin-bottom: 5px;
+ }
+
+a.download {
+ background: #fff;
+ color: #7386D5;
+}
+
+a.article, a.article:hover {
+ background: #6d7fcc !important;
+ color: #fff !important;
}
web-map/Controllers/MapAPIController.cs 42(+42 -0)
diff --git a/web-map/Controllers/MapAPIController.cs b/web-map/Controllers/MapAPIController.cs
new file mode 100644
index 0000000..406f77a
--- /dev/null
+++ b/web-map/Controllers/MapAPIController.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+
+
+using ModelData.WebModel;
+
+namespace web_map.Controllers
+{
+ public class MapAPIController : Controller
+ {
+ /// <summary>
+ /// WebModel MapPoint
+ /// Данные всех объектов базы
+ /// </summary>
+ /// <returns></returns>
+ [HttpGet]
+ public JsonResult GetAllPoints(int YearMin, int YearMax)
+ {
+ WebDataManager webData = WebDataManager.Get();
+
+ return Json(webData.GetMapPoints(), JsonRequestBehavior.AllowGet);
+ }
+
+ /// <summary>
+ /// Buisness Settlement
+ /// Данные конкретного поселения
+ /// </summary>
+ /// <param name="name"></param>
+ /// <returns></returns>
+ [HttpGet]
+ public JsonResult GetSettlement(string Name)
+ {
+ WebDataManager webData = WebDataManager.Get();
+
+ return Json(webData.GetSettlement(Name), JsonRequestBehavior.AllowGet);
+ }
+
+ }
+}
\ No newline at end of file
web-map/Controllers/MapController.cs 48(+2 -46)
diff --git a/web-map/Controllers/MapController.cs b/web-map/Controllers/MapController.cs
index 84998aa..b0c1b54 100644
--- a/web-map/Controllers/MapController.cs
+++ b/web-map/Controllers/MapController.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Web;
using System.Web.Mvc;
+
namespace web_map.Controllers
{
public class MapController : Controller
@@ -12,51 +13,6 @@ namespace web_map.Controllers
public ActionResult Map()
{
return View();
- }
-
- [HttpPost]
- public JsonResult MapData(string id)
- {
- if (Convert.ToInt32(id) == 0)
- {
- List<Settlement> data = Settlement.GetData();
- //var smth = Json(data, JsonRequestBehavior.AllowGet);
-
-
- return Json(data, JsonRequestBehavior.AllowGet);
- //return Json("abc", JsonRequestBehavior.AllowGet);
- }
- return Json(null, JsonRequestBehavior.AllowGet);
- }
-
-
- // Костыль, который надо перенести в модель данных
- public class Settlement
- {
- public class Position
- {
-
- public double X { set; get; }
- public double Y { set; get; }
-
- }
- public string Name { set; get; }
- public Position position { set; get; }
-
- public int Year { set; get; }
- public string Type { set; get; }
-
- public static List<Settlement> GetData(int Count = 5)
- {
- List<Settlement> settlements = new List<Settlement>()
- {
- new Settlement() { Name = "Саратов", Type = "Город", position = new Position() {X = 51.533103, Y = 46.034158 }, Year = 1590 },
- new Settlement() { Name = "Балаково", Type = "Город", position = new Position() { X = 52.02782, Y = 47.8007 }, Year = 1911 },
- new Settlement() { Name = "Балашов", Type = "Город", position = new Position() { X = 51.5502, Y = 43.1667 }, Year = 1780 },
- new Settlement() { Name = "Маркс", Type = "Город", position = new Position() { X = 51.71111, Y = 46.74861 }, Year = 1942 }
- };
- return settlements;
- }
- }
+ }
}
}
\ No newline at end of file
diff --git a/web-map/Properties/PublishProfiles/FolderProfile.pubxml b/web-map/Properties/PublishProfiles/FolderProfile.pubxml
index cc28682..634af90 100644
--- a/web-map/Properties/PublishProfiles/FolderProfile.pubxml
+++ b/web-map/Properties/PublishProfiles/FolderProfile.pubxml
@@ -13,6 +13,6 @@
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>bin\Release\Publish</publishUrl>
- <DeleteExistingFiles>False</DeleteExistingFiles>
+ <DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
</Project>
\ No newline at end of file
web-map/Scripts/SiteScripts/AjaxQuery.js 71(+71 -0)
diff --git a/web-map/Scripts/SiteScripts/AjaxQuery.js b/web-map/Scripts/SiteScripts/AjaxQuery.js
new file mode 100644
index 0000000..77cb2b5
--- /dev/null
+++ b/web-map/Scripts/SiteScripts/AjaxQuery.js
@@ -0,0 +1,71 @@
+//Получить данные поселения по имени
+function GetInfoAboutSettlement(Name, functionWhatNeedToDoWithInfo) {
+ $.ajax({
+ url: '/MapAPI/GetSettlement',
+ type: 'GET',
+ contentType: "application/json; charset=utf-8",
+ dataType: 'json',
+ cache: false,
+ //Параметр контроллеру
+ data: {
+ Name: Name
+ },
+
+ success: function (data) {
+ functionWhatNeedToDoWithInfo(data);
+ },
+
+ error: function (response) {
+ console.log(response.responseText);
+ alert('Ошибка. Не удалось получить данные от сервера');
+ }
+ });
+}
+
+//Получить массив всех точек поселений от сервера
+function GetAllPoints(YearMin, YearMax) {
+ $.ajax({
+ url: '/MapAPI/GetAllPoints',
+ type: 'GET',
+ contentType: "application/json; charset=utf-8",
+ dataType: 'json',
+ cache: false,
+ //Параметр контроллеру
+ data: {
+ YearMin: YearMin,
+ YearMax: YearMax
+ },
+ success: function (data) {
+ LoadCollection(collectionAll, data, true);
+ PlaceFromCollection(collectionAll);
+ },
+
+ error: function (response) {
+ console.log(response.responseText);
+ alert('Ошибка. Не удалось получить данные от сервера');
+ }
+ });
+}
+
+// Функция запроса дат
+function GetDate() {
+ MinYear = 1590;
+ CurrentMinYear = 2016;
+ CurrentMaxYear = MaxYear = new Date().getFullYear();
+ return;
+ $.ajax({
+ url: '/MapAPI/GetDate',
+ type: 'GET',
+ contentType: "application/json; charset=utf-8",
+ dataType: 'json',
+ cache: false,
+ success: function (data) {
+ // Присвоить даты
+ },
+
+ error: function (response) {
+ console.log(response.responseText);
+ alert('Ошибка. Не удалось получить данные от сервера');
+ }
+ });
+}
\ No newline at end of file
web-map/Scripts/SiteScripts/Events.js 55(+55 -0)
diff --git a/web-map/Scripts/SiteScripts/Events.js b/web-map/Scripts/SiteScripts/Events.js
new file mode 100644
index 0000000..896b46a
--- /dev/null
+++ b/web-map/Scripts/SiteScripts/Events.js
@@ -0,0 +1,55 @@
+// Функция обработчик движения слайдера
+function SliderOnFinishMoving(data) {
+ console.log(data.from + " " + data.to);
+}
+
+// Функция заполнения Яндекс-коллекций Яндекс-объектами из JSON массива
+function LoadCollection(collection, fromData, bool = false) {
+ if (bool == true)
+ collection.removeAll(); // Очистка коллекции от старых элементов. Параметры остаются прежними
+
+ fromData.forEach(function (element) {
+ collection.add(CreateYandexPlacemark(element)); // Добавление
+ });
+}
+
+// Функция создания Яндекс-объекта из одного элемента JSON массива
+function CreateYandexPlacemark(fromElement) {
+ var placemark = new ymaps.Placemark([fromElement.Position.X, fromElement.Position.Y],
+ {
+ iconContent: fromElement.Name, // Содержимое названия
+ hintContent: [fromElement.Position.X, fromElement.Position.Y]// Содержимое подписи при наведении
+ }
+ );
+
+ //Добавить свойство - Имя поселения
+ placemark.options.set('Name', fromElement.Name);
+
+ // Переопределяем стадартный обработчик нажатия
+ placemark.events.add('click', function (e) {
+ e.preventDefault(); // Запрещаем стандартный обработчик
+
+ var targetName = e.get('target').options.get('Name');
+
+ // Вызов запроса на получение данных о поселении
+ GetInfoAboutSettlement(targetName, PrintInfoAboutSettlement);
+
+ // Показать боковую панель
+ if ($('#sidebar, #content').hasClass('active')) {
+ // Панель скрыта. Должна выехать
+ $('#sidebar, #content').removeClass('active');
+ $('.collapse.in').toggleClass('in');
+ $('a[aria-expanded=true]').attr('aria-expanded', 'false');
+ }
+ else
+ // Панель есть. Выбор, нужно ли её скрывать
+ if (targetName == document.getElementById('sidebar-header').getElementsByTagName('*')[0].innerHTML) {
+ $('#sidebar, #content').addClass('active');
+ $('.collapse.in').toggleClass('in');
+ $('a[aria-expanded=true]').attr('aria-expanded', 'false');
+ }
+
+
+ });
+ return placemark;
+}
\ No newline at end of file
web-map/Scripts/SiteScripts/Init.js 140(+140 -0)
diff --git a/web-map/Scripts/SiteScripts/Init.js b/web-map/Scripts/SiteScripts/Init.js
new file mode 100644
index 0000000..f14c0dc
--- /dev/null
+++ b/web-map/Scripts/SiteScripts/Init.js
@@ -0,0 +1,140 @@
+ymaps.ready(MapInit);
+
+function MapInit()
+{
+ YandexMapInit();
+ GetDate();
+ SliderInit();
+ CollectionsInit();
+ GetAllPoints(CurrentMinYear, CurrentMaxYear);
+}
+
+var collectionAll;
+var collectionReligion_1;
+var collectionReligion_2;
+var collectionReligion_3;
+var collectionReligion_4;
+var collectionName;
+var collectionExport;
+
+var Map;
+var MinYear;
+var MaxYear;
+var CurrentMinYear;
+var CurrentMaxYear;
+
+// Функция загрузки Яндекс карты
+function YandexMapInit()
+{
+ Map = new ymaps.Map
+ ('map', {
+ center: [51.533103, 46.034158],
+ zoom: 7,
+ type: 'yandex#hybrid',
+ controls: ['zoomControl', 'rulerControl']
+ },
+ {
+ // Ограничим область карты.
+ restrictMapArea: [[48.795, 41.484], [53.823, 51.856]]
+ //restrictMapArea: [[49.795, 42.484], [52.823, 50.856]]
+ }
+ );
+ Map.controls.get('zoomControl').options.set({ size: 'auto' });
+ Map.controls.add(new ymaps.control.TypeSelector(['yandex#map', 'yandex#satellite', 'yandex#hybrid']));
+
+
+ // Загрузим регионы.
+ ymaps.borders.load
+ ('RU', { lang: 'ru', quality: 3 }).then
+ (function (result) {
+ // Создадим многоугольник, который будет скрывать весь мир, кроме заданной области.
+ var background = new ymaps.Polygon
+ (
+ [[
+ [85, -179.99],
+ [85, 179.99],
+ [-85, 179.99],
+ [-85, -179.99],
+ [85, -179.99]
+ ]],
+ {},
+ {
+ fillColor: '#ffffff',
+ strokeWidth: 0,
+ // Для того чтобы полигон отобразился на весь мир, нам нужно поменять
+ // алгоритм пересчета координат геометрии в пиксельные координаты.
+ coordRendering: 'straightPath'
+ }
+ );
+
+ // Найдём область по её iso коду.
+ var region = result.features.filter(function (feature) { return feature.properties.iso3166 == 'RU-SAR'; })[0];
+ // Добавим координаты этой области в полигон, который накрывает весь мир.
+ // В полигоне образуется полость, через которую будет видно заданную область.
+ var masks = region.geometry.coordinates;
+
+ masks.forEach(function (mask) { background.geometry.insert(1, mask); });
+ // Добавим многоугольник на карту.
+ Map.geoObjects.add(background);
+ });
+}
+
+// Функция создания слайдера дат и обработчик поля ввода дат
+function SliderInit() {
+ // $j optional alias to jQuery noConflict()
+ var $j = jQuery.noConflict();
+ var $slider;
+
+ $j(document).ready(function () {
+ $slider = $("#slider").ionRangeSlider({
+ skin: "modern",
+ hide_min_max: true,
+ type: "double",
+ grid: true,
+ drag_interval: true,
+ min: MinYear,
+ max: MaxYear,
+ from: CurrentMinYear,
+ to: new Date().getFullYear(),
+ onFinish: function (data) {
+ console.log("finish");
+ // Called then action is done and mouse is released
+ SliderOnFinishMoving(data);
+ },
+ onUpdate: function (data) {
+ console.log("update");
+ // Called then action is done and mouse is released
+ SliderOnFinishMoving(data);
+ }
+ });
+ });
+ // Поле ввода даты. Обработчик изменения дат слайдера
+ var inputField = document.getElementById('inputYear');
+ inputField.oninput = function () {
+ if (inputField.value <= MaxYear && inputField.value >= MinYear) {
+ var slider_instance = $slider.data("ionRangeSlider");
+ slider_instance.update({
+ from: inputField.value,
+ to: inputField.value
+ });
+ }
+
+ };
+}
+
+// Функция создания коллекций Яндекс-объектов
+function CollectionsInit() {
+ // Набор коллекций, которые формируются для более гибкого отображения данных на странице.
+ // Объявлены, как глобальные переменные, однако инициализируются лишь один раз.
+ collectionAll = new ymaps.GeoObjectCollection({},
+ {
+ // Параметр коллекции всех элементов, отображающий название в красной рамке
+ preset: 'islands#redStretchyIcon'
+ });
+ collectionReligion_1 = new ymaps.GeoObjectCollection();
+ collectionReligion_2 = new ymaps.GeoObjectCollection();
+ collectionReligion_3 = new ymaps.GeoObjectCollection();
+ collectionReligion_4 = new ymaps.GeoObjectCollection();
+ collectionName = new ymaps.GeoObjectCollection();
+ collectionExport = new ymaps.GeoObjectCollection();
+}
\ No newline at end of file
web-map/Scripts/SiteScripts/Output.js 16(+16 -0)
diff --git a/web-map/Scripts/SiteScripts/Output.js b/web-map/Scripts/SiteScripts/Output.js
new file mode 100644
index 0000000..233a40f
--- /dev/null
+++ b/web-map/Scripts/SiteScripts/Output.js
@@ -0,0 +1,16 @@
+// Функция выводит данные о поселении в боковую панель из JSON объекта
+function PrintInfoAboutSettlement(info) {
+ var header = "<h3>" + info.Name + "</h3>"
+ document.getElementById('sidebar-header').innerHTML = header;
+
+ var text = '';
+ text += "<p>" + "Описание: " + info.Description + "</p><br/>";
+ text += "<p>" + "Время основания: " + info.Year + "</p><br/>";
+
+ document.getElementById('sidebar-text').innerHTML = text;
+}
+
+// Функция выгружает все гео-объекты из данной коллекции на карту
+function PlaceFromCollection(collection) {
+ Map.geoObjects.add(collection);
+}
\ No newline at end of file
web-map/Views/Map/Map.cshtml 48(+41 -7)
diff --git a/web-map/Views/Map/Map.cshtml b/web-map/Views/Map/Map.cshtml
index 2802df6..357ee84 100644
--- a/web-map/Views/Map/Map.cshtml
+++ b/web-map/Views/Map/Map.cshtml
@@ -3,15 +3,49 @@
}
<script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU&apikey=0ea4f7d6-01f0-471d-b717-ada9d94faa49&lang=ru_RU" type="text/javascript"></script>
-@section Scripts {@Scripts.Render("~/Scripts/mapInit.js")}
-
-
-<h2>Здесь будет размещена карта</h2>
+<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.3.0/css/ion.rangeSlider.min.css" />
+<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.3.0/js/ion.rangeSlider.min.js"></script>
+
+@section Scripts {@Scripts.Render("~/Scripts/SiteScripts/AjaxQuery.js",
+ "~/Scripts/SiteScripts/Events.js",
+ "~/Scripts/SiteScripts/Output.js",
+ "~/Scripts/SiteScripts/Init.js")}
+
+
+<div class="row" style="margin-top: 20px">
+ <div class="col-xs-12">
+ <div class="input-group">
+ <span class="input-group-addon" id="basic-addon1"><i class="glyphicon glyphicon-search"></i></span>
+ <input type="text" class="form-control" placeholder="Введите название">
+ </div>
+ </div>
+</div>
+<div class="row" style="margin-top: 20px; margin-bottom: 10px">
+ <div class="col-xs-8 col-sm-8" style="line-height: 43px;">
+ <div class="row" style="position:relative;">
+ <span style="position: absolute;top:-15px;left:50%;margin-left:-20px;">Год:</span>
+ <div class="col-xs-1" style="margin-top: 18px"><b>1590</b></div>
+ <div class="col-xs-10">
+ <input type="text" id="slider" class="js-range-slider" value="" />
+
+ </div>
+ <div class="col-xs-1" style="margin-top: 18px"><b>2018</b></div>
+ </div>
+ </div>
+ <div class="col-xs-4 col-sm-4">
+ <div class="row">
+ <div class="col-xs-12">
+ <div class="input-group">
+ <span class="input-group-addon">Год: </span>
+ <input id="inputYear" type="text" class="form-control" placeholder="Введите год">
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
<div id="map" style="width: 100%; height: 1000px; padding-left: 0px; "></div>
-
-
-
web-map/Views/Shared/_Layout.cshtml 14(+12 -2)
diff --git a/web-map/Views/Shared/_Layout.cshtml b/web-map/Views/Shared/_Layout.cshtml
index c8dff71..27b480b 100644
--- a/web-map/Views/Shared/_Layout.cshtml
+++ b/web-map/Views/Shared/_Layout.cshtml
@@ -1,12 +1,12 @@
<!DOCTYPE html>
<html>
<head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title – интерактивная карта</title>
@Styles.Render("~/Content/css")
- @Scripts.Render("~/bundles/modernizr")
+
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
@@ -28,6 +28,15 @@
</div>
</div>
</div>
+ <div class="wrapper">
+ <!-- Sidebar Holder -->
+ <nav id="sidebar" class="active">
+ <div id="sidebar-header" class="sidebar-header">
+ </div>
+ <div id="sidebar-text">
+ </div>
+ </nav>
+ </div>
<div class="container body-content">
@RenderBody()
<hr />
@@ -38,6 +47,7 @@
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
+
@RenderSection("scripts", required: false)
</body>
</html>
web-map/web-map.csproj 13(+12 -1)
diff --git a/web-map/web-map.csproj b/web-map/web-map.csproj
index ae1c9fc..bf9b07c 100644
--- a/web-map/web-map.csproj
+++ b/web-map/web-map.csproj
@@ -168,6 +168,7 @@
<Compile Include="App_Start\RouteConfig.cs" />
<Compile Include="App_Start\WebApiConfig.cs" />
<Compile Include="Controllers\HomeController.cs" />
+ <Compile Include="Controllers\MapAPIController.cs" />
<Compile Include="Controllers\MapController.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
@@ -199,8 +200,11 @@
<Content Include="Scripts\jquery.validate.min.js" />
<Content Include="Scripts\jquery.validate.unobtrusive.js" />
<Content Include="Scripts\jquery.validate.unobtrusive.min.js" />
- <Content Include="Scripts\mapInit.js" />
+ <Content Include="Scripts\SiteScripts\AjaxQuery.js" />
+ <Content Include="Scripts\SiteScripts\Events.js" />
+ <Content Include="Scripts\SiteScripts\Init.js" />
<Content Include="Scripts\modernizr-2.8.3.js" />
+ <Content Include="Scripts\SiteScripts\Output.js" />
<Content Include="Web.config" />
<Content Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
@@ -219,6 +223,7 @@
<ItemGroup>
<Folder Include="App_Data\" />
<Folder Include="Models\" />
+ <Folder Include="Views\MapAPI\" />
</ItemGroup>
<ItemGroup>
<Content Include="fonts\glyphicons-halflings-regular.woff2" />
@@ -233,6 +238,12 @@
<Content Include="Scripts\jquery-3.3.1.slim.min.map" />
<Content Include="Scripts\jquery-3.3.1.min.map" />
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\ModelData\ModelData.csproj">
+ <Project>{5db5c021-7c14-4798-9c0d-79e280583112}</Project>
+ <Name>ModelData</Name>
+ </ProjectReference>
+ </ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>