PageSourceSearch

https://boatcharter.fo/wp-content/themes/wprentals/js/google_js/mapfunctions.js?ver=1.0

js boatcharter.fo collected 2026-10-08 21:28:01 UTC 62,400 bytes, 2,033 lines download raw bytes

1/*global google, $, Modernizr, InfoBox, window, alert, setTimeout, mapbase_vars,wpestate_pan_to_last_pin, alert, wprentals_showMyPosition, errorCallback, wpestate_new_show_advanced_search, MarkerClusterer, navigator, wpestate_new_hide_advanced_search, adv_search_click, wpestate_createMarker, infoBox, map, gmarkers, bounds_list, wpestate_new_open_close_map, custompin,googlecode_property_vars, document, wpestate_placeSavedMarker, wpestate_placeMarker, removeMarkers, googlecode_home_vars, google_map_submit_vars, jQuery, control_vars, setOms, wprentals_google_map_cluster, oms, OverlappingMarkerSpiderfier, wprentals_google_setMarkers, googlecode_regular_vars2, wprentals_google_setMarkers_contact, mapfunctions_vars, wpestate_close_adv_search, show_advanced_search*/
2var page_tracker=   0;
3var pin_images  =   mapfunctions_vars.pin_images;
4var images      =   jQuery.parseJSON(pin_images);
5var ipad_time   =   0;
6var infobox_id  =   0;
7var shape = {
8    coord: [1, 1, 1, 38, 38, 59, 59, 1],
9    type: 'poly'
10};
11
12var mcOptions;
13var markers_cluster;
14var clusterStyles;
15var infoBox;
16var infobox_width;
17var poi_marker_array=[];
18var poi_type='';
19var placeCircle='';
20var circleLayer='';
21var initial_geolocation_circle_flag=0;
22var bounds_list;
23var curent_gview_lat = jQuery('#gmap_wrapper').attr('data-cur_lat');
24var curent_gview_long = jQuery('#gmap_wrapper').attr('data-cur_long');
25
26   
27jQuery(document).ready(function ($) {
28    "use strict";
29    wpestate_map_set_zoom_plus();
30    wpestate_map_set_zoom_minus();
31    wpestate_map_gmap_street();
32    wpestate_map_geolocation_button();
33    wpestate_navigate_pins();
34
35});
36
37
38
39function wpestate_show_pins_filters_from_file() {
40    "use strict";
41
42    if(jQuery("#a_filter_action").length == 0) {
43        var action      =   jQuery('#second_filter_action').attr('data-value');
44        var category    =   jQuery('#second_filter_categ').attr('data-value');
45        var city        =   jQuery('#second_filter_cities').attr('data-value');
46        var area        =   jQuery('#second_filter_areas').attr('data-value');
47        var county      =   jQuery('#second_filter_county').attr('data-value');
48
49    }else{
50        var action      =   jQuery('#a_filter_action').attr('data-value');
51        var category    =   jQuery('#a_filter_categ').attr('data-value');
52        var city        =   jQuery('#a_filter_cities').attr('data-value');
53        var area        =   jQuery('#a_filter_areas').attr('data-value');
54        var county      =   jQuery('#a_filter_county').attr('data-value');
55    }
56
57
58    if( typeof(action)!=='undefined'){
59        action      = action.toLowerCase().trim().replace(" ", "-");
60    }
61
62    if( typeof(action)!=='undefined'){
63        category    = category.toLowerCase().trim().replace(" ", "-");
64    }
65
66    if( typeof(action)!=='undefined'){
67        city        = city.toLowerCase().trim().replace(" ", "-");
68    }
69
70    if( typeof(action)!=='undefined'){
71        area        = area.toLowerCase().trim().replace(" ", "-");
72    }
73
74    if(  typeof infoBox!=='undefined' && infoBox!== null ){
75        infoBox.close();
76    }
77
78
79    var bounds = new google.maps.LatLngBounds();
80
81    if(!isNaN(markers_cluster) ){
82        markers_cluster.setIgnoreHidden(true);
83    }
84
85    if(  typeof gmarkers!=='undefined'){
86
87        for (var i=0; i<gmarkers.length; i++) {
88
89                if( !wpestate_classic_form_tax_visible (gmarkers[i].action, action) && action!='all' && action!='all' && action!='all-sizes' ){
90                    gmarkers[i].setVisible(false);
91
92                }else if (!wpestate_classic_form_tax_visible (gmarkers[i].category, category) && category!='all' && category!='all-types') {
93                    gmarkers[i].setVisible(false);
94
95                }else if( !wpestate_classic_form_tax_visible (gmarkers[i].area, area) && area!='all'  && area!='all-areas'){
96                    gmarkers[i].setVisible(false);
97
98                }else if( !wpestate_classic_form_tax_visible (gmarkers[i].city, city)  && city!='all' && city!='all-cities' ){
99                    gmarkers[i].setVisible(false);
100
101                }else{
102                    gmarkers[i].setVisible(true);
103                    bounds.extend( gmarkers[i].getPosition() );
104                }
105        }//end for
106        if(!isNaN(markers_cluster) ){
107            markers_cluster.repaint();
108        }
109    }//end if
110
111        if( !bounds.isEmpty() ){
112            wpestate_fit_bounds(bounds);
113        }
114
115}
116
117
118function wpestate_fit_bounds_nolsit_leaflet(){
119    map.setZoom(3);
120    is_fit_bounds_zoom=0;
121}
122
123
124
125function wpestate_fit_bounds_nolsit(){
126    map.setZoom(3);
127    is_fit_bounds_zoom=0;
128}
129
130
131function wpestate_fit_bounds(bounds){
132
133    is_fit_bounds_zoom=1;
134
135    if(placeCircle!=''){
136        map.fitBounds(placeCircle.getBounds());
137    }else{
138        if(gmarkers.length===1){
139            var center = gmarkers[0].getPosition();
140            map.setCenter(center);
141            map.setZoom(10);
142
143            google.maps.event.addListenerOnce(map, 'idle', function() {
144                is_fit_bounds_zoom=0;
145            });
146        }else{
147
148            map.fitBounds(bounds);
149            google.maps.event.addListenerOnce(map, 'idle', function() {
150                is_fit_bounds_zoom=0;
151            });
152        }
153    }
154
155
156}
157
158function wpestate_fit_bounds_leaflet(bounds){
159
160    is_fit_bounds_zoom=1;
161
162    if(placeCircle!=''){
163        map.fitBounds(placeCircle.getBounds());// placecircle is google geolocation
164    }else{
165        if(gmarkers.length===1){
166            var center = gmarkers[0].getLatLng();
167            map.panTo(center);
168            map.setZoom(10);
169            is_fit_bounds_zoom=0;
170
171        }else{
172            map.fitBounds(bounds);
173            is_fit_bounds_zoom=0;
174        }
175    }
176
177
178}
179
180 function wpestate_classic_form_tax_visible($onpin,$onreq){
181    $onpin = $onpin.toLowerCase();
182    $onpin = decodeURI($onpin);
183    $onreq = $onreq.toLowerCase();
184    $onreq = decodeURI($onreq);
185    $onpin = $onpin.split(' ').join('-');
186    $onreq = $onreq.split(' ').join('-');
187    $onreq = $onreq.split("'").join('');
188    $onpin = $onpin.latinise();
189    $onreq = $onreq.latinise();
190
191
192    if($onpin.indexOf($onreq)> -1 ){
193        return true;
194    } else{
195        return false;
196    }
197 }
198
199
200/////////////////////////////////////////////////////////////////////////////////////////////////
201//  set markers... loading pins over map
202/////////////////////////////////////////////////////////////////////////////////////////////////
203
204function wprentals_google_setMarkers(map, locations) {
205    "use strict";
206    var  custom_info,pin_price,beach, id, lat, lng, title, pin, counter, image, price, single_first_type, single_first_action, link, city, area, cleanprice, rooms, baths, size, single_first_type_name, single_first_action_name, map_open, myLatLng, selected_id, open_height, boxText, closed_height, width_browser, infobox_width, vertical_pan, myOptions,status, i, slug1, val1, how1, slug2, val2, how2, slug3, val3, how3, slug4, val4, how4, slug5, val5, how5, slug6, val6, how6, slug7, val7, how7, slug8, val8, how8;
207    selected_id = parseInt(jQuery('#gmap_wrapper').attr('data-post_id'), 10);
208    if (isNaN(selected_id)) {
209        selected_id = parseInt(jQuery('#google_map_on_list').attr('data-post_id'), 10);
210    }
211
212    open_height     = parseInt(mapfunctions_vars.open_height, 10);
213    closed_height   = parseInt(mapfunctions_vars.closed_height, 10);
214    boxText         = document.createElement("div");
215    width_browser   = jQuery(window).width();
216
217    infobox_width = 700;
218    vertical_pan = -215;
219    if (width_browser < 900) {
220        infobox_width = 500;
221    }
222    if (width_browser < 600) {
223        infobox_width = 400;
224    }
225    if (width_browser < 400) {
226        infobox_width = 200;
227    }
228
229
230    myOptions = {
231        content: boxText,
232        disableAutoPan: true,
233        maxWidth: infobox_width,
234        boxClass: "mybox",
235        zIndex: null,
236        closeBoxMargin: "-13px 0px 0px 0px",
237        closeBoxURL: "",
238        infoBoxClearance: new google.maps.Size(1, 1),
239        isHidden: false,
240        pane: "floatPane",
241        enableEventPropagation: false
242    };
243    infoBox = new InfoBox(myOptions);
244
245    for (i = 0; i < locations.length; i++) {
246
247        beach                       = locations[i];
248        id                          = beach[10];
249        lat                         = beach[1];
250        lng                         = beach[2];
251        title                       = decodeURIComponent(beach[0]);
252        pin                         = beach[8];
253        counter                     = beach[3];
254        image                       = decodeURIComponent(beach[4]);
255        price                       = decodeURIComponent(beach[5]);
256        single_first_type           = decodeURIComponent(beach[6]);
257        single_first_action         = decodeURIComponent(beach[7]);
258        link                        = decodeURIComponent(beach[9]);
259        city                        = decodeURIComponent(beach[11]);
260        area                        = decodeURIComponent(beach[12]);
261        cleanprice                  = beach[13];
262        rooms                       = beach[14];
263        baths                       = beach[15];
264        size                        = beach[16];
265        single_first_type_name      = decodeURIComponent(beach[17]);
266        single_first_action_name    = decodeURIComponent(beach[18]);
267        status                      = decodeURIComponent(beach[19]);
268        pin_price                   =   decodeURIComponent ( beach[20] );
269        custom_info                 =   decodeURIComponent ( beach[21] );
270
271
272        if (mapfunctions_vars.custom_search === 'yes') {
273            i=1;
274            slug1 = beach[19+i];
275            val1 = beach[20+i];
276            how1 = beach[21+i];
277            slug2 = beach[22+i];
278            val2 = beach[23+i];
279            how2 = beach[24+i];
280            slug3 = beach[25+i];
281            val3 = beach[26+i];
282            how3 = beach[27+i];
283            slug4 = beach[28+i];
284            val4 = beach[29+i];
285            how4 = beach[30+i];
286            slug5 = beach[31+i];
287            val5 = beach[32+i];
288            how5 = beach[33+i];
289            slug6 = beach[34+i];
290            val6 = beach[35+i];
291            how6 = beach[36+i];
292            slug7 = beach[37+i];
293            val7 = beach[38+i];
294            how7 = beach[39+i];
295            slug8 = beach[40+i];
296            val8 = beach[41+i];
297            how8 = beach[42+i];
298        }
299
300        wpestate_createMarker(pin_price,infobox_width ,size, i, id, lat, lng, pin, title, counter, image, price, single_first_type, single_first_action, link, city, area, rooms, baths, cleanprice, slug1, val1, how1, slug2, val2, how2, slug3, val3, how3, slug4, val4, how4, slug5, val5, how5, slug6, val6, how6, slug7, val7, how7, slug8, val8, how8, single_first_type_name, single_first_action_name,status,custom_info);
301        // found the property
302
303        if (selected_id === id) {
304            found_id = i;
305        }
306    }//end for
307
308    // pan to the latest pin for taxonmy and adv search
309
310    if (mapfunctions_vars.generated_pins !== '0') {
311        myLatLng = new google.maps.LatLng(lat, lng);
312
313        if(map_is_pan===0){
314
315            wpestate_pan_to_last_pin(myLatLng);
316            oms = new OverlappingMarkerSpiderfier(map);
317            setOms(gmarkers);
318            oms.addListener('spiderfy', function (markers) {
319            });
320            oms.addListener('unspiderfy ', function (markers) {
321            });
322        }
323        map_is_pan=0;
324    }
325
326    if(mapfunctions_vars.is_prop_list==='1' || mapfunctions_vars.is_tax==='1' ){
327        wpestate_show_pins_filters_from_file();
328    }
329
330}// end wprentals_google_setMarkers
331
332
333/////////////////////////////////////////////////////////////////////////////////////////////////
334//  create marker
335/////////////////////////////////////////////////////////////////////////////////////////////////
336
337function wpestate_createMarker(pin_price,infobox_width, size, i, id, lat, lng, pin, title, counter, image, price, single_first_type, single_first_action, link, city, area, rooms, baths, cleanprice, slug1, val1, how1, slug2, val2, how2, slug3, val3, how3, slug4, val4, how4, slug5, val5, how5, slug6, val6, how6, slug7, val7, how7, slug8, val8, how8, single_first_type_name, single_first_action_name,status,custom_info) {
338    "use strict";
339    var marker, myLatLng;
340    var Titlex = jQuery('<textarea />').html(title).text();
341    var infobox_class="";
342    var poss=0;
343    myLatLng = new google.maps.LatLng(lat, lng);
344    if(mapfunctions_vars.useprice === 'yes'){
345        infobox_class=" pin_price_info ";
346        var myLatlng = new google.maps.LatLng(lat,lng);
347        marker= new WpstateMarker(
348            area,
349            city,
350            pin_price,
351            poss,
352            myLatlng,
353            map,
354            Titlex,
355            counter,
356            image,
357            id,
358            price,
359            single_first_type,
360            single_first_action,
361            link,
362            i,
363            rooms,
364            baths,
365            cleanprice,
366            size,
367            single_first_type_name,
368            single_first_action_name,
369            pin,
370            custom_info
371
372        );
373
374    }else{
375        infobox_class=" classic_info ";
376        if (mapfunctions_vars.custom_search === 'yes') {
377            marker = new google.maps.Marker({
378                position: myLatLng,
379                map: map,
380                icon: custompin(pin),
381                custompin: pin,
382                shape: shape,
383                title: decodeURIComponent(title.replace(/\+/g, ' ')),
384                zIndex: counter,
385                image: image,
386                idul: id,
387                price: price,
388                category: single_first_type,
389                action: single_first_action,
390                link: link,
391                city: city,
392                area: area,
393                infoWindowIndex: i,
394                rooms: rooms,
395                guest_no: baths,
396                size: size,
397                cleanprice: cleanprice,
398                category_name: single_first_type_name,
399                action_name: single_first_action_name,
400                slug1: slug1,
401                val1: val1,
402                howto1: how1,
403                slug2: slug2,
404                val2: val2,
405                howto2: how2,
406                slug3: slug3,
407                val3: val3,
408                howto3: how3,
409                slug4: slug4,
410                val4: val4,
411                howto4: how4,
412                slug5: slug5,
413                val5: val5,
414                howto5: how5,
415                slug6: slug6,
416                val6: val6,
417                howto6: how7,
418                slug7: slug7,
419                val7: val7,
420                howto7: how7,
421                slug8: slug8,
422                val8: val8,
423                howto8: how8
424
425            });
426
427        }else {
428            marker = new google.maps.Marker({
429                position: myLatLng,
430                map: map,
431                icon: custompin(pin),
432                custompin: pin,
433                shape: shape,
434                title: title,
435                zIndex: counter,
436                image: image,
437                idul: id,
438                price: price,
439                category: single_first_type,
440                action: single_first_action,
441                link: link,
442                city: city,
443                area: area,
444                infoWindowIndex: i,
445                rooms: rooms,
446                guest_no: baths,
447                cleanprice: cleanprice,
448                size: size,
449                category_name: single_first_type_name,
450                action_name: single_first_action_name,
451                status:status,
452                custom_info:custom_info
453            });
454        }
455    }
456
457    gmarkers.push(marker);
458
459    if (typeof (bounds_list) !== "undefined") {
460        bounds_list.extend(marker.getPosition());
461    }
462
463
464    google.maps.event.addListener(marker, 'click', function (event) {
465        var title, info_image, category, action, category_name, action_name, in_type, infoguest, inforooms,  vertical_off, status_html,status;
466        wpestate_new_open_close_map(1);
467        external_action_ondemand=1;
468
469        if (this.image === '') {
470            info_image =  mapfunctions_vars.path + '/idxdefault.jpg';
471        } else {
472            info_image = this.image;
473        }
474
475
476
477
478        if ( typeof(this.status)!='undefined'){
479            if( this.status.indexOf('%')!==-1 ){
480                status = this.status;
481                //(this.status.replace(/-/g, ' '));
482            }else{
483                status = decodeURIComponent(this.status.replace(/-/g, ' '));
484            }
485        }else{
486            status='';
487        }
488
489
490
491        category        = decodeURIComponent(this.category.replace(/-/g, ' '));
492        action          = decodeURIComponent(this.action.replace(/-/g, ' '));
493        category_name   = decodeURIComponent(this.category_name.replace(/-/g, ' '));
494        action_name     = decodeURIComponent(this.action_name.replace(/-/g, ' '));
495
496        status_html=wpestate_display_status(status);
497
498
499        in_type = mapfunctions_vars.in_text;
500        if (category === '' || action === '') {
501            in_type = " ";
502        }
503        in_type = " / ";
504
505        if (this.guest_no !== '' &&  this.guest_no !== '0' && this.guest_no !== 0  )  {
506            infoguest = '<span id="infoguest">' + this.guest_no + '</span>';
507        } else {
508            infoguest = '';
509        }
510
511        if (this.rooms !== '') {
512            inforooms = '<span id="inforoom">' + this.rooms + '</span>';
513        } else {
514            inforooms = '';
515        }
516
517        title = this.title.toString();
518
519
520
521
522        if( this.custom_info!=='undefined'){
523            var custom_array=this.custom_info.split(',');
524            inforooms = '<span id="inforoom" class="custom_infobox_icon"><i class="' + custom_array[0] + '"></i>' + custom_array[1] + '</span>';
525            infoguest = '<span id="infoguest" class="custom_infobox_icon"><i class="' + custom_array[2] + '"></i>' + custom_array[3] + '</span>';
526
527        }
528
529
530
531        infoBox.setContent('<div class="info_details '+infobox_class+' "><span id="infocloser" onClick=\'javascript:infoBox.close();\' ></span>'+status_html+'<a href="' + this.link + '"><div class="infogradient"></div><div class="infoimage" style="background-image:url(' + info_image + ')"  ></div></a><a href="' + this.link + '" id="infobox_title"> ' + title + '</a><div class="prop_detailsx">' + category_name + " " + in_type + " " + action_name + '</div><div class="infodetails">' + infoguest + inforooms + '</div><div class="prop_pricex">' + this.price + '</div></div>');
532        infoBox.open(map, this);
533        map.setCenter(this.position);
534
535
536        switch (infobox_width) {
537            case 700:
538                if (!document.getElementById('google_map_on_list')) {
539                    if (mapfunctions_vars.listing_map === 'top') {
540                        if( document.getElementById('google_map_prop_list') ){
541                            map.panBy(0, -100);
542
543                        }else{
544                            map.panBy(100, -100);
545                        }
546                    } else {
547                        map.panBy(10, -110);
548                    }
549                } else {
550
551                    map.panBy(0, -160);
552                }
553                vertical_off = 0;
554                break;
555            case 500:
556                if( document.getElementById('google_map_prop_list') ){
557                    map.panBy(50, -120);
558                }else{
559                    map.panBy(50, -150);
560                }
561                break;
562            case 400:
563
564                if( document.getElementById('google_map_prop_list') ){
565                     map.panBy(100, -220);
566                }else{
567                    map.panBy(0, -150);
568                }
569                break;
570            case 200:
571                map.panBy(20, -170);
572                break;
573        }
574
575        if (control_vars.show_adv_search_map_close === 'no') {
576            $('.search_wrapper').addClass('adv1_close');
577            adv_search_click();
578        }
579        wpestate_close_adv_search();
580    });/////////////////////////////////// end event listener
581
582    if (mapfunctions_vars.generated_pins !== '0') {
583        if(map_is_pan===0){
584            wpestate_pan_to_last_pin(myLatLng);
585        }
586        map_is_pan=1;
587    }
588}
589
590
591
592
593
594function wpestate_pan_to_last_pin(myLatLng) {
595    "use strict";
596    if(wprentals_map_type===1){
597        map.setCenter(myLatLng);
598    }else  if(wprentals_map_type===2){
599        map.panTo(myLatLng);
600    }
601}
602
603/////////////////////////////////////////////////////////////////////////////////////////////////
604//  map set search
605/////////////////////////////////////////////////////////////////////////////////////////////////
606function setOms(gmarkers) {
607    "use strict";
608    var i;
609    for (i = 0; i < gmarkers.length; i++) {
610        if (typeof oms !== 'undefined') {
611            oms.addMarker(gmarkers[i]);
612        }
613    }
614}
615
616
617/////////////////////////////////////////////////////////////////////////////////////////////////
618//  open close map
619/////////////////////////////////////////////////////////////////////////////////////////////////
620function wpestate_new_open_close_map(type) {
621    "use strict";
622    var current_height, closed_height, open_height, googleMap_h, gmapWrapper_h, vertical_off;
623    if (jQuery('#gmap_wrapper').hasClass('fullmap')) {
624        return;
625    }
626
627    if (mapfunctions_vars.open_close_status !== '1') { // we can resize map
628
629        current_height = jQuery('#googleMap').outerHeight();
630        closed_height = parseInt(mapfunctions_vars.closed_height, 10);
631        open_height = parseInt(mapfunctions_vars.open_height, 10);
632        googleMap_h = open_height;
633        gmapWrapper_h = open_height;
634
635        if (infoBox !== null) {
636            infoBox.close();
637        }
638
639        if (current_height === closed_height) {
640            googleMap_h = open_height;
641            if (Modernizr.mq('only all and (max-width: 940px)')) {
642                gmapWrapper_h = open_height;
643            } else {
644                jQuery('#gmap-menu').show();
645                gmapWrapper_h = open_height;
646            }
647
648            wpestate_new_show_advanced_search();
649            vertical_off = 0;
650            jQuery('#openmap').empty().append('<i class="fas fa-angle-up"></i>' + mapfunctions_vars.close_map);
651
652        } else if (type === 2) {
653            jQuery('#gmap-menu').hide();
654            jQuery('#advanced_search_map_form').hide();
655            googleMap_h = gmapWrapper_h = closed_height;
656            // hide_advanced_search();
657            wpestate_new_hide_advanced_search();
658            vertical_off = 150;
659        }
660
661        jQuery('#googleMap').animate({'height': googleMap_h + 'px'});
662        jQuery('#gmap_wrapper').animate({'height': gmapWrapper_h + 'px'}, 500, function () {
663            wprentals_map_resize();
664            if(wprentals_map_type===1){
665                map.setOptions({'scrollwheel': true});
666            }
667            jQuery('#googleMap').addClass('scrollon');
668            jQuery('.tooltip').fadeOut("fast");
669        });
670
671    }
672}
673
674
675/////////////////////////////////////////////////////////////////////////////////////////////////
676//  build map cluter
677/////////////////////////////////////////////////////////////////////////////////////////////////
678function wprentals_google_map_cluster() {
679    "use strict";
680    if (mapfunctions_vars.user_cluster === 'yes') {
681        clusterStyles = [
682            {
683                textColor: '#ffffff',
684                opt_textColor: '#ffffff',
685                url: images['cloud_pin'],
686                height: 72,
687                width: 72,
688                textSize: 15
689            }
690        ];
691        mcOptions = {gridSize: 50,
692            ignoreHidden: true,
693            maxZoom: parseInt( mapfunctions_vars.zoom_cluster,10),
694            styles: clusterStyles
695        };
696        markers_cluster = new MarkerClusterer(map, gmarkers, mcOptions);
697        markers_cluster.setIgnoreHidden(true);
698    }
699
700}
701
702
703/////////////////////////////////////////////////////////////////////////////////////////////////
704/// zoom
705/////////////////////////////////////////////////////////////////////////////////////////////////
706
707
708
709function wpestate_map_set_zoom_plus(){
710
711    if (document.getElementById('gmapzoomminus')) {
712        jQuery('#gmapzoomplus').on('click',function(){
713      
714            "use strict";
715            var current = parseInt(map.getZoom(), 10);
716            current = current + 1;
717            if (current > 20) {
718                current = 20;
719            }
720
721
722            map.setZoom(current);
723        });
724    }
725}    
726
727
728function wpestate_map_set_zoom_minus(){
729    if (document.getElementById('gmapzoomminus')) {
730        jQuery('#gmapzoomminus').on('click',function(){
731            "use strict";
732            var current = parseInt(map.getZoom(), 10);
733            current = current - 1;
734            if (current < 3) {
735                current = 3;
736            }
737            map.setZoom(current);
738        });
739
740
741    }
742}
743
744function wpestate_map_gmap_street(){
745
746    jQuery('#gmapstreet').on('click',function () {
747        "use strict";
748        wpestate_toggleStreetView();
749    });
750}
751
752
753/////////////////////////////////////////////////////////////////////////////////////////////////
754/// geolocation
755/////////////////////////////////////////////////////////////////////////////////////////////////
756
757function wpestate_map_geolocation_button(){
758    if (document.getElementById('geolocation-button')) {
759        jQuery('#geolocation-button').on('click',function(){
760            "use strict";
761            wprentals_myposition(map);
762            wpestate_close_adv_search();
763        });
764
765    }
766
767
768    if (document.getElementById('mobile-geolocation-button')) {
769        google.maps.event.addDomListener(document.getElementById('mobile-geolocation-button'), 'click', function () {
770            "use strict";
771            wprentals_myposition(map);
772            wpestate_close_adv_search();
773        });
774    }
775
776    jQuery('#mobile-geolocation-button,#geolocation-button').on('click',function () {
777        "use strict";
778        wprentals_myposition(map);
779    });
780
781}
782
783
784
785
786
787
788function wprentals_myposition(map){
789
790    if(navigator.geolocation){
791        var latLong,protocol;
792
793        protocol = "http:";
794        if (location.protocol != 'http:'){
795            protocol="https:";
796        }
797
798        if (location.protocol === 'https:') {
799            navigator.geolocation.getCurrentPosition(wpestate_showMyPosition_original,errorCallback,{timeout:10000});
800        }else{
801            jQuery.getJSON(protocol+"//ipinfo.io", function(ipinfo){
802                latLong = ipinfo.loc.split(",");
803                wprentals_showMyPosition (latLong);
804            });
805        }
806
807    }else{
808        alert(mapfunctions_vars.geo_no_brow);
809    }
810}
811
812
813function wpestate_showMyPosition_original(pos){
814    "use strict";
815    if(wprentals_map_type===1){
816        var shape = {
817           coord: [1, 1, 1, 38, 38, 59, 59 , 1],
818           type: 'poly'
819        };
820
821        var MyPoint=  new google.maps.LatLng( pos.coords.latitude, pos.coords.longitude);
822        map.setCenter(MyPoint);
823
824        var marker = new google.maps.Marker({
825                 position: MyPoint,
826                 map: map,
827                 icon: wpestate_custompinchild(),
828                 shape: shape,
829                 title: '',
830                 zIndex: 999999999,
831                 image:'',
832                 price:'',
833                 category:'',
834                 action:'',
835                 link:'' ,
836                 infoWindowIndex : 99 ,
837                 radius: parseInt(mapfunctions_vars.geolocation_radius,10)+' '+mapfunctions_vars.geo_message
838                });
839
840        var populationOptions = {
841            strokeColor: '#67cfd8',
842            strokeOpacity: 0.6,
843            strokeWeight: 1,
844            fillColor: '#67cfd8',
845            fillOpacity: 0.2,
846            map: map,
847            center: MyPoint,
848            radius: parseInt(mapfunctions_vars.geolocation_radius,10)
849        };
850  
851        var cityCircle = new google.maps.Circle(populationOptions);
852
853        var label = new Label({
854            map: map
855        });
856        label.bindTo('position', marker);
857        label.bindTo('text', marker, 'radius');
858        label.bindTo('visible', marker);
859        label.bindTo('clickable', marker);
860        label.bindTo('zIndex', marker);
861    }else{
862
863        var new_pos=[pos.coords.latitude, pos.coords.longitude];
864        wprentals_draw_leaflet_circle(new_pos);
865    }
866
867}
868
869
870
871
872
873function errorCallback() {
874    "use strict";
875    alert(mapfunctions_vars.geo_no_pos);
876}
877
878function wprentals_showMyPosition(pos) {
879    "use strict";
880
881    if(wprentals_map_type===1){
882        wprentals_draw_google_circle(pos);
883    }else if(wprentals_map_type===2){
884        wprentals_draw_leaflet_circle(pos);
885    }
886
887}
888
889
890function wprentals_draw_leaflet_circle(pos){
891
892    L.circle( [pos[0],pos[1]], parseInt(mapfunctions_vars.geolocation_radius, 10)).addTo(map);
893
894    var markerImage = {
895            iconUrl: wprentals_custompinchild_leaflet(),
896            iconSize: [44, 50],
897            iconAnchor: [20, 50],
898            popupAnchor: [1, -50]
899        };
900    var  markerOptions = {
901        riseOnHover: true
902    };
903
904    var markerCenter    =   L.latLng( pos[0], pos[1] );
905    markerOptions.icon = L.icon( markerImage );
906    L.marker( markerCenter, markerOptions ).addTo( map );
907
908
909    var wprentals_leaflet_label = '<div class="wprentals_leaflet_label">';
910    wprentals_leaflet_label+=parseInt(mapfunctions_vars.geolocation_radius, 10) + ' ' + mapfunctions_vars.geo_message;
911    wprentals_leaflet_label += '</div>';
912
913    var myIcon = L.divIcon({
914            className:'someclass',
915            iconSize: new L.Point(0, 0),
916            html: wprentals_leaflet_label
917        });
918
919    L.marker( markerCenter, {icon: myIcon} ).addTo( map );
920
921
922    map.panTo(markerCenter);
923    map.setZoom(10);
924}
925
926
927
928
929function wprentals_draw_google_circle(pos){
930
931    var shape, MyPoint, marker, populationOptions, cityCircle, label;
932    shape = {
933        coord: [1, 1, 1, 38, 38, 59, 59, 1],
934        type: 'poly'
935    };
936
937    MyPoint=  new google.maps.LatLng( pos[0], pos[1]);
938    map.setCenter(MyPoint);
939    map.setZoom(13);
940    marker = new google.maps.Marker({
941        position: MyPoint,
942        map: map,
943        icon: wpestate_custompinchild(),
944        shape: shape,
945        title: '',
946        zIndex: 999999999,
947        image: '',
948        price: '',
949        category: '',
950        action: '',
951        link: '',
952        infoWindowIndex: 99,
953        radius: parseInt(mapfunctions_vars.geolocation_radius, 10) + ' ' + mapfunctions_vars.geo_message
954    });
955
956    populationOptions = {
957        strokeColor: '#67cfd8',
958        strokeOpacity: 0.6,
959        strokeWeight: 1,
960        fillColor: '#67cfd8',
961        fillOpacity: 0.2,
962        map: map,
963        center: MyPoint,
964        radius: parseInt(mapfunctions_vars.geolocation_radius, 10)
965    };
966
967    cityCircle = new google.maps.Circle(populationOptions);
968
969    label = new Label({
970        map: map
971    });
972    label.bindTo('position', marker);
973    label.bindTo('text', marker, 'radius');
974    label.bindTo('visible', marker);
975    label.bindTo('clickable', marker);
976    label.bindTo('zIndex', marker);
977}
978
979
980function wpestate_custompinchild() {
981    "use strict";
982    var custom_img, image;
983    var extension='';
984    var ratio = jQuery(window).dense('devicePixelRatio');
985
986    if(ratio>1){
987        extension='_2x';
988    }
989
990    if (images['userpin'] === '') {
991        custom_img = mapfunctions_vars.path + '/' + 'userpin' +extension+ '.png';
992    } else {
993        custom_img = images['userpin'];
994        if(ratio>1){
995            custom_img=wpestate_get_custom_retina_pin(custom_img);
996        }
997    }
998
999    image = {
1000        url: custom_img,
1001        size: new google.maps.Size(59, 59),
1002        origin: new google.maps.Point(0, 0),
1003       // anchor: new google.maps.Point(16, 59)
1004    };
1005
1006
1007    if(ratio>1){
1008
1009        var   image = {
1010            url: custom_img,
1011            size :  new google.maps.Size(44, 50),
1012            scaledSize   :  new google.maps.Size(44, 50),
1013            origin: new google.maps.Point(0, 0),
1014            optimized:false
1015
1016        };
1017
1018    }else{
1019       var   image = {
1020            url: custom_img,
1021            size: new google.maps.Size(59, 59),
1022            origin: new google.maps.Point(0,0),
1023
1024        };
1025    }
1026
1027
1028    return image;
1029}
1030
1031
1032// same thing as above but with ipad double click workaroud solutin
1033jQuery('#googleMap,#google_map_prop_list_wrapper').on('click',function (event) {
1034    "use strict";
1035    var time_diff;
1036    time_diff = event.timeStamp - ipad_time;
1037
1038    if(wprentals_map_type==1){
1039
1040        if (time_diff > 300) {
1041            ipad_time = event.timeStamp;
1042            if (map.scrollwheel === false) {
1043                if(wprentals_map_type===1){
1044                    map.setOptions({'scrollwheel': true});
1045                }
1046                jQuery('#googleMap').addClass('scrollon');
1047            } else {
1048                if(wprentals_map_type===1){
1049                    map.setOptions({'scrollwheel': false});
1050                }
1051                jQuery('#googleMap').removeClass('scrollon');
1052            }
1053            jQuery('.tooltip').fadeOut("fast");
1054
1055
1056            if (Modernizr.mq('only all and (max-width: 1025px)')) {
1057                if (map.draggable === false) {
1058                    map.setOptions({'draggable': true});
1059                } else {
1060                    map.setOptions({'draggable': false});
1061                }
1062            }
1063
1064        }
1065    }
1066});
1067
1068
1069jQuery('#google_map_on_list').on('click',function (event) {
1070    if (Modernizr.mq('only all and (max-width: 1025px)')) {
1071        if (map.draggable === false) {
1072            map.setOptions({'draggable': true});
1073        } else {
1074            map.setOptions({'draggable': false});
1075        }
1076    }
1077});
1078
1079/////////////////////////////////////////////////////////////////////////////////////////////////
1080///
1081/////////////////////////////////////////////////////////////////////////////////////////////////
1082
1083if (document.getElementById('gmap')) {
1084    google.maps.event.addDomListener(document.getElementById('gmap'), 'mouseout', function () {
1085        "use strict";
1086        if(wprentals_map_type===1){
1087            map.setOptions({'scrollwheel': true});
1088        }
1089        wprentals_map_resize();
1090    });
1091}
1092
1093
1094if (document.getElementById('search_map_button')) {
1095    google.maps.event.addDomListener(document.getElementById('search_map_button'), 'click', function () {
1096        "use strict";
1097        infoBox.close();
1098    });
1099}
1100
1101
1102if (document.getElementById('advanced_search_map_button')) {
1103    google.maps.event.addDomListener(document.getElementById('advanced_search_map_button'), 'click', function () {
1104        "use strict";
1105        infoBox.close();
1106    });
1107}
1108
1109////////////////////////////////////////////////////////////////////////////////////////////////
1110/// navigate troguh pins
1111///////////////////////////////////////////////////////////////////////////////////////////////
1112function wpestate_navigate_pins(){
1113
1114    jQuery('#gmap-next').on('click',function () {
1115        "use strict";
1116        current_place++;
1117        external_action_ondemand=1;
1118        lealet_map_move_on_hover=1;
1119        if (current_place > gmarkers.length) {
1120            current_place = 1;
1121        }
1122        while (gmarkers[current_place-1].visible === false) {
1123            current_place++;
1124            if (current_place > gmarkers.length) {
1125                current_place = 1;
1126            }
1127        }
1128
1129        if (map.getZoom() < 15) {
1130            map.setZoom(15);
1131        }
1132        if(wprentals_map_type===1){
1133            google.maps.event.trigger(gmarkers[current_place - 1], 'click');
1134        }else if(wprentals_map_type===2){
1135
1136            map.setView(gmarkers[current_place - 1].getLatLng());
1137            if (! gmarkers[current_place - 1]._icon) {
1138                gmarkers[current_place - 1].__parent.spiderfy();
1139            }
1140                lealet_map_move_on_hover=1;
1141
1142                map.setZoom(20);
1143
1144                if( (current_place - 1)==0 || (current_place - 1)==gmarkers.length ){
1145                    setTimeout(function(){  gmarkers[current_place - 1].fire('click');  }, 1000);
1146                }else{
1147                    gmarkers[current_place - 1].fire('click');
1148                }
1149
1150            //lealet_map_move_on_hover=0;
1151            lealet_map_move_on_hover=1;
1152        }
1153
1154
1155    });
1156
1157
1158    jQuery('#gmap-prev').on('click',function () {
1159
1160        lealet_map_move_on_hover=1;
1161        external_action_ondemand=1;
1162        if (current_place < 1) {
1163            current_place = gmarkers.length;
1164        }
1165        while (gmarkers[current_place - 1].visible === false) {
1166            current_place--;
1167            if (current_place > gmarkers.length) {
1168                current_place = 1;
1169            }
1170        }
1171        if (map.getZoom() < 15) {
1172            map.setZoom(15);
1173        }
1174
1175        if(wprentals_map_type===1){
1176            google.maps.event.trigger(gmarkers[current_place - 1], 'click');
1177        }else if(wprentals_map_type===2){
1178            map.setView(gmarkers[current_place - 1].getLatLng());
1179            if (! gmarkers[current_place - 1]._icon)  gmarkers[current_place - 1].__parent.spiderfy();
1180                lealet_map_move_on_hover=1;
1181
1182                map.setZoom(20);
1183
1184                if( (current_place - 1)==0 || (current_place )==gmarkers.length ){
1185                    setTimeout(function(){  gmarkers[current_place - 1].fire('click');  }, 1000);
1186                }else{
1187                    gmarkers[current_place - 1].fire('click');
1188                }
1189
1190            lealet_map_move_on_hover=1;
1191
1192        }
1193        current_place--;
1194
1195    });
1196
1197}
1198
1199///////////////////////////////////////////////////////////////////////////////////////////////////////////
1200/// filter pins
1201//////////////////////////////////////////////////////////////////////////////////////////////////////////
1202
1203jQuery('.advanced_action_div li').on('click',function () {
1204    "use strict";
1205    var action = jQuery(this).val();
1206});
1207
1208
1209if (document.getElementById('gmap-menu')) {
1210    google.maps.event.addDomListener(document.getElementById('gmap-menu'), 'click', function (event) {
1211        "use strict";
1212        var category;
1213        infoBox.close();
1214
1215        if (event.target.nodeName === 'INPUT') {
1216            category = event.target.className;
1217
1218            if (event.target.name === "filter_action[]") {
1219                if (actions.indexOf(category) !== -1) {
1220                    actions.splice(actions.indexOf(category), 1);
1221                } else {
1222                    actions.push(category);
1223                }
1224            }
1225
1226            if (event.target.name === "filter_type[]") {
1227                if (categories.indexOf(category) !== -1) {
1228                    categories.splice(categories.indexOf(category), 1);
1229                } else {
1230                    categories.push(category);
1231                }
1232            }
1233
1234            show(actions, categories);
1235        }
1236
1237    });
1238}
1239//!visible_or_not(mapfunctions_vars.hows[0], gmarkers[i].val1, val1, mapfunctions_vars.slugs[0])
1240
1241function wpestate_visible_or_not(how, slug, value, read) {
1242    "use strict";
1243     var slider_min, slider_max, parsevalue;
1244    if (value !== '' && typeof (value) !== 'undefined') {
1245        // value = value.replace('%','');
1246    }
1247
1248    //////////////////////////////////////////////
1249    // in case of slider -
1250    if (read === 'property_price' && mapfunctions_vars.slider_price === 'yes') {
1251        slider_min = parseInt(jQuery('#price_low').val(), 10);
1252        slider_max = parseInt(jQuery('#price_max').val(), 10);
1253        if (slug >= slider_min && slug <= slider_max) {
1254            return true;
1255        } else {
1256            return false;
1257        }
1258    }
1259    //////////////////////////////////////////////
1260    // END in case of slider -
1261
1262    if (read === 'none') {
1263        return true;
1264    }
1265
1266    if (value !== '' && value !== ' ' && value !== 'all') {
1267        parsevalue = parseInt(value, 10);
1268        if (how === 'greater') {
1269            if (slug >= parsevalue) {
1270                return true;
1271            } else {
1272                return false;
1273            }
1274        } else if (how === 'smaller') {
1275            slug = parseInt(slug, 10);
1276            if (slug <= parsevalue) {
1277                return true;
1278            } else {
1279                return false;
1280            }
1281        } else if (how === 'equal') {
1282            if (slug === value || value === 'all') {
1283                return true;
1284            } else {
1285                return false;
1286            }
1287        } else if (how === 'like') {
1288            slug = slug.toLowerCase();
1289            value = value.toLowerCase();
1290            if (slug.indexOf(value) > -1) {
1291                return true;
1292            } else {
1293                return false;
1294            }
1295        } else if (how === 'date bigger') {
1296            slug = new Date(slug);
1297            value = new Date(value);
1298            if (slug >= value) {
1299                return true;
1300            } else {
1301                return false;
1302            }
1303        } else if (how === 'date smaller') {
1304            slug = new Date(slug);
1305            value = new Date(value);
1306            if (slug <= value) {
1307                return true;
1308            } else {
1309                return false;
1310            }
1311        }
1312        //return false;
1313    } else {
1314        return true;
1315    }
1316}
1317
1318
1319function wpestate_get_custom_value(slug) {
1320    "use strict";
1321    var value;
1322
1323    if (slug === 'adv_categ' || slug === 'adv_actions' || slug === 'advanced_city' || slug === 'advanced_area') {
1324        value = jQuery('#' + slug).attr('data-value');
1325    } else if (slug === 'property_price' && mapfunctions_vars.slider_price === 'yes') {
1326        value = jQuery('#price_low').val();
1327    } else {
1328        value = jQuery('#' + slug).val();
1329    }
1330
1331    return value;
1332}
1333
1334
1335function wprentals_show_pins() {
1336    "use strict";
1337    var is_google_map, results_no, city, area, guests, bounds, i;
1338    is_google_map = parseInt(jQuery('#isgooglemap').attr('data-isgooglemap'), 10);
1339    if (is_google_map !== 1) {
1340        return;
1341    }
1342
1343    results_no = 0;
1344    city = jQuery('#advanced_city').attr('data-value');
1345    area = jQuery('#advanced_area').attr('data-value');
1346    guests = parseInt(jQuery('#guest_no').val(), 10);
1347
1348    if (isNaN(guests)) {
1349        guests = 0;
1350    }
1351
1352    if (typeof infoBox !== 'undefined' && infoBox !== null) {
1353        infoBox.close();
1354    }
1355
1356    bounds = new google.maps.LatLngBounds();
1357    markers_cluster.setIgnoreHidden(true);
1358    if (typeof gmarkers !== 'undefined') {
1359        for (i = 0; i < gmarkers.length; i++) {
1360            if (gmarkers[i].area !== area && area !== 'all' && area !== '') {
1361                gmarkers[i].setVisible(false);
1362            } else if (gmarkers[i].city !== city && city !== 'all') {
1363                gmarkers[i].setVisible(false);
1364            } else if (parseInt(gmarkers[i].guests, 10) !== guests && guests !== 0) {
1365                gmarkers[i].setVisible(false);
1366            } else {
1367                gmarkers[i].setVisible(true);
1368                results_no = results_no + 1;
1369                bounds.extend(gmarkers[i].getPosition());
1370            }
1371        }//end for
1372        markers_cluster.repaint();
1373    }//end if
1374
1375    if (mapfunctions_vars.generated_pins === '0') {
1376        if (results_no === 0) {
1377            jQuery('#gmap-noresult').show();
1378            jQuery('#results').hide();
1379        } else {
1380            jQuery('#gmap-noresult').hide();
1381            if (!bounds.isEmpty()) {
1382                wpestate_fit_bounds(bounds);
1383            }
1384            jQuery("#results, #showinpage,#showinpage_mobile").show();
1385
1386            jQuery("#results_no").show().empty().append(results_no);
1387        }
1388    } else {
1389        wpestate_get_filtering_ajax_result();
1390    }
1391}
1392
1393
1394/////////////////////////////////////////////////////////////////////////////////////////////////
1395/// get pin image
1396/////////////////////////////////////////////////////////////////////////////////////////////////
1397function wpestate_convertToSlug(Text) {
1398    "use strict";
1399    return Text.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, '');
1400}
1401
1402
1403function custompin(image) {
1404    "use strict";
1405
1406    if( !mapfunctions_vars.hidden_map ){
1407
1408        // Approximate-location circle: stroke and fill follow the theme main color
1409        image ={
1410            path: google.maps.SymbolPath.CIRCLE,
1411            scale: 60,
1412            strokeColor: mapfunctions_vars.main_color,
1413            fillColor: mapfunctions_vars.main_color,
1414            fillOpacity: 0.4,
1415            strokeWeight: 0.4
1416        }
1417        return image;
1418    }
1419
1420
1421    var custom_img;
1422
1423    var extension='';
1424    var ratio = jQuery(window).dense('devicePixelRatio');
1425
1426    if(ratio>1){
1427        extension='_2x';
1428    }
1429
1430
1431    if(mapfunctions_vars.use_single_image_pin==='no'){
1432        if (image !== '') {
1433            if (images[image] === '') {
1434                custom_img = mapfunctions_vars.path + '/' + image + extension + '.png';
1435            } else {
1436                custom_img = images[image];
1437                if(ratio>1){
1438                    custom_img=custom_img.replace(".png","_2x.png");
1439                }
1440            }
1441        } else {
1442            custom_img = mapfunctions_vars.path + '/none.png';
1443        }
1444
1445        if (typeof (custom_img) === 'undefined') {
1446            custom_img = mapfunctions_vars.path + '/none.png';
1447        }
1448    }else{
1449        if(ratio>1){
1450            custom_img= wpestate_get_custom_retina_pin(  images['single_pin'] );
1451        }else{
1452            custom_img= images['single_pin'];
1453        }
1454    }
1455
1456    if(ratio>1){
1457
1458        image = {
1459            url: custom_img,
1460            size :  new google.maps.Size(44, 50),
1461            scaledSize   :  new google.maps.Size(44, 50),
1462            origin: new google.maps.Point(0, 0),
1463            optimized:false
1464        };
1465
1466    }else{
1467            image = {
1468            url: custom_img,
1469            size: new google.maps.Size(44, 50),
1470            origin: new google.maps.Point(0, 0),
1471
1472        };
1473    }
1474
1475
1476
1477    return image;
1478}
1479
1480
1481function wprentals_custompinhover() {
1482    "use strict";
1483    var custom_img, image;
1484
1485    var extension='';
1486    var ratio = jQuery(window).dense('devicePixelRatio');
1487
1488    if(ratio>1){
1489        extension='_2x';
1490    }
1491
1492    custom_img = mapfunctions_vars.path + '/hover'+extension+'.png';
1493
1494
1495    if(wprentals_map_type===2){
1496
1497        var markerImage    = L.icon({
1498            iconUrl: custom_img,
1499            iconSize: [44, 50],
1500            iconAnchor: [20, 50],
1501            popupAnchor: [1, -50]
1502        });
1503        return markerImage;
1504
1505    }
1506
1507
1508    image = {
1509        url: custom_img,
1510        size: new google.maps.Size(44, 50),
1511        origin: new google.maps.Point(0, 0),
1512       // anchor: new google.maps.Point(26, 25)
1513    };
1514
1515    if(ratio>1){
1516
1517        image = {
1518            url: custom_img,
1519            size :  new google.maps.Size(44, 50),
1520            scaledSize   :  new google.maps.Size(44, 50),
1521            origin: new google.maps.Point(0, 0),
1522            optimized:false
1523
1524          };
1525
1526    }else{
1527        image = {
1528            url: custom_img,
1529            size: new google.maps.Size(44, 50),
1530            origin: new google.maps.Point(0, 0),
1531        };
1532    }
1533
1534    return image;
1535}
1536
1537
1538
1539function wpestate_get_custom_retina_pin(custom_img){
1540    "use strict";
1541    var custom_img_retina;
1542    custom_img_retina=custom_img.replace(".png","_2x.png");
1543
1544    jQuery.get(custom_img_retina)
1545        .done(function() {
1546            custom_img = custom_img_retina;
1547        }).fail(function() {
1548        });
1549    return custom_img;
1550}
1551
1552
1553
1554
1555/////////////////////////////////////////////////////////////////////////////////////////////////
1556//// Circle label
1557/////////////////////////////////////////////////////////////////////////////////////////////////
1558
1559function Label(opt_options) {
1560    "use strict";
1561    // Initialization
1562    this.setValues(opt_options);
1563    // Label specific
1564    var span = this.span_ = document.createElement('span');
1565    span.style.cssText = 'position: relative; left: -50%; top: 8px; ' +
1566            'white-space: nowrap;  ' +
1567            'padding: 2px; background-color: white;opacity:0.7';
1568
1569
1570    var div = this.div_ = document.createElement('div');
1571    div.appendChild(span);
1572    div.style.cssText = 'position: absolute; display: none';
1573}
1574
1575
1576if (typeof google === 'object' && typeof google.maps === 'object') {
1577    Label.prototype = new google.maps.OverlayView;
1578    // Implement onAdd
1579    Label.prototype.onAdd = function () {
1580        var pane = this.getPanes().overlayImage;
1581        pane.appendChild(this.div_);
1582
1583        // Ensures the label is redrawn if the text or position is changed.
1584        var me = this;
1585        this.listeners_ = [
1586            google.maps.event.addListener(this, 'position_changed', function () {
1587                me.draw();
1588            }),
1589            google.maps.event.addListener(this, 'visible_changed', function () {
1590                me.draw();
1591            }),
1592            google.maps.event.addListener(this, 'clickable_changed', function () {
1593                me.draw();
1594            }),
1595            google.maps.event.addListener(this, 'text_changed', function () {
1596                me.draw();
1597            }),
1598            google.maps.event.addListener(this, 'zindex_changed', function () {
1599                me.draw();
1600            }),
1601            google.maps.event.addDomListener(this.div_, 'click', function () {
1602                if (me.get('clickable')) {
1603                    google.maps.event.trigger(me, 'click');
1604                }
1605            })
1606        ];
1607    };
1608
1609    // Implement onRemove
1610    Label.prototype.onRemove = function () {
1611        this.div_.parentNode.removeChild(this.div_);
1612        // Label is removed from the map, stop updating its position/text.
1613        for (var i = 0, I = this.listeners_.length; i < I; ++i) {
1614            google.maps.event.removeListener(this.listeners_[i]);
1615        }
1616    };
1617
1618
1619    // Implement draw
1620    Label.prototype.draw = function () {
1621        var projection = this.getProjection();
1622        var position = projection.fromLatLngToDivPixel(this.get('position'));
1623        var div = this.div_;
1624        div.style.left = position.x + 'px';
1625        div.style.top = position.y + 'px';
1626
1627
1628        var visible = this.get('visible');
1629        div.style.display = visible ? 'block' : 'none';
1630
1631
1632        var clickable = this.get('clickable');
1633        this.span_.style.cursor = clickable ? 'pointer' : '';
1634
1635
1636        var zIndex = this.get('zIndex');
1637        div.style.zIndex = zIndex;
1638
1639
1640        this.span_.innerHTML = this.get('text').toString();
1641    };
1642}
1643
1644
1645/////////////////////////////////////////////////////////////////////////////////////////////////
1646/// close advanced search
1647/////////////////////////////////////////////////////////////////////////////////////////////////
1648function wpestate_close_adv_search() {
1649
1650}
1651
1652
1653function wpestate_new_show_advanced_search() {
1654    "use strict";
1655    jQuery("#search_wrapper").removeClass("hidden");
1656}
1657
1658function wpestate_new_hide_advanced_search() {
1659    "use strict";
1660    if (mapfunctions_vars.show_adv_search === 'no') {
1661        jQuery("#search_wrapper").addClass("hidden");
1662    }
1663}
1664
1665
1666function wpestate_set_filter_pins(map, new_markers) {
1667    "use strict";
1668    if(wprentals_map_type===1){
1669        for (var i = 0; i < gmarkers.length; i++) {
1670            gmarkers[i].setVisible(false);
1671            gmarkers[i].setMap(null);
1672        }
1673        gmarkers = [];
1674
1675
1676        if( typeof (markers_cluster)!=='undefined'){
1677            markers_cluster.clearMarkers();
1678        }
1679
1680        if (new_markers.length > 0) {
1681            bounds_list = new google.maps.LatLngBounds();
1682            wprentals_map_general_set_markers(map, new_markers);
1683            wprentals_google_map_cluster();
1684              wprentals_google_fit_to_bounds();
1685        }
1686
1687    } else if(wprentals_map_type===2){
1688
1689        if (mapfunctions_vars.user_cluster === 'yes') {
1690            map.removeLayer(markers_cluster);
1691        }else{
1692            for (var i = 0; i < gmarkers.length; i++) {
1693                map.removeLayer(gmarkers[i]);
1694            }
1695        }
1696
1697        gmarkers = [];
1698        markers_cluster=L.markerClusterGroup({
1699            showCoverageOnHover: false,
1700            iconCreateFunction: function(cluster) {
1701                    return L.divIcon({ html: '<div class="leaflet_cluster" style="background-image: url('+images['cloud_pin']+')">' + cluster.getChildCount() + '</div>' });
1702            },
1703        });
1704
1705        if (new_markers.length > 0) {
1706
1707            bounds_list =undefined;
1708            wprentals_map_general_set_markers(map, new_markers);
1709            //set map cluster
1710            wprentals_map_general_cluster();
1711            //fit bounds
1712            wprentals_map_general_fit_to_bounds();
1713        }
1714        wprentals_map_general_cluster();
1715
1716    }
1717
1718}
1719
1720
1721function wpestate_set_filter_pins_ondemand(map, new_markers) {
1722    "use strict";
1723    if(wprentals_map_type===1){
1724
1725        for (var i = 0; i < gmarkers.length; i++) {
1726            gmarkers[i].setVisible(false);
1727            gmarkers[i].setMap(null);
1728        }
1729        gmarkers = [];
1730
1731        if (new_markers.length > 0) {
1732            if( typeof (markers_cluster)!=='undefined'){
1733               markers_cluster.clearMarkers();
1734            }
1735            wprentals_google_setMarkers(map, new_markers);
1736            wprentals_google_map_cluster();
1737
1738        }
1739
1740        oms = new OverlappingMarkerSpiderfier(map);
1741        setOms(gmarkers);
1742        oms.addListener('spiderfy', function (markers) {
1743        });
1744        oms.addListener('unspiderfy ', function (markers) {
1745        });
1746
1747
1748    } else if(wprentals_map_type===2){
1749
1750        if (mapfunctions_vars.user_cluster === 'yes') {
1751            map.removeLayer(markers_cluster);
1752        }else{
1753            for (var i = 0; i < gmarkers.length; i++) {
1754                map.removeLayer(gmarkers[i]);
1755            }
1756        }
1757
1758        gmarkers = [];
1759        markers_cluster=L.markerClusterGroup({
1760            showCoverageOnHover: false,
1761            iconCreateFunction: function(cluster) {
1762                    return L.divIcon({ html: '<div class="leaflet_cluster" style="background-image: url('+images['cloud_pin']+')">' + cluster.getChildCount() + '</div>' });
1763            },
1764        });
1765
1766        if (new_markers.length > 0) {
1767            bounds_list = map.getBounds();
1768            wprentals_map_general_set_markers(map, new_markers);
1769        }
1770        wprentals_map_general_cluster();
1771
1772
1773
1774    }
1775
1776}
1777
1778
1779
1780
1781
1782
1783var marker_zindex;
1784
1785function wpestate_hover_action_pin(listing_id) {
1786    "use strict";
1787    wpestate_hover_action_flag=1;
1788
1789    for (var i = 0; i < gmarkers.length; i++) {
1790
1791        if (parseInt(gmarkers[i].idul, 10) === parseInt(listing_id, 10)) {
1792
1793            if(wprentals_map_type===1){
1794                google.maps.event.trigger(gmarkers[i], 'click');
1795                map_geo_first_load=0;
1796                if(mapfunctions_vars.useprice !== 'yes'){
1797                    gmarkers[i].setIcon( wprentals_custompinhover() );
1798                }else{
1799                    gmarkers[i].addHoverClass();
1800                }
1801
1802                marker_zindex=gmarkers[i].getZIndex();
1803                gmarkers[i].setZIndex(9999999);
1804            }else if(wprentals_map_type===2){
1805
1806                lealet_map_move_on_hover=1;
1807                if (! gmarkers[i]._icon)  gmarkers[i].__parent.spiderfy();
1808                map.panTo(  gmarkers[i].getLatLng());
1809                gmarkers[i].togglePopup();
1810
1811
1812                if(mapfunctions_vars.useprice !== 'yes'){
1813                    gmarkers[i].setIcon(wprentals_custompinhover());
1814                }else{
1815                    L.DomUtil.addClass(gmarkers[i]._icon, 'openstreet_price_marker_on_click_parent');
1816                }
1817
1818
1819            }
1820        }
1821    }
1822
1823
1824
1825
1826}
1827
1828function wpestate_return_hover_action_pin(listing_id) {
1829    "use strict";
1830    wpestate_hover_action_flag=0;
1831    map_geo_first_load=1 ;
1832    external_action_ondemand=0;
1833    for (var i = 0; i < gmarkers.length; i++) {
1834        if (parseInt(gmarkers[i].idul, 10) === parseInt(listing_id, 10)) {
1835
1836            if(wprentals_map_type===1){
1837                if (parseInt(gmarkers[i].idul, 10) === parseInt(listing_id, 10)) {
1838                    infoBox.close();
1839                    if(mapfunctions_vars.useprice !== 'yes'){
1840                        gmarkers[i].setIcon(custompin(gmarkers[i].custompin));
1841                    }else{
1842                          gmarkers[i].removeHoverClass();
1843                    }
1844                    gmarkers[i].setZIndex(marker_zindex);
1845                }
1846            }  else if(wprentals_map_type===2){
1847
1848                gmarkers[i].togglePopup();
1849                lealet_map_move_on_hover=0;
1850                if(mapfunctions_vars.useprice !== 'yes'){
1851                 var   markerImage      = L.icon({
1852                        iconUrl: wprentals_custompin_leaflet(gmarkers[i].pin),
1853                        iconSize: [44, 50],
1854                        iconAnchor: [20, 50],
1855                        popupAnchor: [1, -50]
1856                    });
1857                    gmarkers[i].setIcon(markerImage);
1858                }else{
1859                    L.DomUtil.removeClass(gmarkers[i]._icon, 'openstreet_price_marker_on_click_parent');
1860                }
1861            }
1862
1863
1864        }
1865
1866    }
1867
1868}
1869
1870String.prototype.capitalize = function () {
1871    return this.replace(/(?:^|\s)\S/g, function (a) {
1872        return a.toUpperCase();
1873    });
1874};
1875
1876////////////////////////////////////////////////////////////////
1877//map places
1878///////////////////////////////////////////////////////////////
1879
1880var wpestate_initialize_poi = function ( map_for_poi,what){
1881
1882    if( parseInt(mapbase_vars.wprentals_map_type)!==1){
1883        return;
1884    }
1885
1886    var poi_service         =   new google.maps.places.PlacesService( map_for_poi );
1887    var already_serviced    =   '';
1888    var show_poi            =   '';
1889    var map_bounds          =   map_for_poi.getBounds();
1890    var selector            =   '.google_poi';
1891    if(what==2){
1892        selector = '.google_poish';
1893    }
1894
1895
1896
1897    jQuery(selector).on('click',function(event){
1898        event.stopPropagation();
1899        poi_type        =   jQuery(this).attr('id');
1900        var position    =   map_for_poi.getCenter();
1901        var show_poi    =   wpestate_return_poi_values(poi_type);
1902
1903
1904        if( jQuery(this).hasClass('poi_active')){
1905            wpestate_show_hide_poi(poi_type,'hide');
1906        }else{
1907
1908            already_serviced = wpestate_show_hide_poi(poi_type,'show');
1909            if(already_serviced===1){
1910
1911                var request = {
1912                    location:   position,
1913                    types:      show_poi,
1914                    bounds:     map_bounds,
1915                    radius:     2500,
1916                };
1917                poi_service.nearbySearch( request,function (results, status){
1918                    wpestate_googlemap_display_poi(results, status,map_for_poi);
1919                });
1920            }
1921        }
1922        jQuery(this).toggleClass('poi_active');
1923    });
1924
1925
1926
1927
1928
1929    // return google poi types for selected poi
1930    var wpestate_return_poi_values = function (poi_type){
1931        var  show_poi;
1932        switch(poi_type) {
1933                case 'transport':
1934                    show_poi = ['bus_station', 'airport', 'train_station', 'subway_station'];
1935                    break;
1936                case 'supermarkets':
1937                    show_poi = ['grocery_or_supermarket', 'shopping_mall'];
1938                    break;
1939                case 'schools':
1940                    show_poi = ['school', 'university'];
1941                    break;
1942                case 'restaurant':
1943                    show_poi=['restaurant'];
1944                    break;
1945                case 'pharma':
1946                    show_poi = ['pharmacy'];
1947                    break;
1948                case 'hospitals':
1949                    show_poi = ['hospital'];
1950                    break;
1951            }
1952        return show_poi;
1953    };
1954
1955
1956    // add poi markers on the map
1957    var wpestate_googlemap_display_poi = function (results, status,map_for_poi) {
1958        var place, poi_marker;
1959        if ( google.maps.places.PlacesServiceStatus.OK == status  ) {
1960            for (var i = 0; i < results.length; i++) {
1961                poi_marker  =   wpestate_create_poi_marker(results[i],map_for_poi);
1962                poi_marker_array.push(poi_marker);
1963            }
1964        }
1965    };
1966
1967    // create the poi markers
1968    var wpestate_create_poi_marker = function (place,map_for_poi){
1969        marker = new google.maps.Marker({
1970            map: map_for_poi,
1971            position: place.geometry.location,
1972            show_poi:poi_type,
1973            icon: mapfunctions_vars.path+'/poi/'+poi_type+'.png'
1974        });
1975
1976
1977        var boxText         =   document.createElement("div");
1978        var infobox_poi     =   new InfoBox({
1979                    content: boxText,
1980                    boxClass:"estate_poi_box",
1981                    pixelOffset: new google.maps.Size(-30, -70),
1982                    zIndex: null,
1983                    maxWidth: 275,
1984                    closeBoxMargin: "-13px 0px 0px 0px",
1985                    closeBoxURL: "",
1986                    infoBoxClearance: new google.maps.Size(1, 1),
1987                    pane: "floatPane",
1988                    enableEventPropagation: false
1989                });
1990
1991        google.maps.event.addListener(marker, 'mouseover', function(event) {
1992            infobox_poi.setContent(place.name);
1993            infobox_poi.open(map, this);
1994        });
1995
1996        google.maps.event.addListener(marker, 'mouseout', function(event) {
1997            if( infobox_poi!== null){
1998                infobox_poi.close();
1999            }
2000        });
2001        return marker;
2002    };
2003
2004
2005
2006    // hide-show poi
2007    var wpestate_show_hide_poi = function (poi_type,showhide){
2008        var is_hiding=1;
2009
2010        for (var i = 0; i < poi_marker_array.length; i++) {
2011            if (poi_marker_array[i].show_poi === poi_type){
2012                if(showhide==='hide'){
2013                    poi_marker_array[i].setVisible(false);
2014                }else{
2015                    poi_marker_array[i].setVisible(true);
2016                    is_hiding=0;
2017                }
2018            }
2019        }
2020
2021        return is_hiding;
2022    };
2023};
2024
2025
2026function wpestate_makeSafeForCSS(name) {
2027    return name.replace(/[^a-z0-9]/g, function(s) {
2028        var c = s.charCodeAt(0);
2029        if (c == 32) return '-';
2030        if (c >= 65 && c <= 90) return  s.toLowerCase();
2031        return  ('000' + c.toString(16)).slice(-4);
2032    });
2033}

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.