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 image ={ 1409 path: google.maps.SymbolPath.CIRCLE, 1410 scale: 60, 1411 fillColor: "#b881fc", 1412 fillOpacity: 0.4, 1413 strokeWeight: 0.4 1414 } 1415 return image; 1416 } 1417 1418 1419 var custom_img; 1420 1421 var extension=''; 1422 var ratio = jQuery(window).dense('devicePixelRatio'); 1423 1424 if(ratio>1){ 1425 extension='_2x'; 1426 } 1427 1428 1429 if(mapfunctions_vars.use_single_image_pin==='no'){ 1430 if (image !== '') { 1431 if (images[image] === '') { 1432 custom_img = mapfunctions_vars.path + '/' + image + extension + '.png'; 1433 } else { 1434 custom_img = images[image]; 1435 if(ratio>1){ 1436 custom_img=custom_img.replace(".png","_2x.png"); 1437 } 1438 } 1439 } else { 1440 custom_img = mapfunctions_vars.path + '/none.png'; 1441 } 1442 1443 if (typeof (custom_img) === 'undefined') { 1444 custom_img = mapfunctions_vars.path + '/none.png'; 1445 } 1446 }else{ 1447 if(ratio>1){ 1448 custom_img= wpestate_get_custom_retina_pin( images['single_pin'] ); 1449 }else{ 1450 custom_img= images['single_pin']; 1451 } 1452 } 1453 1454 if(ratio>1){ 1455 1456 image = { 1457 url: custom_img, 1458 size : new google.maps.Size(44, 50), 1459 scaledSize : new google.maps.Size(44, 50), 1460 origin: new google.maps.Point(0, 0), 1461 optimized:false 1462 }; 1463 1464 }else{ 1465 image = { 1466 url: custom_img, 1467 size: new google.maps.Size(44, 50), 1468 origin: new google.maps.Point(0, 0), 1469 1470 }; 1471 } 1472 1473 1474 1475 return image; 1476} 1477 1478 1479function wprentals_custompinhover() { 1480 "use strict"; 1481 var custom_img, image; 1482 1483 var extension=''; 1484 var ratio = jQuery(window).dense('devicePixelRatio'); 1485 1486 if(ratio>1){ 1487 extension='_2x'; 1488 } 1489 1490 custom_img = mapfunctions_vars.path + '/hover'+extension+'.png'; 1491 1492 1493 if(wprentals_map_type===2){ 1494 1495 var markerImage = L.icon({ 1496 iconUrl: custom_img, 1497 iconSize: [44, 50], 1498 iconAnchor: [20, 50],
1499 popupAnchor: [1, -50] 1500 }); 1501 return markerImage; 1502 1503 } 1504 1505 1506 image = { 1507 url: custom_img, 1508 size: new google.maps.Size(44, 50), 1509 origin: new google.maps.Point(0, 0), 1510 // anchor: new google.maps.Point(26, 25) 1511 }; 1512 1513 if(ratio>1){ 1514 1515 image = { 1516 url: custom_img, 1517 size : new google.maps.Size(44, 50), 1518 scaledSize : new google.maps.Size(44, 50), 1519 origin: new google.maps.Point(0, 0), 1520 optimized:false 1521 1522 }; 1523 1524 }else{ 1525 image = { 1526 url: custom_img, 1527 size: new google.maps.Size(44, 50), 1528 origin: new google.maps.Point(0, 0), 1529 }; 1530 } 1531 1532 return image; 1533} 1534 1535 1536 1537function wpestate_get_custom_retina_pin(custom_img){ 1538 "use strict"; 1539 var custom_img_retina; 1540 custom_img_retina=custom_img.replace(".png","_2x.png"); 1541 1542 jQuery.get(custom_img_retina) 1543 .done(function() { 1544 custom_img = custom_img_retina; 1545 }).fail(function() { 1546 }); 1547 return custom_img; 1548} 1549 1550 1551 1552 1553///////////////////////////////////////////////////////////////////////////////////////////////// 1554//// Circle label 1555///////////////////////////////////////////////////////////////////////////////////////////////// 1556 1557function Label(opt_options) { 1558 "use strict"; 1559 // Initialization 1560 this.setValues(opt_options); 1561 // Label specific 1562 var span = this.span_ = document.createElement('span'); 1563 span.style.cssText = 'position: relative; left: -50%; top: 8px; ' + 1564 'white-space: nowrap; ' + 1565 'padding: 2px; background-color: white;opacity:0.7'; 1566 1567 1568 var div = this.div_ = document.createElement('div'); 1569 div.appendChild(span); 1570 div.style.cssText = 'position: absolute; display: none'; 1571} 1572 1573 1574if (typeof google === 'object' && typeof google.maps === 'object') { 1575 Label.prototype = new google.maps.OverlayView; 1576 // Implement onAdd 1577 Label.prototype.onAdd = function () { 1578 var pane = this.getPanes().overlayImage; 1579 pane.appendChild(this.div_); 1580 1581 // Ensures the label is redrawn if the text or position is changed. 1582 var me = this; 1583 this.listeners_ = [ 1584 google.maps.event.addListener(this, 'position_changed', function () { 1585 me.draw(); 1586 }), 1587 google.maps.event.addListener(this, 'visible_changed', function () { 1588 me.draw(); 1589 }), 1590 google.maps.event.addListener(this, 'clickable_changed', function () { 1591 me.draw(); 1592 }), 1593 google.maps.event.addListener(this, 'text_changed', function () { 1594 me.draw(); 1595 }), 1596 google.maps.event.addListener(this, 'zindex_changed', function () { 1597 me.draw(); 1598 }), 1599 google.maps.event.addDomListener(this.div_, 'click', function () { 1600 if (me.get('clickable')) { 1601 google.maps.event.trigger(me, 'click'); 1602 } 1603 }) 1604 ]; 1605 }; 1606 1607 // Implement onRemove 1608 Label.prototype.onRemove = function () { 1609 this.div_.parentNode.removeChild(this.div_); 1610 // Label is removed from the map, stop updating its position/text. 1611 for (var i = 0, I = this.listeners_.length; i < I; ++i) { 1612 google.maps.event.removeListener(this.listeners_[i]); 1613 } 1614 }; 1615 1616 1617 // Implement draw 1618 Label.prototype.draw = function () { 1619 var projection = this.getProjection(); 1620 var position = projection.fromLatLngToDivPixel(this.get('position')); 1621 var div = this.div_; 1622 div.style.left = position.x + 'px'; 1623 div.style.top = position.y + 'px'; 1624 1625 1626 var visible = this.get('visible'); 1627 div.style.display = visible ? 'block' : 'none'; 1628 1629 1630 var clickable = this.get('clickable'); 1631 this.span_.style.cursor = clickable ? 'pointer' : ''; 1632 1633 1634 var zIndex = this.get('zIndex'); 1635 div.style.zIndex = zIndex; 1636 1637 1638 this.span_.innerHTML = this.get('text').toString(); 1639 }; 1640} 1641 1642 1643///////////////////////////////////////////////////////////////////////////////////////////////// 1644/// close advanced search 1645///////////////////////////////////////////////////////////////////////////////////////////////// 1646function wpestate_close_adv_search() { 1647 1648} 1649 1650 1651function wpestate_new_show_advanced_search() { 1652 "use strict"; 1653 jQuery("#search_wrapper").removeClass("hidden"); 1654} 1655 1656function wpestate_new_hide_advanced_search() { 1657 "use strict"; 1658 if (mapfunctions_vars.show_adv_search === 'no') { 1659 jQuery("#search_wrapper").addClass("hidden"); 1660 } 1661} 1662 1663 1664function wpestate_set_filter_pins(map, new_markers) { 1665 "use strict"; 1666 if(wprentals_map_type===1){ 1667 for (var i = 0; i < gmarkers.length; i++) { 1668 gmarkers[i].setVisible(false); 1669 gmarkers[i].setMap(null); 1670 } 1671 gmarkers = []; 1672 1673 1674 if( typeof (markers_cluster)!=='undefined'){ 1675 markers_cluster.clearMarkers(); 1676 } 1677 1678 if (new_markers.length > 0) { 1679 bounds_list = new google.maps.LatLngBounds(); 1680 wprentals_map_general_set_markers(map, new_markers); 1681 wprentals_google_map_cluster();
1682 wprentals_google_fit_to_bounds(); 1683 } 1684 1685 } else if(wprentals_map_type===2){ 1686 1687 if (mapfunctions_vars.user_cluster === 'yes') { 1688 map.removeLayer(markers_cluster); 1689 }else{ 1690 for (var i = 0; i < gmarkers.length; i++) { 1691 map.removeLayer(gmarkers[i]); 1692 } 1693 } 1694 1695 gmarkers = []; 1696 markers_cluster=L.markerClusterGroup({ 1697 showCoverageOnHover: false, 1698 iconCreateFunction: function(cluster) { 1699 return L.divIcon({ html: '<div class="leaflet_cluster" style="background-image: url('+images['cloud_pin']+')">' + cluster.getChildCount() + '</div>' }); 1700 }, 1701 }); 1702 1703 if (new_markers.length > 0) { 1704 1705 bounds_list =undefined; 1706 wprentals_map_general_set_markers(map, new_markers); 1707 //set map cluster 1708 wprentals_map_general_cluster(); 1709 //fit bounds 1710 wprentals_map_general_fit_to_bounds(); 1711 } 1712 wprentals_map_general_cluster(); 1713 1714 } 1715 1716} 1717 1718 1719function wpestate_set_filter_pins_ondemand(map, new_markers) { 1720 "use strict"; 1721 if(wprentals_map_type===1){ 1722 1723 for (var i = 0; i < gmarkers.length; i++) { 1724 gmarkers[i].setVisible(false); 1725 gmarkers[i].setMap(null); 1726 } 1727 gmarkers = []; 1728 1729 if (new_markers.length > 0) { 1730 if( typeof (markers_cluster)!=='undefined'){ 1731 markers_cluster.clearMarkers(); 1732 } 1733 wprentals_google_setMarkers(map, new_markers); 1734 wprentals_google_map_cluster(); 1735 1736 } 1737 1738 oms = new OverlappingMarkerSpiderfier(map); 1739 setOms(gmarkers); 1740 oms.addListener('spiderfy', function (markers) { 1741 }); 1742 oms.addListener('unspiderfy ', function (markers) { 1743 }); 1744 1745 1746 } else if(wprentals_map_type===2){ 1747 1748 if (mapfunctions_vars.user_cluster === 'yes') { 1749 map.removeLayer(markers_cluster); 1750 }else{ 1751 for (var i = 0; i < gmarkers.length; i++) { 1752 map.removeLayer(gmarkers[i]); 1753 } 1754 } 1755 1756 gmarkers = []; 1757 markers_cluster=L.markerClusterGroup({ 1758 showCoverageOnHover: false, 1759 iconCreateFunction: function(cluster) { 1760 return L.divIcon({ html: '<div class="leaflet_cluster" style="background-image: url('+images['cloud_pin']+')">' + cluster.getChildCount() + '</div>' }); 1761 }, 1762 }); 1763 1764 if (new_markers.length > 0) { 1765 bounds_list = map.getBounds(); 1766 wprentals_map_general_set_markers(map, new_markers); 1767 } 1768 wprentals_map_general_cluster(); 1769 1770 1771 1772 } 1773 1774} 1775 1776 1777 1778 1779 1780 1781var marker_zindex; 1782 1783function wpestate_hover_action_pin(listing_id) { 1784 "use strict"; 1785 wpestate_hover_action_flag=1; 1786 1787 for (var i = 0; i < gmarkers.length; i++) { 1788 1789 if (parseInt(gmarkers[i].idul, 10) === parseInt(listing_id, 10)) { 1790 1791 if(wprentals_map_type===1){ 1792 google.maps.event.trigger(gmarkers[i], 'click'); 1793 map_geo_first_load=0; 1794 if(mapfunctions_vars.useprice !== 'yes'){ 1795 gmarkers[i].setIcon( wprentals_custompinhover() ); 1796 }else{ 1797 gmarkers[i].addHoverClass(); 1798 } 1799 1800 marker_zindex=gmarkers[i].getZIndex(); 1801 gmarkers[i].setZIndex(9999999); 1802 }else if(wprentals_map_type===2){ 1803 1804 lealet_map_move_on_hover=1; 1805 if (! gmarkers[i]._icon) gmarkers[i].__parent.spiderfy(); 1806 map.panTo( gmarkers[i].getLatLng()); 1807 gmarkers[i].togglePopup(); 1808 1809 1810 if(mapfunctions_vars.useprice !== 'yes'){ 1811 gmarkers[i].setIcon(wprentals_custompinhover()); 1812 }else{ 1813 L.DomUtil.addClass(gmarkers[i]._icon, 'openstreet_price_marker_on_click_parent'); 1814 } 1815 1816 1817 } 1818 } 1819 } 1820 1821 1822 1823 1824} 1825 1826function wpestate_return_hover_action_pin(listing_id) { 1827 "use strict"; 1828 wpestate_hover_action_flag=0; 1829 map_geo_first_load=1 ; 1830 external_action_ondemand=0; 1831 for (var i = 0; i < gmarkers.length; i++) { 1832 if (parseInt(gmarkers[i].idul, 10) === parseInt(listing_id, 10)) { 1833 1834 if(wprentals_map_type===1){ 1835 if (parseInt(gmarkers[i].idul, 10) === parseInt(listing_id, 10)) { 1836 infoBox.close(); 1837 if(mapfunctions_vars.useprice !== 'yes'){ 1838 gmarkers[i].setIcon(custompin(gmarkers[i].custompin)); 1839 }else{ 1840 gmarkers[i].removeHoverClass(); 1841 } 1842 gmarkers[i].setZIndex(marker_zindex); 1843 } 1844 } else if(wprentals_map_type===2){ 1845 1846 gmarkers[i].togglePopup(); 1847 lealet_map_move_on_hover=0; 1848 if(mapfunctions_vars.useprice !== 'yes'){ 1849 var markerImage = L.icon({ 1850 iconUrl: wprentals_custompin_leaflet(gmarkers[i].pin), 1851 iconSize: [44, 50], 1852 iconAnchor: [20, 50],
1853 popupAnchor: [1, -50] 1854 }); 1855 gmarkers[i].setIcon(markerImage); 1856 }else{ 1857 L.DomUtil.removeClass(gmarkers[i]._icon, 'openstreet_price_marker_on_click_parent'); 1858 } 1859 } 1860 1861 1862 } 1863 1864 } 1865 1866} 1867 1868String.prototype.capitalize = function () { 1869 return this.replace(/(?:^|\s)\S/g, function (a) { 1870 return a.toUpperCase(); 1871 }); 1872}; 1873 1874//////////////////////////////////////////////////////////////// 1875//map places 1876/////////////////////////////////////////////////////////////// 1877 1878var wpestate_initialize_poi = function ( map_for_poi,what){ 1879 1880 if( parseInt(mapbase_vars.wprentals_map_type)!==1){ 1881 return; 1882 } 1883 1884 var poi_service = new google.maps.places.PlacesService( map_for_poi ); 1885 var already_serviced = ''; 1886 var show_poi = ''; 1887 var map_bounds = map_for_poi.getBounds(); 1888 var selector = '.google_poi'; 1889 if(what==2){ 1890 selector = '.google_poish'; 1891 } 1892 1893 1894 1895 jQuery(selector).on('click',function(event){ 1896 event.stopPropagation(); 1897 poi_type = jQuery(this).attr('id'); 1898 var position = map_for_poi.getCenter(); 1899 var show_poi = wpestate_return_poi_values(poi_type); 1900 1901 1902 if( jQuery(this).hasClass('poi_active')){ 1903 wpestate_show_hide_poi(poi_type,'hide'); 1904 }else{ 1905 1906 already_serviced = wpestate_show_hide_poi(poi_type,'show'); 1907 if(already_serviced===1){ 1908 1909 var request = { 1910 location: position, 1911 types: show_poi, 1912 bounds: map_bounds, 1913 radius: 2500, 1914 }; 1915 poi_service.nearbySearch( request,function (results, status){ 1916 wpestate_googlemap_display_poi(results, status,map_for_poi); 1917 }); 1918 } 1919 } 1920 jQuery(this).toggleClass('poi_active'); 1921 }); 1922 1923 1924 1925 1926 1927 // return google poi types for selected poi 1928 var wpestate_return_poi_values = function (poi_type){ 1929 var show_poi; 1930 switch(poi_type) { 1931 case 'transport': 1932 show_poi = ['bus_station', 'airport', 'train_station', 'subway_station']; 1933 break; 1934 case 'supermarkets': 1935 show_poi = ['grocery_or_supermarket', 'shopping_mall']; 1936 break; 1937 case 'schools': 1938 show_poi = ['school', 'university']; 1939 break; 1940 case 'restaurant': 1941 show_poi=['restaurant']; 1942 break; 1943 case 'pharma': 1944 show_poi = ['pharmacy']; 1945 break; 1946 case 'hospitals': 1947 show_poi = ['hospital']; 1948 break; 1949 } 1950 return show_poi; 1951 }; 1952 1953 1954 // add poi markers on the map 1955 var wpestate_googlemap_display_poi = function (results, status,map_for_poi) { 1956 var place, poi_marker; 1957 if ( google.maps.places.PlacesServiceStatus.OK == status ) { 1958 for (var i = 0; i < results.length; i++) { 1959 poi_marker = wpestate_create_poi_marker(results[i],map_for_poi); 1960 poi_marker_array.push(poi_marker); 1961 } 1962 } 1963 }; 1964 1965 // create the poi markers 1966 var wpestate_create_poi_marker = function (place,map_for_poi){ 1967 marker = new google.maps.Marker({ 1968 map: map_for_poi, 1969 position: place.geometry.location, 1970 show_poi:poi_type, 1971 icon: mapfunctions_vars.path+'/poi/'+poi_type+'.png' 1972 }); 1973 1974 1975 var boxText = document.createElement("div"); 1976 var infobox_poi = new InfoBox({ 1977 content: boxText, 1978 boxClass:"estate_poi_box", 1979 pixelOffset: new google.maps.Size(-30, -70), 1980 zIndex: null, 1981 maxWidth: 275, 1982 closeBoxMargin: "-13px 0px 0px 0px", 1983 closeBoxURL: "", 1984 infoBoxClearance: new google.maps.Size(1, 1), 1985 pane: "floatPane", 1986 enableEventPropagation: false 1987 }); 1988 1989 google.maps.event.addListener(marker, 'mouseover', function(event) { 1990 infobox_poi.setContent(place.name); 1991 infobox_poi.open(map, this); 1992 }); 1993 1994 google.maps.event.addListener(marker, 'mouseout', function(event) { 1995 if( infobox_poi!== null){ 1996 infobox_poi.close(); 1997 } 1998 }); 1999 return marker; 2000 }; 2001 2002 2003 2004 // hide-show poi 2005 var wpestate_show_hide_poi = function (poi_type,showhide){ 2006 var is_hiding=1; 2007 2008 for (var i = 0; i < poi_marker_array.length; i++) { 2009 if (poi_marker_array[i].show_poi === poi_type){ 2010 if(showhide==='hide'){ 2011 poi_marker_array[i].setVisible(false); 2012 }else{ 2013 poi_marker_array[i].setVisible(true); 2014 is_hiding=0; 2015 } 2016 } 2017 } 2018 2019 return is_hiding; 2020 }; 2021}; 2022 2023 2024function wpestate_makeSafeForCSS(name) { 2025 return name.replace(/[^a-z0-9]/g, function(s) {
2026 var c = s.charCodeAt(0); 2027 if (c == 32) return '-'; 2028 if (c >= 65 && c <= 90) return s.toLowerCase(); 2029 return ('000' + c.toString(16)).slice(-4); 2030 }); 2031}
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.