1function waitForTilesLoad(layer) { 2 return new ymaps.vow.Promise(function (resolve, reject) { 3 var tc = getTileContainer(layer), readyAll = true; 4 tc.tiles.each(function (tile, number) { 5 if (!tile.isReady()) { 6 readyAll = false; 7 } 8 }); 9 if (readyAll) { 10 resolve(); 11 } else { 12 tc.events.once("ready", function() { 13 resolve(); 14 }); 15 } 16 }); 17} 18 19function getTileContainer(layer) { 20 for (var k in layer) { 21 if (layer.hasOwnProperty(k)) { 22 if ( 23 layer[k] instanceof ymaps.layer.tileContainer.CanvasContainer 24 || layer[k] instanceof ymaps.layer.tileContainer.DomContainer 25 ) { 26 return layer[k]; 27 } 28 } 29 } 30 return null; 31} 32 33var maps = []; 34var box_heights = []; 35var clusterers = []; 36function loadMap ( ) { 37 if(typeof $.infotaskFn == 'function') $.infotask.ui.showPreload(); 38 $('.js-map').each (function( map_num ) { 39 if(typeof $(this).attr('data-map-id') != 'undefined') 40 map_num = $(this).attr('data-map-id'); 41 var parent_height = $(this).parent('div').height(); 42 var $new_map = $("<div class='flex-grow-1 flex-column' style='cursor: pointer;visibility:hidden; width:100%;' id='map-"+map_num+"'></div>"); 43 $(this).append( $new_map ) ; 44 45 box_heights.push($('#map-'+map_num).height()); 46 47 var myMap = new ymaps.Map("map-" + map_num, { 48 center: [55.76, 37.64], // Сâ¬Ð ÑСÐÐ ÑСâР°, Ð ÒÐ ÑР»РÑÐ ÑСâР° 49 zoom: 10, 50 controls: ['zoomControl'] 51 },{maxZoom: 18, yandexMapDisablePoiInteractivity: true}), 52 clusterer = new ymaps.Clusterer({ 53 preset: 'islands#invertedGreenClusterIcons', 54 groupByCoordinates: false, 55 gridSize: 80, 56 //clusterDisableClickZoom: true, 57 clusterHideIconOnBalloonOpen: false, 58 geoObjectHideIconOnBalloonOpen: false, 59 clusterBalloonContentLayoutWidth: 250, 60 clusterBalloonLeftColumnWidth: 60, 61 clusterBalloonLeftColumnHeight: 100, 62 clusterBalloonContentLayoutHeight: 100, 63 }); 64 65 clusterers['map-'+map_num] = clusterer; 66 67 //ÐÑвод кооÑдинаÑÑ ÑоÑки ÐÐÐ 68 /* 69 var click_event; 70 var timeoutId; 71 myMap.events.add('click', function (e) { 72 click_event = e; 73 if (!timeoutId) 74 timeoutId = setTimeout(function(){ 75 clearTimeout(timeoutId); 76 timeoutId = 0; 77 if (!myMap.balloon.isOpen()) { 78 var coords_ballon = click_event.get('coords'); 79 myMap.balloon.open(coords_ballon, { 80 contentBody: 81 '<p>ÐооÑдинаÑÑ ÑоÑки: </p><p>' + [ 82 coords_ballon[0].toPrecision(6), 83 coords_ballon[1].toPrecision(6) 84 ].join(', ') + '</p>' 85 }); 86 } 87 else { 88 myMap.balloon.close(); 89 } 90 }, 500); 91 }); 92 93 myMap.events.add('dblclick', function (e) { 94 clearTimeout(timeoutId); 95 timeoutId = 0; 96 }); 97 */ 98 //Ðобавление балÑна ÐÐÐ 99 /* 100 myMap.events.add('contextmenu', function (e) { 101 myMap.geoObjects.add(new ymaps.GeoObject({ 102 geometry: { 103 type: "Point", 104 coordinates: e.get('coords') 105 }, 106 properties: { 107 balloonContent: 'test' 108 } 109 })); 110 }); 111 */ 112 113 myMap.behaviors.disable('scrollZoom'); 114 var o = ymaps.geoQuery(); 115 $(this).children().each( function () { 116 if ( typeof $(this).data('address') !== 'undefined' ) { 117 var c = ymaps.geocode( $(this).data('address'), { results: 1 } ); 118 o = o.add( c ); 119 } 120 121 if (typeof $(this).data('coordinate') !== 'undefined') { 122 var coords = $(this).data('coordinate').split(';'); 123 coords = coords.filter(function (el) { 124 return (el != ""); 125 }); 126 $.each(coords, function(i, v){ 127 var coord1 = 0; 128 var coord2 = 0; 129 var parts = v.split('-'); 130 var parts_coord = parts[0].split(',');
131 $.each(parts_coord, function(i1, v1){ 132 v1 = v1.replace(' ',''); 133 if (coord1 == 0) 134 coord1 = v1; 135 else coord2 = v1; 136 }); 137 /* 138 o = o.add({ 139 type: 'Point', 140 coordinates: [coord1, coord2] 141 });*/ 142 var point_name = ''; 143 if (parts[1] !== undefined) 144 point_name = parts[1].trim(); 145 o = o.add(new ymaps.GeoObject({ 146 geometry: { 147 type: "Point", 148 coordinates: [coord1, coord2] 149 }, 150 properties: { 151 balloonContent: parts[1] 152 } 153 })); 154 }); 155 } 156 } ); 157 if (o._objects.length > 0){ 158 o.addToMap( myMap ); 159 160 o.then(function () { 161 o.each(function (object) { 162 myMap.geoObjects.add(object); 163 }); 164 myMap.setBounds(myMap.geoObjects.getBounds(), {checkZoomRange:true, zoomMargin: [50, 30, 20, 30]}).then( 165 function() { 166 //$('#map-'+map_num+' > *').css('visibility','visible'); 167 } 168 ); 169 }); 170 }else{ 171 //$('#map-'+map_num+' > *').css('visibility','visible'); 172 } 173 174 //maps.push(myMap); 175 maps['map-'+map_num] = myMap; 176 var layer = myMap.layers.get(0).get(0); 177 $(this).trigger('init.yamap', map_num); 178 179 }); 180} 181 182var old_height = $(window).height(); 183$(window).resize(function(){ 184 185 if(!Object.keys(box_heights).length) return; 186 187 var new_height = $(window).height(); 188 189 $.each(box_heights, function(map_num, height){ 190 var window_diff = new_height - old_height; 191 192 $('#map-' + map_num).height(height + window_diff); 193 194 if(typeof maps[map_num] != 'undefined'){ 195 setTimeout(function(){ 196 maps[map_num].setBounds(maps[map_num].geoObjects.getBounds(), {checkZoomRange:true, zoomMargin: [50, 30, 20, 30]}); 197 }, 0); 198 } 199 }); 200}); 201 202$(window).on('load', function() { 203 if (typeof window['map_load'] != 'undefined'){ 204 delete window['map_load']; 205 return; 206 } 207 init_map(); 208}); 209 210$(document).off('infotask.ui.navigate.success.map'); 211 212$(document).on('infotask.ui.navigate.success.map', function(){ 213 init_map(); 214}); 215 216$(document).off('from.ui.navigate.success.map'); 217 218$(document).on('from.ui.navigate.success.map', function(){ 219 init_map(); 220}); 221 222$(document).off('from.ui.navigate.success_map.map'); 223 224$(document).on('from.ui.navigate.success_map.map', function(){ 225 $(document).off('from.ui.navigate.success_map.map'); 226 //if (typeof window['ajax_load'] == 'undefined') return; 227 init_map(); 228}); 229 230function init_map(){ 231 if ( $('.js-map').length > 0 ) { 232 loadScriptMap("https://api-maps.yandex.ru/2.1/?apikey=e46db226-0711-474a-9d46-1a22f83ebd80&lang=ru_RU&loadByRequire=1", function() { 233 ymaps.ready( { successCallback: loadMap } ); 234 }); 235 } 236} 237 238function ymap_add_points(points_str, map){ 239 240 //points_str = '{"map-0":[{"coord":"53.0242,50.2631","name":"СамаÑа"},{"coord":"51.5146,39.2767","name":"ÐоÑонеж"},{"coord":"55.5929,49.2963","name":"ÐазанÑ"},{"coord":"48.5143,44.5502","name":"ÐолгогÑад"},{"coord":"54.5847,56.1517","name":"УÑа"},{"coord":"59.8654,30.5756","name":"СанкÑ-ÐеÑеÑбÑÑг"},{"coord":"54.8899,73.5541","name":"ÐмÑк"},{"coord":"49.7826,36.4642","name":"ХаÑÑков"},{"coord":"48.2215,35.1459","name":"ÐнепÑ"}]}'; 241 if (points_str != null && map != null){ 242 points_arr = JSON.parse(b64_to_utf8_map(points_str))[map]; 243 244 if (points_arr !== undefined){ 245 var points = []; 246 $.each(points_arr, function(i, v){ 247 var coord1 = 0; 248 var coord2 = 0; 249 250 if (v.coord != null && v.coord.split(',').length > 1){ 251 var parts_coord = v.coord.split(',');
252 $.each(parts_coord, function(i1, v1){ 253 v1 = v1.trim(); 254 if (coord1 == 0) 255 coord1 = v1; 256 else coord2 = v1; 257 }); 258 var point_name = ''; 259 if (v.name != null) 260 point_name = v.name.trim(); 261 262 /* 263 maps[map].geoObjects.add(new ymaps.GeoObject({ 264 geometry: { 265 type: "Point", 266 coordinates: [coord1, coord2] 267 }, 268 properties: { 269 balloonContent: point_name 270 } 271 }));*/ 272 points.push([[coord1, coord2], point_name, typeof v.preset_img != 'undefined' ? v.preset_img : false]); 273 } 274 }); 275 276 var geo = []; 277 for(var i = 0, len = points.length; i < len; i++) { 278 var point_name_paths = points[i][1].split(';'); 279 var point_preset_img = points[i][2]; 280 281 282 var point_placemark = {preset: 'islands#greenVegetationIcon'} 283 284 if(point_preset_img){ 285 point_placemark = { 286 iconLayout: 'default#imageWithContent', 287 iconImageHref: point_preset_img, 288 iconImageSize: [30, 30], 289 iconImageOffset: [-15, -15], 290 iconContentOffset: [10, 10], 291 }; 292 } 293 294 geo[i] = new ymaps.Placemark(points[i][0], { 295 balloonContentBody: point_name_paths[0], 296 clusterCaption: point_name_paths[1] 297 }, point_placemark); 298 } 299 300 if(geo.length > 0){ 301 clusterers[map].add(geo); 302 maps[map].geoObjects.add(clusterers[map]); 303 304 maps[map].setBounds(maps[map].geoObjects.getBounds(), {checkZoomRange:true, zoomMargin: [50, 30, 20, 30]}).then(function(){ 305 setTimeout(function(){if(typeof $.infotaskFn == 'function') $.infotask.ui.hidePreload();}, 100); 306 $('#'+map+' > *').css('visibility','visible'); 307 }); 308 }else{ 309 setTimeout(function(){if(typeof $.infotaskFn == 'function') $.infotask.ui.hidePreload();}, 100); 310 $('#'+map+' > *').css('visibility','visible'); 311 } 312 }else{ 313 setTimeout(function(){if(typeof $.infotaskFn == 'function') $.infotask.ui.hidePreload();}, 100); 314 $('#'+map+' > *').css('visibility','visible'); 315 } 316 }else{ 317 setTimeout(function(){if(typeof $.infotaskFn == 'function') $.infotask.ui.hidePreload();}, 100); 318 } 319} 320 321function loadScriptMap(url, callback){ 322 var already = already_loaded_script_map.find(element => element == url); 323 324 if (already !== undefined){ 325 callback(); 326 return; 327 }else{ 328 already_loaded_script_map.push(url); 329 } 330 331 var script = document.createElement("script"); 332 if (script.readyState){ // IE 333 script.onreadystatechange = function(){ 334 if (script.readyState == "loaded" || 335 script.readyState == "complete"){ 336 script.onreadystatechange = null; 337 callback(); 338 339 } 340 }; 341 } else { 342 script.onload = function(){ 343 callback(); 344 }; 345 } 346 347 script.src = url; 348 document.getElementsByTagName("head")[0].appendChild(script); 349} 350 351function b64_to_utf8_map(str) { 352 return decodeURIComponent(escape(window.atob( str ))); 353} 354 355function endMap(map){ 356 if(typeof $.infotaskFn == 'function') $.infotask.ui.hidePreload(); 357 $('#'+map+' > *').css('visibility','visible'); 358} 359 360$(document).on('init.yamap', '.js-map', function(e, map_num){ 361 if (typeof window['map_points'] != 'undefined' && typeof window['map_points']['map-'+map_num] != 'undefined') 362 ymap_add_points_coord(map_points['map-'+map_num], 'map-'+map_num); 363 364 if (typeof window['map_points_arr'] != 'undefined' && typeof window['map_points_arr']['map-'+map_num] != 'undefined') 365 ymap_add_points_coord(map_points_arr, 'map-'+map_num, 'array'); 366}); 367 368function ymap_add_points_coord(points_str, map, val_type){ 369 if (points_str != null && map != null){ 370 if (typeof val_type != 'undefined' && val_type == 'array') 371 var points_arr = points_str[map]; 372 else 373 var points_arr = JSON.parse(b64_to_utf8_map(points_str))[map]; 374 375 if (points_arr !== undefined){ 376 var objects = ymaps.geoQuery(); 377 378 $.each(points_arr, function(inx, el){ 379 if (typeof el.address != 'undefined' && el.address != '') 380 objects = objects.add(ymaps.geocode(el.address, {results: 1})); 381 else 382 points_arr.splice(inx, 1); 383 }); 384 385 objects.then( 386 function () { 387 var i = 0; 388 objects.each(function (el) { 389 var geoCoords = el.geometry.getCoordinates();
390 391 if (typeof geoCoords != 'undefined' && geoCoords.length > 1){ 392 var point_content = ''; 393 if (typeof points_arr[i].content != 'undefined') 394 point_content = points_arr[i].content.trim(); 395 if (point_content == '') 396 point_content = points_arr[i].address.trim(); 397 398 var point_title = ''; 399 if (typeof points_arr[i].title != 'undefined') 400 point_title = points_arr[i].title.trim(); 401 402 var point_head = ''; 403 if (typeof points_arr[i].head != 'undefined') 404 point_head = points_arr[i].head.trim(); 405 if (point_head == '') 406 point_head = point_title; 407 408 var preset_color = 'red'; 409 if (typeof points_arr[i].color != 'undefined') 410 preset_color = points_arr[i].color.trim(); 411 412 var myGeoObject = new ymaps.Placemark(geoCoords, { 413 balloonContentHeader: point_head, 414 balloonContentBody: point_content, 415 iconContent: point_title 416 }, {preset: 'islands#'+preset_color+'StretchyIcon'}); 417 418 maps[map].geoObjects.add(myGeoObject); 419 } 420 i++; 421 }); 422 423 if (maps[map].geoObjects.getLength() > 1){ 424 maps[map].setBounds(maps[map].geoObjects.getBounds(), {checkZoomRange:true, zoomMargin: [50, 30, 20, 30]}).then(function(){ 425 endMap(map); 426 }); 427 428 }else{ 429 maps[map].setBounds(maps[map].geoObjects.getBounds()).then(function(){ 430 maps[map].setZoom(14); 431 endMap(map); 432 }); 433 } 434 } 435 ); 436 }else{ 437 endMap(map); 438 } 439 }else{ 440 if(typeof $.infotaskFn == 'function') $.infotask.ui.hidePreload(); 441 } 442}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.