Permalink
Browse files

init

  • Loading branch information...
0 parents commit dc6a77e70fce9fb59691c538c8d5868b77770ff5 @efedin committed Apr 13, 2012
Showing with 971 additions and 0 deletions.
  1. +33 −0 gmap.html
  2. +87 −0 gmiks.js
  3. +88 −0 iks.js
  4. +125 −0 iks.json
  5. BIN images/Red-Couch32.png
  6. BIN images/Red-chair32.png
  7. +37 −0 index.html
  8. +487 −0 json2.js
  9. +81 −0 yiks.js
  10. +33 −0 ymap.html
@@ -0,0 +1,33 @@
+<!doctype html>
+<html>
+ <head>
+ <meta content="text/html;charset=UTF-8" http-equiv="content-type" />
+ <title>Карта выборов мэра Яхромы</title>
+ <script src="json2.js"></script>
+ <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDlA6ChRb4je9RjWPrPDKNNL9xRlpdTNVM&sensor=false"></script>
+ <style>
+ #map {
+ height: 800px
+ }
+ ul {
+ list-style-type: none;
+ }
+ li {
+ float: left;
+ margin: 0 10px;
+ }
+ br {
+ clear: all
+ }
+ </style>
+ </head>
+ <body>
+ <ul>
+ <li><a href="index.html">osm карта</a></li>
+ <li><a href="ymap.html">yandex карта</a></li>
+ </ul>
+ <br>
+ <div id="map"></div>
+ <script src="gmiks.js"></script>
+ </body>
+</html>
@@ -0,0 +1,87 @@
+(function() {
+ "use strict";
+var ikData = [
+ {
+ "type": "УИКи",
+ "pict": "images/Red-chair32.png",
+ "popupTpl": "<strong>УИК {number}</strong><br/>{obj}. {addr}, тел. {phone}"
+ },
+ {
+ "type": "ТИКи",
+ "pict": "images/Red-Couch32.png",
+ "popupTpl": "<strong>ТИК <a href='{url}'>{name}</a></strong><br/>{desc}"
+ }
+];
+
+var getMapYaCentered = function() {
+ return (new google.maps.Map(document.getElementById('map'),
+ {
+ zoom: 12,
+ center: new google.maps.LatLng(56.283333, 37.483333),
+ mapTypeId: google.maps.MapTypeId.ROADMAP
+ }));
+};
+var tpl = function(templ, obj) {
+ return templ.replace(/{([^}]+)}/g, function(a, b) {
+ return obj[b];
+ });
+};
+var createMap = function() {
+ var map = getMapYaCentered(),
+ marker,
+ arr,
+ infoWindow;
+
+ for (var i = 0, len = ikData.length; i < len; i++) {
+ arr = ikData[i].data;
+ for (var j = 0, leng = arr.length; j < leng; j++) {
+ marker = new google.maps.Marker({
+ position: new google.maps.LatLng(arr[j].lat, arr[j].lon),
+ map: map,
+ title: arr[j].number
+ });
+ (function(marker, html) {
+ infoWindow = new google.maps.InfoWindow();
+ google.maps.event.addListener(marker, 'click', function() {
+ infoWindow.setContent(html);
+ infoWindow.open(map, marker);
+ });
+ })(marker, tpl(ikData[i].popupTpl, arr[j]));
+ }
+ }
+
+
+ var successGetLoc = function(position) {
+ map.setCenter(new google.maps.LatLng(position.coords.latitude, position.coords.longitude));
+ };
+ if (navigator.geolocation) {
+ navigator.geolocation.getCurrentPosition(successGetLoc);
+ }
+};
+function getHTTPObject() {
+ if (typeof XMLHttpRequest != "undefined") {
+ return new XMLHttpRequest();
+ } else if (window.ActiveXObject) {
+ var versions = ["MSXML2.XMLHttp.6.0", "MSXML2.XMLHttp.3.0"];
+ for (var i = 0; i < versions.length; i++) {
+ try {
+ var oXmlHttp = new ActiveXObject(versions[i]);
+ return oXmlHttp;
+ } catch (err) {}
+ }
+ }
+}
+var xhr = getHTTPObject();
+xhr.open("GET", "iks.json", true);
+xhr.onreadystatechange = function() {
+ if (xhr.readyState == 4) {
+ if (xhr.status == 200 || xhr.status == 304) {
+ var iks = JSON.parse(xhr.responseText);
+ ikData[0].data = iks.uiks;
+ ikData[1].data = iks.tiks;
+ createMap();
+ }
+ }
+};
+xhr.send(null);
+})();
88 iks.js
@@ -0,0 +1,88 @@
+(function() {
+ "use strict";
+var ikData = [
+ {
+ "type": "УИКи",
+ "pict": "images/Red-chair32.png",
+ "popupTpl": "<strong>УИК {number}</strong><br/>{obj}. {addr}, тел. {phone}"
+ },
+ {
+ "type": "ТИКи",
+ "pict": "images/Red-Couch32.png",
+ "popupTpl": "<strong>ТИК <a href='{url}'>{name}</a></strong><br/>{desc}"
+ }
+];
+
+var getMapYaCentered = function() {
+var map = new L.Map('map');
+ var cloudmade = new L.TileLayer('http://{s}.tile.cloudmade.com/4dbea02acb2d47779913c727fa16dda9/997/256/{z}/{x}/{y}.png',
+ {
+ attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://cloudmade.com">CloudMade</a>',
+ maxZoom: 18
+ }
+ );
+ var yar = new L.LatLng(56.283333, 37.483333);
+ map.setView(yar, 13).addLayer(cloudmade);
+ return map;
+};
+var tpl = function(templ, obj) {
+ return templ.replace(/{([^}]+)}/g, function(a, b) {
+ return obj[b];
+ });
+};
+var createMap = function() {
+ var map = getMapYaCentered(),
+ IkIcon = L.Icon.extend({
+ iconSize: new L.Point(32, 32)
+ }),
+ groupIcon,
+ markerPlace,
+ marker,
+ arr;
+
+ for (var i = 0, len = ikData.length; i < len; i++) {
+ groupIcon = new IkIcon(ikData[i].pict);
+ arr = ikData[i].data;
+ for (var j = 0, leng = arr.length; j < leng; j++) {
+ markerPlace = new L.LatLng(arr[j].lat, arr[j].lon);
+ marker = new L.Marker(markerPlace, {icon: groupIcon});
+ marker.bindPopup(tpl(ikData[i].popupTpl, arr[j]));
+ map.addLayer(marker);
+ }
+ }
+
+
+ var successGetLoc = function(position) {
+ map.setView(new L.LatLng(position.coords.latitude, position.coords.longitude), 15);
+ };
+ if (navigator.geolocation) {
+ navigator.geolocation.getCurrentPosition(successGetLoc);
+ }
+};
+function getHTTPObject() {
+ if (typeof XMLHttpRequest != "undefined") {
+ return new XMLHttpRequest();
+ } else if (window.ActiveXObject) {
+ var versions = ["MSXML2.XMLHttp.6.0", "MSXML2.XMLHttp.3.0"];
+ for (var i = 0; i < versions.length; i++) {
+ try {
+ var oXmlHttp = new ActiveXObject(versions[i]);
+ return oXmlHttp;
+ } catch (err) {}
+ }
+ }
+}
+var xhr = getHTTPObject();
+xhr.open("GET", "iks.json", true);
+xhr.onreadystatechange = function() {
+ if (xhr.readyState == 4) {
+ if (xhr.status == 200 || xhr.status == 304) {
+ var iks = JSON.parse(xhr.responseText);
+ ikData[0].data = iks.uiks;
+ ikData[1].data = iks.tiks;
+ createMap();
+ }
+ }
+};
+xhr.send(null);
+})();
125 iks.json
@@ -0,0 +1,125 @@
+{
+ "tiks": [
+ {
+ "lon": 37.517014,
+ "lat": 56.341972,
+ "desc": "г. Дмитров, Советская, 4. (495) 993-79-21",
+ "url": "http://www.moscow_reg.vybory.izbirkom.ru/region/moscow_reg?action=show_komissia&region=50&sub_region=50&type=100&vrnorg=250200090792&vrnkomis=450400616985",
+ "name": "Дмитровского района"
+ }
+ ],
+ "uiks": [
+ {
+ "lon": 37.477222,
+ "lat": 56.291115,
+ "obj": "Яхромская средняя школа №2",
+ "addr": "ул. Кирьянова, д. 12а",
+ "phone": "5-17-57",
+ "number": "1"
+ },
+ {
+ "lon": 37.471947,
+ "lat": 56.293953,
+ "obj": "Помещение изостудии",
+ "addr": "ул. Кирьянова, д. 32",
+ "phone": "5-10-51",
+ "number": "2"
+ },
+ {
+ "lon": 37.486504,
+ "lat": 56.290859,
+ "obj": "ДК г. Яхромы",
+ "addr": "ул. Заречная, 2",
+ "phone": "5-20-10",
+ "number": "3"
+ },
+ {
+ "lon": 37.480904,
+ "lat": 56.286594,
+ "obj": "Вечерняя школа",
+ "addr": "ул. Конярова, д. 31",
+ "phone": "5-26-16",
+ "number": "4"
+ },
+ {
+ "lon": 37.478706,
+ "lat": 56.285439,
+ "obj": "Красный уголок Яхромского территориально-медицинского комплекса",
+ "addr": "ул. Конярова, д. 9",
+ "phone": "5-10-60",
+ "number": "5"
+ },
+ {
+ "lon": 37.491081,
+ "lat": 56.283588,
+ "obj": "Яхромская средняя школа №1",
+ "addr": "микрорайон Левобережье, д. 17",
+ "phone": "5-19-39",
+ "number": "6"
+ },
+ {
+ "lon": 37.479027,
+ "lat": 56.296593,
+ "obj": "Помещение красного уголка общежития",
+ "addr": "ул. Бусалова, 8",
+ "phone": "5-10-00",
+ "number": "7"
+ },
+ {
+ "lon": 37.482910,
+ "lat": 56.279182,
+ "obj": "Яхромская техшкола",
+ "addr": "ул. Большевистская, д. 16",
+ "phone": "5-27-79",
+ "number": "8"
+ },
+ {
+ "lon": 37.485641,
+ "lat": 56.280701,
+ "obj": "Здание проходной ЗАО «Яхромский автобусный завод»",
+ "addr": "ул. Ленина, д. 42",
+ "phone": "5-12-70",
+ "number": "9"
+ },
+ {
+ "lon": 37.512669,
+ "lat": 56.289982,
+ "obj": "Яхромская средняя школа №3",
+ "addr": "ул. Семешинская, д. 1",
+ "phone": "5-28-66",
+ "number": "10"
+ },
+ {
+ "lon": 37.430737,
+ "lat": 56.305706,
+ "obj": "ОАО «Гамма»",
+ "addr": "деревня Астрецово",
+ "phone": "5-76-41",
+ "number": "11"
+ },
+ {
+ "lon": 37.341927,
+ "lat": 56.270527,
+ "obj": "Помещение клуба ОАО «Апраксин центр»",
+ "addr": "село Ольгово, стр. 92, корп. 11",
+ "phone": "5-75-48",
+ "number": "12"
+ },
+ {
+ "lon": 37.474152,
+ "lat": 56.267902,
+ "obj": "Спортивно-развлекательный парк «Яхрома»",
+ "addr": "деревня Степаново",
+ "phone": "981-89-39",
+ "number": "13"
+ },
+ {
+ "lon": 37.249645,
+ "lat": 56.263130,
+ "obj": "Школа села Подъячево",
+ "addr": "село Подъячево",
+ "phone": "5-71-45.",
+ "number": "14"
+ }
+ ]
+}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,37 @@
+<!doctype html>
+<html>
+ <head>
+ <meta content="text/html;charset=UTF-8" http-equiv="content-type" />
+ <title>Карта выборов мэра Яхромы</title>
+ <script src="json2.js"></script>
+ <link rel="stylesheet" href="http://code.leafletjs.com/leaflet-0.3.1/leaflet.css" />
+ <!--[if lte IE 8]>
+ <link rel="stylesheet" href="http://code.leafletjs.com/leaflet-0.3.1/leaflet.ie.css" />
+ <![endif]-->
+ <style>
+ #map {
+ height: 800px
+ }
+ ul {
+ list-style-type: none;
+ }
+ li {
+ float: left;
+ margin: 0 10px;
+ }
+ br {
+ clear: all
+ }
+ </style>
+ </head>
+ <body>
+ <ul>
+ <li><a href="gmap.html">google карта</a></li>
+ <li><a href="ymap.html">yandex карта</a></li>
+ </ul>
+ <br>
+ <div id="map"></div>
+ <script src="http://code.leafletjs.com/leaflet-0.3.1/leaflet.js"></script>
+ <script src="iks.js"></script>
+ </body>
+</html>
Oops, something went wrong.

0 comments on commit dc6a77e

Please sign in to comment.