window.src_marker = '/i/map/bullet_03.png'; window.src_marker_active = '/i/map/bullet_03.png'; window.src_marker_deactive = '/i/map/bullet_02.png'; window.src_marker_14 = '/i/map/bullet_03.png'; window.src_marker_10 = '/i/map/bullet_orange.png'; window.corn_y = -23 + 16; window.corn_y_ = 87 + 14; // 87 + 53 - 16 window.corn_x = 74 + 14; window.corn_x_ = 308 + 14; window.minZoom = 8; window.manZoom = 16;(function(){ /** * Constructor */ ArendaMap = function() { this.scope = this; this.mapContainerSelector = null; this.filterAreaSlider = $('#filter-slider'); this.areaMaxInput = $( "#area-max" ) this.areaMinInput = $( "#area-min" ) this.maxArea = 2000; this.minArea = 0 this.currentMinArea = this.getCookie('areaMin') || 0; this.currentMaxArea = this.getCookie('areaMax') || 2000; this.map = null; this.mapOptions = null; this.currentLocation = null; this.markers = {}; this.markersArray = []; this.markerDefaultMode = this.getCookie('mode') || 'all'; this.markerMode = this.markerDefaultMode; this.MOVE_DIRECTION = 50; this.list = []; this.data = {"moscow":{"lat":"56.000337039743","lng":"36.820145263672","zoom":10,"items":{"item1":{"lat":"56.066705733167","lng":"37.276077880859","index":1,"href":"\/projects\/wholesale\/?ID=11099","title":"\u0434. \u0412\u0435\u0440\u0435\u0432\u0441\u043a\u043e\u0435 (4,99 \u0413\u0430)","area":"\u041b\u0435\u043d\u0438\u043d\u0433\u0440\u0430\u0434\u0441\u043a\u043e\u0435 \u0448., \u0434. \u0412\u0435\u0440\u0435\u0432\u0441\u043a\u043e\u0435, \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c","type":14},"item2":{"lat":"56.055013179549","lng":"37.149391784668","index":2,"href":"\/projects\/wholesale\/?ID=11100","title":"\u0434. \u0414\u0443\u0440\u044b\u043a\u0438\u043d\u043e (6,77 \u0413\u0430)","area":"\u041b\u0435\u043d\u0438\u043d\u0433\u0440\u0430\u0434\u0441\u043a\u043e\u0435 \u0448., \u0434. \u0414\u0443\u0440\u044b\u043a\u0438\u043d\u043e, \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c","type":14},"item3":{"lat":"56.055013179549","lng":"37.149391784668","index":3,"href":"\/projects\/wholesale\/?ID=11103","title":"\u0434. \u0414\u0443\u0440\u044b\u043a\u0438\u043d\u043e, \u0434. \u0411\u0435\u0440\u0441\u0435\u043d\u0435\u0432\u043a\u0430 (78,86 \u0413\u0430)","area":"\u041b\u0435\u043d\u0438\u043d\u0433\u0440\u0430\u0434\u0441\u043a\u043e\u0435 \u0448., \u0434. \u0414\u0443\u0440\u044b\u043a\u0438\u043d\u043e, \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c","type":14},"item4":{"lat":"55.989776588655","lng":"37.272987976074","index":4,"href":"\/projects\/wholesale\/?ID=11104","title":"\u0434. \u0415\u043b\u0438\u043d\u043e (3,68 \u0413\u0430)","area":"\u041b\u0435\u043d\u0438\u043d\u0433\u0440\u0430\u0434\u0441\u043a\u043e\u0435 \u0448., \u0434. \u0415\u043b\u0438\u043d\u043e, \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c","type":14},"item5":{"lat":"55.295183985392","lng":"35.191422119141","index":5,"href":"\/projects\/wholesale\/?ID=11106","title":"\u0434. \u0416\u0438\u043b\u0438\u043d\u043e (4,78 \u0413\u0430)","area":"\u041b\u0435\u043d\u0438\u043d\u0433\u0440\u0430\u0434\u0441\u043a\u043e\u0435 \u0448., \u0434. \u0416\u0438\u043b\u0438\u043d\u043e, \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c","type":14},"item6":{"lat":"55.295183985392","lng":"35.191422119141","index":6,"href":"\/projects\/wholesale\/?ID=11107","title":"\u0434. \u0416\u0438\u043b\u0438\u043d\u043e (1,28 \u0413\u0430)","area":"\u041b\u0435\u043d\u0438\u043d\u0433\u0440\u0430\u0434\u0441\u043a\u043e\u0435 \u0448., \u0434. \u0416\u0438\u043b\u0438\u043d\u043e, \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c","type":14},"item7":{"lat":"56.075424919495","lng":"37.148876800537","index":7,"href":"\/projects\/wholesale\/?ID=11108","title":"\u0434. \u0420\u0430\u0434\u0443\u043c\u043b\u044f (11,12 \u0413\u0430)","area":"\u041b\u0435\u043d\u0438\u043d\u0433\u0440\u0430\u0434\u0441\u043a\u043e\u0435 \u0448., \u0434. \u0420\u0430\u0434\u0443\u043c\u043b\u044f, \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c","type":14},"item8":{"lat":"56.01377344143","lng":"37.336502685547","index":8,"href":"\/projects\/wholesale\/?ID=11112","title":"\u0434. \u041f\u043e\u044f\u0440\u043a\u043e\u0432\u043e (5,66 \u0413\u0430)","area":"\u041b\u0435\u043d\u0438\u043d\u0433\u0440\u0430\u0434\u0441\u043a\u043e\u0435 \u0448., \u0434. \u041f\u043e\u044f\u0440\u043a\u043e\u0432\u043e, \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c","type":14},"item9":{"lat":"56.01377344143","lng":"37.336502685547","index":9,"href":"\/projects\/wholesale\/?ID=11113","title":"\u0434. \u041f\u043e\u044f\u0440\u043a\u043e\u0432\u043e (48,8 \u0413\u0430)","area":"\u041b\u0435\u043d\u0438\u043d\u0433\u0440\u0430\u0434\u0441\u043a\u043e\u0435 \u0448., \u0434. \u041f\u043e\u044f\u0440\u043a\u043e\u0432\u043e, \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c","type":14},"item10":{"lat":"56.062489155405","lng":"37.103729858398","index":10,"href":"\/projects\/wholesale\/?ID=11110","title":"\u0434. \u041b\u0438\u043f\u0443\u043d\u0438\u0445\u0430 (11,31 \u0413\u0430)","area":"\u041b\u0435\u043d\u0438\u043d\u0433\u0440\u0430\u0434\u0441\u043a\u043e\u0435 \u0448., \u0434. \u041b\u0438\u043f\u0443\u043d\u0438\u0445\u0430, \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c","type":14},"item11":{"lat":"56.061339099611","lng":"37.188187255859","index":11,"href":"\/projects\/wholesale\/?ID=11111","title":"\u0434. \u041d\u0438\u043a\u043e\u043b\u044c\u0441\u043a\u043e\u0435 (4,71 \u0413\u0430)","area":"\u041b\u0435\u043d\u0438\u043d\u0433\u0440\u0430\u0434\u0441\u043a\u043e\u0435 \u0448., \u0434. \u041d\u0438\u043a\u043e\u043b\u044c\u0441\u043a\u043e\u0435, \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c","type":14},"item12":{"lat":"56.029075648183","lng":"37.165656700134","index":12,"href":"\/projects\/wholesale\/?ID=11114","title":"\u0434. \u0427\u0430\u0448\u043d\u0438\u043a\u043e\u0432\u043e (139,13 \u0413\u0430)","area":"\u041b\u0435\u043d\u0438\u043d\u0433\u0440\u0430\u0434\u0441\u043a\u043e\u0435 \u0448., \u0434. \u0427\u0430\u0448\u043d\u0438\u043a\u043e\u0432\u043e , \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c","type":14},"item13":{"lat":"56.005328248702","lng":"37.385941162109","index":13,"href":"\/projects\/wholesale\/?ID=11116","title":"\u0434. \u041b\u0443\u043d\u0435\u0432\u043e (0,36 \u0413\u0430)","area":"\u041b\u0435\u043d\u0438\u043d\u0433\u0440\u0430\u0434\u0441\u043a\u043e\u0435 \u0448., \u0434. \u041b\u0443\u043d\u0435\u0432\u043e, \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c","type":14},"item14":{"lat":"56.01722776092","lng":"37.328305854797","index":14,"href":"\/projects\/estate\/?id=10924","title":"\u043a\u043e\u0442\u0442\u0435\u0434\u0436\u043d\u044b\u0439 \u043f\u043e\u0441\u0435\u043b\u043e\u043a \u00ab\u0412\u043b\u0430\u0434\u044b\u0447\u0438\u043d\u043e\u00bb","type":10},"item15":{"lat":"60.162164330357","lng":"29.875130653381","index":15,"href":"\/projects\/estate\/?id=11322","title":"\u043a\u043e\u0442\u0442\u0435\u0434\u0436\u043d\u044b\u0439 \u043f\u043e\u0441\u0435\u043b\u043e\u043a \u0420\u0415\u041f\u0418\u041d\u041e \u0411\u0420\u0418\u0417","type":10},"item16":{"lat":"55.908653093503","lng":"37.198143615723","index":16,"href":"\/projects\/estate\/?id=10925","title":"\u043a\u043e\u0442\u0442\u0435\u0434\u0436\u043d\u044b\u0439 \u043f\u043e\u0441\u0435\u043b\u043e\u043a \u00ab\u041d\u0438\u043a\u043e\u043b\u043e-\u041f\u044f\u0442\u043d\u0438\u0446\u043a\u043e\u0435\u00bb","type":10},"item17":{"lat":"55.904996614597","lng":"37.228356018067","index":17,"href":"\/projects\/estate\/?id=73","title":"\u0420\u0415\u0410\u041b\u0418\u0417\u041e\u0412\u0410\u041d\u041d\u042b\u0419 \u041f\u0420\u041e\u0415\u041a\u0422 \u041a\u041e\u041c\u041f\u0410\u041d\u0418\u0418 - \u043a\u043e\u0442\u0442\u0435\u0434\u0436\u043d\u044b\u0439 \u043f\u043e\u0441\u0451\u043b\u043e\u043a \u00ab\u0411\u043b\u0430\u0433\u043e\u0432\u0435\u0449\u0435\u043d\u043a\u0430\u00bb","type":10}}}}; }; ArendaMap.prototype = { init:function(data) { var th = this; this.mapContainerSelector = "arenda-map"; this.setLocation(this.getCookie('location') || 'moscow'); this.initMarkers(); this.mapInit(); this.markersFilterByType(this.map, this.markers); if(!this.bind) { if(this.getCookie('location')) $('UL.city>LI').removeClass('active').parent().find('.' + this.getCookie('location')).addClass('active'); if(this.getCookie('mode')) $('UL.premises>LI').removeClass('active').parent().find('.' + this.getCookie('mode')).addClass('active'); $('UL.city>LI').bind('click', $.proxy(this.scope, "changeLocation")); $('UL.premises>LI').bind('click', $.proxy(this.scope, "changeMarkerMode")); $('.map-navigation>LI').bind('click', $.proxy(this.scope, "moveMap")); setTimeout(function(){ th.markersFilterByType(th.map, th.markers); $(window).trigger('resize'); }, 1); /* $('.rent li.location-item').bind('click', function(e){ if($(this).hasClass('active')) return false; $('li.location-item').toggleClass('active'); $('div.map').toggleClass('my_hide'); $('p.use-filter').toggleClass('my_hide'); $('div.premises').toggleClass('my_hide'); th.initMarkers(); th.mapInit(); th.markersFilterByType(th.map, th.markers); $(window).trigger('resize'); return false; }); */ this.bind = true; } this.areaMaxInput = $( "#area-max" ) this.areaMinInput = $( "#area-min" ) this.filterAreaSlider.slider({ range: true, animate: true, min: this.minArea, max: this.maxArea, values: [ this.currentMinArea, this.currentMaxArea ], slide: $.proxy(this.scope, "onSliderSlide"), stop: $.proxy(this.scope, "onSliderStop") }); this.areaMinInput.val( this.currentMinArea ).bind('keyup', $.proxy(this.scope, "changeSlider")); this.areaMaxInput.val( this.currentMaxArea ).bind('keyup', $.proxy(this.scope, "changeSlider")); var text = ''; for(city in this.data){ for(Item in this.data[city].items) { text = ''; var area_arr = [], type_arr = [], i = 0, j = 0; for(y in this.data[city].items[Item].blocks) { if(this.data[city].items[Item].blocks[y].area) area_arr[i] = this.data[city].items[Item].blocks[y].area; else area_arr[i] = false; if(this.data[city].items[Item].blocks[y].type) type_arr[i] = this.data[city].items[Item].blocks[y].type; else type_arr[i] = false; i++ } text += ''; text += '

' + this.data[city].items[Item].title + ''; if(this.data[city].items[Item].area) text += ' (' + this.data[city].items[Item].area + ' м²)'; text += '

'; if(this.data[city].items[Item].address) text += '

' + this.data[city].items[Item].address + '

'; text += '
'; text = $(text); if(city != 'moscow' || (this.data[city].items[Item].area > 1000 || this.data[city].items[Item].area < 50)) text.hide(); $('div.premises .scroll-pane .my_content').append(text); } } }, changeSlider: function(e, ui) { var d = $(e.currentTarget).parent(); if(/[^\d\.]/.test(d.find('input').eq(0).val()) || /[^\d\.]/.test(d.find('input').eq(1).val())) return true; var th = this, val_Min = Number(d.find('input').eq(0).val()) * 100 / this.maxArea, val_Max = Number(d.find('input').eq(1).val()) * 100 / this.maxArea; //if(!val_Min || !val_Max) // return true; val_Min = MinOrMax(val_Min); val_Max = MinOrMax(val_Max); if(val_Min > val_Max) { val_Max = val_Min - val_Max; val_Min -= val_Max; val_Max += val_Min; } this.filterAreaSlider.find('a').eq(0).stop(true).animate({'left': val_Min + '%'}, 'fast'); this.filterAreaSlider.find('a').eq(1).stop(true).animate({'left': val_Max + '%'}, 'fast'); this.onSliderStop(); function MinOrMax(p){ return p > 100 ? 100 : (p < 0 ? 0 : p); } }, onSliderSlide:function(e, ui) { this.updateSliderToInput(e, ui); }, onSliderStop:function(e, ui) { this.setCookie('areaMin', this.currentMinArea = this.areaMinInput.val()); this.setCookie('areaMax', this.currentMaxArea = this.areaMaxInput.val()); var th = this; setTimeout(function(){ th.filterAreaSlider.slider("option", { values: [ th.currentMinArea, th.currentMaxArea ], }); }, 300); this.markersFilterByType(this.map, this.markers); }, updateSliderToInput:function(e, ui) { this.areaMinInput.val( ui.values[ 0 ] ); this.areaMaxInput.val( ui.values[ 1 ]); this.currentMinArea = this.areaMinInput.val(); this.currentMaxArea = this.areaMaxInput.val(); }, updateSliderFormInput:function(e, ui) { }, moveMap:function(e) { var direction = $(e.currentTarget); if(direction.hasClass('top')) this.map.panBy(0, this.MOVE_DIRECTION); if(direction.hasClass('left')) this.map.panBy(this.MOVE_DIRECTION, 0); if(direction.hasClass('right')) this.map.panBy(-this.MOVE_DIRECTION, 0); if(direction.hasClass('bottom')) this.map.panBy(0, -this.MOVE_DIRECTION); this.checkBounds(); return false; }, changeMarkerMode:function(e) { if($(e.currentTarget).hasClass('active')) return false; this.markerMode = $(e.currentTarget).attr('class'); this.markersFilterByType(this.map, this.markers); this.setCookie('mode', $(e.currentTarget).attr('class')); $(e.currentTarget).parent().find('li').removeClass('active'); $(e.currentTarget).addClass('active'); return false; }, changeLocation:function(e) { if($(e.currentTarget).hasClass('active')) return false; this.setLocation($(e.currentTarget).attr('class')); this.initMarkers(); this.setCookie('location', $(e.currentTarget).attr('class')); this.mapInit(); this.markersFilterByType(this.map, this.markers); $(e.currentTarget).parent().find('li').removeClass('active'); $(e.currentTarget).addClass('active'); return false; }, setLocation:function(city) { this.currentLocation = city; }, getLocation:function(city) { return this.currentLocation; }, initMarkers:function(){ this.markers = this.data[this.getLocation()].items; //console.log(this.markers); }, mapInit:function() { this.mapOptions = { zoom: this.data[this.getLocation()].zoom, minZoom: window.minZoom || 1, maxZoom: window.maxZoom || 18, disableDefaultUI: true, zoomControl: true, panControl: true, mapTypeControl: true, center: new google.maps.LatLng( this.data[this.getLocation()].lat, this.data[this.getLocation()].lng ), //disableDoubleClickZoom: true, mapTypeId: google.maps.MapTypeId.ROADMAP } this.map = new google.maps.Map(document.getElementById(this.mapContainerSelector), this.mapOptions); //this.map.scrollwheel = false; var mapBoundsSouthWest = new google.maps.LatLng( Number(this.data[this.getLocation()].mapBoundsSouth), Number(this.data[this.getLocation()].mapBoundsWest) ) var mapBoundsNorthEast = new google.maps.LatLng( Number(this.data[this.getLocation()].mapBoundsNorth), Number(this.data[this.getLocation()].mapBoundsEast) ) var mapBounds = new google.maps.LatLngBounds(mapBoundsSouthWest, mapBoundsNorthEast); var overlay = new google.maps.GroundOverlay("../i/map/"+this.data[this.getLocation()].city+".png", mapBounds); overlay.setMap(this.map); var map = this.map; function gmnoprint_c(v, t, m) { var gmnoprint = $('.gmnoprint'); if(gmnoprint.size() && gmnoprint.size() && !t && !m) return setTimeout(function(){gmnoprint_c(gmnoprint.size(), true)}, 200); if(gmnoprint.size() && gmnoprint.size() && t && !m) return setTimeout(function(){gmnoprint_c(gmnoprint.size(), true, true)}, 200); if(gmnoprint.size() && gmnoprint.size() == v & t & m) { gmnoprint.eq(-1).animate({'margin-top': '20px', 'margin-right': '24px'}, 'fast'); /* gmnoprint.eq(-2).prev().prev().css({'top':0}).hide().fadeOut(10, function(){ map.panBy(-1, 0); map.panBy(1, 0); });*/ } else setTimeout(function(){gmnoprint_c(gmnoprint.size())}, 200); }; gmnoprint_c(0); google.maps.event.addListener(this.map, "drag", $.proxy(this.scope, "checkBounds")); }, checkBounds:function (e) { var southWest = new google.maps.LatLng(Number(this.data[this.getLocation()].mapBoundsSouth_),Number(this.data[this.getLocation()].mapBoundsWest_)); var northEast = new google.maps.LatLng(Number(this.data[this.getLocation()].mapBoundsNorth_),Number(this.data[this.getLocation()].mapBoundsEast_)); var allowedBounds = new google.maps.LatLngBounds(southWest, northEast); if (allowedBounds.contains(this.map.getCenter())) { return; } var C = this.map.getCenter(); var X = C.lng(); var Y = C.lat(); var AmaxX = allowedBounds.getNorthEast().lng(); var AmaxY = allowedBounds.getNorthEast().lat(); var AminX = allowedBounds.getSouthWest().lng(); var AminY = allowedBounds.getSouthWest().lat(); var AmaxX_ = this.data[this.getLocation()].mapBoundsEast_; var AmaxY_ = this.data[this.getLocation()].mapBoundsNorth_; var AminX_ = this.data[this.getLocation()].mapBoundsWest_; var AminY_ = this.data[this.getLocation()].mapBoundsSouth_; if (X < AminX) {X = AminX_;} if (X > AmaxX) {X = AmaxX_;} if (Y < AminY) {Y = AminY_;} if (Y > AmaxY) {Y = AmaxY_;} this.map.setCenter(new google.maps.LatLng(Y,X)); }, checkAreas: function(location){ //console.log(location); var icon = ''; if(!window.filter) { if (location.type == 14) // земельные участки icon = window.src_marker_14; else if (location.type == 10) icon = window.src_marker_10; } else { var icon = window.src_marker_deactive; } if(location.blocks && location.blocks.length) for(i in location.blocks) { if(location.blocks[i].type == this.markerMode || this.markerMode == 'all') { if(!(Number(location.blocks[i].area) > this.currentMaxArea && this.currentMaxArea < this.maxArea || Number(location.blocks[i].area) < this.currentMinArea)) { icon = window.src_marker; break; } } } /* else { if(location == this.markerMode || this.markerMode == 'all') if(!(Number(location.area) > this.currentMaxArea && this.currentMaxArea < this.maxArea || Number(location.area) < this.currentMinArea)) icon = window.src_marker; } */ return icon; }, markersFilterByType:function(map, locations) { var image = new google.maps.MarkerImage(window.src_marker, new google.maps.Size(17, 16), new google.maps.Point(0,0), new google.maps.Point(0, 32)); var image_deactive = new google.maps.MarkerImage(window.src_marker, new google.maps.Size(17, 16), new google.maps.Point(0,0), new google.maps.Point(0, 32)); if (this.markersArray) { for (var i in this.markersArray) { this.markersArray[i].setMap(null); } this.markersArray.length = 0; } $(window).trigger('resize'); for(var i in locations) { var latlng = new google.maps.LatLng(locations[i].lat, locations[i].lng), icon = this.checkAreas(locations[i]); if(!icon) continue; var marker = new google.maps.Marker({ position: latlng, map: map, icon: new google.maps.MarkerImage( icon, new google.maps.Size(17, 16), new google.maps.Point(0,0), new google.maps.Point(17, 16) ), title: locations[i].title, href: locations[i].href, area: locations[i].area, photo: locations[i].photo, type: locations[i].type, zIndex: 1000, optimized: false }); //console.log(marker); this.markersArray.push(marker); google.maps.event.addListener(marker, 'click', function(e){ th.buildTooltip(th.scope, this, e); }); } var selector = 'span.my_content span.my_block.' + this.currentLocation; $('span.my_content span.my_block').hide(); // if(this.markerMode != this.markerDefaultMode) // selector += '.' + this.markerMode; var th = this; $(selector).show().each(function(){ var area = $(this).attr('area'), type = $(this).attr('type'), areas = explode(',', $(this).attr('areas')), types = explode(',', $(this).attr('types')), ok = false; for(a in areas) { if(types[a] == th.markerMode || th.markerMode == 'all') { if(areas[a] && !(Number(areas[a]) > th.currentMaxArea && th.currentMaxArea < th.maxArea || Number(areas[a]) < th.currentMinArea)) { ok =true; break; } } } if(!ok) $(this).hide(); }); }, buildTooltip: function(th, marker, e) { var map_block = $('#arenda-map div:first div:first div:first'), corn = map_block.find('#bar_corn'), bar = $('.bar_map'); if(bar.data('latLng') == e.latLng) return false; var img = bar.find('.picture .bar_img'), title = bar.find('.bar_title'), area = bar.find('.bar_area'), a = bar.find('a'); var image = new google.maps.MarkerImage( window.src_marker_active, new google.maps.Size(17, 16), new google.maps.Point(0,0), new google.maps.Point(17, 16) ); //marker.setIcon(image); marker.setZIndex(9999); $('html').bind('mousedown', function(e){ var re = new RegExp (src_marker_deactive + '$') if(e.target.nodeName == 'IMG' && !re.test(e.target.src) || e.target.src == window.src_marker || !(!(e.target.className != 'bar_img' && e.target.className == 'gmnoprint') && e.target.className != 'gmnoprint' && !/(area|bar_title|bar_area|bar_)/.test(e.target.className))) return true; /* var image = new google.maps.MarkerImage( window.src_marker, new google.maps.Size(17, 16), new google.maps.Point(0,0), new google.maps.Point(17, 16) );*/ // marker.setIcon(image); marker.setZIndex(1000); }); if(!corn.size()) { map_block.prepend(corn = bar.find('#bar_corn').clone().end().remove()); corn.css({ 'top': '0', 'left': '0', 'width': '90px', 'height': '90px', 'z-index': '2' }).hide(0); bar.removeClass('hidden') .hide() .clone() .css({ 'position': 'absolute', 'z-index': 102 }) $('body').bind('mousedown', function(e){ //th.map.getDiv() if(e.target.nodeName != 'IMG' && e.target.className != 'bar_img' && e.target.className != 'gmnoprint' && !/(area|bar_title|bar_area|bar_)/.test(e.target.className)) { corn.hide(); bar.data('latLng', 'false').fadeOut('fast'); } }); $(window).resize(function(){corn.fadeOut(100);bar.data('latLng', 'false').fadeOut('fast');}); /* $('.map-navigation>LI').bind('click', function(){ corn.hide(); bar.data('latLng', 'false').fadeOut('fast') }); */ }; corn.fadeOut(100); if(!bar.data('latLng') || bar.data('latLng') == 'false') bar.fadeIn('fast'); if(bar.data('latLng') != 'false' && bar.data('latLng') != undefined) { if(!bar.data('area')) bar.data('area', area.css('color')); if(!bar.data('title')) bar.data('title', title.css('color')); area.fadeOut(0, function() { if(marker.href) a.attr('href', marker.href); if(marker.title) title.html(marker.title.replace('&', '&')); else title.html(marker.title.replace('&', '&')); if(marker.area) area.html(marker.area); else area.html(''); if(marker.photo) img.attr('src', marker.photo).show(); else img.hide(); }); title.fadeOut(0); } else { if(marker.href) a.attr('href', marker.href); bar if(marker.title) title.html(marker.title); else title.html(marker.title); if(marker.area) area.html(marker.area); else area.html(''); if(marker.photo) img.attr('src', marker.photo).show(); else img.hide(); } if(bar.data('latLng') != 'false' && bar.data('latLng')) { area.fadeIn(0); title.fadeIn(0); } bar.data('latLng', e.latLng); var Height_ = 0; if(Height_ = $('div.map.rent.my_project').height()){ Height_ = ($('#wrapper').height() - 750)/2; Height_CSS = (($('div.map.rent.my_project').height() - 415)/4) - Height_/2; } else { Height_ = ($('#wrapper').height() - 750)/2 + 80; Height_CSS = 0; } corn.css({ 'top': (e.pixel.y + window.corn_y) + Height_CSS + 'px', 'left': (e.pixel.x - window.corn_x) + 'px' }); $('.map').find('span.icon').height($('.map').find('span.city').height()); th.map.setCenter(e.latLng, th.map.getZoom()); th.map.panBy(($('#arenda-map').width() / 2) - window.corn_x_, - window.corn_y_ - Height_ + ($('html').css('margin-top').replace('px', '')*1) + bar.height()); setTimeout(function(){ corn.fadeIn('fast'); }, 400); return false; }, // возвращает cookie если есть или undefined getCookie: function (name) { var matches = document.cookie.match(new RegExp( "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" )) return matches ? decodeURIComponent(matches[1]) : undefined }, // уcтанавливает cookie setCookie: function (name, value, props) { props = props || {} var exp = props.expires if (typeof exp == "number" && exp) { var d = new Date() d.setTime(false) exp = props.expires = d } if(exp && exp.toUTCString) { props.expires = exp.toUTCString() } value = encodeURIComponent(value) var updatedCookie = name + "=" + value for(var propName in props){ updatedCookie += "; " + propName var propValue = props[propName] if(propValue !== true){ updatedCookie += "=" + propValue } } document.cookie = updatedCookie }, // удаляет cookie deleteCookie: function (name) { setCookie(name, null, { expires: -1 }) } } })(); $(function(){ var _aM = new ArendaMap(); _aM.init(); })