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 533 infoBox.open(map, this); 534 535 map.setCenter(this.position); 536 537 538 switch (infobox_width) { 539 case 700: 540 if (!document.getElementById('google_map_on_list')) { 541 if (mapfunctions_vars.listing_map === 'top') { 542 if( document.getElementById('google_map_prop_list') ){ 543 map.panBy(0, -100); 544 545 }else{ 546 map.panBy(100, -100); 547 } 548 } else { 549 map.panBy(10, -110); 550 } 551 } else { 552 553 map.panBy(0, -160); 554 } 555 vertical_off = 0; 556 break; 557 case 500: 558 if( document.getElementById('google_map_prop_list') ){ 559 map.panBy(50, -120); 560 }else{ 561 map.panBy(50, -150); 562 } 563 break; 564 case 400: 565 566 if( document.getElementById('google_map_prop_list') ){ 567 map.panBy(100, -220); 568 }else{ 569 map.panBy(0, -150); 570 } 571 break; 572 case 200: 573 map.panBy(20, -170); 574 break; 575 } 576 577 if (control_vars.show_adv_search_map_close === 'no') { 578 $('.search_wrapper').addClass('adv1_close'); 579 adv_search_click(); 580 } 581 wpestate_close_adv_search(); 582 });/////////////////////////////////// end event listener 583 584 if (mapfunctions_vars.generated_pins !== '0') { 585 if(map_is_pan===0){ 586 wpestate_pan_to_last_pin(myLatLng); 587 } 588 map_is_pan=1; 589 } 590} 591 592 593 594 595 596function wpestate_pan_to_last_pin(myLatLng) { 597 "use strict"; 598 if(wprentals_map_type===1){ 599 map.setCenter(myLatLng); 600 }else if(wprentals_map_type===2){ 601 map.panTo(myLatLng); 602 } 603} 604
605///////////////////////////////////////////////////////////////////////////////////////////////// 606// map set search 607///////////////////////////////////////////////////////////////////////////////////////////////// 608function setOms(gmarkers) { 609 "use strict"; 610 var i; 611 for (i = 0; i < gmarkers.length; i++) { 612 if (typeof oms !== 'undefined') { 613 oms.addMarker(gmarkers[i]); 614 } 615 } 616} 617 618 619///////////////////////////////////////////////////////////////////////////////////////////////// 620// open close map 621///////////////////////////////////////////////////////////////////////////////////////////////// 622function wpestate_new_open_close_map(type) { 623 "use strict"; 624 var current_height, closed_height, open_height, googleMap_h, gmapWrapper_h, vertical_off; 625 if (jQuery('#gmap_wrapper').hasClass('fullmap')) { 626 return; 627 } 628 629 if (mapfunctions_vars.open_close_status !== '1') { // we can resize map 630 631 current_height = jQuery('#googleMap').outerHeight(); 632 closed_height = parseInt(mapfunctions_vars.closed_height, 10); 633 open_height = parseInt(mapfunctions_vars.open_height, 10); 634 googleMap_h = open_height; 635 gmapWrapper_h = open_height; 636 637 if (infoBox !== null) { 638 infoBox.close(); 639 } 640 641 if (current_height === closed_height) { 642 googleMap_h = open_height; 643 if (Modernizr.mq('only all and (max-width: 940px)')) { 644 gmapWrapper_h = open_height; 645 } else { 646 jQuery('#gmap-menu').show(); 647 gmapWrapper_h = open_height; 648 } 649 650 wpestate_new_show_advanced_search(); 651 vertical_off = 0; 652 jQuery('#openmap').empty().append('<i class="fas fa-angle-up"></i>' + mapfunctions_vars.close_map); 653 654 } else if (type === 2) { 655 jQuery('#gmap-menu').hide(); 656 jQuery('#advanced_search_map_form').hide(); 657 googleMap_h = gmapWrapper_h = closed_height; 658 // hide_advanced_search(); 659 wpestate_new_hide_advanced_search(); 660 vertical_off = 150; 661 } 662 663 jQuery('#googleMap').animate({'height': googleMap_h + 'px'}); 664 jQuery('#gmap_wrapper').animate({'height': gmapWrapper_h + 'px'}, 500, function () { 665 wprentals_map_resize(); 666 if(wprentals_map_type===1){ 667 map.setOptions({'scrollwheel': true}); 668 } 669 jQuery('#googleMap').addClass('scrollon'); 670 jQuery('.tooltip').fadeOut("fast"); 671 }); 672 673 } 674} 675 676 677///////////////////////////////////////////////////////////////////////////////////////////////// 678// build map cluter 679///////////////////////////////////////////////////////////////////////////////////////////////// 680function wprentals_google_map_cluster() { 681 "use strict"; 682 if (mapfunctions_vars.user_cluster === 'yes') { 683 clusterStyles = [ 684 { 685 textColor: '#ffffff', 686 opt_textColor: '#ffffff', 687 url: images['cloud_pin'], 688 height: 72, 689 width: 72, 690 textSize: 15 691 } 692 ]; 693 mcOptions = {gridSize: 50, 694 ignoreHidden: true, 695 maxZoom: parseInt( mapfunctions_vars.zoom_cluster,10), 696 styles: clusterStyles 697 }; 698 markers_cluster = new MarkerClusterer(map, gmarkers, mcOptions); 699 markers_cluster.setIgnoreHidden(true); 700 } 701 702} 703 704 705///////////////////////////////////////////////////////////////////////////////////////////////// 706/// zoom 707///////////////////////////////////////////////////////////////////////////////////////////////// 708 709 710 711function wpestate_map_set_zoom_plus(){ 712 713 if (document.getElementById('gmapzoomminus')) { 714 jQuery('#gmapzoomplus').on('click',function(){ 715 716 "use strict"; 717 var current = parseInt(map.getZoom(), 10); 718 current = current + 1; 719 if (current > 20) { 720 current = 20; 721 } 722 723 724 map.setZoom(current); 725 }); 726 } 727} 728 729 730function wpestate_map_set_zoom_minus(){
731 if (document.getElementById('gmapzoomminus')) { 732 jQuery('#gmapzoomminus').on('click',function(){ 733 "use strict"; 734 var current = parseInt(map.getZoom(), 10); 735 current = current - 1; 736 if (current < 3) { 737 current = 3; 738 } 739 map.setZoom(current); 740 }); 741 742 743 } 744} 745 746function wpestate_map_gmap_street(){ 747 748 jQuery('#gmapstreet').on('click',function () { 749 "use strict"; 750 wpestate_toggleStreetView(); 751 }); 752} 753 754 755///////////////////////////////////////////////////////////////////////////////////////////////// 756/// geolocation 757///////////////////////////////////////////////////////////////////////////////////////////////// 758 759function wpestate_map_geolocation_button(){ 760 if (document.getElementById('geolocation-button')) { 761 jQuery('#geolocation-button').on('click',function(){ 762 "use strict"; 763 wprentals_myposition(map); 764 wpestate_close_adv_search(); 765 }); 766 767 } 768 769 770 if (document.getElementById('mobile-geolocation-button')) { 771 google.maps.event.addDomListener(document.getElementById('mobile-geolocation-button'), 'click', function () { 772 "use strict"; 773 wprentals_myposition(map); 774 wpestate_close_adv_search(); 775 }); 776 } 777 778 jQuery('#mobile-geolocation-button,#geolocation-button').on('click',function () { 779 "use strict"; 780 wprentals_myposition(map); 781 }); 782 783} 784 785 786 787 788 789 790function wprentals_myposition(map){ 791 792 if(navigator.geolocation){ 793 var latLong,protocol; 794 795 protocol = "http:"; 796 if (location.protocol != 'http:'){ 797 protocol="https:"; 798 } 799 800 if (location.protocol === 'https:') { 801 navigator.geolocation.getCurrentPosition(wpestate_showMyPosition_original,errorCallback,{timeout:10000}); 802 }else{ 803 jQuery.getJSON(protocol+"//ipinfo.io", function(ipinfo){ 804 latLong = ipinfo.loc.split(","); 805 wprentals_showMyPosition (latLong); 806 }); 807 } 808 809 }else{ 810 alert(mapfunctions_vars.geo_no_brow); 811 } 812} 813 814 815function wpestate_showMyPosition_original(pos){ 816 "use strict"; 817 if(wprentals_map_type===1){ 818 var shape = { 819 coord: [1, 1, 1, 38, 38, 59, 59 , 1], 820 type: 'poly' 821 }; 822 823 var MyPoint= new google.maps.LatLng( pos.coords.latitude, pos.coords.longitude); 824 map.setCenter(MyPoint); 825 826 var marker = new google.maps.Marker({ 827 position: MyPoint, 828 map: map, 829 icon: wpestate_custompinchild(), 830 shape: shape, 831 title: '', 832 zIndex: 999999999, 833 image:'', 834 price:'', 835 category:'', 836 action:'', 837 link:'' , 838 infoWindowIndex : 99 , 839 radius: parseInt(mapfunctions_vars.geolocation_radius,10)+' '+mapfunctions_vars.geo_message 840 }); 841 842 var populationOptions = { 843 strokeColor: '#67cfd8', 844 strokeOpacity: 0.6, 845 strokeWeight: 1, 846 fillColor: '#67cfd8', 847 fillOpacity: 0.2, 848 map: map, 849 center: MyPoint, 850 radius: parseInt(mapfunctions_vars.geolocation_radius,10) 851 }; 852 853 var cityCircle = new google.maps.Circle(populationOptions); 854 855 var label = new Label({ 856 map: map 857 }); 858 label.bindTo('position', marker); 859 label.bindTo('text', marker, 'radius'); 860 label.bindTo('visible', marker); 861 label.bindTo('clickable', marker); 862 label.bindTo('zIndex', marker); 863 }else{ 864 865 var new_pos=[pos.coords.latitude, pos.coords.longitude]; 866 wprentals_draw_leaflet_circle(new_pos); 867 } 868 869} 870 871 872 873 874 875function errorCallback() { 876 "use strict"; 877 alert(mapfunctions_vars.geo_no_pos); 878} 879 880function wprentals_showMyPosition(pos) { 881 "use strict"; 882 883 if(wprentals_map_type===1){ 884 wprentals_draw_google_circle(pos); 885 }else if(wprentals_map_type===2){ 886 wprentals_draw_leaflet_circle(pos); 887 } 888 889} 890 891 892function wprentals_draw_leaflet_circle(pos){ 893 894 L.circle( [pos[0],pos[1]], parseInt(mapfunctions_vars.geolocation_radius, 10)).addTo(map); 895 896 var markerImage = { 897 iconUrl: wprentals_custompinchild_leaflet(), 898 iconSize: [44, 50], 899 iconAnchor: [20, 50],
900 popupAnchor: [1, -50] 901 }; 902 var markerOptions = { 903 riseOnHover: true 904 }; 905 906 var markerCenter = L.latLng( pos[0], pos[1] ); 907 markerOptions.icon = L.icon( markerImage ); 908 L.marker( markerCenter, markerOptions ).addTo( map ); 909 910 911 var wprentals_leaflet_label = '<div class="wprentals_leaflet_label">'; 912 wprentals_leaflet_label+=parseInt(mapfunctions_vars.geolocation_radius, 10) + ' ' + mapfunctions_vars.geo_message; 913 wprentals_leaflet_label += '</div>'; 914 915 var myIcon = L.divIcon({ 916 className:'someclass', 917 iconSize: new L.Point(0, 0), 918 html: wprentals_leaflet_label 919 }); 920 921 L.marker( markerCenter, {icon: myIcon} ).addTo( map ); 922 923 924 map.panTo(markerCenter); 925 map.setZoom(10); 926} 927 928 929 930 931function wprentals_draw_google_circle(pos){ 932 933 var shape, MyPoint, marker, populationOptions, cityCircle, label; 934 shape = { 935 coord: [1, 1, 1, 38, 38, 59, 59, 1], 936 type: 'poly' 937 }; 938 939 MyPoint= new google.maps.LatLng( pos[0], pos[1]); 940 map.setCenter(MyPoint); 941 map.setZoom(13); 942 marker = new google.maps.Marker({ 943 position: MyPoint, 944 map: map, 945 icon: wpestate_custompinchild(), 946 shape: shape, 947 title: '', 948 zIndex: 999999999, 949 image: '', 950 price: '', 951 category: '', 952 action: '', 953 link: '', 954 infoWindowIndex: 99, 955 radius: parseInt(mapfunctions_vars.geolocation_radius, 10) + ' ' + mapfunctions_vars.geo_message 956 }); 957 958 populationOptions = { 959 strokeColor: '#67cfd8', 960 strokeOpacity: 0.6, 961 strokeWeight: 1, 962 fillColor: '#67cfd8', 963 fillOpacity: 0.2, 964 map: map, 965 center: MyPoint, 966 radius: parseInt(mapfunctions_vars.geolocation_radius, 10) 967 }; 968 969 cityCircle = new google.maps.Circle(populationOptions); 970 971 label = new Label({ 972 map: map 973 }); 974 label.bindTo('position', marker); 975 label.bindTo('text', marker, 'radius'); 976 label.bindTo('visible', marker); 977 label.bindTo('clickable', marker); 978 label.bindTo('zIndex', marker); 979} 980 981 982function wpestate_custompinchild() { 983 "use strict"; 984 var custom_img, image; 985 var extension=''; 986 var ratio = jQuery(window).dense('devicePixelRatio'); 987 988 if(ratio>1){ 989 extension='_2x'; 990 } 991 992 if (images['userpin'] === '') { 993 custom_img = mapfunctions_vars.path + '/' + 'userpin' +extension+ '.png'; 994 } else { 995 custom_img = images['userpin']; 996 if(ratio>1){ 997 custom_img=wpestate_get_custom_retina_pin(custom_img); 998 } 999 } 1000 1001 image = { 1002 url: custom_img, 1003 size: new google.maps.Size(59, 59), 1004 origin: new google.maps.Point(0, 0), 1005 // anchor: new google.maps.Point(16, 59) 1006 }; 1007 1008 1009 if(ratio>1){ 1010 1011 var image = { 1012 url: custom_img, 1013 size : new google.maps.Size(44, 50), 1014 scaledSize : new google.maps.Size(44, 50), 1015 origin: new google.maps.Point(0, 0), 1016 optimized:false 1017 1018 }; 1019 1020 }else{ 1021 var image = { 1022 url: custom_img, 1023 size: new google.maps.Size(59, 59), 1024 origin: new google.maps.Point(0,0), 1025 1026 }; 1027 } 1028 1029 1030 return image; 1031} 1032 1033 1034// same thing as above but with ipad double click workaroud solutin 1035jQuery('#googleMap,#google_map_prop_list_wrapper').on('click',function (event) { 1036 "use strict"; 1037 var time_diff; 1038 time_diff = event.timeStamp - ipad_time; 1039 1040 if(wprentals_map_type==1){ 1041 1042 if (time_diff > 300) { 1043 ipad_time = event.timeStamp; 1044 if (map.scrollwheel === false) { 1045 if(wprentals_map_type===1){ 1046 map.setOptions({'scrollwheel': true}); 1047 } 1048 jQuery('#googleMap').addClass('scrollon'); 1049 } else { 1050 if(wprentals_map_type===1){ 1051 map.setOptions({'scrollwheel': false}); 1052 } 1053 jQuery('#googleMap').removeClass('scrollon'); 1054 } 1055 jQuery('.tooltip').fadeOut("fast"); 1056 1057 1058 if (Modernizr.mq('only all and (max-width: 1025px)')) { 1059 if (map.draggable === false) { 1060 map.setOptions({'draggable': true}); 1061 } else { 1062 map.setOptions({'draggable': false}); 1063 } 1064 } 1065 1066 } 1067 } 1068}); 1069 1070 1071jQuery('#google_map_on_list').on('click',function (event) { 1072 if (Modernizr.mq('only all and (max-width: 1025px)')) { 1073 if (map.draggable === false) { 1074 map.setOptions({'draggable': true}); 1075 } else { 1076 map.setOptions({'draggable': false}); 1077 } 1078 } 1079}); 1080 1081///////////////////////////////////////////////////////////////////////////////////////////////// 1082/// 1083///////////////////////////////////////////////////////////////////////////////////////////////// 1084 1085if (document.getElementById('gmap')) { 1086 google.maps.event.addDomListener(document.getElementById('gmap'), 'mouseout', function () { 1087 "use strict"; 1088 if(wprentals_map_type===1){ 1089 map.setOptions({'scrollwheel': true}); 1090 } 1091 wprentals_map_resize(); 1092 }); 1093} 1094 1095 1096if (document.getElementById('search_map_button')) { 1097 google.maps.event.addDomListener(document.getElementById('search_map_button'), 'click', function () { 1098 "use strict"; 1099 infoBox.close(); 1100 }); 1101} 1102 1103 1104if (document.getElementById('advanced_search_map_button')) { 1105 google.maps.event.addDomListener(document.getElementById('advanced_search_map_button'), 'click', function () { 1106 "use strict"; 1107 infoBox.close(); 1108 }); 1109} 1110
1111//////////////////////////////////////////////////////////////////////////////////////////////// 1112/// navigate troguh pins 1113/////////////////////////////////////////////////////////////////////////////////////////////// 1114function wpestate_navigate_pins(){ 1115 1116 jQuery('#gmap-next').on('click',function () { 1117 "use strict"; 1118 current_place++; 1119 external_action_ondemand=1; 1120 lealet_map_move_on_hover=1; 1121 if (current_place > gmarkers.length) { 1122 current_place = 1; 1123 } 1124 while (gmarkers[current_place-1].visible === false) { 1125 current_place++; 1126 if (current_place > gmarkers.length) { 1127 current_place = 1; 1128 } 1129 } 1130 1131 if (map.getZoom() < 15) { 1132 map.setZoom(15); 1133 } 1134 if(wprentals_map_type===1){ 1135 google.maps.event.trigger(gmarkers[current_place - 1], 'click'); 1136 }else if(wprentals_map_type===2){ 1137 1138 map.setView(gmarkers[current_place - 1].getLatLng()); 1139 if (! gmarkers[current_place - 1]._icon) { 1140 gmarkers[current_place - 1].__parent.spiderfy(); 1141 } 1142 lealet_map_move_on_hover=1; 1143 1144 map.setZoom(20); 1145 1146 if( (current_place - 1)==0 || (current_place - 1)==gmarkers.length ){ 1147 setTimeout(function(){ gmarkers[current_place - 1].fire('click'); }, 1000); 1148 }else{ 1149 gmarkers[current_place - 1].fire('click'); 1150 } 1151 1152 //lealet_map_move_on_hover=0; 1153 lealet_map_move_on_hover=1; 1154 } 1155 1156 1157 }); 1158 1159 1160 jQuery('#gmap-prev').on('click',function () { 1161 1162 lealet_map_move_on_hover=1; 1163 external_action_ondemand=1; 1164 if (current_place < 1) { 1165 current_place = gmarkers.length; 1166 } 1167 while (gmarkers[current_place - 1].visible === false) { 1168 current_place--; 1169 if (current_place > gmarkers.length) { 1170 current_place = 1; 1171 } 1172 } 1173 if (map.getZoom() < 15) { 1174 map.setZoom(15); 1175 } 1176 1177 if(wprentals_map_type===1){ 1178 google.maps.event.trigger(gmarkers[current_place - 1], 'click'); 1179 }else if(wprentals_map_type===2){
1180 map.setView(gmarkers[current_place - 1].getLatLng()); 1181 if (! gmarkers[current_place - 1]._icon) gmarkers[current_place - 1].__parent.spiderfy(); 1182 lealet_map_move_on_hover=1; 1183 1184 map.setZoom(20); 1185 1186 if( (current_place - 1)==0 || (current_place )==gmarkers.length ){ 1187 setTimeout(function(){ gmarkers[current_place - 1].fire('click'); }, 1000); 1188 }else{ 1189 gmarkers[current_place - 1].fire('click'); 1190 } 1191 1192 lealet_map_move_on_hover=1; 1193 1194 } 1195 current_place--; 1196 1197 }); 1198 1199} 1200 1201/////////////////////////////////////////////////////////////////////////////////////////////////////////// 1202/// filter pins 1203////////////////////////////////////////////////////////////////////////////////////////////////////////// 1204 1205jQuery('.advanced_action_div li').on('click',function () { 1206 "use strict"; 1207 var action = jQuery(this).val(); 1208}); 1209 1210 1211if (document.getElementById('gmap-menu')) { 1212 google.maps.event.addDomListener(document.getElementById('gmap-menu'), 'click', function (event) { 1213 "use strict"; 1214 var category; 1215 infoBox.close(); 1216 1217 if (event.target.nodeName === 'INPUT') { 1218 category = event.target.className; 1219 1220 if (event.target.name === "filter_action[]") { 1221 if (actions.indexOf(category) !== -1) { 1222 actions.splice(actions.indexOf(category), 1); 1223 } else { 1224 actions.push(category); 1225 } 1226 } 1227 1228 if (event.target.name === "filter_type[]") { 1229 if (categories.indexOf(category) !== -1) { 1230 categories.splice(categories.indexOf(category), 1); 1231 } else { 1232 categories.push(category); 1233 } 1234 } 1235 1236 show(actions, categories); 1237 } 1238 1239 }); 1240} 1241//!visible_or_not(mapfunctions_vars.hows[0], gmarkers[i].val1, val1, mapfunctions_vars.slugs[0]) 1242 1243function wpestate_visible_or_not(how, slug, value, read) { 1244 "use strict"; 1245 var slider_min, slider_max, parsevalue; 1246 if (value !== '' && typeof (value) !== 'undefined') { 1247 // value = value.replace('%',''); 1248 } 1249 1250 ////////////////////////////////////////////// 1251 // in case of slider - 1252 if (read === 'property_price' && mapfunctions_vars.slider_price === 'yes') { 1253 slider_min = parseInt(jQuery('#price_low').val(), 10); 1254 slider_max = parseInt(jQuery('#price_max').val(), 10); 1255 if (slug >= slider_min && slug <= slider_max) { 1256 return true; 1257 } else { 1258 return false; 1259 } 1260 } 1261 ////////////////////////////////////////////// 1262 // END in case of slider - 1263 1264 if (read === 'none') { 1265 return true; 1266 } 1267 1268 if (value !== '' && value !== ' ' && value !== 'all') { 1269 parsevalue = parseInt(value, 10); 1270 if (how === 'greater') { 1271 if (slug >= parsevalue) { 1272 return true; 1273 } else { 1274 return false; 1275 } 1276 } else if (how === 'smaller') { 1277 slug = parseInt(slug, 10); 1278 if (slug <= parsevalue) { 1279 return true; 1280 } else { 1281 return false; 1282 } 1283 } else if (how === 'equal') { 1284 if (slug === value || value === 'all') { 1285 return true; 1286 } else { 1287 return false; 1288 } 1289 } else if (how === 'like') { 1290 slug = slug.toLowerCase(); 1291 value = value.toLowerCase(); 1292 if (slug.indexOf(value) > -1) { 1293 return true; 1294 } else { 1295 return false; 1296 } 1297 } else if (how === 'date bigger') { 1298 slug = new Date(slug); 1299 value = new Date(value); 1300 if (slug >= value) { 1301 return true; 1302 } else { 1303 return false; 1304 } 1305 } else if (how === 'date smaller') { 1306 slug = new Date(slug); 1307 value = new Date(value); 1308 if (slug <= value) { 1309 return true; 1310 } else { 1311 return false;
1312 } 1313 } 1314 //return false; 1315 } else { 1316 return true; 1317 } 1318} 1319 1320 1321function wpestate_get_custom_value(slug) { 1322 "use strict"; 1323 var value; 1324 1325 if (slug === 'adv_categ' || slug === 'adv_actions' || slug === 'advanced_city' || slug === 'advanced_area') { 1326 value = jQuery('#' + slug).attr('data-value'); 1327 } else if (slug === 'property_price' && mapfunctions_vars.slider_price === 'yes') { 1328 value = jQuery('#price_low').val(); 1329 } else { 1330 value = jQuery('#' + slug).val(); 1331 } 1332 1333 return value; 1334} 1335 1336 1337function wprentals_show_pins() { 1338 "use strict"; 1339 var is_google_map, results_no, city, area, guests, bounds, i; 1340 is_google_map = parseInt(jQuery('#isgooglemap').attr('data-isgooglemap'), 10); 1341 if (is_google_map !== 1) { 1342 return; 1343 } 1344 1345 results_no = 0; 1346 city = jQuery('#advanced_city').attr('data-value'); 1347 area = jQuery('#advanced_area').attr('data-value'); 1348 guests = parseInt(jQuery('#guest_no').val(), 10); 1349 1350 if (isNaN(guests)) { 1351 guests = 0; 1352 } 1353 1354 if (typeof infoBox !== 'undefined' && infoBox !== null) { 1355 infoBox.close(); 1356 } 1357 1358 bounds = new google.maps.LatLngBounds(); 1359 markers_cluster.setIgnoreHidden(true); 1360 if (typeof gmarkers !== 'undefined') { 1361 for (i = 0; i < gmarkers.length; i++) { 1362 if (gmarkers[i].area !== area && area !== 'all' && area !== '') { 1363 gmarkers[i].setVisible(false); 1364 } else if (gmarkers[i].city !== city && city !== 'all') { 1365 gmarkers[i].setVisible(false); 1366 } else if (parseInt(gmarkers[i].guests, 10) !== guests && guests !== 0) { 1367 gmarkers[i].setVisible(false); 1368 } else { 1369 gmarkers[i].setVisible(true); 1370 results_no = results_no + 1; 1371 bounds.extend(gmarkers[i].getPosition()); 1372 } 1373 }//end for 1374 markers_cluster.repaint(); 1375 }//end if 1376 1377 if (mapfunctions_vars.generated_pins === '0') { 1378 if (results_no === 0) { 1379 jQuery('#gmap-noresult').show(); 1380 jQuery('#results').hide(); 1381 } else { 1382 jQuery('#gmap-noresult').hide(); 1383 if (!bounds.isEmpty()) { 1384 wpestate_fit_bounds(bounds); 1385 } 1386 jQuery("#results, #showinpage,#showinpage_mobile").show(); 1387 1388 jQuery("#results_no").show().empty().append(results_no); 1389 } 1390 } else { 1391 wpestate_get_filtering_ajax_result(); 1392 } 1393} 1394 1395 1396///////////////////////////////////////////////////////////////////////////////////////////////// 1397/// get pin image 1398///////////////////////////////////////////////////////////////////////////////////////////////// 1399function wpestate_convertToSlug(Text) { 1400 "use strict"; 1401 return Text.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, ''); 1402} 1403 1404 1405function custompin(image) { 1406 "use strict"; 1407 1408 if( !mapfunctions_vars.hidden_map ){ 1409 1410 image ={ 1411 path: google.maps.SymbolPath.CIRCLE, 1412 scale: 60, 1413 fillColor: "#b881fc", 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 1788 for (var i = 0; i < gmarkers.length; i++) { 1789 1790 if (parseInt(gmarkers[i].idul, 10) === parseInt(listing_id, 10)) { 1791 1792 if(wprentals_map_type===1){ 1793 google.maps.event.trigger(gmarkers[i], 'click'); 1794 1795 if(mapfunctions_vars.useprice !== 'yes'){ 1796 gmarkers[i].setIcon( wprentals_custompinhover() ); 1797 }else{ 1798 gmarkers[i].addHoverClass(); 1799 } 1800 1801 marker_zindex=gmarkers[i].getZIndex(); 1802 gmarkers[i].setZIndex(9999999); 1803 }else if(wprentals_map_type===2){ 1804 1805 lealet_map_move_on_hover=1; 1806 if (! gmarkers[i]._icon) gmarkers[i].__parent.spiderfy(); 1807 map.panTo( gmarkers[i].getLatLng()); 1808 gmarkers[i].togglePopup(); 1809 1810 1811 if(mapfunctions_vars.useprice !== 'yes'){ 1812 gmarkers[i].setIcon(wprentals_custompinhover()); 1813 }else{ 1814 L.DomUtil.addClass(gmarkers[i]._icon, 'openstreet_price_marker_on_click_parent'); 1815 } 1816 1817 1818 } 1819 } 1820 } 1821 1822 1823 1824 1825} 1826 1827function wpestate_return_hover_action_pin(listing_id) { 1828 "use strict"; 1829 for (var i = 0; i < gmarkers.length; i++) { 1830 if (parseInt(gmarkers[i].idul, 10) === parseInt(listing_id, 10)) { 1831 1832 if(wprentals_map_type===1){ 1833 if (parseInt(gmarkers[i].idul, 10) === parseInt(listing_id, 10)) { 1834 infoBox.close(); 1835 if(mapfunctions_vars.useprice !== 'yes'){ 1836 gmarkers[i].setIcon(custompin(gmarkers[i].custompin)); 1837 }else{ 1838 gmarkers[i].removeHoverClass(); 1839 } 1840 gmarkers[i].setZIndex(marker_zindex); 1841 } 1842 } else if(wprentals_map_type===2){ 1843 1844 gmarkers[i].togglePopup(); 1845 lealet_map_move_on_hover=0; 1846 if(mapfunctions_vars.useprice !== 'yes'){ 1847 var markerImage = L.icon({ 1848 iconUrl: wprentals_custompin_leaflet(gmarkers[i].pin), 1849 iconSize: [44, 50], 1850 iconAnchor: [20, 50],
1851 popupAnchor: [1, -50] 1852 }); 1853 gmarkers[i].setIcon(markerImage); 1854 }else{ 1855 L.DomUtil.removeClass(gmarkers[i]._icon, 'openstreet_price_marker_on_click_parent'); 1856 } 1857 } 1858 1859 1860 } 1861 1862 } 1863 1864} 1865 1866String.prototype.capitalize = function () { 1867 return this.replace(/(?:^|\s)\S/g, function (a) { 1868 return a.toUpperCase(); 1869 }); 1870}; 1871 1872//////////////////////////////////////////////////////////////// 1873//map places 1874/////////////////////////////////////////////////////////////// 1875 1876var wpestate_initialize_poi = function ( map_for_poi,what){ 1877 1878 if( parseInt(mapbase_vars.wprentals_map_type)!==1){ 1879 return; 1880 } 1881 1882 var poi_service = new google.maps.places.PlacesService( map_for_poi ); 1883 var already_serviced = ''; 1884 var show_poi = ''; 1885 var map_bounds = map_for_poi.getBounds(); 1886 var selector = '.google_poi'; 1887 if(what==2){ 1888 selector = '.google_poish'; 1889 } 1890 1891 1892 1893 jQuery(selector).on('click',function(event){ 1894 event.stopPropagation(); 1895 poi_type = jQuery(this).attr('id'); 1896 var position = map_for_poi.getCenter(); 1897 var show_poi = wpestate_return_poi_values(poi_type); 1898 1899 1900 if( jQuery(this).hasClass('poi_active')){ 1901 wpestate_show_hide_poi(poi_type,'hide'); 1902 }else{ 1903 1904 already_serviced = wpestate_show_hide_poi(poi_type,'show'); 1905 if(already_serviced===1){ 1906 1907 var request = { 1908 location: position, 1909 types: show_poi, 1910 bounds: map_bounds, 1911 radius: 2500, 1912 }; 1913 poi_service.nearbySearch( request,function (results, status){ 1914 wpestate_googlemap_display_poi(results, status,map_for_poi); 1915 }); 1916 } 1917 } 1918 jQuery(this).toggleClass('poi_active'); 1919 }); 1920 1921 1922 1923 1924 1925 // return google poi types for selected poi 1926 var wpestate_return_poi_values = function (poi_type){ 1927 var show_poi; 1928 switch(poi_type) { 1929 case 'transport': 1930 show_poi = ['bus_station', 'airport', 'train_station', 'subway_station']; 1931 break; 1932 case 'supermarkets': 1933 show_poi = ['grocery_or_supermarket', 'shopping_mall']; 1934 break; 1935 case 'schools': 1936 show_poi = ['school', 'university']; 1937 break; 1938 case 'restaurant': 1939 show_poi=['restaurant']; 1940 break; 1941 case 'pharma': 1942 show_poi = ['pharmacy']; 1943 break; 1944 case 'hospitals': 1945 show_poi = ['hospital']; 1946 break; 1947 } 1948 return show_poi; 1949 }; 1950 1951 1952 // add poi markers on the map 1953 var wpestate_googlemap_display_poi = function (results, status,map_for_poi) { 1954 var place, poi_marker; 1955 if ( google.maps.places.PlacesServiceStatus.OK == status ) { 1956 for (var i = 0; i < results.length; i++) { 1957 poi_marker = wpestate_create_poi_marker(results[i],map_for_poi); 1958 poi_marker_array.push(poi_marker); 1959 } 1960 } 1961 }; 1962 1963 // create the poi markers 1964 var wpestate_create_poi_marker = function (place,map_for_poi){ 1965 marker = new google.maps.Marker({ 1966 map: map_for_poi, 1967 position: place.geometry.location, 1968 show_poi:poi_type, 1969 icon: mapfunctions_vars.path+'/poi/'+poi_type+'.png' 1970 }); 1971 1972 1973 var boxText = document.createElement("div"); 1974 var infobox_poi = new InfoBox({ 1975 content: boxText, 1976 boxClass:"estate_poi_box", 1977 pixelOffset: new google.maps.Size(-30, -70), 1978 zIndex: null, 1979 maxWidth: 275, 1980 closeBoxMargin: "-13px 0px 0px 0px", 1981 closeBoxURL: "", 1982 infoBoxClearance: new google.maps.Size(1, 1), 1983 pane: "floatPane", 1984 enableEventPropagation: false 1985 }); 1986 1987 google.maps.event.addListener(marker, 'mouseover', function(event) { 1988 infobox_poi.setContent(place.name); 1989 infobox_poi.open(map, this); 1990 }); 1991 1992 google.maps.event.addListener(marker, 'mouseout', function(event) { 1993 if( infobox_poi!== null){ 1994 infobox_poi.close(); 1995 } 1996 }); 1997 return marker; 1998 }; 1999 2000 2001 2002 // hide-show poi 2003 var wpestate_show_hide_poi = function (poi_type,showhide){ 2004 var is_hiding=1; 2005 2006 for (var i = 0; i < poi_marker_array.length; i++) { 2007 if (poi_marker_array[i].show_poi === poi_type){ 2008 if(showhide==='hide'){ 2009 poi_marker_array[i].setVisible(false); 2010 }else{ 2011 poi_marker_array[i].setVisible(true); 2012 is_hiding=0; 2013 } 2014 } 2015 } 2016 2017 return is_hiding; 2018 }; 2019}; 2020 2021 2022function wpestate_makeSafeForCSS(name) { 2023 return name.replace(/[^a-z0-9]/g, function(s) {
2024 var c = s.charCodeAt(0); 2025 if (c == 32) return '-'; 2026 if (c >= 65 && c <= 90) return s.toLowerCase(); 2027 return ('000' + c.toString(16)).slice(-4); 2028 }); 2029}
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.