Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var hrefBase = '/bg/obiavi';
- var foreignSearchKeyword = 'foreign';
- var property_type_all = '';
- var property_type_buildings_only = '';
- property_type_all = property_type_all + '<option value="5" data-disable-floor-ctl="" data-disable-floor-ctl="">Едностаен апартамент</option>';
- property_type_all = property_type_all + '<option value="6" data-disable-floor-ctl="" data-disable-floor-ctl="">Двустаен апартамент</option>';
- property_type_all = property_type_all + '<option value="9" data-disable-floor-ctl="" data-disable-floor-ctl="">Тристаен апартамент</option>';
- property_type_all = property_type_all + '<option value="27" data-disable-floor-ctl="" data-disable-floor-ctl="">Четиристаен апартамент</option>';
- property_type_all = property_type_all + '<option value="10" data-disable-floor-ctl="" data-disable-floor-ctl="">Многостаен апартамент</option>';
- property_type_all = property_type_all + '<option value="8" data-disable-floor-ctl="" data-disable-floor-ctl="">Мезонет</option>';
- property_type_all = property_type_all + '<option value="13" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Ателие,Таван, Студио</option>';
- property_type_all = property_type_all + '<option value="11" data-disable-floor-ctl="" data-disable-floor-ctl="">Офис</option>';
- property_type_all = property_type_all + '<option value="12" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Стая</option>';
- property_type_all = property_type_all + '<option value="20" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Гараж, паркомясто</option>';
- property_type_all = property_type_all + '<option value="30" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Сутерен, Мазе, Партер</option>';
- property_type_all = property_type_all + '<option value="26" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Сграда</option>';
- property_type_buildings_only = property_type_buildings_only + '<option value="26" data-disable-floor-ctl="1" data-disable-floor-ctl="1" selected>Сграда</option>';
- property_type_all = property_type_all + '<option value="14" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Къща</option>';
- property_type_all = property_type_all + '<option value="15" data-disable-floor-ctl="" data-disable-floor-ctl="">Етаж от къща</option>';
- property_type_all = property_type_all + '<option value="25" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Вила</option>';
- property_type_all = property_type_all + '<option value="16" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Парцел</option>';
- property_type_all = property_type_all + '<option value="33" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Зала</option>';
- property_type_all = property_type_all + '<option value="17" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Магазин</option>';
- property_type_all = property_type_all + '<option value="32" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Търговски обект</option>';
- property_type_all = property_type_all + '<option value="18" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Заведение</option>';
- property_type_all = property_type_all + '<option value="23" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Промишлен имот</option>';
- property_type_all = property_type_all + '<option value="29" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Бензиностанция</option>';
- property_type_all = property_type_all + '<option value="21" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Хотел</option>';
- property_type_all = property_type_all + '<option value="19" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Склад</option>';
- property_type_all = property_type_all + '<option value="22" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Фабрика</option>';
- property_type_all = property_type_all + '<option value="24" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Земеделски имот</option>';
- property_type_all = property_type_all + '<option value="28" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Гора</option>';
- property_type_all = property_type_all + '<option value="31" data-disable-floor-ctl="1" data-disable-floor-ctl="1">Язовир</option>';
- var months_to_target_date = parseInt();
- if (!months_to_target_date > 0) {
- months_to_target_date = 36
- }
- $(document).ready(function() {
- $(document).on('click', '.mini-tabs a', function() {
- $('a.active', $(this).parent()).removeClass('active');
- $(this).addClass('active');
- if ($(this).data('show-buildings-only')) {
- $('#property_type_id').html(property_type_buildings_only);
- $('#property_type_id').cSelectbox('instance').refresh();
- $('#new_buildings').val(1);
- $('#building-type-ctl-wrapper').show();
- $('#building_type_id').cSelectbox('instance').refresh()
- } else if ($('#property_type_id option').length == 1) {
- $('#property_type_id').html(property_type_all);
- $('#property_type_id').cSelectbox('instance').refresh();
- $('#new_buildings').val(0);
- $('#building-type-ctl-wrapper').hide();
- $('#building_type_id option[selected]').prop('selected', !1);
- $('#building_type_id').val('');
- $('#building_type_id').cSelectbox('instance').refresh()
- }
- if ($(this).data('show-target-date')) {
- $('.search-tools-box.features-filtered-box').hide();
- $('#months_to_target_date').cSelectbox('instance').setSelected(months_to_target_date);
- $('#months_to_target_date').cSelectbox('instance').update();
- $('#target-date-ctl-wrapper').show();
- $('#months_to_target_date').cSelectbox('instance').gotoHighlighted()
- } else {
- $('#target-date-ctl-wrapper').hide();
- $('.search-tools-box.features-filtered-box').show();
- $('#months_to_target_date').val('');
- $('#months_to_target_date option[selected]').prop('selected', !1);
- $('#months_to_target_date').cSelectbox('instance').refresh()
- }
- });
- var cityId = 0 + -1;
- var countryId = 0 + 66;
- var waId = cityId;
- if (waId == -1) {
- waId = countryId
- }
- var url = xhr_url + '?' + $.param({
- method: 'get_map_regions_by_wa_id',
- waid: waId
- });
- $.get(url).done(function(json) {
- clearPolygons();
- renderPolygons(json.polygons, json.mapCenter, parseInt(json.zoomLevel))
- });
- $('#world_area_id').cSelectbox("instance").gotoHighlighted()
- });
- var selectedSubTabName = 'all';
- if (selectedSubTabName != 'all') {
- var selectedSubTabObj = $('a[data-tabname="' + selectedSubTabName + '"]');
- setTimeout(function() {
- selectedSubTabObj.trigger("click")
- }, 100)
- }
- var gmaps_api_key = 'AIzaSyCrrSjAo5YvR40sAG8QKXhBtW5p1sA84Ws';
- $('.js-load-map').one('click', function(e) {
- e.preventDefault();
- var mapsScript = document.createElement("script");
- mapsScript.type = "text/javascript";
- mapsScript.src = "https://maps.googleapis.com/maps/api/js?key=" + gmaps_api_key + "&v=3&callback";
- document.head.appendChild(mapsScript);
- mapsScript.onload = function() {
- initMap();
- $('.js-map-overlay').hide();
- var country_id = $("#country_id").find(':selected').val();
- var city_id = $("#world_area_id").find(':selected').val();
- if (city_id) {
- var waId = city_id
- } else {
- var waId = country_id
- }
- var url = xhr_url + '?' + $.param({
- method: 'get_map_regions_by_wa_id',
- waid: waId
- });
- $.get(url).done(function(json) {
- clearPolygons();
- renderPolygons(json.polygons, json.mapCenter, parseInt(json.zoomLevel));
- $('[data-waid]').trigger('change', {
- trigger: !0
- })
- })
- }
- });
- var defaultMapCenter = {
- lat: 42.730097,
- lng: 23.2632953
- };
- var defaultZoomLevel = 13;
- var map = null;
- var polyCount = 0;
- var userDefinedPolygons = {};
- var polyDelete = !1;
- var mapPolygons = {};
- var COLORDEF = {
- "active": {
- "fill": '#b81b6f',
- "stroke": '#b81b6f',
- "strokeOpacity": 1,
- "fillOpacity": 0.5
- },
- "inactive": {
- "fill": '#b81b6f',
- "stroke": '#b81b6f',
- "strokeOpacity": 0.5,
- "fillOpacity": 0.1
- },
- "drawing": {
- "fill": '#b81b6f',
- "stroke": '#b81b6f',
- "strokeOpacity": 1,
- "fillOpacity": 0.5
- },
- "hover": {
- "fill": '#b81b6f',
- "stroke": '#b81b6f',
- "strokeOpacity": 1,
- "fillOpacity": 0.4
- },
- };
- function clearPolygons() {
- for (var i in mapPolygons) {
- if (mapPolygons.hasOwnProperty(i)) {
- mapPolygons[i].setMap(null);
- delete mapPolygons[i]
- }
- }
- mapPolygons = {}
- }
- function renderPolygons($polygons, $center, $zoomLevel) {
- if (undefined === $center) {
- $center = defaultMapCenter
- }
- if (undefined === $zoomLevel) {
- $zoomLevel = defaultZoomLevel
- }
- if (!map) return !0;
- map.setCenter($center);
- map.setZoom($zoomLevel);
- mapPolygons = {};
- for (var j in $polygons) {
- var polygonsArray = new google.maps.MVCArray();
- var bounds = new google.maps.LatLngBounds();
- if ($polygons.hasOwnProperty(j)) {
- var waId = parseInt($polygons[j].waid);
- var geometry = $.parseJSON($polygons[j].geometry);
- var waTitle = $polygons[j].title;
- for (var i in geometry) {
- if (geometry.hasOwnProperty(i)) {
- var point = new google.maps.LatLng(geometry[i].y, geometry[i].x);
- polygonsArray.push(point);
- bounds.extend(point)
- }
- }
- mapPolygons[j] = new google.maps.Polygon({
- map: map,
- path: polygonsArray,
- strokeColor: COLORDEF.inactive.stroke,
- strokeOpacity: COLORDEF.inactive.strokeOpacity,
- strokeWeight: 2,
- fillColor: COLORDEF.inactive.fill,
- fillOpacity: COLORDEF.inactive.fillOpacity,
- index: waId,
- selected: !1,
- waTitle: waTitle,
- polygonCenter: bounds.getCenter()
- });
- google.maps.event.addDomListener(mapPolygons[j], 'click', function(e) {
- this.selected = !this.selected;
- if (!this.selected) {
- this.setOptions({
- fillOpacity: COLORDEF.inactive.fillOpacity
- })
- } else {
- this.setOptions({
- fillOpacity: COLORDEF.active.fillOpacity
- })
- }
- var wa_id = $('input[data-waid="' + this.index + '"]');
- if (wa_id.length > 0) {
- wa_id.prop('checked', this.selected).trigger('change');
- $('#second_descendant_id').cSelectbox("instance").gotoHighlighted()
- }
- });
- var polygonLabel = waTitle;
- mapPolygons[j].infoBox = new InfoBox({
- content: '<div class="polybox_cont" data-id="' + mapPolygons[j].index + '" data-index="' + j + '">' + polygonLabel + '</div>',
- boxStyle: {
- textAlign: "center",
- fontSize: "14px",
- color: "#FFFFFF",
- background: COLORDEF.active.fill,
- padding: "5px"
- },
- pixelOffset: new google.maps.Size(((polygonLabel.length / 2) * -10), -10),
- position: mapPolygons[j].polygonCenter,
- closeBoxURL: "",
- isHidden: !1,
- pane: "floatPane",
- polygon_id: mapPolygons[j].index
- });
- mapPolygons[j].infoBox.addListener("domready", function() {
- $('.polybox_cont').on('click', function() {
- var boxParent = mapPolygons[$(this).data('index')];
- google.maps.event.trigger(boxParent, 'click', boxParent.polygonCenter)
- })
- });
- google.maps.event.addListener(mapPolygons[j], "mouseover", function(event) {
- if (this.fillOpacity != COLORDEF.active.fillOpacity) {
- this.setOptions({
- fillOpacity: COLORDEF.hover.fillOpacity
- })
- }
- this.infoBox.open(map)
- });
- google.maps.event.addListener(mapPolygons[j], "mouseout", function(event) {
- if (this.fillOpacity == COLORDEF.hover.fillOpacity) {
- this.setOptions({
- fillOpacity: COLORDEF.inactive.fillOpacity
- })
- }
- this.infoBox.close()
- })
- }
- }
- }
- function initMap() {
- if (map != null) {
- return
- } else {
- $.getScript(_public + 'js/google-infobox.js');
- map = new google.maps.Map(document.getElementById('map'), {
- center: defaultMapCenter,
- zoom: defaultZoomLevel,
- scrollwheel: !1,
- mapTypeControl: !1,
- streetViewControl: !1,
- clickableIcons: !1
- });
- var isIE11 = !!(navigator.userAgent.match(/Trident/) && navigator.userAgent.match(/rv[:]11/));
- var mapPin = '{$_public}images/contact-pin.svg';
- if ($('html').hasClass('no-svg') || isIE11 == !0) {
- mapPin = '{$_public}images/contact-pin.png'
- }
- var thisPlace = defaultMapCenter;
- var thisEstatePin = new google.maps.Marker({
- position: thisPlace,
- map: map,
- icon: mapPin
- });
- panorama = map.getStreetView();
- panorama.setPosition(thisPlace);
- panorama.setPov(({
- heading: 265,
- pitch: 0
- }));
- panorama.setVisible(!1)
- }
- $(".icon-draw").on('click', function() {
- disablePolyDelete();
- $('.map-btn').removeClass('active');
- $(this).addClass('active');
- disable();
- for (var i in userDefinedPolygons) {
- if (userDefinedPolygons.hasOwnProperty(i)) {
- userDefinedPolygons[i].setMap(map)
- }
- }
- for (var i in mapPolygons) {
- if (mapPolygons.hasOwnProperty(i)) {
- mapPolygons[i].setMap(null)
- }
- }
- google.maps.event.addDomListener(map.getDiv(), 'mousedown', function(e) {
- drawFreeHand()
- })
- });
- $(".icon-draw-clear").on('click', function(e) {
- enablePolyDelete();
- google.maps.event.clearListeners(map.getDiv(), 'mousedown');
- $('.map-btn').removeClass('active');
- $(this).addClass('active');
- disable();
- for (var i in userDefinedPolygons) {
- if (userDefinedPolygons.hasOwnProperty(i)) {
- userDefinedPolygons[i].setMap(map)
- }
- }
- for (var i in mapPolygons) {
- if (mapPolygons.hasOwnProperty(i)) {
- mapPolygons[i].setMap(null)
- }
- }
- });
- $('.icon-sector').on('click', function() {
- $('.map-btn').removeClass('active');
- $(this).addClass('active');
- google.maps.event.clearListeners(map.getDiv(), 'mousedown');
- enable();
- disablePolyDelete();
- for (var i in userDefinedPolygons) {
- if (userDefinedPolygons.hasOwnProperty(i)) {
- userDefinedPolygons[i].setMap(null)
- }
- }
- for (var i in mapPolygons) {
- if (mapPolygons.hasOwnProperty(i)) {
- mapPolygons[i].setMap(map)
- }
- }
- })
- }
- function disablePolyDelete() {
- polyDelete = !1;
- for (var i in userDefinedPolygons) {
- if (userDefinedPolygons.hasOwnProperty(i)) {
- google.maps.event.clearListeners(userDefinedPolygons[i], "mouseover");
- google.maps.event.clearListeners(userDefinedPolygons[i], "mouseout");
- google.maps.event.clearListeners(userDefinedPolygons[i], "click")
- }
- }
- }
- function enablePolyDelete() {
- polyDelete = !1;
- for (var i in userDefinedPolygons) {
- if (userDefinedPolygons.hasOwnProperty(i)) {
- google.maps.event.addListener(userDefinedPolygons[i], "mouseover", function() {
- this.setOptions({
- fillOpacity: "0.2"
- })
- });
- google.maps.event.addListener(userDefinedPolygons[i], "mouseout", function() {
- this.setOptions({
- fillOpacity: "0.5"
- })
- });
- google.maps.event.addListener(userDefinedPolygons[i], "click", function() {
- this.setMap(null);
- delete userDefinedPolygons[this.index]
- })
- }
- }
- }
- function serializePolys() {
- var serialized = '';
- var data = {};
- var poly = {};
- var key = 0;
- var first_key = null;
- for (var i in userDefinedPolygons) {
- if (userDefinedPolygons.hasOwnProperty(i)) {
- if (userDefinedPolygons[i].getMap() == map) {
- poly[key] = {};
- var path = userDefinedPolygons[i].getPath().getArray();
- for (var p in path) {
- if (path.hasOwnProperty(p)) {
- if (typeof path[p] == 'undefined') {
- continue
- }
- if (first_key === null) first_key = p;
- var point = {
- lat: path[p].lat(),
- lng: path[p].lng()
- };
- if (typeof data[key] == 'undefined') {
- data[key] = {}
- }
- data[key][p] = point
- }
- }
- if (typeof path[first_key] != 'undefined') {
- data[key][p + 1] = {
- lat: path[first_key].lat(),
- lng: path[first_key].lng()
- }
- }
- }
- }
- key++
- }
- }
- function drawFreeHand() {
- poly = new google.maps.Polyline({
- map: map,
- clickable: !1,
- strokeColor: COLORDEF.drawing.stroke,
- strokeOpacity: COLORDEF.drawing.strokeOpacity,
- strokeWeight: 2,
- fillColor: COLORDEF.drawing.fill,
- fillOpacity: COLORDEF.drawing.fillOpacity
- });
- var move = google.maps.event.addListener(map, 'mousemove', function(e) {
- poly.getPath().push(e.latLng)
- });
- google.maps.event.addListenerOnce(map, 'mouseup', function(e) {
- google.maps.event.removeListener(move);
- var path = poly.getPath();
- poly.setMap(null);
- poly = new google.maps.Polygon({
- path: path
- });
- var ArrayforPolygontoUse = GDouglasPeucker(poly.getPath().getArray(), 5);
- poly = new google.maps.Polygon({
- path: ArrayforPolygontoUse,
- map: map,
- geodesic: !0,
- strokeColor: COLORDEF.active.stroke,
- strokeOpacity: 1,
- strokeWeight: 2,
- fillColor: COLORDEF.active.fill,
- fillOpacity: COLORDEF.active.fillOpacity,
- index: "poly_" + polyCount
- });
- userDefinedPolygons["poly_" + polyCount] = poly;
- polyCount++
- })
- }
- function disable() {
- map.setOptions({
- draggable: !1,
- zoomControl: !1,
- scrollwheel: !1,
- disableDoubleClickZoom: !1
- })
- }
- function enable() {
- map.setOptions({
- draggable: !0,
- zoomControl: !0,
- scrollwheel: !0,
- disableDoubleClickZoom: !0
- })
- }
- function array_unique(arr) {
- var out = [];
- arr = arr.sort();
- for (var i in arr) {
- if (arr[i - 1] != arr[i]) {
- out.push(arr[i])
- }
- }
- return out
- }
- $('[data-quarterid]').on('change', function(e, params) {
- if (e.originalEvent || typeof params.trigger !== 'undefined') {
- var i = $(this).data('quarterid');
- if (predefinedPoly.hasOwnProperty(i)) {
- if ($(this).is(':checked')) {
- predefinedPoly[i].setOptions({
- fillOpacity: COLORDEF.active.fillOpacity,
- selected: !0
- })
- } else {
- predefinedPoly[i].setOptions({
- fillOpacity: COLORDEF.inactive.fillOpacity,
- selected: !1
- })
- }
- }
- }
- });
- $(document).on('change', 'input[data-regions]', function() {
- var selectedArray = [];
- var checked = $('input[data-regions]:checked');
- if (checked.length > 0) {
- checked.each(function() {
- var selected = $(this).data('regions');
- $.merge(selectedArray, selected)
- });
- selectedArray = array_unique(selectedArray)
- }
- for (var i in mapPolygons) {
- if (mapPolygons.hasOwnProperty(i)) {
- mapPolygons[i].setOptions({
- fillOpacity: COLORDEF.inactive.fillOpacity,
- selected: !1
- })
- }
- }
- for (var i in selectedArray) {
- if (mapPolygons.hasOwnProperty(selectedArray[i])) {
- mapPolygons[selectedArray[i]].setOptions({
- fillOpacity: COLORDEF.active.fillOpacity,
- selected: !0
- })
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement