1/** 2 * This jQuery plugin displays map and it's components. 3 * @author Flipper Code (hello *at* flippercode *dot* com) 4 * @version 1.0 5 */ 6(function($, window, document, undefined) { 7 8 9 10 function Map_Control(options) { 11 this.options = options; 12 } 13 14 Map_Control.prototype.create_element = function(controlDiv, map, html_element) { 15 16 // Set CSS for the control border 17 controlDiv.className = 'wpgmp-control-outer'; 18 var controlUI = document.createElement('div'); 19 controlUI.className = 'wpgmp-control-inner'; 20 controlDiv.appendChild(controlUI); 21 22 // Set CSS for the control interior 23 var controlText = document.createElement('div'); 24 controlText.className = 'wpgmp-control-content'; 25 controlText.innerHTML = html_element; 26 controlUI.appendChild(controlText); 27 }; 28 29 function overlay_generator(tileSize, options) { 30 this.tileSize = tileSize; 31 this.overlay_options = options; 32 } 33 34 overlay_generator.prototype.getTile = function(coord, zoom, ownerDocument) { 35 var div = ownerDocument.createElement("div"); 36 div.innerHTML = coord; 37 div.style.width = "200px"; 38 div.style.height = "300px"; 39 div.style.fontSize = this.overlay_options.font_size + "px"; 40 div.style.borderStyle = this.overlay_options.border_style; 41 div.style.borderWidth = this.overlay_options.border_width + "px"; 42 div.style.borderColor = this.overlay_options.border_color; 43 return div; 44 }; 45 46 function GoogleMaps(element, map_data) { 47 var options; 48 this.element = element; 49 this.map_data = $.extend({}, {}, map_data); 50 options = this.map_data.map_options; 51 this.settings = $.extend({ 52 "min_zoom": "0", 53 "max_zoom": "19", 54 "zoom": "5", 55 "map_type_id": "ROADMAP", 56 "scroll_wheel": true, 57 "map_visual_refresh": false, 58 "full_screen_control": false, 59 "full_screen_control_position": "BOTTOM_RIGHT", 60 "zoom_control": true, 61 "zoom_control_style": "SMALL", 62 "zoom_control_position": "TOP_LEFT", 63 "map_type_control": true, 64 "map_type_control_style": "HORIZONTAL_BAR", 65 "map_type_control_position": "RIGHT_TOP", 66 "scale_control": true, 67 "street_view_control": true, 68 "street_view_control_position": "TOP_LEFT", 69 "overview_map_control": true, 70 "center_lat": "40.6153983", 71 "center_lng": "-74.2535216", 72 "draggable": true, 73 "gesture" : "auto", 74 }, {}, options); 75 this.container = $("div[rel='" + $(this.element).attr("id") + "']"); 76 var suppress_markers = false; 77 if (this.map_data.map_tabs && this.map_data.map_tabs.direction_tab) { 78 suppress_markers = this.map_data.map_tabs.direction_tab.suppress_markers; 79 } 80 this.directionsService = new google.maps.DirectionsService(); 81 this.directionsDisplay = new google.maps.DirectionsRenderer({ 82 suppressMarkers: suppress_markers, 83 }); 84 this.drawingmanager = {}; 85 this.geocoder = new google.maps.Geocoder(); 86 this.places = []; 87 this.show_places = []; 88 this.categories = {}; 89 this.tabs = []; 90 this.all_shapes = []; 91 this.wpgmp_polylines = []; 92 this.wpgmp_polygons = []; 93 this.wpgmp_circles = []; 94 this.wpgmp_shape_events = []; 95 this.wpgmp_rectangles = []; 96 this.per_page_value = 0; 97 this.current_amenities = []; 98 this.route_directions = []; 99 this.search_area = ''; 100 this.markerClusterer = null; 101 this.url_filters = []; 102 this.infowindow_marker = new google.maps.InfoWindow(); 103 this.infobox = new InfoBox(); 104 this.init(); 105 } 106 107 GoogleMaps.prototype = { 108 109 init: function() { 110 var map_obj = this; 111 112 if( map_obj.map_data.map_property && map_obj.map_data.map_property.debug_mode == true) { 113 console.log('*********WPGMP Debug Mode Output*********'); 114 console.log('Map ID =' + map_obj.map_data.map_property.map_id); 115 if(map_obj.map_data.places) 116 { 117 console.log('Total Locations=' + map_obj.map_data.places.length); 118 } 119 if(map_obj.map_data.routes) 120 { 121 console.log('Total Routes=' + map_obj.map_data.routes.length); 122 } 123 console.log('WPGMP Object='); 124 console.log(map_obj.map_data); 125 console.log('*********WPGMP Debug Mode End Output*********'); 126 } 127 var isMobile = false;
128 129 var screen_type = 'desktop'; 130 131 var screen_size = $(window).width(); 132 if ( screen_size <= 480 ) { 133 screen_type = 'smartphones'; 134 } else if( screen_size > 480 && screen_size <= 768 ) { 135 screen_type = 'ipads'; 136 } else if( screen_size >= 1824 ) { 137 screen_type = 'large-screens'; 138 } 139 140 if (screen_type !='desktop' && map_obj.settings.mobile_specific == true ) { 141 142 isMobile = true; 143 144 if( map_obj.settings.screens && map_obj.settings.screens[screen_type] ) { 145 146 map_obj.settings.width_mobile = map_obj.settings.screens[screen_type].map_width_mobile; 147 map_obj.settings.height_mobile = map_obj.settings.screens[screen_type].map_height_mobile; 148 map_obj.settings.zoom = parseInt(map_obj.settings.screens[screen_type].map_zoom_level_mobile); 149 map_obj.settings.draggable = (map_obj.settings.screens[screen_type].map_draggable_mobile !== 'false'); 150 map_obj.settings.scroll_wheel = ( map_obj.settings.screens[screen_type].map_scrolling_wheel_mobile !=='false'); 151 152 } else { 153 map_obj.settings.width_mobile = ''; 154 map_obj.settings.height_mobile = ''; 155 } 156 157 if( map_obj.settings.width_mobile!='' ) 158 $(map_obj.element).css('width', map_obj.settings.width_mobile); 159 160 if( map_obj.settings.height_mobile!='' ) 161 $(map_obj.element).css('height', map_obj.settings.height_mobile); 162 } 163 164 var center = new google.maps.LatLng(map_obj.settings.center_lat, map_obj.settings.center_lng); 165 map_obj.map = new google.maps.Map(map_obj.element, { 166 zoom: parseInt(map_obj.settings.zoom), 167 center: center, 168 disableDoubleClickZoom: (map_obj.settings.doubleclickzoom === true), 169 scrollwheel: map_obj.settings.scroll_wheel, 170 zoomControl: (map_obj.settings.zoom_control === true), 171 fullscreenControl: (map_obj.settings.full_screen_control === true), 172 fullscreenControlOptions: { 173 position: eval("google.maps.ControlPosition." + map_obj.settings.full_screen_control_position) 174 }, 175 zoomControlOptions: { 176 style: eval("google.maps.ZoomControlStyle." + map_obj.settings.zoom_control_style), 177 position: eval("google.maps.ControlPosition." + map_obj.settings.zoom_control_position) 178 }, 179 mapTypeControl: (map_obj.settings.map_type_control == true), 180 mapTypeControlOptions: { 181 style: eval("google.maps.MapTypeControlStyle." + map_obj.settings.map_type_control_style), 182 position: eval("google.maps.ControlPosition." + map_obj.settings.map_type_control_position) 183 }, 184 scaleControl: (map_obj.settings.scale_control == true), 185 streetViewControl: (map_obj.settings.street_view_control == true), 186 streetViewControlOptions: { 187 position: eval("google.maps.ControlPosition." + map_obj.settings.street_view_control_position) 188 }, 189 overviewMapControl: (map_obj.settings.overview_map_control == true), 190 overviewMapControlOptions: { 191 opened: map_obj.settings.overview_map_control 192 }, 193 draggable: map_obj.settings.draggable, 194 mapTypeId: eval("google.maps.MapTypeId." + map_obj.settings.map_type_id), 195 styles: eval(map_obj.map_data.styles), 196 minZoom: parseInt(map_obj.settings.min_zoom), 197 maxZoom: parseInt(map_obj.settings.max_zoom), 198 gestureHandling: map_obj.settings.gesture, 199 }); 200 201 map_obj.map_loaded(); 202 map_obj.responsive_map(); 203 map_obj.create_markers(); 204 map_obj.display_markers(); 205 206 //Load google fonts 207 if(typeof map_obj.settings.google_fonts !== 'undefined'){ 208 map_obj.load_google_fonts(map_obj.settings.google_fonts); 209 } 210 if (map_obj.settings.map_control == true) { 211 if (typeof map_obj.settings.map_control_settings != 'undefined') { 212 var map_control_obj = new Map_Control(); 213 $.each(map_obj.settings.map_control_settings, function(k, val) { 214 var centerControlDiv = document.createElement('div');
215 map_control_obj.create_element(centerControlDiv, map_obj.map, val.html); 216 centerControlDiv.index = 1; 217 map_obj.map.controls[eval("google.maps.ControlPosition." + val.position)].push(centerControlDiv); 218 }); 219 } 220 } 221 222 //CUSTOM CONTROLS UI 223 if (map_obj.settings.locateme_control == true && map_obj.settings.locateme_control_position) { 224 var map_control_obj = new Map_Control(); 225 var centerControlDiv = document.createElement('div'); 226 map_control_obj.create_element(centerControlDiv, map_obj.map, "<span title='"+wpgmp_local.locate_me+"' alt class='wpgmp_locateme_control "+map_obj.settings.locateme_control_position.toLowerCase()+"'></span>"); 227 map_obj.map.controls[eval("google.maps.ControlPosition." + map_obj.settings.locateme_control_position)].push(centerControlDiv); 228 } 229 230 if ( map_obj.map_data.street_view ) { 231 map_obj.set_streetview(center); 232 } 233 234 if ( map_obj.map_data.weather_layer) { 235 map_obj.set_weather_layer(); 236 } 237 238 if ( map_obj.map_data.bicyle_layer) { 239 map_obj.set_bicyle_layer(); 240 } 241 242 if ( map_obj.map_data.traffic_layer) { 243 map_obj.set_traffic_layer(); 244 } 245 246 if (map_obj.map_data.transit_layer) { 247 map_obj.set_transit_layer(); 248 } 249 250 if ( map_obj.map_data.panoramio_layer ) { 251 map_obj.set_panoramic_layer(); 252 } 253 254 if ( map_obj.map_data.overlay_setting ) { 255 map_obj.set_overlay(); 256 } 257 258 if (map_obj.settings.display_45_imagery == '45') { 259 map_obj.set_45_imagery(); 260 } 261 262 if (typeof map_obj.map_data.map_visual_refresh === true) { 263 map_obj.set_visual_refresh(); 264 } 265 266 if ( map_obj.map_data.marker_cluster ) { 267 map_obj.set_marker_cluster(); 268 } 269 270 if ( map_obj.map_data.panning_control ) { 271 map_obj.set_panning_control(); 272 } 273 274 if ( map_obj.map_data.kml_layer ) { 275 map_obj.set_kml_layer(); 276 } 277 278 if ( map_obj.map_data.fusion_layer ) { 279 map_obj.set_fusion_layer(); 280 } 281 282 if (map_obj.settings.search_control == true) { 283 map_obj.show_search_control(); 284 } 285 286 if (typeof map_obj.map_data.shapes != 'undefined') { 287 288 if (typeof map_obj.map_data.shapes.shape != 'undefined') { 289 map_obj.opened_info = map_obj.infowindow_marker; 290 if (typeof map_obj.map_data.shapes.shape.polygons != 'undefined') 291 map_obj.create_polygon(); 292 293 if (typeof map_obj.map_data.shapes.shape.polylines != 'undefined') 294 map_obj.create_polyline(); 295 296 if (typeof map_obj.map_data.shapes.shape.circles != 'undefined') 297 map_obj.create_circle(); 298 299 if (typeof map_obj.map_data.shapes.shape.rectangles != 'undefined') 300 map_obj.create_rectangle(); 301 } 302 } 303 304 if ( map_obj.map_data.routes ) { 305 map_obj.create_routes(); 306 } 307 308 if ( map_obj.map_data.listing ) { 309 if ( map_obj.map_data.listing.default_sorting ) { 310 var data_type = ''; 311 if( map_obj.map_data.listing.default_sorting.orderby == 'listorder') { 312 data_type = 'num'; 313 } 314 map_obj.sorting(map_obj.map_data.listing.default_sorting.orderby, map_obj.map_data.listing.default_sorting.inorder,data_type); 315 } 316 317 } 318 319 if ( map_obj.map_data.listing ) { 320 321 $(map_obj.container).on('change','[data-filter="dropdown"]', function() { 322 map_obj.update_filters(); 323 }); 324 325 $(map_obj.container).on('click','[data-filter="checklist"]', function() { 326 map_obj.update_filters(); 327 }); 328 329 $(map_obj.container).on('click','[data-filter="list"]', function() { 330 331 if($(this).hasClass('fc_selected')) { 332 $(this).removeClass('fc_selected'); 333 } else { 334 $(this).addClass('fc_selected'); 335 } 336 337 map_obj.update_filters(); 338 }); 339 340 341 map_obj.display_filters_listing(); 342 map_obj.custom_filters(); 343 344 $.each(map_obj.map_data.listing.filters, function(key, filter) { 345 346 $(map_obj.container).find('select[name="' + filter + '"]').on('change', function() { 347 map_obj.update_filters(); 348 }); 349 350 }); 351 352 $(map_obj.container).find('[data-filter="map-sorting"]').on('change', function() { 353 354 var order_data = $(this).val().split("__"); 355 var data_type = ''; 356 if (order_data[0] !== '' && order_data[1] !== '') { 357 358 if(typeof order_data[2] !='undefined') { 359 data_type = order_data[2]; 360 } 361 map_obj.sorting(order_data[0], order_data[1],data_type); 362 map_obj.update_places_listing(); 363 364 } 365 366 }); 367 368 $(map_obj.container).find('[data-name="radius"]').on('change', function() { 369 370 var search_data = $(map_obj.container).find('[data-input="wpgmp-search-text"]').val(); 371 if (search_data.length >= 2 && $(this).val() != '') { 372 map_obj.geocoder.geocode({ 373 "address": search_data 374 }, function(results, status) { 375 376 if (status == google.maps.GeocoderStatus.OK) { 377 map_obj.search_area = results[0].geometry.location; 378 map_obj.update_filters(); 379 } 380 381 }); 382 } else { 383 map_obj.search_area = ''; 384 map_obj.update_filters(); 385 } 386 387 388 }); 389 390 $(map_obj.container).find('[data-filter="map-perpage-location-sorting"]').on('change', function() { 391 392 map_obj.per_page_value = $(this).val(); 393 map_obj.update_filters(); 394 395 }); 396 397 $(map_obj.container).find('[data-input="wpgmp-search-text"]').on('keyup', function() { 398 var search_data = $(this).val(); 399 $(map_obj.container).find('[data-filter="map-radius"]').val(''); 400 map_obj.search_area = ''; 401 // Apply default radius 402 if( search_data.length >
402= 2 && map_obj.map_data.listing.apply_default_radius == true ) { 403 if (search_data.length >= 2) { 404 map_obj.geocoder.geocode({ 405 "address": search_data 406 }, function(results, status) { 407 408 if (status == google.maps.GeocoderStatus.OK) { 409 map_obj.search_area = results[0].geometry.location; 410 map_obj.update_filters(); 411 } 412 413 }); 414 } 415 416 } else { 417 map_obj.update_filters(); 418 } 419 420 421 }); 422 423 $(map_obj.container).find(".location_pagination" + map_obj.map_data.map_property.map_id).pagination(map_obj.show_places.length, { 424 callback: map_obj.display_places_listing, 425 map_data: map_obj, 426 items_per_page: map_obj.map_data.listing.pagination.listing_per_page, 427 prev_text: wpgmp_local.prev, 428 next_text: wpgmp_local.next 429 }); 430 431 // $(map_obj.container).find('.wpgmp_locations').responsiveEqualHeightGrid(); 432 433 //Print listing 434 $(map_obj.container).find('[data-action="wpgmp-print"]').on('click', function() { 435 if ($('[data-container="wpgmp-listing-' + $(map_obj.element).attr("id") + '"]').length > 0) { 436 $('[data-container="wpgmp-listing-' + $(map_obj.element).attr("id") + '"]').print(); 437 } 438 439 if ($('[data-container="wpgmp-custom-listing-' + $(map_obj.element).attr("id") + '"]').length > 0) 440 $('[data-container="wpgmp-custom-listing-' + $(map_obj.element).attr("id") + '"]').print(); 441 }); 442 443 } 444 445 $('.wpgmp-shape-delete').click(function() { 446 447 map_obj.deleteSelectedShape(); 448 $('.hiderow').hide(); 449 }); 450 451 $('select[name="shape_stroke_opacity"]').change(function() { 452 map_obj.set_shapes_options(map_obj.selectedShape); 453 }); 454 $('select[name="shape_stroke_weight"]').change(function() { 455 map_obj.set_shapes_options(map_obj.selectedShape); 456 }); 457 $('select[name="shape_stroke_color"]').change(function() { 458 map_obj.set_shapes_options(map_obj.selectedShape); 459 }); 460 $('select[name="shape_fill_opacity"]').change(function() { 461 map_obj.set_shapes_options(map_obj.selectedShape); 462 }); 463 $('select[name="shape_fill_color"]').change(function() { 464 map_obj.set_shapes_options(map_obj.selectedShape); 465 }); 466 $('input[name="shape_click_url"]').change(function() { 467 map_obj.set_shapes_options(map_obj.selectedShape); 468 }); 469 $('textarea[name="shape_click_message"]').blur(function() { 470 map_obj.set_shapes_options(map_obj.selectedShape); 471 }); 472 473 $("textarea[name='shape_path']").blur(function() { 474 var cordinates = $(this).val().split(' '); 475 if (cordinates.length == 1) { 476 cordinates = $(this).val().split("\n"); 477 } 478 var path = []; 479 $.each(cordinates, function(ind, cordinate) { 480 var latlng = cordinate.split(','); 481 path.push(new google.maps.LatLng(latlng[0], latlng[1])); 482 }); 483 map_obj.selectedShape.setPath(path); 484 }); 485 486 $("input[name='shape_radius']").blur(function() { 487 var radius = parseFloat($(this).val()); 488 map_obj.selectedShape.setRadius(radius); 489 }); 490 491 $("input[name='shape_center']").blur(function() { 492 var latlng = $(this).val().split(','); 493 map_obj.selectedShape.setCenter(new google.maps.LatLng(parseFloat(latlng[0]), parseFloat(latlng[1]))); 494 }); 495 496 $("input[name='shape_northeast']").blur(function() { 497 var ea = $(this).val().split(','); 498 var sw = $("input[name='shape_southwest']").val().split(','); 499 500 map_obj.selectedShape.setBounds(new google.maps.LatLngBounds(new google.maps.LatLng(parseFloat(sw[0]), parseFloat(sw[1])), new google.maps.LatLng(parseFloat(ea[0]), parseFloat(ea[1])))); 501 }); 502 503 $("input[name='shape_southwest']").blur(function() { 504 var sw = $(this).val().split(','); 505 var ea = $("input[name='shape_northeast']").val().split(','); 506 507 map_obj.selectedShape.setBounds(new google.maps.LatLngBounds(new google.maps.LatLng(parseFloat(sw[0]), parseFloat(sw[1])), new google.maps.LatLng(parseFloat(ea[0]), parseFloat(ea[1])))); 508 }); 509 510 $("input[name='shape_center']").blur(function() { 511 var latlng = $(this).val().split(','); 512 map_obj.selectedShape.setCenter(new google.maps.LatLng(parseFloat(latlng[0]), parseFloat(latlng[1]))); 513 }); 514 515 $('input[name="wpgmp_save_drawing"]').click(function() { 516 517 var all_shapes_cordinate = []; 518
519 all_shapes_cordinate.push('polylines=' + map_obj.wpgmp_save_polylines().join('::')); 520 all_shapes_cordinate.push('polygons=' + map_obj.wpgmp_save_polygons().join('::')); 521 all_shapes_cordinate.push('circles=' + map_obj.wpgmp_save_circles().join('::')); 522 all_shapes_cordinate.push('rectangles=' + map_obj.wpgmp_save_rectangles().join('::')); 523 524 map_obj.wpgmp_save_shapes(all_shapes_cordinate); 525 526 }); 527 if (typeof map_obj.map_data.shapes != 'undefined') { 528 if (map_obj.map_data.shapes.drawing_editable === true) { 529 $('.wpgmp-overview .color').wpColorPicker({ 530 change: function(event, ui) { 531 map_obj.set_shapes_options(map_obj.selectedShape); 532 } 533 }); 534 } 535 } 536 537 538 539 if (typeof map_obj.map_data.map_tabs != 'undefined') { 540 this.map_widgets(); 541 542 $(map_obj.container).find(".wpgmp_toggle_main_container").find("div[id^='wpgmp_tab_']").css("display", "none"); 543 544 if (map_obj.settings.infowindow_filter_only === false) { 545 546 $(map_obj.container).find("input[data-marker-category]").attr("checked", true); 547 548 $(map_obj.container).find("input[data-marker-location]").attr("checked", true); 549 550 } 551 552 if (this.map_data.map_tabs.category_tab && this.map_data.map_tabs.category_tab.select_all === true) { 553 554 $(map_obj.container).find('input[name="wpgmp_select_all"]').click(function() { 555 if ($(this).is(":checked")) { 556 $(map_obj.container).find("input[data-marker-category]").attr("checked", true); 557 $(map_obj.container).find('input[data-marker-location]').attr('checked', true); 558 } else { 559 $(map_obj.container).find("input[data-marker-category]").attr("checked", false); 560 $(map_obj.container).find('input[data-marker-location]').attr('checked', false); 561 } 562 map_obj.update_filters(); 563 }); 564 } 565 566 $(map_obj.container).find(".wpgmp_toggle_container").click(function() { 567 568 $(map_obj.container).find(".wpgmp_toggle_main_container").slideToggle("slow"); 569 570 if ($(this).text() == wpgmp_local.hide) { 571 $(this).text(wpgmp_local.show); 572 } else { 573 $(this).text(wpgmp_local.hide); 574 } 575 576 }); 577 578 if (map_obj.map_data.map_tabs.hide_tabs_default === true) { 579 $(map_obj.container).find(".wpgmp_toggle_container").trigger('click'); 580 } 581 582 $(map_obj.container).find(".wpgmp_specific_route_item").attr("checked", true); 583 584 $(map_obj.container).find(".wpgmp_toggle_main_container").find("div[id^='wpgmp_tab_']").first().css("display", "block"); 585 586 $(map_obj.container).on('click', "li[class^='wpgmp-tab-'] a", function() { 587 588 $(map_obj.container).find("li[class^='wpgmp-tab-'] a").removeClass('active'); 589 590 $(this).addClass('active'); 591 592 $(map_obj.container).find(".wpgmp_toggle_main_container").find("div[id^='wpgmp_tab_']").css("display", "none"); 593 594 $(map_obj.container).find(".wpgmp_toggle_main_container").find("#wpgmp_tab_" + $(this).parent().attr('rel')).css("display", "block"); 595 596 }); 597 598 $(map_obj.container).on('change', "input[data-marker-category]", function() { 599 //uncheck all locations 600 var current_marker_id = $(this).data('marker-category'); 601 var that = this; 602 if($(that).data('child-cats')){ 603 var data_child = $(that).data('child-cats').toString(); 604 if(data_child.indexOf(',') !== -1){ 605 var child_cats = data_child.split(','); 606 }else{ 607 var child_cats = []; 608 child_cats.push(data_child); 609 } 610 } 611 if ($(this).is(":checked") === false){ 612 $(that).closest('[data-container="wpgmp-category-tab-item"]').find('input[data-marker-location]').attr('checked', false); 613 if(child_cats){ 614 $.each( child_cats, function( i, cat){ 615 $(that).parent().parent().find('[data-marker-category="'+cat+'"]').attr('checked', false); 616 $(that).parent().parent().find('[data-marker-category="'+cat+'"]').parent().find('input[data-marker-location]').attr('checked', false); 617 }); 618 } 619 } else{ 620 $(that).closest('[data-container="wpgmp-category-tab-item"]').find('input[data-marker-location]').attr('checked', true); 621 if(child_cats){ 622 $.each( child_cats, function( i, cat){ 623 $(that).parent().parent().find('[data-marker-category="'+cat+'"]').attr('checked', true); 624 $(that).parent().parent().find('[data-marker-category="'+cat+'"]').parent().find('input[data-marker-location]').attr('checked', true); 625 }); 626 } 627 } 628 map_obj.update_filters(); 629 }); 630 631 $(map_obj.container).find(".wpgmp_toggle_main_container").on('change', ".wpgmp_specific_route_item", function() { 632 //uncheck all locations 633 var selected_route = map_obj.route_directions[$(this).val()]; 634 if ($(this).is(":checked") === false) { 635 selected_route.setMap(null); 636 } else {
637 selected_route.setMap(map_obj.map); 638 } 639 640 }); 641 642 $(map_obj.container).on('change', "input[data-marker-location]", function() { 643 map_obj.update_filters(); 644 }); 645 646 //directions tabs 647 if (this.map_data.map_tabs.direction_tab && this.map_data.map_tabs.direction_tab.dir_tab === true) { 648 $(this.container).find(".wpgmp_find_direction").click(function() { 649 650 var start = $(map_obj.container).find('.start_point'); 651 var end = $(map_obj.container).find('.end_point'); 652 var travel_mode = $(map_obj.container).find('select[name="travel_mode"]').val(); 653 var travel_unit = $(map_obj.container).find('select[name="travel_unit"]').val(); 654 var direction_panel = $(map_obj.container).find('.directions-panel'); 655 var current_address = ''; 656 if ($(start).val() === "") { 657 $(start).focus(); 658 return false; 659 } 660 661 if ($(end).val() === "") { 662 $(end).focus(); 663 return false; 664 } 665 666 var options = { 667 "start": start.val(), 668 "end": end.val(), 669 "mode": travel_mode, 670 "unit": travel_unit, 671 "direction_panel": direction_panel[0], 672 "map": map_obj.map 673 }; 674 map_obj.find_direction(options); 675 676 }); 677 } 678 679 $(this.container).find(".wpgmp_find_nearby_button").click(function() { 680 var target = $(this).parent().parent(); 681 var lat = $(target).find(".wpgmp_auto_suggest").data('latitude'); 682 var lon = $(target).find(".wpgmp_auto_suggest").data('longitude'); 683 684 if( !lat || !lon ) { 685 $(target).find(".wpgmp_auto_suggest").focus(); 686 return; 687 } 688 689 var radius = $(map_obj.container).find("input[name='wpgmp_radius']").val(); 690 var dim = $(map_obj.container).find("select[name='wpgmp_route_dimension']").val(); 691 var amenities = $(map_obj.container).find('input[name^="wpgmp_place_types"]:checked'); 692 var divide_by = 1.60934; 693 var service; 694 if (dim == 'miles') { 695 divide_by = 1.60934; 696 } else { 697 divide_by = 1; 698 } 699 var circle_radius_meters = parseInt(radius) * divide_by * 1000; 700 // Now draw a circle. 701 if (amenities.length > 0 && lat && lon) { 702 //remove all previous amenities 703 if (map_obj.current_amenities.length > 0) { 704 $.each(map_obj.current_amenities, function(am, amenity) { 705 amenity.marker.setMap(null); 706 }); 707 } 708 map_obj.amenity_infowindow = map_obj.infowindow_marker; 709 var place_types = []; 710 $.each(amenities, function(index, amenity) { 711 place_types.push($(amenity).val()); 712 }); 713 var request = { 714 location: new google.maps.LatLng(lat, lon), 715 radius: circle_radius_meters, 716 types: place_types 717 }; 718 service = new google.maps.places.PlacesService(map_obj.map); 719 service.nearbySearch(request, function(results, status) { 720 if (status == google.maps.places.PlacesServiceStatus.OK) { 721 for (var i = 0; i < results.length; i++) { 722 map_obj.createMarker(results[i]); 723 } 724 } 725 }); 726 727 map_obj.map.setCenter(new google.maps.LatLng(lat, lon)); 728 729 if (map_obj.map_data.map_tabs.nearby_tab.show_nearby_circle === true) { 730 731 if (typeof map_obj.set_nearbycenter_circle != 'undefined') { 732 map_obj.set_nearbycenter_circle.setMap(null); 733 } 734 //this.map_data.map_tabs.nearby_tab.near_tab 735 // 736 map_obj.set_nearbycenter_circle = new google.maps.Circle({ 737 map: map_obj.map, 738 fillColor: map_obj.map_data.map_tabs.nearby_tab.nearby_circle_fillcolor, 739 fillOpacity: map_obj.map_data.map_tabs.nearby_tab.nearby_circle_fillopacity, 740 strokeColor: map_obj.map_data.map_tabs.nearby_tab.nearby_circle_strokecolor, 741 strokeOpacity: map_obj.map_data.map_tabs.nearby_tab.nearby_circle_strokeopacity, 742 strokeWeight: map_obj.map_data.map_tabs.nearby_tab.nearby_circle_strokeweight, 743 center: new google.maps.LatLng(lat, lon), 744 radius: circle_radius_meters, 745 }); 746 map_obj.map.setZoom(parseInt(map_obj.map_data.map_tabs.nearby_tab.nearby_circle_zoom)); 747 } 748 } 749 750 751 }), 752 753 $(this.container).on("click",".wpgmp_locateme_control",function(){ 754 755 map_obj.get_current_location(function(user_location) { 756 757 map_obj.map.setCenter(user_location); 758 759 if( map_obj.map_center_marker ) { 760 map_obj.map_center_marker.setPosition(user_location); 761 } 762 763 if( map_obj.set_center_circle ) { 764 map_obj.set_center_circle.setCenter(user_location); 765 } 766 767 768 }); 769 770 771 }); 772 773 $(this.container).find(".wpgmp_mcurrent_loction").click(function() { 774 var this_current = this; 775 map_obj.get_current_location(function(user_location) { 776 777 $(this_current).parent().find('.wpgmp_auto_suggest').data('latitude', user_location.lat()); 778 $(this_current).parent().find('.wpgmp_auto_suggest').data('longitude', user_location.lng()); 779 780 map_obj.geocoder.geocode({ 781 "latLng": user_location 782 }, function(results, status) { 783 784 if (status == google.maps.GeocoderStatus.OK) { 785 current_address = results[0]["formatted_address"]; 786 $(this_current).parent().find('.wpgmp_auto_suggest').val(current_address); 787 } else 788 console.log(status); 789 790 }); 791 792 }, function() { 793 794 795 }); 796 797 }); 798 } //tabs ended 799 800 801 802 if (typeof map_obj.map_data.geojson != 'undefined') { 803 map_obj.load_json(map_obj.map_data.geojson); 804 } 805 806 $("body").on("click", ".wpgmp_marker_link", function() { 807 $('html, body').animate({ 808 scrollTop: $(map_obj.container).offset().top - 150 809 }, 500); 810 811 map_obj.open_infowindow($(this).data("marker")); 812 813 }); 814 815 $(map_obj.container).on("click", ".wpgmp_locations a[data-marker]", function() { 816 var current_marker = this; 817 $('html, body').animate({ 818 scrollTop: $(map_obj.container).offset().top - 150 819 }, 500); 820 821 setTimeout( function(){ 822 map_obj.open_infowindow($(current_marker).data("marker")); 823 } , 600 ); 824 }); 825 826 $(map_obj.container).on("click", ".wpgmp_location_container a[data-marker]", function() { 827 map_obj.open_infowindow($(this).data("marker")); 828 }); 829 830 // REGISTER AUTO SUGGEST
831 map_obj.google_auto_suggest($(".wpgmp_auto_suggest")); 832 833 if (map_obj.settings.show_center_circle === true) { 834 map_obj.show_center_circle(); 835 } 836 837 if (map_obj.settings.show_center_marker === true) { 838 map_obj.show_center_marker(); 839 } 840 841 if (typeof map_obj.map_data.shapes != 'undefined') { 842 843 if (map_obj.map_data.shapes.drawing_editable === true) 844 this.enable_drawing(); 845 846 } 847 848 if (map_obj.settings.fit_bounds === true) { 849 map_obj.fit_bounds(); 850 } 851 852 853 //url filters 854 if (map_obj.settings.url_filters === true) { 855 map_obj.apply_url_filters(); 856 } 857 858 859 }, 860 load_google_fonts: function(fonts){ 861 if(fonts && fonts.length > 0){ 862 $.each(fonts, function(k,font){ 863 if(font.indexOf(',') >= 0){ 864 font = font.split(","); 865 font = font[0]; 866 } 867 if(font.indexOf('"') >= 0){ 868 font = font.replace('"', ''); 869 font = font.replace('"', ''); 870 } 871 WebFont.load({ 872 google: { 873 families: [font] 874 } 875 }); 876 }); 877 } 878 }, 879 load_json: function(url) { 880 this.map.data.loadGeoJson(url); 881 }, 882 createMarker: function(place) { 883 var map_obj = this; 884 var map = map_obj.map; 885 var placeLoc = place.geometry.location; 886 var image = { 887 url: place.icon, 888 size: new google.maps.Size(25, 25), 889 scaledSize: new google.maps.Size(25, 25) 890 }; 891 892 place.marker = new google.maps.Marker({ 893 map: map, 894 position: place.geometry.location, 895 icon: image 896 }); 897 898 google.maps.event.addListener(place.marker, 'click', function() { 899 var new_place = {}; 900 var post_info_class = 'fc-infowindow-'; 901 new_place.marker = place.marker; 902 new_place.address = place.vicinity; 903 new_place.title = place.name; 904 new_place.location = {}; 905 new_place.location.onclick_action ='marker'; 906 var content = ''; 907 var marker_image = ''; 908 909 if( place.photos ) { 910 marker_image = place.photos[0].getUrl(); 911 } else { 912 marker_image = ''; 913 } 914 915 var temp_listing_placeholder = ''; 916 temp_listing_placeholder = map_obj.settings.infowindow_setting; 917 918 if( map_obj.settings.infowindow_skin ) 919 post_info_class = 'fc-infowindow-'+map_obj.settings.infowindow_skin.name; 920 921 if( typeof temp_listing_placeholder == 'undefined' ) { 922 temp_listing_placeholder = place.content; 923 } 924 925 replaceData = { 926 "{marker_id}": place.id, 927 "{marker_title}": place.name, 928 "{marker_address}": place.vicinity, 929 "{marker_latitude}": place.geometry.location.lat(), 930 "{marker_longitude}": place.geometry.location.lng(), 931 "{marker_city}": '', 932 "{marker_state}": '', 933 "{marker_country}": '', 934 "{marker_postal_code}": '', 935 "{marker_zoom}": '', 936 "{marker_icon}": place.icon, 937 "{marker_category}": '', 938 "{marker_message}": place.content, 939 "{marker_image}": marker_image, 940 "{marker_rating}": '' 941 }; 942 943 temp_listing_placeholder = temp_listing_placeholder.replace(/{[^{}]+}/g, function(match) { 944 if (match in replaceData) { 945 return (replaceData[match]); 946 } else { 947 return (""); 948 } 949 }); 950 951 content = temp_listing_placeholder; 952 953 954 955 if (content === "") { 956 if (map_obj.settings.map_infowindow_customisations === true && map_obj.settings.show_infowindow_header === true) 957 content = '<div class="wpgmp_infowindow '+post_info_class+'"><div class="wpgmp_iw_head"><div class="wpgmp_iw_head_content">' + place.name + '</div></div><div class="wpgmp_iw_content">' + place.vicinity + '</div></div>'; 958 else 959 content = '<div class="wpgmp_infowindow '+post_info_class+'"><div class="wpgmp_iw_content">' + place.content + '</div></div>'; 960 } else { 961 if (map_obj.settings.map_infowindow_customisations === true && map_obj.settings.show_infowindow_header === true) 962 content = '<div class="wpgmp_infowindow '+post_info_class+'"><div class="wpgmp_iw_head"><div class="wpgmp_iw_head_content">' + place.name + '</div></div><div class="wpgmp_iw_content">' + content + '</div></div>'; 963 else 964 content = '<div class="wpgmp_infowindow '+post_info_class+'"><div class="wpgmp_iw_content">' + content + '</div></div>'; 965 966 } 967 new_place.infowindow_data = content; 968 969 map_obj.openInfoWindow(new_place); 970 }); 971 // map_obj.current_amenities.push(place); 972 }, 973 wpgmp_image_type_overlays: function() { 974 var map_obj = this; 975 var imageMapType = new google.maps.ImageMapType({ 976 getTileUrl: function(coord, zoom) {
977 return ['http://www.gstatic.com/io2010maps/tiles/5/L2_', 978 zoom, '_', coord.x, '_', coord.y, '.png' 979 ].join(''); 980 }, 981 tileSize: new google.maps.Size(256, 256) 982 }); 983 984 map_obj.map.overlayMapTypes.push(imageMapType); 985 986 }, 987 wpgmp_within_radius: function(place, search_area) { 988 var map_obj = this; 989 var radius = $(map_obj.container).find('[data-name="radius"]').val(); 990 var dimension = map_obj.map_data.listing.radius_dimension; 991 if( map_obj.map_data.listing.apply_default_radius == true && radius == '' ) { 992 radius = map_obj.map_data.listing.default_radius; 993 dimension = map_obj.map_data.listing.default_radius_dimension; 994 } 995 if (dimension == 'km') { 996 radius = parseInt(radius) * 1000; 997 } else { 998 radius = parseInt(radius) * 1609.34; 999 } 1000 if (google.maps.geometry.spherical.computeDistanceBetween(place.marker.getPosition(), search_area) < radius) { 1001 return true; 1002 } else { 1003 return false; 1004 } 1005 }, 1006 wpgmp_get_nearby_locations: function(lat1, lon1, radius) { 1007 var current_rd = 'miles'; 1008 var map_obj = this; 1009 var radius_km = 6371; 1010 1011 1012 if (current_rd == "miles") { 1013 max_radius_km = radius * 1.61; 1014 } else if (current_rd == "km") { 1015 max_radius_km = radius; 1016 } 1017 1018 var distances = []; 1019 var closest = -1; 1020 var pi = Math.PI; 1021 var marker_info = {}; 1022 1023 $.each(map_obj.places, function(index, place) { 1024 1025 var lat2 = place.location.lat; 1026 var lon2 = place.location.lng; 1027 1028 var chLat = lat2 - lat1; 1029 var chLon = lon2 - lon1; 1030 1031 var dLat = chLat * (pi / 180); 1032 var dLon = chLon * (pi / 180); 1033 1034 1035 var rLat1 = lat1 * (pi / 180); 1036 var rLat2 = lat2 * (pi / 180); 1037 1038 var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + 1039 Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(rLat1) * Math.cos(rLat2); 1040 var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); 1041 var d = radius_km * c; 1042 1043 1044 if (max_radius_km !== 0) { 1045 if (d <= max_radius_km) { 1046 distances[d] = place; 1047 distances.sort(function(a, b) { 1048 return a - b; 1049 }); 1050 marker_info["marker" + place.id] = d; 1051 } 1052 } else { 1053 distances[d] = markers[i]; 1054 distances.sort(function(a, b) { 1055 return a - b; 1056 }); 1057 marker_info["marker" + place.id] = d; 1058 } 1059 1060 }); 1061 1062 sortest_markers = map_obj.wpgmp_sort_distance(marker_info); 1063 1064 return sortest_markers; 1065 }, 1066 1067 wpgmp_sort_distance: function(obj) { 1068 var arr = []; 1069 for (var prop in obj) { 1070 if (obj.hasOwnProperty(prop)) { 1071 arr.push({ 1072 "key": prop, 1073 "value": obj[prop] 1074 }); 1075 } 1076 } 1077 arr.sort(function(a, b) { 1078 return a.value - b.value; 1079 }); 1080 return arr; 1081 }, 1082 1083 get_user_position: function() { 1084 1085 var map_obj = this; 1086 1087 navigator.geolocation.getCurrentPosition(function(position) { 1088 1089 map_obj.user_lat_lng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); 1090 1091 }, function(ErrorPosition) { 1092 }, { 1093 enableHighAccuracy: true, 1094 timeout: 5000, 1095 maximumAge: 0 1096 }); 1097 1098 }, 1099 1100 marker_bind: function(marker) { 1101 1102 map_obj = this; 1103 1104 google.maps.event.addListener(marker, 'drag', function() { 1105 1106 var position = marker.getPosition(); 1107 1108 map_obj.geocoder.geocode({ 1109 latLng: position 1110 }, function(results, status) { 1111 1112 if (status == google.maps.GeocoderStatus.OK) { 1113 1114 $("#googlemap_address").val(results[0].formatted_address); 1115 1116 $(".google_city").val(map_obj.wpgmp_finddata(results[0], 'administrative_area_level_3') || map_obj.wpgmp_finddata(results[0], 'locality')); 1117 $(".google_state").val(map_obj.wpgmp_finddata(results[0], "administrative_area_level_1")); 1118 $(".google_country").val(map_obj.wpgmp_finddata(results[0], "country")); 1119 1120 if (results[0].address_components) { 1121 for (var i = 0; i < results[0].address_components.length; i++) { 1122 for (var j = 0; j < results[0].address_components[i].types.length; j++) { 1123 if (results[0].address_components[i].types[j] == "postal_code") { 1124 wpgmp_zip_code = results[0].address_components[i].long_name; 1125 $(".google_postal_code").val(wpgmp_zip_code); 1126 } 1127 } 1128 } 1129 } 1130 } 1131 }); 1132 1133 $(".google_latitude").val(position.lat()); 1134 $(".google_longitude").val(position.lng()); 1135 }); 1136 1137 }, 1138
1139 google_auto_suggest: function(obj) { 1140 1141 var map_obj = this; 1142 1143 obj.each(function() { 1144 var current_input = this; 1145 var autocomplete = new google.maps.places.Autocomplete(this); 1146 1147 autocomplete.bindTo('bounds', map_obj.map); 1148 1149 if ($(this).attr("name") == 'location_address') { 1150 var infowindow = map_obj.infowindow_marker; 1151 var marker = new google.maps.Marker({ 1152 map: map_obj.map, 1153 draggable: true, 1154 anchorPoint: new google.maps.Point(0, -29) 1155 }); 1156 1157 map_obj.marker_bind(marker); 1158 1159 google.maps.event.addListener(autocomplete, 'place_changed', function() { 1160 1161 var place = autocomplete.getPlace(); 1162 if (!place.geometry) { 1163 return; 1164 } 1165 1166 // If the place has a geometry, then present it on a map. 1167 if (place.geometry.viewport) { 1168 map_obj.map.fitBounds(place.geometry.viewport); 1169 } else { 1170 map_obj.map.setCenter(place.geometry.location); 1171 map_obj.map.setZoom(17); 1172 } 1173 1174 $(".google_latitude").val(place.geometry.location.lat()); 1175 $(".google_longitude").val(place.geometry.location.lng()); 1176 $(".google_city").val(map_obj.wpgmp_finddata(place, 'administrative_area_level_3') || map_obj.wpgmp_finddata(place, 'locality')); 1177 $(".google_state").val(map_obj.wpgmp_finddata(place, "administrative_area_level_1")); 1178 $(".google_country").val(map_obj.wpgmp_finddata(place, "country")); 1179 if (place.address_components) { 1180 for (var i = 0; i < place.address_components.length; i++) { 1181 for (var j = 0; j < place.address_components[i].types.length; j++) { 1182 if (place.address_components[i].types[j] == "postal_code") { 1183 wpgmp_zip_code = place.address_components[i].long_name; 1184 $(".google_postal_code").val(wpgmp_zip_code); 1185 } 1186 } 1187 } 1188 } 1189 1190 marker.setPosition(place.geometry.location); 1191 marker.setVisible(true); 1192 }); 1193 } else { 1194 1195 google.maps.event.addListener(autocomplete, 'place_changed', function() { 1196 1197 var place = autocomplete.getPlace(); 1198 if (!place.geometry) { 1199 return; 1200 } 1201 1202 $().val(place.geometry.location.lat()); 1203 $(current_input).data('longitude', place.geometry.location.lng()); 1204 $(current_input).data('latitude', place.geometry.location.lat()); 1205 1206 }); 1207 } 1208 }); 1209 }, 1210 1211 wpgmp_finddata: function(result, type) { 1212 var component_name = ""; 1213 for (i = 0; i < result.address_components.length; ++i) { 1214 var component = result.address_components[i]; 1215 $.each(component.types, function(index, value) { 1216 if (value == type) { 1217 component_name = component.long_name; 1218 } 1219 }); 1220 1221 1222 } 1223 return component_name; 1224 }, 1225 clearSelection: function() { 1226 var map_obj = this; 1227 if (map_obj.selectedShape) { 1228 map_obj.selectedShape.setEditable(false); 1229 map_obj.selectedShape = null; 1230 } 1231 }, 1232 setSelection: function(shape) { 1233 var map_obj = this; 1234 map_obj.clearSelection(); 1235 map_obj.selectedShape = shape; 1236 map_obj.selectedShape.setEditable(true); 1237 }, 1238 deleteSelectedShape: function() { 1239 var map_obj = this; 1240 var key; 1241 if (map_obj.selectedShape) { 1242 for (key in map_obj.wpgmp_circles) { 1243 if (map_obj.wpgmp_circles[key] == map_obj.selectedShape) { 1244 map_obj.wpgmp_circles.splice(key, 1); 1245 } 1246 } 1247 for (key in map_obj.wpgmp_rectangles) { 1248 if (map_obj.wpgmp_rectangles[key] == map_obj.selectedShape) { 1249 map_obj.wpgmp_rectangles.splice(key, 1); 1250 } 1251 } 1252 for (key in map_obj.wpgmp_polygons) { 1253 if (map_obj.wpgmp_polygons[key] == map_obj.selectedShape) { 1254 map_obj.wpgmp_polygons.splice(key, 1); 1255 } 1256 } 1257 for (key in map_obj.wpgmp_polylines) { 1258 if (map_obj.wpgmp_polylines[key] == map_obj.selectedShape) { 1259 map_obj.wpgmp_polylines.splice(key, 1); 1260 } 1261 } 1262 map_obj.selectedShape.setMap(null); 1263 } 1264 }, 1265 add_tab: function(title, content) { 1266 1267 var tab = []; 1268 1269 tab.title = title; 1270 tab.content = content; 1271 this.tabs.push(tab); 1272 }, 1273 1274 show_tabs: function() { 1275 1276 if (this.tabs.length === 0) 1277 return; 1278 1279 var content = '<div class="wpgmp_tabs_container cleanslate"><ul class="wpgmp_tabs clearfix">'; 1280 1281 $.each(this.tabs, function(index, tab) { 1282 if (index == 0) 1283 content += '<li class="wpgmp-tab-' + index + '" rel="' + index + '"><a class="active" href="javascript:void(0);">' + tab.title + '</a></li>'; 1284 else 1285 content += '<li class="wpgmp-tab-' + index + '" rel="' + index + '"><a href="javascript:void(0);">' + tab.title + '</a></li>'; 1286 }); 1287 1288 content += '</ul>'; 1289 1290 content += '<div class="wpgmp_toggle_main_container">'; 1291 1292 $.each(this.tabs, function(index, tab) { 1293 content += '<div id="wpgmp_tab_' + index + '">'; 1294 content += tab.content; 1295 content += '</div>'; 1296 }); 1297 1298 content += '</div><div class="wpgmp_toggle_container">' + wpgmp_local.hide + '</div></div>'; 1299 1300 return content; 1301 }, 1302 1303 map_widgets: function() { 1304 1305 var content = ''; 1306 1307 if (this.map_data.map_tabs.category_tab && this.map_data.map_tabs.category_tab.cat_tab === true) 1308 this.widget_category(); 1309 1310 if (this.map_data.map_tabs.direction_tab && this.map_data.map_tabs.direction_tab.dir_tab === true) 1311 this.widget_directions(); 1312 1313 if (this.map_data.map_tabs.nearby_tab && this.map_data.map_tabs.nearby_tab.near_tab === true) 1314 this.widget_nearby(); 1315 1316 if (this.map_data.map_tabs.route_tab && this.map_data.map_tabs.route_tab.display_route_tab === true) 1317 this.widget_route_tab(); 1318 1319 if (this.map_data.map_tabs.extension_tabs) { 1320 this.widget_extensions_tab(); 1321 } 1322 content += this.show_tabs(); 1323 $(content).insertAfter(this.element); 1324 }, 1325 1326 widget_extensions_tab: function() { 1327 var map_obj = this; 1328 var new_tabs = map_obj.map_data.map_tabs.extension_tabs; 1329 if (typeof new_tabs != 'undefined' && new_tabs.length > 0) { 1330 $.each(new_tabs, function(index, tab) { 1331 map_obj.add_tab(tab.title, tab.content); 1332 }); 1333 } 1334 }, 1335 widget_route_tab: function() { 1336 1337 var route_data = this.map_data.map_tabs.route_tab.route_tab_data; 1338 1339 var content = ''; 1340 1341 if (this.map_data.map_tabs.route_tab.display_route_tab_data === true) { 1342 content += '<div id="wpgmp_route_tab">'; 1343 if (route_data) { 1344 $.each(route_data, function(index, route) { 1345 content += '<div class="wpgmp_tab_item">'; 1346 content += '<input type="checkbox" class="wpgmp_
1346specific_route_item" value="' + route.route_id + '">'; 1347 var box = '<span style="display:inline-block;width:10px;height:10px;background-color:' + route.route_stroke_color + ';float:right;margin-right:10px;margin-top:5px;"></span>'; 1348 content += '<a href="javascript:void(0);" class="wpgmp_cat_title accordion accordion-close">' + route.route_title + box + '</a>'; 1349 1350 content += '<div class="directions-panel-route' + route.route_id + ' wpgmp-directions-panel-route-style" style="overflow-y:scroll; height:200px;"></div>'; 1351 1352 content += '</div>'; 1353 }); 1354 } 1355 1356 content += '</div>'; 1357 } 1358 this.add_tab(this.map_data.map_tabs.route_tab.route_tab_title, content); 1359 }, 1360 1361 widget_nearby: function() { 1362 var content = '<div class="wpgmp_nearby_container">'; 1363 content += '<p><input placeholder="' + wpgmp_local.start_point + '" type="text" name="start_point" class="input start_point wpgmp_auto_suggest" autocomplete="off" /><span class="wpgmp_mcurrent_loction" title="' + wpgmp_local.take_current_location + '"> </span></p>'; 1364 content += '<p><input name="wpgmp_radius" placeholder="' + wpgmp_local.radius + '" type="text" class="input" value="25" size="8"> <select name="wpgmp_route_dimension"><option value="miles">' + wpgmp_local.miles + '</option><option value="km">' + wpgmp_local.km + '</option></select></p>'; 1365 if (typeof this.map_data.map_tabs.nearby_tab.nearby_amenities != 'undefined') { 1366 var all_amenities = this.map_data.map_tabs.nearby_tab.nearby_amenities; 1367 1368 if (all_amenities) { 1369 content += '<div class="choose_amenities">'; 1370 $.each(all_amenities, function(index, amenity) { 1371 content += "<span class='amenity_type'><input type='checkbox' value='" + amenity + "' name='wpgmp_place_types[]' /> " + amenity + '</span>'; 1372 }); 1373 } 1374 1375 } 1376 content += '</div>'; 1377 content += '<p style="clear:both;"><input type="submit" value="' + wpgmp_local.find_location + '" class="wpgmp_find_nearby_button" /></p><div class="location_panel"></div></div>'; 1378 1379 1380 this.add_tab(this.map_data.map_tabs.nearby_tab.nearby_tab_title, content); 1381 1382 }, 1383 1384 widget_directions: function() { 1385 1386 var content = ''; 1387 1388 content = '<div class="wpgmp_direction_container">'; 1389 1390 if (this.map_data.map_tabs.route_start_location == "textbox") { 1391 content += '<p><input value="' + this.map_data.map_tabs.direction_tab.default_start_location + '" placeholder="' + wpgmp_local.start_location + '" type="text" name="start_point" class="input start_point wpgmp_auto_suggest" autocomplete="off" /><span class="wpgmp_mcurrent_loction" title="' + wpgmp_local.take_current_location + '"> </span></p>'; 1392 } else if (this.map_data.map_tabs.route_start_location == "selectbox") { 1393 content += '<p><select name="start_point" class="input start_point" autocomplete="off" >'; 1394 1395 content += '<option value="">' + wpgmp_local.start_location + '</option>'; 1396 1397 $.each(this.places, function(index, place) { 1398 1399 content += '<option value="' + place.address + '">' + place.title + '</option>'; 1400 1401 }); 1402 1403 content += '</select>'; 1404 } 1405 1406 if (this.map_data.map_tabs.route_end_location == "textbox") { 1407 content += '<p><input value="' + this.map_data.map_tabs.direction_tab.default_end_location + '" placeholder="' + wpgmp_local.end_location + '" name="end_point" type="text" class="input end_point wpgmp_auto_suggest" autocomplete="off" /></p>'; 1408 } else if (this.map_data.map_tabs.route_end_location == "selectbox") { 1409 content += '<p><select name="end_point" class="input end_point" autocomplete="off" >'; 1410 1411 content += '<option value="">' + wpgmp_local.end_location + '</option>'; 1412 1413 $.each(this.places, function(index, place) { 1414 content += '<option value="' + place.address + '">' + place.title + '</option>'; 1415 1416 }); 1417 1418 content += '</select>'; 1419 } 1420 1421 content += '<p><select name="travel_mode" id="travaling_mode"> <option value="DRIVING" selected="selected">' + wpgmp_local.driving + '</option> <option value="BICYCLING">' + wpgmp_local.bicycling + '</option> <option value="WALKING">' + wpgmp_local.walking + '</option> <option value="TRANSIT">' + wpgmp_local.transit + '</option> </select></p>'; 1422 1423 content += '<p><select name="travel_unit" id="travel_unit"> <option value="metric" selected="selected">' + wpgmp_local.metric + '</option> <option value="imperial">' + wpgmp_local.imperial + '</option></select></p><p><input type="submit" value="' + wpgmp_local.find_direction + '" class="wpgmp_find_direction"></p><div class="directions-panel" style="overflow-y:scroll;display:none;"></div></div>'; 1424 1425 this.add_tab(this.map_data.map_tabs.direction_tab.direction_tab_title, content); 1426 }, 1427 1428 widget_category: function() { 1429 1430 var map_obj = this; 1431 if (map_obj.map_data.map_tabs.category_tab.select_all === true) { 1432 var content = '<div class="wpgmp-select-all"><input checked="checked" type="checkbox" value="true" name="wpgmp_select_all">  ' + wpgmp_local.select_all + '</div>'; 1433 } else { 1434 var content = ''; 1435 } 1436 var categories_tab_data = {}; 1437 var child_categories_tab_data = {}; 1438 if (typeof map_obj.map_data.places != 'undefined') { 1439 $.each(map_obj.map_data.places, function(index, place) { 1440 if (typeof place.categories != 'undefined') { 1441 $.each(place.categories, function(index, categories) { 1442 var show = true; 1443 var parent_cat = ''; 1444 parent_cat = map_obj.search_category(map_obj.map_data.map_tabs.category_tab.child_cats, categories.id, [], categories_tab_data, child_categories_tab_data); 1445 1446 if (parent_cat.length > 0) 1447 show = false;
1448 1449 if (typeof categories.type != "undefined" && categories.type == 'category' && categories.name && show == true) { 1450 1451 1452 if (typeof categories_tab_data[categories.id] == "undefined") { 1453 categories_tab_data[categories.id] = {}; 1454 categories_tab_data[categories.id]['data'] = []; 1455 } 1456 categories_tab_data[categories.id]['cat_id'] = categories.id; 1457 categories_tab_data[categories.id]['cat_title'] = categories.name; 1458 categories_tab_data[categories.id]['cat_marker_icon'] = categories.icon; 1459 1460 if( categories.extension_fields && categories.extension_fields.cat_order ) { 1461 categories_tab_data[categories.id]['cat_order'] = categories.extension_fields.cat_order; 1462 } 1463 1464 var redirect_permalink = ""; 1465 if (place.location.redirect_permalink) 1466 redirect_permalink = place.location.redirect_permalink; 1467 1468 var redirect_custom_link = ""; 1469 if (place.location.redirect_custom_link) 1470 redirect_custom_link = place.location.redirect_custom_link; 1471 1472 categories_tab_data[categories.id]['data'].push({ 1473 "cat_location_id": place.id, 1474 "cat_location_title": place.title, 1475 "cat_location_address": place.address, 1476 "cat_location_zoom": place.location.zoom, 1477 "onclick_action": place.location.onclick_action, 1478 "redirect_permalink": redirect_permalink, 1479 "redirect_custom_link": redirect_custom_link, 1480 }); 1481 1482 } else if (typeof categories.type != "undefined" && categories.type == 'category' && categories.name && show == false) { 1483 if (typeof child_categories_tab_data[categories.id] == "undefined") { 1484 child_categories_tab_data[categories.id] = {}; 1485 child_categories_tab_data[categories.id]['data'] = []; 1486 child_categories_tab_data[categories.id]['parent_cat'] = parent_cat; 1487 } 1488 1489 child_categories_tab_data[categories.id]['cat_id'] = categories.id; 1490 child_categories_tab_data[categories.id]['cat_title'] = categories.name; 1491 child_categories_tab_data[categories.id]['cat_marker_icon'] = categories.icon; 1492 if( categories.extension_fields && categories.extension_fields.cat_order ) { 1493 child_categories_tab_data[categories.id]['cat_order'] = categories.extension_fields.cat_order; 1494 } 1495 var redirect_permalink = ""; 1496 if (place.location.redirect_permalink) 1497 redirect_permalink = place.location.redirect_permalink; 1498 1499 var redirect_custom_link = ""; 1500 if (place.location.redirect_custom_link) 1501 redirect_custom_link = place.location.redirect_custom_link; 1502 1503 child_categories_tab_data[categories.id]['data'].push({ 1504 "cat_location_id": place.id, 1505 "cat_location_title": place.title, 1506 "cat_location_address": place.address, 1507 "cat_location_zoom": place.location.zoom, 1508 "onclick_action": place.location.onclick_action, 1509 "redirect_permalink": redirect_permalink, 1510 "redirect_custom_link": redirect_custom_link, 1511 }); 1512 1513 if(categories_tab_data[parent_cat] !== undefined){ 1514 if(typeof categories_tab_data[parent_cat]['child_cats']=='undefined'){ 1515 categories_tab_data[parent_cat]['child_cats'] = []; 1516 } 1517 categories_tab_data[parent_cat]['child_cats'][categories.id] = categories.id; 1518 } 1519 } 1520 }); 1521 } 1522 1523 }); 1524 } 1525 1526 var category_orders = []; 1527 if (typeof categories_tab_data != 'undefined') { 1528 $.each(categories_tab_data, function(index, categories) { 1529 var loc_count = categories.data.length; 1530 1531 if (typeof child_categories_tab_data != "undefined") { 1532 $.each(child_categories_tab_data, function(c,ccat) { 1533 if( ccat.parent_cat == categories.cat_id) { 1534 loc_count = loc_count + ccat.data.length; 1535 $.each(child_categories_tab_data, function(cc,cccat) { 1536 if( cccat.parent_cat == ccat.cat_id) { 1537 loc_count = loc_count + cccat.data.length; 1538 } 1539 }); 1540 } 1541 }); 1542 } 1543 categories.loc_count = loc_count; 1544 1545 if (map_obj.map_data.map_tabs.category_tab.cat_order_by == 'count') { 1546 category_orders.push(categories.loc_count); 1547 } else if (map_obj.map_data.map_tabs.category_tab.cat_order_by == 'category') { 1548 if(categories.cat_order) { 1549 category_orders.push(categories.cat_order); 1550 } else if( !categories.cat_order && map_obj.map_data.map_tabs.category_tab.all_cats[categories.cat_id] && map_obj.map_data.map_tabs.category_tab.all_cats[categories.cat_id].extensions_fields) { 1551 categories.cat_order = map_obj.map_data.map_tabs.category_tab.all_cats[categories.cat_id].extensions_fields.cat_order;
1552 category_orders.push(categories.cat_order); 1553 } 1554 1555 } else { 1556 if(categories.cat_title) { 1557 category_orders.push(categories.cat_title); 1558 } else if( !categories.cat_title && map_obj.map_data.map_tabs.category_tab.all_cats[categories.cat_id] ) { 1559 categories.cat_title = map_obj.map_data.map_tabs.category_tab.all_cats[categories.cat_id].group_map_title; 1560 category_orders.push(categories.cat_title); 1561 } 1562 1563 } 1564 }); 1565 } 1566 if( map_obj.map_data.map_tabs.category_tab.cat_order_by == 'category' ) { 1567 category_orders.sort(function(a, b){return a-b}); 1568 } else if( map_obj.map_data.map_tabs.category_tab.cat_order_by == 'count' ) { 1569 category_orders.sort(function(a, b){return b-a}); 1570 } else { 1571 category_orders.sort(); 1572 } 1573 var ordered_categories = []; 1574 var check_cats = []; 1575 $.each(category_orders, function(index, cat_title) { 1576 $.each(categories_tab_data, function(index, categories) { 1577 var compare_with; 1578 if (map_obj.map_data.map_tabs.category_tab.cat_order_by == 'count') { 1579 compare_with = categories.loc_count; 1580 } else if (map_obj.map_data.map_tabs.category_tab.cat_order_by == 'category') { 1581 compare_with = categories.cat_order; 1582 } else { 1583 compare_with = categories.cat_title; 1584 } 1585 1586 if (cat_title == compare_with && $.inArray(categories.cat_id, check_cats) == -1) { 1587 ordered_categories.push(categories); 1588 check_cats.push(categories.cat_id); 1589 } 1590 }); 1591 }); 1592 1593 if (typeof ordered_categories != 'undefined') { 1594 $.each(ordered_categories, function(index, categories) { 1595 1596 var category_image = ''; 1597 1598 if( !categories.cat_title && map_obj.map_data.map_tabs.category_tab.all_cats[categories.cat_id] ) { 1599 categories.cat_title = map_obj.map_data.map_tabs.category_tab.all_cats[categories.cat_id].group_map_title; 1600 } 1601 1602 if( !categories.cat_marker_icon && map_obj.map_data.map_tabs.category_tab.all_cats[categories.cat_id] ) { 1603 categories.cat_marker_icon = map_obj.map_data.map_tabs.category_tab.all_cats[categories.cat_id].group_marker; 1604 } 1605 1606 if (typeof categories.cat_marker_icon != 'undefined') { 1607 category_image = '<span class="arrow"><img src="' + categories.cat_marker_icon + '"></span>'; 1608 } 1609 1610 content += '<div class="wpgmp_tab_item" data-container="wpgmp-category-tab-item">'; 1611 1612 if(categories.child_cats !== undefined){ 1613 categories.child_cats = categories.child_cats.filter(function(v){return v!==''}); 1614 var child_cats_str = ' data-child-cats="'+categories.child_cats.join(",")+'"'; 1615 }else{ 1616 var child_cats_str = ''; 1617 } 1618 1619 content += '<input type="checkbox"'+child_cats_str+' data-marker-category="' + categories.cat_id + '" value="' + categories.cat_id + '">'; 1620 1621 var loc_count = categories.loc_count;; 1622 1623 $.each(map_obj.map_data.map_tabs.category_tab.child_cats, function(k, v) { 1624 if (v == categories.cat_id && loc_count == 0) 1625 loc_count = ""; 1626 }); 1627 1628 if (map_obj.map_data.map_tabs.category_tab.show_count === true && loc_count != "") { 1629 location_count = " (" + loc_count + ")"; 1630 } else { 1631 location_count = ""; 1632 } 1633 1634 1635 content += '<a href="javascript:void(0);" class="wpgmp_cat_title accordion accordion-close">
1635' + categories.cat_title + location_count + category_image + '</a>'; 1636 1637 if (map_obj.map_data.map_tabs.category_tab.hide_location !== true) { 1638 1639 content += '<div class="scroll-pane" style="max-height:300px;width:100%;">'; 1640 1641 content += '<ul class="wpgmp_location_container">'; 1642 1643 $.each(categories.data, function(name, location) { 1644 1645 if (location.onclick_action == "marker") { 1646 content += '<li><input type="checkbox" data-marker-location="' + location.cat_location_id + '" value="' + location.cat_location_id + '" /><a data-marker="' + location.cat_location_id + '" data-zoom="' + location.cat_location_zoom + '" href="javascript:void(0);">' + location.cat_location_title + '</a></li>'; 1647 } else if (location.onclick_action == "post") { 1648 content += '<li><input type="checkbox" data-marker-location="' + location.cat_location_id + '" value="' + location.cat_location_id + '" /><a href="' + location.redirect_permalink + '" target="_blank">' + location.cat_location_title + '</a></li>'; 1649 } else if (location.onclick_action == "custom_link") { 1650 content += '<li><input type="checkbox" data-marker-location="' + location.cat_location_id + '" value="' + location.cat_location_id + '" /><a href="' + location.redirect_custom_link + '" target="_blank">' + location.cat_location_title + '</a></li>'; 1651 } 1652 1653 }); 1654 1655 content += '</ul>'; 1656 1657 content += '</div>'; 1658 } 1659 1660 content += '</div>'; 1661 1662 if (typeof child_categories_tab_data != "undefined") { 1663 var padding = 20; 1664 content += map_obj.display_sub_categories(child_categories_tab_data, categories.cat_id, '', padding); 1665 } 1666 }); 1667 } 1668 1669 map_obj.add_tab(map_obj.map_data.map_tabs.category_tab.cat_tab_title, content); 1670 1671 }, 1672 1673 search_category: function(array, cat_id, index, categories_tab_data, child_categories_tab_data) { 1674 var map_obj = this; 1675 var flag = true; 1676 $.each(array, function(k, i) { 1677 if (k == cat_id) { 1678 index = i; 1679 flag = false; 1680 if (typeof child_categories_tab_data[cat_id] == "undefined") { 1681 child_categories_tab_data[cat_id] = {}; 1682 child_categories_tab_data[cat_id]['data'] = []; 1683 child_categories_tab_data[cat_id]['parent_cat'] = i; 1684 child_categories_tab_data[cat_id]['cat_id'] = cat_id; 1685 $.each(map_obj.categories, function(k, e) { 1686 if (e.group_map_id == cat_id) { 1687 child_categories_tab_data[cat_id]['cat_title'] = e.group_map_title; 1688 child_categories_tab_data[cat_id]['cat_marker_icon'] = e.group_marker; 1689 } 1690 }); 1691 } 1692 index = map_obj.search_category(map_obj.map_data.map_tabs.category_tab.child_cats, i, index, categories_tab_data, child_categories_tab_data); 1693 } 1694 }); 1695 if (flag == true) { 1696 if (typeof categories_tab_data[cat_id] == "undefined") { 1697 categories_tab_data[cat_id] = {}; 1698 categories_tab_data[cat_id]['data'] = []; 1699 categories_tab_data[cat_id]['cat_id'] = cat_id; 1700 $.each(map_obj.categories, function(k, e) { 1701 if (e.group_map_id == cat_id) { 1702 categories_tab_data[cat_id]['cat_title'] = e.group_map_title; 1703 categories_tab_data[cat_id]['cat_marker_icon'] = e.group_marker; 1704 } 1705 }); 1706 } 1707 } 1708 return index; 1709 }, 1710 display_sub_categories: function(child_categories_tab_data, cat_id, content, padding) { 1711 var map_obj = this; 1712 1713 var category_orders = []; 1714 if (typeof child_categories_tab_data != 'undefined') { 1715 $.each(child_categories_tab_data, function(index, categories) { 1716 var loc_count = categories.data.length; 1717 1718 if (typeof child_categories_tab_data != "undefined") { 1719 $.each(child_categories_tab_data, function(c,ccat) { 1720 if( ccat.parent_cat == categories.cat_id) { 1721 loc_count = loc_count + ccat.data.length; 1722 $.each(child_categories_tab_data, function(cc,cccat) { 1723 if( cccat.parent_cat == ccat.cat_id) { 1724 loc_count = loc_count + cccat.data.length; 1725 } 1726 }); 1727 } 1728 }); 1729 } 1730 categories.loc_count = loc_count; 1731 1732 if (map_obj.map_data.map_tabs.category_tab.cat_order_by == 'count') { 1733 category_orders.push(categories.loc_count); 1734 } else if (map_obj.map_data.map_tabs.category_tab.cat_order_by == 'category') { 1735 if(categories.cat_order) { 1736 category_orders.push(categories.cat_order); 1737 } else if( !categories.cat_order && map_obj.map_data.map_tabs.category_tab.all_cats[categories.cat_id] ) { 1738 categories.cat_order = map_obj.map_data.map_tabs.category_tab.all_cats[categories.cat_id].extensions_fields.cat_order;
1739 category_orders.push(categories.cat_order); 1740 } 1741 1742 } else { 1743 if(categories.cat_title) { 1744 category_orders.push(categories.cat_title); 1745 } else if( !categories.cat_title && map_obj.map_data.map_tabs.category_tab.all_cats[categories.cat_id] ) { 1746 categories.cat_title = map_obj.map_data.map_tabs.category_tab.all_cats[categories.cat_id].group_map_title; 1747 category_orders.push(categories.cat_title); 1748 } 1749 1750 } 1751 }); 1752 } 1753 if( map_obj.map_data.map_tabs.category_tab.cat_order_by == 'category' ) { 1754 category_orders.sort(function(a, b){return a-b}); 1755 } else if( map_obj.map_data.map_tabs.category_tab.cat_order_by == 'count' ) { 1756 category_orders.sort(function(a, b){return b-a}); 1757 } else { 1758 category_orders.sort(); 1759 } 1760 var ordered_categories = []; 1761 var check_cats = []; 1762 $.each(category_orders, function(index, cat_title) { 1763 $.each(child_categories_tab_data, function(index, categories) { 1764 var compare_with; 1765 if (map_obj.map_data.map_tabs.category_tab.cat_order_by == 'count') { 1766 compare_with = categories.loc_count; 1767 } else if (map_obj.map_data.map_tabs.category_tab.cat_order_by == 'category') { 1768 compare_with = categories.cat_order; 1769 } else { 1770 compare_with = categories.cat_title; 1771 } 1772 1773 if (cat_title == compare_with && $.inArray(categories.cat_id, check_cats) == -1) { 1774 ordered_categories.push(categories); 1775 check_cats.push(categories.cat_id); 1776 } 1777 }); 1778 }); 1779 1780 $.each(ordered_categories, function(index, child_cat) { 1781 if (child_cat.parent_cat == cat_id) { 1782 var category_image = ''; 1783 1784 if( !child_cat.cat_title && map_obj.map_data.map_tabs.category_tab.all_cats[child_cat.cat_id] ) { 1785 child_cat.cat_title = map_obj.map_data.map_tabs.category_tab.all_cats[child_cat.cat_id].group_map_title; 1786 } 1787 1788 if( !child_cat.cat_marker_icon && map_obj.map_data.map_tabs.category_tab.all_cats[child_cat.cat_id] ) { 1789 child_cat.cat_marker_icon = map_obj.map_data.map_tabs.category_tab.all_cats[child_cat.cat_id].group_marker; 1790 } 1791 if (typeof child_cat.cat_marker_icon != 'undefined') { 1792 category_image = '<span class="arrow"><img src="' + child_cat.cat_marker_icon + '"></span>'; 1793 } 1794 content += '<div class="wpgmp_tab_item" data-container="wpgmp-category-tab-item" style="padding-left:' + padding + 'px;">'; 1795 1796 if(map_obj.map_data.map_tabs.category_tab.parent_cats !== undefined && map_obj.map_data.map_tabs.category_tab.parent_cats[child_cat.cat_id]) 1797 var child_cats_str = ' data-child-cats="'+map_obj.map_data.map_tabs.category_tab.parent_cats[child_cat.cat_id].join(",")+'"'; 1798 else 1799 var child_cats_str = ''; 1800 1801 content += '<input type="checkbox"'+child_cats_str+' data-parent-cat="'+cat_id+'" data-marker-category="' + child_cat.cat_id + '" value="' + child_cat.cat_id + '">'; 1802 1803 var loc_count = child_cat.loc_count; 1804 1805 $.each(map_obj.map_data.map_tabs.category_tab.child_cats, function(k, v) { 1806 if (v == child_cat.cat_id && loc_count == 0) 1807 loc_count = ""; 1808 }); 1809 if (map_obj.map_data.map_tabs.category_tab.show_count === true && loc_count != "") { 1810 location_count = " (" + loc_count + ")"; 1811 } else { 1812 location_count = ""; 1813 } 1814 1815 content += '<a href="javascript:void(0);" class="wpgmp_cat_title accordion accordion-close">
1815' + child_cat.cat_title + location_count + category_image + '</a>'; 1816 1817 if (map_obj.map_data.map_tabs.category_tab.hide_location !== true) { 1818 1819 content += '<div class="scroll-pane" style="height: 97px; width:100%;">'; 1820 content += '<ul class="wpgmp_location_container">'; 1821 1822 $.each(child_cat.data, function(name, location) { 1823 1824 if (location.onclick_action == "marker") { 1825 content += '<li><input type="checkbox" data-marker-location="' + location.cat_location_id + '" value="' + location.cat_location_id + '" /><a data-marker="' + location.cat_location_id + '" data-zoom="' + location.cat_location_zoom + '" href="javascript:void(0);">' + location.cat_location_title + '</a></li>'; 1826 } else if (location.onclick_action == "post") { 1827 content += '<li><input type="checkbox" data-marker-location="' + location.cat_location_id + '" value="' + location.cat_location_id + '" /><a href="' + location.redirect_permalink + '" target="_blank">' + location.cat_location_title + '</a></li>'; 1828 } else if (location.onclick_action == "custom_link") { 1829 content += '<li><input type="checkbox" data-marker-location="' + location.cat_location_id + '" value="' + location.cat_location_id + '" /><a href="' + location.redirect_custom_link + '" target="_blank">' + location.cat_location_title + '</a></li>'; 1830 } 1831 1832 }); 1833 1834 content += '</ul>'; 1835 content += '</div>'; 1836 } 1837 content += '</div>'; 1838 content += map_obj.display_sub_categories(child_categories_tab_data, child_cat.cat_id, '', (padding + 20)); 1839 } else if ((index + 1) == child_categories_tab_data.length) 1840 return; 1841 }); 1842 return content; 1843 }, 1844 sorting: function(order_by, in_order,data_type) { 1845 1846 switch (order_by) { 1847 1848 case 'category': 1849 this.places.sort(this.sortByCategory); 1850 this.show_places.sort(this.sortByCategory); 1851 if (in_order == 'desc') { 1852 this.places.reverse(); 1853 this.show_places.reverse(); 1854 } 1855 break; 1856 1857 case 'title': 1858 this.map_data.places.sort(this.sortByTitle); 1859 this.show_places.sort(this.sortByTitle); 1860 if (in_order == 'desc') { 1861 this.places.reverse(); 1862 this.show_places.reverse(); 1863 } 1864 break; 1865 1866 case 'address': 1867 this.map_data.places.sort(this.sortByAddress); 1868 this.show_places.sort(this.sortByAddress); 1869 if (in_order == 'desc') { 1870 this.places.reverse(); 1871 this.show_places.reverse(); 1872 } 1873 break; 1874 default : 1875 1876 var first_place = this.map_data.places[0]; 1877 if(typeof first_place[order_by] != 'undefined' ) { 1878 this.map_data.places.sort(this.sortByPlace(order_by,data_type)); 1879 this.show_places.sort(this.sortByPlace(order_by,data_type)); 1880 } else if( typeof first_place.location[order_by] !='undefined' ) { 1881 this.map_data.places.sort(this.sortByLocation(order_by,data_type)); 1882 this.show_places.sort(this.sortByLocation(order_by,data_type)); 1883 } else if( typeof first_place.location.extra_fields[order_by] !='undefined' ) { 1884 this.map_data.places.sort(this.sortByExtraFields(order_by,data_type)); 1885 this.show_places.sort(this.sortByExtraFields(order_by,data_type)); 1886 } 1887 1888 if (in_order == 'desc') { 1889 this.places.reverse(); 1890 this.show_places.reverse(); 1891 } 1892 } 1893 }, 1894 1895 sortByExtraFields: function(order_by,data_type) { 1896 1897 return function(a, b) { 1898 1899 if (typeof b.location.extra_fields[order_by] !='undefined' && typeof a.location.extra_fields[order_by] !='undefined') { 1900 1901 if (b.location.extra_fields[order_by] == null) { 1902 b.location.extra_fields[order_by] = ''; 1903 } 1904 1905 if (a.location.extra_fields[order_by] == null) { 1906 a.location.extra_fields[order_by] = ''; 1907 } 1908 1909 if( data_type == 'num' ) { 1910 var a_val = parseInt(a.location.extra_fields[order_by]); 1911 var b_val = parseInt(b.location.extra_fields[order_by]); 1912 } else { 1913 var a_val = a.location.extra_fields[order_by].toLowerCase(); 1914 var b_val = b.location.extra_fields[order_by].toLowerCase(); 1915 } 1916 1917 return ((a_val < b_val) ? -1 : ((a_val > b_val) ? 1 : 0)); 1918 1919 } 1920 } 1921 1922 }, 1923 sortByLocation: function(order_by,data_type) { 1924 return function(a, b) { 1925 1926 if (b.location[order_by] && a.location[order_by]) { 1927 1928 if (a.location[order_by] && b.location[order_by]) { 1929 var a_val = a.location[order_by].toLowerCase(); 1930 var b_val = b.location[order_by].toLowerCase(); 1931 if( data_type == 'num' ) { 1932 a_val = parseInt(a_val); 1933 b_val = parseInt(b_val); 1934 } 1935 return ((a_val < b_val) ? -1 : ((a_val > b_val) ? 1 : 0)); 1936 } 1937 1938 } 1939 } 1940 1941 }, 1942 sortByPlace: function(order_by,data_type) { 1943 1944 return function(a, b) { 1945 1946 if (b[order_by] && a[order_by]) { 1947 1948 if (a[order_by] && b[order_by]) { 1949 var a_val = a[order_by].toLowerCase(); 1950 var b_val = b[order_by].toLowerCase(); 1951 if( data_type == 'num' ) { 1952 a_val = parseInt(a_val); 1953 b_val = parseInt(b_val); 1954 } 1955 return ((a_val < b_val) ? -1 : ((a_val > b_val) ? 1 : 0)); 1956 } 1957 1958 } 1959 } 1960 1961 }, 1962 sortByCategory: function(a, b) { 1963 if (b.categories[0] && a.categories[0]) { 1964 if (a.categories[0].name && b.categories[0].name) { 1965 var a_val = a.categories[0].name.toLowerCase(); 1966 var b_val = b.categories[0].name.toLowerCase(); 1967 return ((a_val < b_val) ? -1 : ((a_val > b_val) ? 1 : 0)); 1968 } 1969 1970 } 1971 }, 1972 1973 sortByTitle: function(a, b) { 1974 var a_val = a.title.toLowerCase(); 1975 var b_val = b.title.toLowerCase(); 1976 return ((a_val < b_val) ? -1 : ((a_val > b_val) ? 1 : 0)); 1977 }, 1978 1979 sortByValue: function(a, b) { 1980 var a_val = a.toLowerCase(); 1981 var b_val = b.toLowerCase(); 1982 return ((a_val < b_val) ? -1 : ((a_val > b_val) ? 1 : 0)); 1983 }, 1984 1985 sortByAddress: function(a, b) { 1986 var a_val = a.address.toLowerCase(); 1987 var b_val = b.address.toLowerCase(); 1988 return ((a_val < b_val) ? -1 : ((a_val > b_val) ? 1 : 0)); 1989 }, 1990 1991 update_filters: function() { 1992 var map_obj = this; 1993 var filters = {}; 1994 1995 var all_dropdowns = $(map_obj.container).find('[data-filter="dropdown"]'); 1996 var all_checkboxes = $(map_obj.container).find('[data-filter="checklist"]:checked'); 1997 var all_list = $(map_obj.container).find('[data-filter="list"].fc_selected'); 1998 1999 $.each(all_dropdowns,function(index,element) { 2000 if( $(this).val() != '' ) { 2001 2002 if(typeof filters[$(this).data('name')] == 'undefined' ) { 2003 filters[$(this).data('name')] = []; 2004 } 2005 2006 filters[$(this).data('name')].push($(this).val()); 2007 } 2008 2009 }); 2010 2011 $.each(all_checkboxes,function(index,element) { 2012 2013 if(typeof filters[$(this).data('name')] == 'undefined' ) { 2014 filters[$(this).data('name')] = []; 2015 } 2016 2017 filters[$(this).data('name')].push($(this).val()); 2018 2019 }); 2020 2021 $.each(all_list,function(index,element) { 2022 2023 if(typeof filters[$(this).data('name')] == 'undefined' ) { 2024 filters[$(this).data('name')] = []; 2025 } 2026 2027 filters[$(this).data('name')].push($(this).data('value').toString()); 2028 2029 }); 2030 this.apply_filters(filters); 2031 2032 }, 2033 2034 apply_url_filters : function() { 2035 2036 var map_obj = this; 2037 var search = location.search.substring(1); 2038 var url_filters = $.parseParams( search || '' ); 2039 var filters = {}; 2040 if(! $.isEmptyObject(url_filters)){ 2041 2042 map_obj.url_filters = url_filters; 2043 2044 $.each(url_filters,function(index,element) { 2045 if(index == 'search'){ 2046 $(map_obj.container).find('[data-input="wpgmp-search-text"]').val(element); 2047 } 2048 }); 2049 2050 map_obj.apply_filters(filters); 2051 } 2052 }, 2053 2054 apply_filters: function(filters) { 2055 var map_obj = this; 2056 2057 var showAll = true; 2058 var show = true; 2059 map_obj.show_places = []; 2060 2061 var enable_search_term = false;
2062 // Filter by search box. 2063 if ($(map_obj.container).find('[data-input="wpgmp-search-text"]').length > 0) { 2064 search_term = $(map_obj.container).find('[data-input="wpgmp-search-text"]').val(); 2065 search_term = search_term.toLowerCase(); 2066 if (search_term.length > 0) { 2067 enable_search_term = true; 2068 } 2069 } 2070 2071 if ((( map_obj.map_data.map_tabs && map_obj.map_data.map_tabs.category_tab && map_obj.map_data.map_tabs.category_tab.cat_tab === true) || $(map_obj.container).find('input[data-marker-category]').length > 0)) { 2072 var all_selected_category_sel = $(map_obj.container).find('input[data-marker-category]:checked'); 2073 var all_selected_category = []; 2074 var all_not_selected_location = []; 2075 if(all_selected_category_sel.length > 0){ 2076 $.each(all_selected_category_sel, function(index, selected_category) { 2077 all_selected_category.push($(selected_category).data("marker-category")); 2078 var all_not_selected_location_sel = $(selected_category).closest('[data-container="wpgmp-category-tab-item"]').find('input[data-marker-location]:not(:checked)'); 2079 if(all_not_selected_location_sel.length > 0){ 2080 $.each(all_not_selected_location_sel, function(index, not_selected_location) { 2081 all_not_selected_location.push($(not_selected_location).data("marker-location")); 2082 }); 2083 } 2084 }); 2085 } 2086 var all_selected_location_sel = $(map_obj.container).find('[data-container="wpgmp-category-tab-item"]').find('input[data-marker-location]:checked'); 2087 var all_selected_location = []; 2088 if(all_selected_location_sel.length > 0){ 2089 $.each(all_selected_location_sel, function(index, selected_location) { 2090 all_selected_location.push($(selected_location).data("marker-location")); 2091 }); 2092 } 2093 } 2094 2095 if (typeof map_obj.map_data.places != 'undefined') { 2096 $.each(map_obj.map_data.places, function(place_key, place) { 2097 2098 show = true; 2099 2100 if (typeof filters != 'undefined') { 2101 $.each(filters, function(filter_key, filter_values) { 2102 2103 var in_fields = false; 2104 2105 if ($.isArray(filter_values)) { 2106 2107 if (typeof place.categories != 'undefined' && filter_key == "category") { 2108 $.each(place.categories, function(cat_index, category) { 2109 if ( $.inArray(category.id,filter_values) > -1 ){ 2110 in_fields = true; 2111 } 2112 }); 2113 } 2114 2115 if (typeof place.custom_filters != 'undefined') { 2116 $.each(place.custom_filters, function(k, val) { 2117 if (filter_key == k) { 2118 in_fields = false; 2119 if ($.isArray(val)) { 2120 $.each(val, function(index, value) { 2121 if ($.inArray(value,filter_values) > -1) 2122 in_fields = true; 2123 }); 2124 } else if (val == filter_values.val) 2125 in_fields = true; 2126 } 2127 }); 2128 } 2129 2130 if (typeof place[filter_key] != 'undefined') { 2131 if( $.inArray(place[filter_key],filter_values) > -1 ) { 2132 in_fields = true; 2133 } 2134 } else if( typeof place.location[filter_key] != 'undefined' ) { 2135 if( $.inArray(place.location[filter_key],filter_values) > -1 ) { 2136 in_fields = true; 2137 } 2138 } else if (typeof place.location.extra_fields[filter_key] != 'undefined') { 2139 2140 if( $.inArray(place.location.extra_fields[filter_key],filter_values) > -1 ) { 2141 in_fields = true; 2142 } 2143 } 2144 2145 if ( in_fields == false ) 2146 show = false;
2147 2148 } else { 2149 filter_values.val = ""; 2150 } 2151 }); 2152 } 2153 //Apply Search Filter. 2154 if (enable_search_term === true && show === true) { 2155 2156 if (place.title.toLowerCase().indexOf(search_term) >= 0) { 2157 show = true; 2158 2159 } else if (place.content.toLowerCase().indexOf(search_term) >= 0) { 2160 show = true; 2161 2162 } else if (place.location.lat.toLowerCase().indexOf(search_term) >= 0) { 2163 show = true; 2164 2165 } else if (place.location.lng.toLowerCase().indexOf(search_term) >= 0) { 2166 show = true; 2167 2168 } else if (place.address && place.address.toLowerCase().indexOf(search_term) >= 0) { 2169 show = true; 2170 } else if (place.location.state && place.location.state.toLowerCase().indexOf(search_term) >= 0) { 2171 show = true; 2172 2173 } else if (place.location.country && place.location.country.toLowerCase().indexOf(search_term) >= 0) { 2174 show = true; 2175 2176 } else if (place.location.postal_code && place.location.postal_code.toLowerCase().indexOf(search_term) >= 0) { 2177 show = true; 2178 2179 } else if (place.location.city && place.location.city.toLowerCase().indexOf(search_term) >= 0) { 2180 show = true; 2181 } else if (typeof map_obj.search_area != 'undefined' && map_obj.search_area != '' && map_obj.wpgmp_within_radius(place, map_obj.search_area) === true) { 2182 show = true; 2183 } else { 2184 show = false; 2185 } 2186 2187 if (typeof place.location.extra_fields != 'undefined') { 2188 $.each(place.location.extra_fields, function(field, value) { 2189 2190 if (value && value.toLowerCase().indexOf(search_term) >= 0) 2191 show = true; 2192 }); 2193 } 2194 2195 } 2196 2197 // if checked category 2198 if (all_selected_category && show != false) { 2199 //var all_selected_category = $('input[data-marker-category]:checked'); 2200 var in_checked_category = false; 2201 2202 if (all_selected_category.length === 0) { 2203 // means no any category selected so show those location without categories. 2204 if (typeof place.categories != 'undefined') { 2205 $.each(place.categories, function(cat_index, category) { 2206 if (category.id === '') 2207 in_checked_category = true; 2208 }); 2209 } 2210 }else{ 2211 if (typeof place.categories != 'undefined') { 2212 $.each(place.categories, function(cat_index, category) { 2213 if (category.id === '') 2214 in_checked_category = true; 2215 else if ($.inArray(parseInt(category.id),all_selected_category) > -1) { 2216 in_checked_category = true; 2217 place.marker.setIcon(category.icon); 2218 } 2219 2220 }); 2221 } 2222 } 2223 2224 //Hide unchecked locations. 2225 if (all_not_selected_location.length !== 0) { 2226 if ($.inArray(parseInt(place.id),all_not_selected_location) > -1) { 2227 in_checked_category = false; 2228 } 2229 } 2230 2231 2232 if (in_checked_category === false) 2233 show = false; 2234 else 2235 show = true; 2236 2237 //Show Here checked location. 2238 if ( all_selected_location.length !== 0) { 2239 if ($.inArray(parseInt(place.id),all_selected_location) > -1) { 2240 show = true; 2241 } 2242 } 2243 2244 } 2245 2246 place.marker.visible = show; 2247 place.marker.setVisible(show); 2248 if( show == false ) { 2249 place.infowindow.close(); 2250 } 2251 place.marker.setAnimation(null); 2252 if (show === true) 2253 map_obj.show_places.push(place); 2254 }); 2255 } 2256 2257 2258 2259 if ( map_obj.map_data.listing ) { 2260 2261 if($(map_obj.container).find('[data-filter="map-sorting"]').val()) { 2262 var order_data = $(map_obj.container).find('[data-filter="map-sorting"]').val().split("__"); 2263 var data_type = ''; 2264 if (order_data[0] !== '' && order_data[1] !== '') { 2265 2266 if(typeof order_data[2] !='undefined') { 2267 data_type = order_data[2]; 2268 } 2269 map_obj.sorting(order_data[0], order_data[1],data_type); 2270 } 2271 } else { 2272 if ( map_obj.map_data.listing.default_sorting ) { 2273 var data_type = ''; 2274 if( map_obj.map_data.listing.default_sorting.orderby == 'listorder') { 2275 data_type = 'num'; 2276 } 2277 map_obj.sorting(map_obj.map_data.listing.default_sorting.orderby, map_obj.map_data.listing.default_sorting.inorder,data_type); 2278 } 2279 } 2280 2281 map_obj.update_places_listing(); 2282 } 2283 2284 if ( map_obj.map_data.marker_cluster) { 2285 map_obj.set_marker_cluster(); 2286 } 2287 2288 }, 2289 2290 create_perpage_option: function() { 2291 2292 var map_obj = this; 2293 var options = ''; 2294 var content = ''; 2295 2296 content += '<select name="map_perpage_location_sorting" data-filter="map-perpage-location-sorting" class="choose_salutation">'; 2297 content += '<option value="' + map_obj.map_data.listing.pagination.listing_per_page + '">' + wpgmp_local.show_locations + '</option>'; 2298 content += '<option value="25">25</option>'; 2299 content += '<option value="50">50</option>'; 2300 content += '<option value="100">100</option>'; 2301 content += '<option value="200">200</option>'; 2302 content += '<option value="500">500</option>'; 2303 content += '<option value="' + map_obj.show_places.length + '">' + wpgmp_local.all_location + '</option>'; 2304 content += '</select>'; 2305 2306 return content; 2307 2308 }, 2309 2310 create_sorting: function() { 2311 2312 var options = ''; 2313 2314 var content = ''; 2315 2316 if (this.map_data.listing.display_sorting_filter === true) { 2317 content += '<select name="map_sorting" data-filter="map-sorting"><option value="">' + wpgmp_local.sort_by + '</option>'; 2318 $.each(this.map_data.listing.sorting_options, function(id, name) { 2319 content += "<option value='" + id + "'>" + name + "</option>"; 2320 }); 2321 content += '</select>'; 2322 } 2323 2324 return content; 2325 }, 2326 2327 create_radius: function() { 2328 2329 var options = ''; 2330 2331 var content = ''; 2332 if (this.map_data.listing.display_radius_filter === true) { 2333 2334 content += '<select data-name="radius" name="map_radiu
2334s"><option value="">' + wpgmp_local.select_radius + '</option>'; 2335 var radius_options = this.map_data.listing.radius_options; 2336 var radius_dimension = this.map_data.listing.radius_dimension; 2337 $.each(radius_options.split(','), function(id, name) { 2338 if (radius_dimension == 'miles') { 2339 content += "<option value='" + name + "'>" + name + ' ' + wpgmp_local.miles + "</option>"; 2340 } else { 2341 content += "<option value='" + name + "'>" + name + ' ' + wpgmp_local.km + "</option>"; 2342 } 2343 }); 2344 content += '</select>'; 2345 } 2346 2347 return content; 2348 }, 2349 2350 custom_filters: function() { 2351 var map_obj = this; 2352 var options = ''; 2353 var places = this.map_data.places; 2354 var wpgmp_filters = this.map_data.filters; 2355 if( typeof wpgmp_filters == 'undefined' || typeof wpgmp_filters.custom_filters == 'undefined' || wpgmp_filters.custom_filters.length == 0 ) { 2356 return; 2357 } 2358 2359 $.each(wpgmp_filters.custom_filters, function(template_shortcode, filter_options) { 2360 var all_filters = []; 2361 var content = ''; 2362 var filters = {}; 2363 $.each(filter_options,function(filter_type,filter_parameter){ 2364 2365 $.each(filter_parameter, function(filter_name, filter_label) { 2366 $.each(places, function(index, place) { 2367 if( filter_name == 'category' ) { 2368 if (typeof place.categories == 'undefined') { 2369 place.categories = {}; 2370 } 2371 $.each(place.categories, function(cat_index, category) { 2372 2373 if (typeof filters[category.type] == 'undefined') { 2374 filters[category.type] = {}; 2375 } 2376 if (category.name) { 2377 filters[category.type][category.name] = category.id; 2378 } 2379 2380 }); 2381 2382 } else { 2383 2384 if (typeof place[filter_name] != 'undefined') { 2385 if (typeof filters[filter_name] == 'undefined') { 2386 filters[filter_name] = {}; 2387 } 2388 if (place[filter_name]) { 2389 filters[filter_name][place[filter_name]] = place[filter_name]; 2390 } 2391 } 2392 2393 if (typeof place.location.extra_fields[filter_name] != 'undefined') { 2394 if (typeof filters[filter_name] == 'undefined') { 2395 filters[filter_name] = {}; 2396 } 2397 if (place.location.extra_fields[filter_name]) { 2398 filters[filter_name][place.location.extra_fields[filter_name]] = place.location.extra_fields[filter_name]; 2399 } 2400 } 2401 2402 if (typeof place.location[filter_name] != 'undefined') { 2403 if (typeof filters[filter_name] == 'undefined') { 2404 filters[filter_name] = {}; 2405 } 2406 if (place.location[filter_name]) { 2407 filters[filter_name][place.location[filter_name]] = place.location[filter_name]; 2408 } 2409 } 2410 2411 if (typeof place.custom_filters != 'undefined' && typeof place.custom_filters[filter_name] != 'undefined' ) { 2412 if (typeof filters[filter_name] == 'undefined') { 2413 filters[filter_name] = {}; 2414 } 2415 if (place.custom_filters[filter_name]) { 2416 var options = place.custom_filters[filter_name]; 2417 if ($.isArray(options)) { 2418 $.each(options, function(index, value) { 2419 filters[filter_name][value] = value; 2420 }); 2421 } else { 2422 filters[filter_name][options] = options; 2423 } 2424 } 2425 } 2426 2427 // It could be radius filter. 2428 if( filter_name == 'radius' ) { 2429 if (typeof filters[filter_name] == 'undefined') { 2430 filters[filter_name] = {}; 2431 } 2432 2433 var radius_options = wpgmp_filters.radius_options; 2434 var radius_dimension = wpgmp_filters.radius_dimension; 2435 $.each(radius_options.split(','), function(id, name) { 2436 if (radius_dimension == 'miles') { 2437 filters[filter_name][name + ' ' + wpgmp_local.miles] = name; 2438 } else { 2439 filters[filter_name][name + ' ' + wpgmp_local.km] = name; 2440 } 2441 }); 2442 2443 } 2444 } 2445 2446 }); 2447 2448 }); 2449 2450 2451 2452 if( filter_type == 'dropdown' ) { 2453 if(typeof filters != 'undefined' ) { 2454 $.each(filters, function(index, options) { 2455 options = map_obj.sort_object_by_value(options); 2456 content += '<select data-filter="dropdown" name="place_' + index + '" data-name = "' + index + '">'; 2457 content += '<option value="">' + ((filter_parameter[index]) ? filter_parameter[index] : 'Select ' + index) + '</option>'; 2458 $.each(options, function(name, value) { 2459 if (value != '' && value != null) 2460 content += "<option value='" + value + "'>" + value + "</option>"; 2461 }); 2462 content += '</select>'; 2463 }); 2464 } 2465 } 2466 2467 if( filter_type == 'checklist' ) { 2468 if(typeof filters != 'undefined' ) { 2469 $.each(filters, function(index, options) { 2470 content += '<div class="wpgmp_filters_checklist">'; 2471 content += '<label data-filter = "place_' + index + '" >' + ((wpgmp_filters.custom_filters[index]) ? wpgmp_filters.custom_filters[index] : 'Select ' + index) + '</label>'; 2472 $.each(options, function(name, value) { 2473 if (value != '' && value != null) 2474 content += "<input data-filter='checklist' type='checkbox' data-name = '" + index + "' value='" + value + "'>" + name; 2475 }); 2476 content += '</div>'; 2477 }); 2478 } 2479 } 2480 2481 if( filter_type == 'list' ) { 2482 if(typeof filters != 'undefined' ) { 2483 $.each(filters, function(index, options) { 2484 content += '<div class="wpgmp_filters_list">'; 2485 content += '<label data-filter = "place_' + index + '" >' + ((wpgmp_filters.custom_filters[index]) ? wpgmp_filters.custom_filters[index] : 'Select ' + index) + '</label><ul>'; 2486 $.each(options, function(name, value) { 2487 if (value != '' && value != null) 2488 content += "<li data-filter='list' data-name = '" + index + "' data-value='" + value + "'>" + name + "</li>"; 2489 }); 2490 content += '</ul></div>'; 2491 }); 2492 } 2493 } 2494 }); 2495 2496 //$(map_obj.container).find("."+template_shortcode).html(content); 2497 $('body').find(wpgmp_filters.filters_container).append(content); 2498 }); 2499 2500 2501 2502 // now create select boxes 2503 2504 2505 2506 }, 2507 sort_object_by_keyvalue: function(options, by, type, in_order ) { 2508 2509 var sortable = []; 2510 for (var key in options) { 2511 sortable.push(options[key]); 2512 } 2513 2514 sortable.sort(this.sortByPlace(by,type)); 2515 2516 if(in_order == 'desc') { 2517 sortable.reverse(); 2518 } 2519 2520 return sortable; 2521 }, 2522 sort_object_by_value: function(options) { 2523 2524 var sortable = []; 2525 for (var key in options) { 2526 sortable.push(key); 2527 } 2528 2529 sortable.sort(this.sortByValue); 2530 var new_options = {} 2531 for(i=0;i<sortable.length;i++) { 2532 new_options[sortable[i]] = options[sortable[i]]; 2533 } 2534 2535 return new_options; 2536 }, 2537 create_filters: function() { 2538 var map_obj = this; 2539 var options = ''; 2540 var filters = {}; 2541 var places = this.map_data.places; 2542 var wpgmp_listing_filter = this.map_data.listing; 2543 var wpgmp_alltfilter = wpgmp_listing_filter.display_taxonomies_all_filter; 2544 2545 $.each(places, function(index, place) { 2546 if (typeof place.categories == 'undefined') { 2547 place.categories = {}; 2548 } 2549 $.each(place.categories, function(cat_index, category) { 2550 2551 if (typeof filters[category.type] == 'undefined') { 2552 filters[category.type] = {}; 2553 } 2554 2555 if (category.name) { 2556 if( category.extension_fields && category.extension_fields.cat_order ) { 2557 filters[category.type][category.name] = {'id':category.id,'order':category.extension_fields.cat_order,'name': category.name}; 2558 } else { 2559 filters[category.type][category.name] = {'id':category.id,'order':0,'name':category.name}; 2560 } 2561 2562 } 2563 2564 }); 2565 }); 2566 // now create select boxes 2567 2568 var content = '', by='name',type='', inorder='asc'; 2569 2570 if ( map_obj.map_data.listing ) { 2571 if ( map_obj.map_data.listing.default_sorting ) { 2572 if( map_obj.map_data.listing.default_sorting.orderby == 'listorder') { 2573 by = 'order'; 2574 type = 'num'; 2575 inorder = map_obj.map_data.listing.default_sorting.inorder; 2576 } 2577 inorder = map_obj.map_data.listing.default_sorting.inorder; 2578 } 2579 2580 } 2581 2582 $.each(filters, function(index, options) { 2583 if (wpgmp_listing_filter.display_category_filter === true && index == "category") { 2584 content += '<select data-filter="dropdown" data-name="category" name="place_' + index + '">'; 2585 content += '<option value="">' + wpgmp_local.select_category + '</option>'; 2586 options = map_obj.sort_object_by_keyvalue(options,by,type,inorder); 2587 $.each(options, function(name, value) { 2588 content += "<option value='" + value.id + "'>" + value.name + "</option>"; 2589 }); 2590 content += '</select>'; 2591 } else if (wpgmp_listing_filter.display_taxonomies_filter === true) { 2592 if (wpgmp_alltfilter === null) 2593 return false;
2594 2595 if (wpgmp_alltfilter.indexOf(index) > -1) { 2596 content += '<select data-filter="dropdown" data-name="category" name="place_' + index + '">'; 2597 content += '<option value="">Select ' + index + '</option>'; 2598 $.each(options, function(name, value) { 2599 content += "<option value='" + value + "'>" + name + "</option>"; 2600 }); 2601 content += '</select>'; 2602 } 2603 } 2604 2605 }); 2606 2607 return content; 2608 }, 2609 2610 update_places_listing: function() { 2611 2612 var map_obj = this; 2613 2614 if (map_obj.per_page_value > 0) 2615 map_obj.per_page_value = map_obj.per_page_value; 2616 else 2617 map_obj.per_page_value = map_obj.map_data.listing.pagination.listing_per_page; 2618 $(map_obj.container).find(".location_pagination" + map_obj.map_data.map_property.map_id).pagination(map_obj.show_places.length, { 2619 callback: map_obj.display_places_listing, 2620 map_data: map_obj, 2621 items_per_page: map_obj.per_page_value, 2622 prev_text: wpgmp_local.prev, 2623 next_text: wpgmp_local.next 2624 }); 2625 2626 }, 2627 2628 display_filters_listing: function() { 2629 2630 if( this.map_data.listing ) { 2631 2632 var hide_locations = this.map_data.listing.hide_locations; 2633 2634 var wpgmpgl = this.map_data.listing.list_grid; 2635 2636 if(hide_locations != true) { 2637 2638 var content = '<div class="wpgmp_listing_container">'; 2639 2640 2641 content += "<div class='wpgmp_categories wpgmp_print_listing " + wpgmpgl + "' data-container='wpgmp-listing-" + $(this.element).attr("id") + "'></div>"; 2642 2643 2644 content += "</div>"; 2645 2646 $(this.map_data.listing.listing_container).html(content); 2647 2648 } 2649 2650 var filter_position = this.map_data.listing.filters_position; 2651 var filter_content = '<div class="wpgmp_filter_wrappers">'+this.display_filters()+'</div>'; 2652 2653 2654 if( filter_position == 'top_map' ) { 2655 $(this.container).find(".wpgmp_map").before(filter_content); 2656 } else if( hide_locations == true ) { 2657 $(this.container).find(".wpgmp_map").after(filter_content); 2658 } else { 2659 $(this.container).find(".wpgmp_categories").before(filter_content); 2660 } 2661 2662 } 2663 2664 }, 2665 2666 display_filters: function() { 2667 2668 var hide_locations = this.map_data.listing.hide_locations; 2669 2670 var content = ''; 2671 content += '<div class="wpgmp_before_listing">' + this.map_data.listing.listing_header + '</div>'; 2672 2673 if (this.map_data.listing.display_search_form === true) { 2674 var autosuggest_class = ''; 2675 2676 if( this.map_data.listing.search_field_autosuggest === true ) { 2677 autosuggest_class = "wpgmp_auto_suggest"; 2678 } 2679 2680 content += '<div class="wpgmp_listing_header"><div class="wpgmp_search_form"><input type="text" rel="24" data-input="wpgmp-search-text" name="wpgmp_search_input" class="wpgmp_search_input '+autosuggest_class+'" placeholder="' + wpgmp_local.search_placeholder + '"></div></div>'; 2681 } 2682 2683 content += '<div class="categories_filter">' + this.create_filters() +'<div data-container="wpgmp-filters-container"></div>'; 2684 2685 if( hide_locations != true ) 2686 content += this.create_sorting() + ''; 2687 2688 if (hide_locations != true && this.map_data.listing.display_location_per_page_filter === true) { 2689 content += ' ' + this.create_perpage_option() + ' '; 2690 } 2691 2692 content += ' ' + this.create_radius() + ' '; 2693 2694 if ( hide_locations != true && this.map_data.listing.display_print_option === true) { 2695 content += ' ' + wpgmp_local.img_print; 2696 } 2697 2698 if (hide_locations != true && this.map_data.listing.display_grid_option === true) { 2699 content += ' ' + wpgmp_local.img_grid + wpgmp_local.img_list; 2700 } 2701 2702 content += '</div>'; 2703 2704 return content; 2705 }, 2706 2707 find_direction: function(options) { 2708 2709 var map_obj = this; 2710 var request = { 2711 origin: options.start, 2712 destination: options.end, 2713 optimizeWaypoints: true, 2714 travelMode: eval("google.maps.TravelMode." + options.mode), 2715 unitSystem: eval("google.maps.UnitSystem." + options.unit) 2716 }; 2717 map_obj.directionsService = new google.maps.DirectionsService(); 2718 map_obj.directionsService.route(request, function(response, status) { 2719 if (status == google.maps.DirectionsStatus.OK) { 2720
2721 map_obj.directionsDisplay.setMap(map_obj.map); 2722 map_obj.directionsDisplay.setDirections(response); 2723 if (false == map_obj.map_data.map_tabs.direction_tab.suppress_markers) { 2724 map_obj.directionsDisplay.setPanel(options.direction_panel); 2725 $(options.direction_panel).css('display', 'block'); 2726 } 2727 2728 } 2729 }); 2730 }, 2731 2732 display_places_listing: function(page_index, jq) { 2733 2734 var content = ''; 2735 2736 var map_obj = this; 2737 var items_per_page = 10; 2738 if (map_obj.items_per_page) 2739 items_per_page = map_obj.items_per_page; 2740 else 2741 items_per_page = map_obj.map_data.map_data.listing.pagination.listing_per_page; 2742 2743 var data_source = map_obj.map_data.show_places; 2744 2745 var listing_container = map_obj.map_data.map_data.listing.listing_container; 2746 2747 2748 var listing_placeholder = map_obj.map_data.map_data.listing.listing_placeholder; 2749 2750 var max_elem = Math.min((page_index + 1) * items_per_page, data_source.length); 2751 var link = ''; var onclick_action=''; 2752 if (max_elem > 0) { 2753 for (var i = page_index * items_per_page; i < max_elem; i++) { 2754 var place = data_source[i]; 2755 var temp_listing_placeholder = listing_placeholder; 2756 if (place.marker.visible === true) { 2757 if (place.id) { 2758 if (place.location.onclick_action == "marker") { 2759 link = '<a href="javascript:void(0);" class="place_title" data-zoom="' + place.location.zoom + '" data-marker="' + place.id + '" >' + place.title + '</a>'; 2760 onclick_action='href="javascript:void(0);" data-zoom="' + place.location.zoom + '" data-marker="' + place.id + '"'; 2761 } else if (place.location.onclick_action == "post") { 2762 link = '<a href="' + place.location.redirect_permalink + '" target="_blank">' + place.title + '</a>'; 2763 onclick_action='href="' + place.location.redirect_permalink + '" target="_blank"'; 2764 } else if (place.location.onclick_action == "custom_link") { 2765 link = '<a href="' + place.location.redirect_custom_link + '" target="_blank">' + place.title + '</a>'; 2766 onclick_action='href="' + place.location.redirect_custom_link + '" target="_blank"'; 2767 } 2768 } 2769 2770 var image = []; 2771 var category_name = []; 2772 var wpgmp_arr = {}; 2773 2774 if (place.categories) { 2775 for (c = 0; c < place.categories.length; c++) { 2776 if (place.categories[c].icon !== '') { 2777 image.push("<img title='" + place.categories[c].name + "' alt='" + place.categories[c].name + "' src='" + place.categories[c].icon + "' />"); 2778 } 2779 2780 if (place.categories[c].type == 'category' && place.categories[c].name != '') { 2781 category_name.push(place.categories[c].name); 2782 } 2783 2784 if (place.categories[c].type != 'category') { 2785 if (typeof place.categories[c].name == "undefined") 2786 continue; 2787 2788 if (place.categories[c].name) 2789 var sep = ','; 2790 2791 if (typeof wpgmp_arr[place.categories[c].type] == "undefined") 2792 wpgmp_arr[place.categories[c].type] = ''; 2793 2794 wpgmp_arr[place.categories[c].type] += place.categories[c].name + sep; 2795 } 2796 } 2797 } 2798 2799 var marker_image = ''; 2800 2801 if( place.source == 'post' ) { 2802 marker_image = place.location.extra_fields.post_featured_image; 2803 } else { 2804 marker_image = place.location.marker_image; 2805 } 2806 var replaceData = { 2807 "{marker_id}": place.id, 2808 "{marker_title}": link, 2809 "{marker_address}": place.address, 2810 "{marker_latitude}": place.location.lat, 2811 "{marker_longitude}": place.location.lng, 2812 "{marker_city}": place.location.city, 2813 "{marker_state}": place.location.state, 2814 "{marker_country}": place.location.country, 2815 "{marker_postal_code}": place.location.postal_code, 2816 "{marker_zoom}": place.location.zoom, 2817 "{marker_icon}": image, 2818 "{marker_category}": category_name.join(", "), 2819 "{marker_message}": place.content, 2820 "{marker_image}": marker_image, 2821 "{marker_featured_image}": marker_image, 2822 "{wpgmp_listing_html}": place.listing_hook, 2823 "{onclick_action}":onclick_action 2824 2825 }; 2826 2827 //Add extra fields of locations 2828 if (typeof place.location.extra_fields != 'undefined') { 2829 for (var extra in place.location.extra_fields) { 2830 if (!place.location.extra_fields[extra]) { 2831 replaceData['{' + extra + '}'] = '<div class="wpgmp_empty"></div>'; 2832 2833 } else { 2834 replaceData['{' + extra + '}'] = place.location.extra_fields[extra]; 2835 } 2836 } 2837 } 2838 2839 if (wpgmp_arr) { 2840 for (var n in wpgmp_arr) { 2841 replaceData["{" + n + "}"] = wpgmp_remove_last_comma(wpgmp_arr[n]); 2842 } 2843 } 2844 2845 function wpgmp_remove_last_comma(strng) { 2846 var n = strng.lastIndexOf(","); 2847 var a = strng.substring(0, n) 2848 return a; 2849 } 2850 2851 temp_listing_placeholder = temp_listing_placeholder.replace(/{[^{}]+}/g, function(match) { 2852 if (match in replaceData) { 2853 return (replaceData[match]); 2854 } else { 2855 return (""); 2856 } 2857 }); 2858 2859 content += temp_listing_placeholder; 2860 } 2861 } 2862 } else { 2863 content = "<div class='wpgmp_no_locations'>" + wpgmp_local.wpgmp_location_no_results + "</div>"; 2864 } 2865 2866 content += '<div id="wpgmp_pagination"></div>'; 2867 2868 content = '<div class="fc-'+map_obj.map_data.map_data.listing.list_item_skin.type+'-'+map_obj.map_data.map_data.listing.list_item_skin.name+' fc-wait"><div data-page="2" class="fc-component-6" data-layout="' + map_obj.map_data.map_data.listing.list_item_skin.name + '" >'+content+'</div></div>'; 2869 2870 $(listing_container).find(".wpgmp_categories").html(content); 2871 2872 $(listing_container).find(".wpgmp_empty").prev().remove(); 2873 $(listing_container).find(".wpgmp_empty").remove(); 2874 2875 try { 2876 var container = $(listing_container).find('.wpgmp_listing_grid'); 2877 if(container){ 2878 2879 var msnry = $(container).data('masonry'); 2880 if(msnry) { 2881 msnry.destroy(); 2882 } 2883 2884 var $grid = $(container).imagesLoaded( function() { 2885 // init Masonry after all images have loaded 2886 $grid.masonry({ 2887 itemSelector: '.wpgmp_listing_grid .wpgmp_locations', 2888 columnWidth: '.wpgmp_listing_grid .wpgmp_locations', 2889 }); 2890 }); 2891 2892 } 2893 2894 } catch( err) { 2895 console.log(err); 2896 } 2897 2898 return false;
2899 }, 2900 2901 open_infowindow: function(current_place) { 2902 var map_obj = this; 2903 2904 $.each(this.map_data.places, function(key, place) { 2905 if (parseInt(place.id) == parseInt(current_place) && place.marker.visible === true) { 2906 google.maps.event.trigger(place.marker, 'click'); } 2907 }); 2908 }, 2909 2910 place_info: function(place_id) { 2911 2912 var place_obj; 2913 2914 $.each(this.places, function(index, place) { 2915 2916 if (parseInt(place.id) == parseInt(place_id)) { 2917 place_obj = place; 2918 } 2919 }); 2920 2921 return place_obj; 2922 }, 2923 2924 create_routes: function() { 2925 var map_obj = this; 2926 if (this.map_data.routes) { 2927 $.each(this.map_data.routes, function(index, routeobj) { 2928 2929 var directionsService = new google.maps.DirectionsService(); 2930 2931 var route_polyline = { 2932 strokeColor: routeobj.route_stroke_color, 2933 strokeOpacity: routeobj.route_stroke_opacity, 2934 strokeWeight: routeobj.route_stroke_weight, 2935 clickable: routeobj.route_marker_draggable 2936 }; 2937 2938 var renderer_options = { 2939 draggable: routeobj.route_marker_draggable, 2940 suppressMarkers: true, 2941 suppressInfoWindows: true, 2942 preserveViewport: true, 2943 polylineOptions: route_polyline, 2944 2945 }; 2946 2947 2948 var start = routeobj.start_location_data; 2949 var end = routeobj.end_location_data; 2950 var waypts = []; 2951 if (typeof routeobj.way_points != 'undefined') { 2952 $.each(routeobj.way_points, function(point_index, place) { 2953 waypts.push({ 2954 location: place, 2955 stopover: true 2956 }); 2957 }); 2958 } 2959 2960 var request = { 2961 origin: start, 2962 destination: end, 2963 2964 waypoints: waypts, 2965 optimizeWaypoints: routeobj.route_optimize_waypoints, 2966 2967 travelMode: eval("google.maps.TravelMode." + routeobj.route_travel_mode), 2968 unitSystem: eval("google.maps.UnitSystem." + routeobj.route_unit_system), 2969 }; 2970 2971 directionsService.route(request, function(response, status) { 2972 2973 if (status == google.maps.DirectionsStatus.OK) { 2974 directionsDisplay = new google.maps.DirectionsRenderer(renderer_options); 2975 directionsDisplay.setMap(map_obj.map); 2976 directionsDisplay.setDirections(response); 2977 directionsDisplay.setPanel($(".directions-panel-route" + routeobj.route_id + "").get(0)); 2978 2979 if (typeof routeobj.route_id != 'undefined') { 2980 /* 2981 if (typeof routeobj.route_direction_panel != 'undefined') { 2982 if (routeobj.route_direction_panel == true) { 2983 var dirpanel = $(".wpgmp_direction_panel_route" + routeobj.route_id + "").get(0); 2984 2985 dirpanel.innerHTML = ""; 2986 2987 $.each(response.routes, function(key, value) { 2988 2989 $.each(value.legs, function(key1, dir) { 2990 2991 var output = ''; 2992 2993 output += '<div class="dir_start">' + dir.start_address + '</div>'; 2994 output += '<div class="dir_summary silver">' + dir.distance.text + ' - about ' + dir.duration.text + '</div>'; 2995 output += '<table>'; 2996 for (i = 0;
2996 i < dir.steps.length; i++) { 2997 output += '<tr style="border-bottom: 1px solid silver;">'; 2998 output += '<td class="dir_row"><span class="dir_sprite ' + dir.steps[i].maneuver + '"></span></td>'; 2999 output += '<td class="dir_row">' + (i + 1) + '.</td>'; 3000 output += '<td class="dir_row">' + dir.steps[i].instructions + '</td>'; 3001 output += '<td class="dir_row" style="white-space:nowrap;">' + dir.steps[i].distance.text + '</td>'; 3002 output += '</tr>'; 3003 } 3004 output += '</table>'; 3005 output += '<div class="dir_end">' + dir.end_address + '</div>'; 3006 3007 dirpanel.innerHTML += output; 3008 3009 }); 3010 }); 3011 } 3012 } 3013 */ 3014 map_obj.route_directions[routeobj.route_id] = directionsDisplay; 3015 } 3016 } else { 3017 console.log("" + wpgmp_local.wpgmp_route_not_avilable + ""); 3018 } 3019 }); 3020 }); 3021 } 3022 3023 }, 3024 3025 enable_drawing: function() { 3026 var map_obj = this; 3027 map_obj.drawingmanager = new google.maps.drawing.DrawingManager({ 3028 drawingMode: null, 3029 drawingControl: true, 3030 drawingControlOptions: { 3031 position: google.maps.ControlPosition.TOP_CENTER, 3032 drawingModes: [ 3033 3034 google.maps.drawing.OverlayType.CIRCLE, google.maps.drawing.OverlayType.POLYGON, google.maps.drawing.OverlayType.POLYLINE, google.maps.drawing.OverlayType.RECTANGLE 3035 3036 ] 3037 }, 3038 3039 circleOptions: { 3040 fillColor: '#003dce', 3041 strokeColor: '#003dce', 3042 strokeWeight: '1', 3043 strokeOpacity: '0.5', 3044 zindex: 1, 3045 fillOpacity: '0.5', 3046 editable: false, 3047 draggable: false 3048 }, 3049 polygonOptions: { 3050 fillColor: '#003dce', 3051 strokeColor: '#003dce', 3052 strokeWeight: '1', 3053 strokeOpacity: '0.5', 3054 zindex: 1, 3055 fillOpacity: '0.5', 3056 editable: false, 3057 draggable: false 3058 }, 3059 polylineOptions: { 3060 fillColor: '#003dce', 3061 strokeColor: '#003dce', 3062 strokeWeight: '1', 3063 strokeOpacity: '0.5', 3064 zindex: 1, 3065 fillOpacity: '0.5', 3066 editable: false, 3067 draggable: false 3068 }, 3069 rectangleOptions: { 3070 fillColor: '#003dce', 3071 strokeColor: '#003dce', 3072 strokeWeight: '1', 3073 strokeOpacity: '0.5', 3074 zindex: 1, 3075 fillOpacity: '0.5', 3076 editable: false, 3077 draggable: false 3078 } 3079 }); 3080 map_obj.drawingmanager.setMap(map_obj.map); 3081 map_obj.event_listener(map_obj.drawingmanager, 'circlecomplete', function(circle) { 3082 map_obj.wpgmp_circles.push(circle); 3083 map_obj.wpgmp_shape_complete(circle, 'circle'); 3084 }); 3085 map_obj.event_listener(map_obj.drawingmanager, 'polygoncomplete', function(polygon) { 3086 map_obj.wpgmp_polygons.push(polygon);
3087 map_obj.wpgmp_shape_complete(polygon, 'polygon'); 3088 }); 3089 map_obj.event_listener(map_obj.drawingmanager, 'polylinecomplete', function(polyline) { 3090 map_obj.wpgmp_polylines.push(polyline); 3091 map_obj.wpgmp_shape_complete(polyline, 'polyline'); 3092 }); 3093 map_obj.event_listener(map_obj.drawingmanager, 'rectanglecomplete', function(rectangle) { 3094 map_obj.wpgmp_rectangles.push(rectangle); 3095 map_obj.wpgmp_shape_complete(rectangle, 'rectangle'); 3096 }); 3097 }, 3098 3099 create_polygon: function() { 3100 3101 var map_obj = this; 3102 3103 $.each(this.map_data.shapes.shape.polygons, function(index, polygon) { 3104 var path = []; 3105 $.each(polygon.cordinates, function(ind, cordinate) { 3106 var latlng = cordinate.split(','); 3107 path.push(new google.maps.LatLng(latlng[0], latlng[1])); 3108 }); 3109 3110 polygon.reference = new google.maps.Polygon({ 3111 paths: path, 3112 strokeColor: polygon.settings.stroke_color, 3113 strokeOpacity: polygon.settings.stroke_opacity, 3114 strokeWeight: polygon.settings.stroke_weight, 3115 fillColor: polygon.settings.fill_color, 3116 fillOpacity: polygon.settings.fill_opacity 3117 }); 3118 if (typeof map_obj.map_data.shapes != 'undefined') { 3119 3120 if (map_obj.map_data.shapes.drawing_editable === true) { 3121 map_obj.event_listener(polygon.reference, "click", function() { 3122 map_obj.setSelection(polygon.reference); 3123 map_obj.get_shapes_options(polygon.reference, 'polygon'); 3124 }); 3125 3126 3127 } else if (polygon.events.url !== '' || polygon.events.message !== '') { 3128 3129 map_obj.event_listener(polygon.reference, "click", function() { 3130 3131 if (polygon.events.url === '' && polygon.events.message !== '') { 3132 var bounds = new google.maps.LatLngBounds(); 3133 polygon.reference.getPath().forEach(function(element, index) { 3134 bounds.extend(element); 3135 }); 3136 $.each(map_obj.places, function(key, place) { 3137 place.infowindow.close(); 3138 }); 3139 map_obj.opened_info.setPosition(bounds.getCenter()); 3140 if (map_obj.settings.map_infowindow_customisations === true) 3141 map_obj.opened_info.setContent('<div class="wpgmp_infowindow"><div class="wpgmp_iw_content">' + polygon.events.message + '</div></div>'); 3142 else 3143 map_obj.opened_info.setContent(polygon.events.message); map_obj.opened_info.open(map_obj.map, this); 3144 3145 } else { 3146 window.location = polygon.events.url; 3147 } 3148 3149 }); 3150 3151 } 3152 } 3153 polygon.reference.setMap(map_obj.map); 3154 3155 map_obj.wpgmp_polygons.push(polygon.reference); 3156 map_obj.wpgmp_shape_events.push({ 3157 'shape': polygon.reference, 3158 'url': polygon.events.url, 3159 'message': polygon.events.message 3160 }); 3161 }); 3162 }, 3163 3164 create_polyline: function() { 3165 3166 var map_obj = this; 3167 3168 3169 $.each(this.map_data.shapes.shape.polylines, function(index, polyline) { 3170 var path = []; 3171
3172 if (typeof polyline.cordinates != 'undefined') { 3173 $.each(polyline.cordinates, function(ind, cordinate) { 3174 var latlng = cordinate.split(','); 3175 path.push(new google.maps.LatLng(latlng[0], latlng[1])); 3176 }); 3177 3178 polyline.reference = new google.maps.Polyline({ 3179 path: path, 3180 strokeColor: polyline.settings.stroke_color, 3181 strokeOpacity: polyline.settings.stroke_opacity, 3182 strokeWeight: polyline.settings.stroke_weight 3183 }); 3184 3185 3186 3187 if (typeof map_obj.map_data.shapes != 'undefined') { 3188 3189 if (map_obj.map_data.shapes.drawing_editable === true) { 3190 3191 map_obj.event_listener(polyline.reference, "click", function() { 3192 map_obj.setSelection(polyline.reference); 3193 map_obj.get_shapes_options(polyline.reference, 'polyline'); 3194 }); 3195 3196 3197 } else if (polyline.events.url !== '' || polyline.events.message !== '') { 3198 3199 map_obj.event_listener(polyline.reference, "click", function() { 3200 3201 3202 if (polyline.events.url === '' && polyline.events.message !== '') { 3203 var bounds = new google.maps.LatLngBounds(); 3204 polyline.reference.getPath().forEach(function(element, index) { 3205 bounds.extend(element); 3206 }); 3207 $.each(map_obj.places, function(key, place) { 3208 place.infowindow.close(); 3209 }); 3210 map_obj.opened_info.setPosition(bounds.getCenter()); 3211 if (map_obj.settings.map_infowindow_customisations === true) 3212 map_obj.opened_info.setContent('<div class="wpgmp_infowindow"><div class="wpgmp_iw_content">' + polyline.events.message + '</div></div>'); 3213 else 3214 map_obj.opened_info.setContent(polyline.events.message); 3215 map_obj.opened_info.open(map_obj.map, this); 3216 3217 } else if (polyline.events.url !== '') { 3218 window.location = polyline.events.url; 3219 } 3220 3221 }); 3222 3223 3224 } 3225 } 3226 }
3227 if (typeof polyline.reference != 'undefined') { 3228 polyline.reference.setMap(map_obj.map); 3229 map_obj.wpgmp_polylines.push(polyline.reference); 3230 map_obj.wpgmp_shape_events.push({ 3231 'shape': polyline.reference, 3232 'url': polyline.events.url, 3233 'message': polyline.events.message 3234 }); 3235 } 3236 }); 3237 }, 3238 event_listener: function(obj, type, func) { 3239 google.maps.event.addListener(obj, type, func); 3240 }, 3241 create_circle: function() { 3242 3243 var map_obj = this; 3244 $.each(this.map_data.shapes.shape.circles, function(index, circle) { 3245 var path; 3246 $.each(circle.cordinates, function(ind, cordinate) { 3247 var latlng = cordinate.split(','); 3248 path = new google.maps.LatLng(latlng[0], latlng[1]); 3249 }); 3250 3251 circle.reference = new google.maps.Circle({ 3252 fillColor: circle.settings.fill_color, 3253 fillOpacity: circle.settings.fill_opacity, 3254 strokeColor: circle.settings.stroke_color, 3255 strokeOpacity: circle.settings.stroke_opacity, 3256 strokeWeight: circle.settings.stroke_weight, 3257 center: path, 3258 radius: parseInt(circle.settings.radius) 3259 }); 3260 3261 if (typeof map_obj.map_data.shapes != 'undefined') { 3262 3263 if (map_obj.map_data.shapes.drawing_editable === true) { 3264 map_obj.event_listener(circle.reference, "click", function() { 3265 map_obj.setSelection(circle.reference); 3266 map_obj.get_shapes_options(circle.reference, 'circle'); 3267 }); 3268 3269 } else if (circle.events.url !== '' || circle.events.message !== '') { 3270 map_obj.event_listener(circle.reference, "click", function() { 3271 3272 if (circle.events.url === '' && circle.events.message !== '') { 3273 $.each(map_obj.places, function(key, place) { 3274 place.infowindow.close(); 3275 }); 3276 map_obj.opened_info.setPosition(circle.reference.getCenter()); 3277 if (map_obj.settings.map_infowindow_customisations === true) 3278 map_obj.opened_info.setContent('<div class="wpgmp_infowindow"><div class="wpgmp_iw_content">' + circle.events.message + '</div></div>'); 3279 else 3280 map_obj.opened_info.setContent(circle.events.message); 3281 map_obj.opened_info.open(map_obj.map, this); 3282 3283 } else if (circle.events.url !== '') { 3284 window.location = circle.events.url; 3285 } 3286 3287 3288 }); 3289 3290 } 3291 } 3292 3293 3294 circle.reference.setMap(map_obj.map); 3295 map_obj.wpgmp_circles.push(circle.reference); 3296 map_obj.wpgmp_shape_events.push({ 3297 'shape': circle.reference, 3298 'url': circle.events.url, 3299 'message': circle.events.message 3300 }); 3301 }); 3302 }, 3303 3304 create_rectangle: function() { 3305 3306 var map_obj = this; 3307 $.each(this.map_data.shapes.shape.rectangles, function(index, rectangle) { 3308 var left_latlng = rectangle.cordinates[0].split(','); 3309 var right_latlng = rectangle.cordinates[1].split(','); 3310 3311 var path = new google.maps.LatLngBounds(new google.maps.LatLng(left_latlng[0], left_latlng[1]), new google.maps.LatLng(right_latlng[0], right_latlng[1])); 3312 3313 rectangle.reference = new google.maps.Rectangle({ 3314 bounds: path, 3315 fillColor: rectangle.settings.fill_color, 3316 fillOpacity: rectangle.settings.fill_opacity, 3317 strokeColor: rectangle.settings.stroke_color, 3318 strokeOpacity: rectangle.settings.stroke_opacity, 3319 strokeWeight: rectangle.settings.stroke_weight 3320 }); 3321 3322 if (typeof map_obj.map_data.shapes != 'undefined') { 3323 3324 if (map_obj.map_data.shapes.drawing_editable === true) { 3325 3326 map_obj.event_listener(rectangle.reference, "click", function() { 3327 3328 map_obj.setSelection(rectangle.reference); 3329 map_obj.get_shapes_options(rectangle.reference, 'rectangle'); 3330 3331 }); 3332 3333 } else if (rectangle.events.url !== '' || rectangle.events.message !== '') { 3334 map_obj.event_listener(rectangle.reference, "click", function() { 3335 3336 if (rectangle.events.url === '' && rectangle.events.message !== '') { 3337 $.each(map_obj.places, function(key, place) { 3338 place.infowindow.close(); 3339 }); 3340 map_obj.opened_info.setPosition(rectangle.reference.getBounds().getCenter()); 3341 if (map_obj.settings.map_infowindow_customisations === true) 3342 map_obj.opened_info.setContent('<div class="wpgmp_infowindow"><div class="wpgmp_iw_content">' + rectangle.events.message + '</div></div>'); 3343 else 3344 map_obj.opened_info.setContent(rectangle.events.message); 3345 map_obj.opened_info.open(map_obj.map, this); 3346 } else if (rectangle.events.url !== '') { 3347 window.location = rectangle.events.url; 3348 } 3349 3350 }); 3351 3352 } 3353 } 3354
3355 rectangle.reference.setMap(map_obj.map); 3356 map_obj.wpgmp_rectangles.push(rectangle.reference); 3357 map_obj.wpgmp_shape_events.push({ 3358 'shape': rectangle.reference, 3359 'url': rectangle.events.url, 3360 'message': rectangle.events.message, 3361 }); 3362 }); 3363 }, 3364 3365 get_shapes_options: function(shape, type) { 3366 $(".hiderow").show(); 3367 $("input[name='shape_fill_color']").val(shape.fillColor); 3368 $("input[name='shape_fill_color']").parent().parent().find('.wp-color-result').css('background-color', shape.fillColor); 3369 $("select[name='shape_fill_opacity']").val(shape.fillOpacity); 3370 $("input[name='shape_stroke_color']").val(shape.strokeColor); 3371 $("input[name='shape_stroke_color']").parent().parent().find('.wp-color-result').css('background-color', shape.strokeColor); 3372 $("select[name='shape_stroke_opacity']").val(shape.strokeOpacity); 3373 $("select[name='shape_stroke_weight']").val(shape.strokeWeight); 3374 $("textarea[name='shape_path']").parent().hide(); 3375 $("input[name='shape_radius']").parent().hide(); 3376 $("input[name='shape_center']").parent().hide(); 3377 $("input[name='shape_northeast']").parent().hide(); 3378 $("input[name='shape_southwest']").parent().hide(); 3379 3380 var all_shape_events = this.wpgmp_shape_events; 3381 $.each(all_shape_events, function(i, shape_event) { 3382 3383 if (shape_event.shape == shape) { 3384 $("input[name='shape_click_url']").val(shape_event.url); 3385 $("textarea[name='shape_click_message']").val(shape_event.message); 3386 } 3387 }); 3388 if (type == 'circle') { 3389 $("input[name='shape_radius']").parent().show(); 3390 $("input[name='shape_radius']").val(shape.getRadius()); 3391 $("input[name='shape_center']").parent().show(); 3392 $("input[name='shape_center']").val(shape.getCenter().lat() + ',' + shape.getCenter().lng()); 3393 3394 } else if (type == 'rectangle') { 3395 $("input[name='shape_northeast']").parent().show(); 3396 $("input[name='shape_northeast']").val(shape.getBounds().getNorthEast().lat() + ',' + shape.getBounds().getNorthEast().lng()); 3397 $("input[name='shape_southwest']").parent().show(); 3398 $("input[name='shape_southwest']").val(shape.getBounds().getSouthWest
3398().lat() + ',' + shape.getBounds().getSouthWest().lng()); 3399 3400 } else { 3401 var polygon_cordinate = []; 3402 3403 var cordinates = shape.getPath(); 3404 3405 cordinates.forEach(function(latlng, index) { 3406 3407 var latlngin = [latlng.lat(), latlng.lng()]; 3408 3409 if (latlng.lat() !== "" && latlng.lng() !== "") 3410 polygon_cordinate.push(latlngin); 3411 3412 }); 3413 $("textarea[name='shape_path']").parent().show(); 3414 $("textarea[name='shape_path']").val(polygon_cordinate.join(' ')); 3415 } 3416 }, 3417 3418 set_shapes_options: function(shape) { 3419 var polyOptions2 = { 3420 fillColor: $("input[name='shape_fill_color']").val(), 3421 fillOpacity: $("select[name='shape_fill_opacity']").val(), 3422 strokeColor: $("input[name='shape_stroke_color']").val(), 3423 strokeOpacity: $("select[name='shape_stroke_opacity']").val(), 3424 strokeWeight: $("select[name='shape_stroke_weight']").val(), 3425 }; 3426 shape.setOptions(polyOptions2); 3427 var all_shape_events = this.wpgmp_shape_events; 3428 $.each(all_shape_events, function(i, shape_event) { 3429 if (shape_event.shape == shape) { 3430 shape_event.url = $("input[name='shape_click_url']").val(); 3431 shape_event.message = $("textarea[name='shape_click_message']").val(); 3432 } 3433 }); 3434 3435 }, 3436 3437 wpgmp_save_shapes: function(allcordinate) { 3438 $("input[name='shapes_values']").val(allcordinate.join("|")); 3439 }, 3440 3441 wpgmp_shape_complete: function(shape, type) { 3442 var map_obj = this; 3443 map_obj.setSelection(shape); 3444 map_obj.drawingmanager.setDrawingMode(null); 3445 if (typeof map_obj.map_data.shapes != 'undefined') { 3446 3447 if (map_obj.map_data.shapes.drawing_editable === true) { 3448 3449 map_obj.event_listener(shape, 'click', function() { 3450 map_obj.setSelection(shape); 3451 map_obj.get_shapes_options(shape, type); 3452 }); 3453 3454 map_obj.wpgmp_shape_events.push({ 3455 'shape': shape, 3456 'url': '', 3457 'message': '' 3458 }); 3459 } 3460 3461 } 3462 3463 }, 3464 3465  wpgmp_save_polylines: function() { 3466 3467 var all_polylines = []; 3468 var map_obj = this; 3469 var wpgmp_polylines = map_obj.wpgmp_polylines; 3470 var all_shape_events = map_obj.wpgmp_shape_events; 3471 3472 for (var i = 0; i < wpgmp_polylines.length; i++) { 3473 3474 var polyline_cordinate = []; 3475 3476 var cordinates = wpgmp_polylines[i].getPath(); 3477 3478 var settings = wpgmp_polylines[i].strokeWeight + "," + wpgmp_polylines[i].strokeOpacity + "," + wpgmp_polylines[i].strokeColor; 3479 var events = ""; 3480 $.each(all_shape_events, function(j, shape_event) { 3481 if (shape_event.shape == wpgmp_polylines[i]) { 3482 events = shape_event.url + "***" + shape_event.message; 3483 } 3484 }); 3485 3486 cordinates.forEach(function(latlng, index) { 3487 3488 var latlngin = [latlng.lat(), latlng.lng()]; 3489 polyline_cordinate.push(latlngin); 3490 3491 } 3492 3493 ); 3494 3495 all_polylines.push(polyline_cordinate.join("----") + "..." + settings + "..." + events); 3496 3497 } 3498 return all_polylines; 3499 3500 3501 }, 3502 3503 3504 wpgmp_save_polygons: function() { 3505 3506 var all_polygons = []; 3507 var map_obj = this; 3508 var wpgmp_polygons = map_obj.wpgmp_polygons; 3509 var all_shape_events = map_obj.wpgmp_shape_events; 3510 3511 for (var i = 0; i < wpgmp_polygons.length; i++) { 3512 3513 var polygon_cordinate = []; 3514 3515 var cordinates = wpgmp_polygons[i].getPath(); 3516 3517 var settings = wpgmp_polygons[i].strokeWeight + "," + wpgmp_polygons[i].strokeOpacity + "," + wpgmp_polygons[i].strokeColor + "," + wpgmp_polygons[i].fillColor + "," + wpgmp_polygons[i].fillOpacity; 3518 3519 var events = ""; 3520 $.each(all_shape_events, function(j, shape_event) { 3521 if (shape_event.shape == wpgmp_polygons[i]) { 3522 events = shape_event.url + "***" + shape_event.message; 3523 } 3524 }); 3525
3526 cordinates.forEach(function(latlng, index) { 3527 3528 var latlngin = [latlng.lat(), latlng.lng()]; 3529 3530 if (latlng.lat() !== "" && latlng.lng() !== "") 3531 polygon_cordinate.push(latlngin); 3532 3533 } 3534 3535 ); 3536 3537 all_polygons.push(polygon_cordinate.join("----") + "..." + settings + "..." + events); 3538 3539 } 3540 3541 return all_polygons; 3542 3543 }, 3544 3545 3546 wpgmp_save_circles: function() { 3547 3548 var all_circles = []; 3549 var map_obj = this; 3550 var wpgmp_circles = map_obj.wpgmp_circles; 3551 var all_shape_events = map_obj.wpgmp_shape_events; 3552 3553 for (var i = 0; i < wpgmp_circles.length; i++) { 3554 3555 var circle_cordinate = []; 3556 3557 var latlng = wpgmp_circles[i].getCenter(); 3558 3559 var settings = wpgmp_circles[i].strokeWeight + "," + wpgmp_circles[i].strokeOpacity + "," + wpgmp_circles[i].strokeColor + "," + wpgmp_circles[i].fillColor + "," + wpgmp_circles[i].fillOpacity + "," + wpgmp_circles[i].getRadius(); 3560 3561 var events = ""; 3562 $.each(all_shape_events, function(j, shape_event) { 3563 if (shape_event.shape == wpgmp_circles[i]) { 3564 events = shape_event.url + "***" + shape_event.message; 3565 } 3566 }); 3567 3568 3569 var latlngin = [latlng.lat(), latlng.lng()]; 3570 3571 if (latlng.lat() !== "" && latlng.lng() !== "") 3572 circle_cordinate.push(latlngin); 3573 3574 all_circles.push(circle_cordinate.join("----") + "..." + settings + "..." + events); 3575 3576 } 3577 3578 return all_circles; 3579 3580 }, 3581 3582 wpgmp_save_rectangles: function() { 3583 3584 var all_rectangles = []; 3585 var map_obj = this; 3586 var wpgmp_rectangles = map_obj.wpgmp_rectangles; 3587 var all_shape_events = map_obj.wpgmp_shape_events; 3588 for (var i = 0; i < wpgmp_rectangles.length; i++) { 3589 3590 var rectangle_cordinate = []; 3591 3592 3593 3594 var settings = wpgmp_rectangles[i].strokeWeight + "," + wpgmp_rectangles[i].strokeOpacity + "," + wpgmp_rectangles[i].strokeColor + "," + wpgmp_rectangles[i].fillColor + "," + wpgmp_rectangles[i].fillOpacity; 3595 3596 var events = ""; 3597 $.each(all_shape_events, function(j, shape_event) { 3598 if (shape_event.shape == wpgmp_rectangles[i]) { 3599 events = shape_event.url + "***" + shape_event.message; 3600 } 3601 }); 3602 3603 var latlng = wpgmp_rectangles[i].getBounds().getSouthWest
3603(); 3604 3605 3606 3607 var latlngin = [latlng.lat(), latlng.lng()]; 3608 3609 if (latlng.lat() !== "" && latlng.lng() !== "") 3610 rectangle_cordinate.push(latlngin); 3611 3612 3613 3614 latlng = wpgmp_rectangles[i].getBounds().getNorthEast(); 3615 3616 3617 var latlngin = [latlng.lat(), latlng.lng()]; 3618 3619 if (latlng.lat() !== "" && latlng.lng() !== "") 3620 rectangle_cordinate.push(latlngin); 3621 3622 all_rectangles.push(rectangle_cordinate.join("----") + "..." + settings + "..." + events); 3623 3624 } 3625 3626 return all_rectangles; 3627 3628 }, 3629 3630 set_kml_layer: function() { 3631 3632 var map_obj = this.map; 3633 3634 $.each(this.map_data.kml_layer.kml_layers_links, function(index, link) { 3635 3636 var kmlLayerOptions = { 3637 url: link, 3638 map: map_obj, 3639 preserveViewport: true 3640 3641 }; 3642 3643 new google.maps.KmlLayer(kmlLayerOptions); 3644 }); 3645 }, 3646 3647 set_fusion_layer: function() { 3648 3649 var fusionlayer = new google.maps.FusionTablesLayer({ 3650 query: { 3651 select: this.map_data.fusion_layer.fusion_table_select, 3652 from: this.map_data.fusion_layer.fusion_table_from 3653 }, 3654 heatmap: { 3655 enabled: this.map_data.fusion_layer.fusion_heat_map 3656 }, 3657 styles: [{ 3658 markerOptions: { 3659 iconName: this.map_data.fusion_layer.fusion_icon_name 3660 } 3661 }] 3662 }); 3663 3664 fusionlayer.setMap(this.map); 3665 }, 3666 3667 set_marker_cluster: function() { 3668 var map_obj = this; 3669 var markers = []; 3670 var clusterStyles = [{ 3671 textColor: 'black', 3672 url: map_obj.map_data.marker_cluster.icon, 3673 height: 32, 3674 width: 33 3675 }]; 3676 $.each(this.places, function(index, place) { 3677 if (place.marker.visible == true) { 3678 markers.push(place.marker); 3679 } 3680 3681 }); 3682 3683 if (map_obj.map_data.marker_cluster.apply_style === true) { 3684 if (!map_obj.markerClusterer) { 3685 map_obj.markerClusterer = new MarkerClusterer(map_obj.map, {}, { 3686 gridSize: parseInt(map_obj.map_data.marker_cluster.grid), 3687 maxZoom: parseInt(map_obj.map_data.marker_cluster.max_zoom), 3688 styles: clusterStyles 3689 3690 }); 3691 } 3692 3693 map_obj.markerClusterer.clearMarkers(); 3694 map_obj.markerClusterer.addMarkers(markers); 3695 3696 google.maps.event.addListener(map_obj.markerClusterer, 'mouseover', function(c) { 3697 3698 c.clusterIcon_.div_.firstChild.src = map_obj.map_data.marker_cluster.hover_icon 3699 }); 3700 3701 google.maps.event.addListener(map_obj.markerClusterer, 'mouseout', function(c) { 3702 c.clusterIcon_.div_.firstChild.src = map_obj.map_data.marker_cluster.icon 3703 }); 3704 3705 } else { 3706 if (!map_obj.markerClusterer) { 3707 map_obj.markerClusterer = new MarkerClusterer(map_obj.map, {}, { 3708 gridSize: parseInt(map_obj.map_data.marker_cluster.grid), 3709 maxZoom: parseInt(map_obj.map_data.marker_cluster.max_zoom), 3710 imagePath: map_obj.map_data.marker_cluster.image_path, 3711 }); 3712 } 3713 3714 map_obj.markerClusterer.clearMarkers(); 3715 map_obj.markerClusterer.addMarkers(markers); 3716 3717 3718 } 3719 3720 }, 3721 3722 set_panning_control: function() { 3723 3724 var panning_data = this.map_data.panning_control; 3725 var panning_map_obj = this.map; 3726 var map_obj = this; 3727 3728 var strictBounds = new google.maps.LatLngBounds( 3729 new google.maps.LatLng(panning_data.from_latitude, panning_data.from_longitude), 3730 new google.maps.LatLng(panning_data.to_latitude, panning_data.to_longitude) 3731 ); 3732 3733 google.maps.event.addListener(panning_map_obj, "dragend", function() { 3734 3735 if (strictBounds.contains(panning_map_obj.getCenter())) return; 3736 3737 var c = panning_map_obj.getCenter(), 3738 x = c.lng(), 3739 y = c.lat(), 3740 maxX = strictBounds.getNorthEast().lng(), 3741 maxY = strictBounds.getNorthEast().lat(),
3742 minX = strictBounds.getSouthWest().lng(), 3743 minY = strictBounds.getSouthWest().lat(); 3744 3745 if (x < minX) x = minX; 3746 if (x > maxX) x = maxX; 3747 if (y < minY) y = minY; 3748 if (y > maxY) y = maxY; 3749 3750 panning_map_obj.setCenter(new google.maps.LatLng(y, x)); 3751 }); 3752 3753 google.maps.event.addListener(panning_map_obj, "zoom_changed", function() { 3754 if (panning_map_obj.getZoom() < panning_data.zoom_level) { 3755 panning_map_obj.setZoom(parseInt(map_obj.settings.zoom)); 3756 } 3757 }); 3758 }, 3759 3760 set_visual_refresh: function() { 3761 3762 google.maps.visualRefresh = true; 3763 }, 3764 3765 set_45_imagery: function() { 3766 //this.map.setTilt(45); 3767 }, 3768 3769 set_overlay: function() { 3770 3771 this.map.overlayMapTypes.insertAt(0, new overlay_generator(new google.maps.Size(this.map_data.overlay_setting.width, this.map_data.overlay_setting.height), this.map_data.overlay_setting)); 3772 }, 3773 3774 set_bicyle_layer: function() { 3775 3776 var bikeLayer = new google.maps.BicyclingLayer(); 3777 bikeLayer.setMap(this.map); 3778 }, 3779 3780 set_traffic_layer: function() { 3781 3782 var traffic_layer = new google.maps.TrafficLayer(); 3783 traffic_layer.setMap(this.map); 3784 }, 3785 3786 set_panoramic_layer: function() { 3787 3788 var panoramic_layer = new google.maps.panoramio.PanoramioLayer(); 3789 panoramic_layer.setMap(this.map); 3790 }, 3791 3792 set_transit_layer: function() { 3793 3794 var transit_layer = new google.maps.TransitLayer(); 3795 transit_layer.setMap(this.map); 3796 }, 3797 3798 3799 set_weather_layer: function() { 3800 3801 var weatherLayer = new google.maps.weather.WeatherLayer({ 3802 windSpeedUnit: eval('google.maps.weather.WindSpeedUnit.' + this.map_data.weather_layer.wind_unit), 3803 temperatureUnits: eval('google.maps.weather.TemperatureUnit.' + this.map_data.weather_layer.temperature_unit) 3804 }); 3805 3806 weatherLayer.setMap(this.map); 3807 var cloudLayer = new google.maps.weather.CloudLayer(); 3808 cloudLayer.setMap(this.map); 3809 }, 3810 3811 set_streetview: function(latlng) { 3812 3813 var panoOptions = { 3814 position: latlng, 3815 addressControlOptions: { 3816 position: google.maps.ControlPosition.BOTTOM_CENTER 3817 }, 3818 linksControl: this.map_data.street_view.links_control, 3819 panControl: this.map_data.street_view.street_view_pan_control, 3820 zoomControlOptions: { 3821 style: google.maps.ZoomControlStyle.SMALL 3822 }, 3823 enableCloseButton: this.map_data.street_view.street_view_close_button 3824 }; 3825 if (this.map_data.street_view.pov_heading && this.map_data.street_view.pov_pitch) { 3826 panoOptions['pov'] = { 3827 heading: parseInt(this.map_data.street_view.pov_heading), 3828 pitch: parseInt(this.map_data.street_view.pov_pitch) 3829 }; 3830 } 3831 var panorama = new google.maps.StreetViewPanorama(this.element, panoOptions); 3832 }, 3833 3834 map_loaded: function() { 3835 3836 var map_obj = this; 3837 3838 var gmap = map_obj.map; 3839 3840 google.maps.event.addListenerOnce(gmap, 'idle', function() { 3841 3842 var center = gmap.getCenter(); 3843 google.maps.event.trigger(gmap, 'resize'); 3844 gmap.setCenter(center); 3845 3846 }); 3847 3848 if (map_obj.settings.center_by_nearest === true) { 3849 map_obj.center_by_nearest(); 3850 } 3851 if (map_obj.settings.close_infowindow_on_map_click === true) { 3852 google.maps.event.addListener(gmap, "click", function(event) { 3853 $.each(map_obj.places, function(key, place) { 3854 place.infowindow.close(); 3855 place.marker.setAnimation(null); 3856 }); 3857 }); 3858 } 3859 3860 if (map_obj.map_data.default_amenities) { 3861 var gm_dim = map_obj.map_data.default_amenities.dimension; 3862 var gm_radius = map_obj.map_data.default_amenities.radius; 3863 var default_amenities = map_obj.map_data.default_amenities.amenities; 3864 var divide_by = 1.60934; 3865 map_obj.amenity_infowindow = map_obj.infowindow_marker; 3866 var service; 3867 if (gm_dim == 'miles') { 3868 divide_by = 1.60934; 3869 } else { 3870 divide_by = 1; 3871 } 3872 var circle_radius_meters = parseInt(gm_radius) * divide_by * 1000; 3873 // Now draw a circle. 3874 if (default_amenities) { 3875 3876 var place_types = []; 3877 $.each(default_amenities, function(index, amenity) { 3878 place_types.push(amenity); 3879 }); 3880 3881 var request = { 3882 location: map_obj.map.getCenter(), 3883 radius: circle_radius_meters, 3884 types: place_types 3885 }; 3886 service = new google.maps.places.PlacesService(map_obj.map); 3887 service.nearbySearch(request, function(results, status) { 3888 if (status == google.maps.places.PlacesServiceStatus.OK) { 3889 for (var i = 0; i < results.length; i++) { 3890 map_obj.createMarker(results[i]); 3891 } 3892 } 3893 }); 3894 3895 } 3896 3897 /** End **/ 3898 } 3899 3900 //for infowindow skins 3901 google.maps.event.addListener(map_obj.infobox, 'domready', function() { 3902 var wpgmp_iwOuter = $(map_obj.container).find('.infoBox'); 3903 if(wpgmp_iwOuter.find('.fc-infowindow-default').length == 0 && wpgmp_iwOuter.find('.fc-item-default').length == 0 && wpgmp_iwOuter.find('.wpgmp_infowindow').length > 0 ){ 3904 wpgmp_iwOuter.find('.wpgmp_infowindow').prepend('<div class="infowindow-close"></div>'); 3905 $('.infowindow-close').click(function(e) { 3906 e.preventDefault(); 3907 $.each(map_obj.places, function(key, place) { 3908 place.infowindow.close(); 3909 place.marker.setAnimation(null); 3910 }); 3911 }); 3912 3913 //accordian 3914 $(wpgmp_iwOuter).on('click', ".fc-accordion-tab", function(){ 3915 if($(this).hasClass('active')){ 3916 $(this).removeClass('active'); 3917 var acc_child = $(this).next().removeClass('active'); 3918 }else{ 3919 $(".fc-accordion-tab").removeClass('active'); 3920 $(".fc-accordion dd").removeClass('active'); 3921 $(this).addClass('active'); 3922 var acc_child = $(this).next().addClass('active'); 3923 } 3924 }); 3925 if(wpgmp_iwOuter.find('.fc-infowindow-fano').length == 0 && wpgmp_iwOuter.find('.fc-item-fano').length == 0){ 3926 wpgmp_iwOuter.addClass('infoBoxTail'); 3927 }else{ 3928 wpgmp_iwOuter.removeClass('infoBoxTail'); 3929 } 3930 //Rating 3931 if(wpgmp_iwOuter.find('.wpgmp-rating').length > 0){ 3932 //on load 3933 jQuery.ajax({ 3934 type: "POST", 3935 url: wpgmp_local.ajax_url, 3936 dataType: 'json', 3937 data: { 3938 action: 'wpgmp_ajax_call', 3939 operation: 'wpgmp_get_rating', 3940 loc_id: wpgmp_iwOuter.find('.wpgmp-rating').data('marker_id'), 3941 map_id: wpgmp_iwOuter.find('.wpgmp-rating').data('map_id'), 3942 marker_type: wpgmp_iwOuter.find('.wpgmp-rating').data('marker_type'), 3943 nonce: wpgmp_local.nonce, 3944 }, 3945 beforeSend: function() { 3946 wpgmp_iwOuter.find('.wpgmp-rating input[type="radio"]').removeAttr('checked'); 3947 }, 3948 success: function(data) {//console.log(data); 3949 wpgmp_iwOuter.find('.wpgmp-rating input[value="'+data+'"]').attr('checked','checked'); 3950 } 3951 }); 3952 //on click 3953 $(wpgmp_iwOuter).on('click','.wpgmp-rating input[name="rating"]',function(e){ 3954 e.preventDefault(); 3955 var action_btn = $(this); 3956 jQuery.ajax({ 3957 type: "POST", 3958 url: wpgmp_local.ajax_url, 3959 dataType: 'json', 3960 data: { 3961 action: 'wpgmp_ajax_call', 3962 operation: 'wpgmp_save_rating', 3963 loc_id: $(action_btn).closest('.wpgmp-rating').data('marker_id'), 3964 map_id: $(action_btn).closest('.wpgmp-rating').data('map_id'), 3965 marker_type: $(action_btn).closest('.wpgmp-rating').data('marker_type'), 3966 rating: $(action_btn).val(), 3967 nonce: wpgmp_local.nonce, 3968 }, 3969 beforeSend: function() { 3970 3971 }, 3972 3973 success: function(data) { 3974 $(action_btn).attr('checked','checked'); 3975 } 3976 }); 3977 }); 3978 } 3979 } 3980 }); 3981 3982 3983 if (map_obj.settings.map_infowindow_customisations === true) { 3984 google.maps.event.addListener(map_obj.infowindow_marker, 'domready', function() { 3985 3986 var wpgmp_iwOuter = $(map_obj.container).find('.gm-style-iw'); 3987 3988 wpgmp_iwOuter.parent().css({ 3989 'width': '0px', 3990 'height': '0px' 3991 }); 3992 var wpgmp_iwCloseBtn = wpgmp_iwOuter.next(); 3993 wpgmp_iwCloseBtn.css('display', 'none'); 3994
3995 var wpgmp_iwBackground = wpgmp_iwOuter.prev(); 3996 3997 wpgmp_iwBackground.children(':nth-child(2)').css({ 3998 'display': 'none' 3999 }); 4000 4001 wpgmp_iwBackground.children(':nth-child(3)').css({ 4002 'background-color': '#000;', 4003 }); 4004 4005 wpgmp_iwBackground.children(':nth-child(4)').css({ 4006 'display': 'none' 4007 }); 4008 var height = wpgmp_iwOuter.outerHeight() ; 4009 wpgmp_iwBackground.children(':nth-child(3)').css({ 4010 'top':(height+14)+'px' 4011 }); 4012 wpgmp_iwBackground.children(':nth-child(1)').css({ 4013 'top':(height+6)+'px' 4014 }); 4015 wpgmp_iwBackground.children(':nth-child(3)').find('div').children().css({ 4016 'box-shadow': map_obj.settings.infowindow_border_color + ' 0px 1px 6px', 4017 'border': '1px solid ' + map_obj.settings.infowindow_border_color, 4018 'border-top': '', 4019 'z-index': '1', 4020 'background-color': map_obj.settings.infowindow_bg_color 4021 }); 4022 wpgmp_iwOuter.find('.wpgmp_infowindow').prepend('<div class="infowindow-close"></div>'); 4023 wpgmp_iwOuter.on('click', '.infowindow-close', function(event){ 4024 $.each(map_obj.places, function(key, place) { 4025 place.infowindow.close(); 4026 place.marker.setAnimation(null); 4027 }); 4028 }); 4029 }); 4030 } 4031 4032 if (map_obj.settings.map_infowindow_customisations === true) { 4033 4034 } 4035 4036 }, 4037 resize_map: function() { 4038 var map_obj = this; 4039 var gmap = map_obj.map; 4040 var zoom = gmap.getZoom(); 4041 var center = gmap.getCenter(); 4042 google.maps.event.trigger(this.map, 'resize'); 4043 gmap.setZoom(zoom); 4044 gmap.setCenter(center); 4045 }, 4046 responsive_map: function() { 4047 4048 var map_obj = this; 4049 4050 var gmap = map_obj.map; 4051 4052 google.maps.event.addDomListener(window, "resize", function() { 4053 4054 var zoom = gmap.getZoom(); 4055 var center = gmap.getCenter(); 4056 4057 google.maps.event.trigger(gmap, "resize"); 4058 gmap.setZoom(zoom); 4059 gmap.setCenter(center); 4060 gmap.getBounds(); 4061 4062 if ( map_obj.map_data.marker_cluster ) { 4063 map_obj.set_marker_cluster(); 4064 } 4065 4066 }); 4067 4068 }, 4069 show_search_control: function() { 4070 var map_obj = this; 4071 var input = $(map_obj.container).find('[data-input="map-search-control"]')[0]; 4072 if (input !== undefined) { 4073 var searchBox = new google.maps.places.SearchBox(input); 4074 map_obj.map.controls[eval("google.maps.ControlPosition." + map_obj.settings.search_control_position)].push(input); 4075 4076 // Bias the SearchBox results towards current map's viewport. 4077 map_obj.map.addListener('bounds_changed', function() { 4078 searchBox.setBounds(map_obj.map.getBounds()); 4079 }); 4080 4081 google.maps.event.addListener(searchBox, 'places_changed', function() { 4082 var places = searchBox.getPlaces(); 4083 if (places.length == 0) { 4084 return; 4085 } 4086 // For each place, get the icon, name and location. 4087 var bounds = new google.maps.LatLngBounds(); 4088 places.forEach(function(place) { 4089 if (!place.geometry) { 4090 console.log("Returned place contains no geometry"); 4091 return; 4092 } 4093 if (place.geometry.viewport) { 4094 // Only geocodes have viewport. 4095 bounds.union(place.geometry.viewport); 4096 } else { 4097 bounds.extend(place.geometry.location); 4098 } 4099 }); 4100 map_obj.map.fitBounds(bounds); 4101 }); 4102 } 4103 }, 4104 fit_bounds : function() { 4105 var map_obj = this; 4106 var places = map_obj.map_data.places; 4107 var bounds = new google.maps.LatLngBounds();
4108 places.forEach(function(place) { 4109 4110 if (place.location.lat && place.location.lng) { 4111 bounds.extend(new google.maps.LatLng( 4112 parseFloat(place.location.lat), 4113 parseFloat(place.location.lng) 4114 )); 4115 } 4116 4117 }); 4118 map_obj.map.fitBounds(bounds); 4119 4120 }, 4121 create_markers: function() { 4122 4123 var map_obj = this; 4124 var places = map_obj.map_data.places; 4125 var temp_listing_placeholder; 4126 var replaceData; 4127 var remove_keys = []; 4128 4129 $.each(places, function(key, place) { 4130 4131 if (place.location.lat && place.location.lng) { 4132 if (typeof place.categories == 'undefined') { 4133 place.categories = {}; 4134 } 4135 place.marker = new google.maps.Marker({ 4136 position: new google.maps.LatLng( 4137 parseFloat(place.location.lat), 4138 parseFloat(place.location.lng) 4139 ), 4140 icon: place.location.icon, 4141 url: place.url, 4142 draggable: place.location.draggable, 4143 map: map_obj.map, 4144 clickable: place.location.infowindow_disable, 4145 }); 4146 4147 if (map_obj.settings.infowindow_drop_animation === true) { 4148 place.marker.setAnimation(google.maps.Animation.DROP); 4149 } 4150 4151 if (map_obj.settings.infowindow_filter_only === true) { 4152 place.marker.visible = false; 4153 place.marker.setVisible(false); 4154 } 4155 4156 4157 // bind event to marker 4158 if (map_obj.map_data.page == 'edit_location') 4159 map_obj.marker_bind(place.marker); 4160 var location_categories = []; 4161 if (typeof place.categories != 'undefined') { 4162 for (var cat in place.categories) { 4163 location_categories.push(place.categories[cat].name); 4164 } 4165 } 4166 var content = ''; 4167 // replace infowindow content. 4168 var marker_image = ''; 4169 4170 if( place.source == 'post' ) { 4171 marker_image = place.location.extra_fields.post_featured_image; 4172 } else { 4173 marker_image = place.location.marker_image; 4174 } 4175 4176 var temp_listing_placeholder = ''; var post_info_class = 'fc-infowindow-'; 4177 if( place.source == 'post' ) { 4178 temp_listing_placeholder = map_obj.settings.infowindow_geotags_setting; 4179 post_info_class = 'wpgmp_infowindow_post fc-item-'+map_obj.settings.infowindow_post_skin.name; 4180 } else { 4181 temp_listing_placeholder = map_obj.settings.infowindow_setting; 4182 if (map_obj.map_data.page != 'edit_location' && map_obj.settings.infowindow_skin) 4183 post_info_class = 'fc-infowindow-'+map_obj.settings.infowindow_skin.name; 4184 } 4185 4186 if( typeof temp_listing_placeholder == 'undefined' ) { 4187 temp_listing_placeholder = place.content; 4188 } 4189 4190 replaceData = { 4191 "{marker_id}": place.id, 4192 "{marker_title}": place.title, 4193 "{marker_address}": place.address, 4194 "{marker_latitude}": place.location.lat, 4195 "{marker_longitude}": place.location.lng, 4196 "{marker_city}": place.location.city, 4197 "{marker_state}": place.location.state, 4198 "{marker_country}": place.location.country, 4199 "{marker_postal_code}": place.location.postal_code, 4200 "{marker_zoom}": place.location.zoom, 4201 "{marker_icon}": place.location.icon, 4202 "{marker_category}": location_categories.join(', '), 4203 "{marker_message}": place.content, 4204 "{marker_image}": marker_image, 4205 "{marker_rating}": place.rating 4206 }; 4207 4208 //Add extra fields of locations 4209 if (typeof place.location.extra_fields != 'undefined') { 4210 for (var extra in place.location.extra_fields) { 4211 if (!place.location.extra_fields[extra]) { 4212 replaceData['{' + extra + '}'] = "<div class='wpgmp_empty'></div>"; 4213 } else { 4214 replaceData['{' + extra + '}'] = place.location.extra_fields[extra]; 4215 } 4216 } 4217 } 4218 temp_listing_placeholder = temp_listing_placeholder.replace(/{[^{}]+}/g, function(match) { 4219 if (match in replaceData) { 4220 return (replaceData[match]); 4221 } else { 4222 return (""); 4223 } 4224 }); 4225 4226 content = temp_listing_placeholder; 4227 4228 4229 4230 if (content === "") { 4231 if (map_obj.settings.map_infowindow_customisations === true && map_obj.settings.show_infowindow_header === true) 4232 content = '<div class="wpgmp_infowindow '+post_info_class+'"><div class="wpgmp_iw_head"><div class="wpgmp_iw_head_content">' + place.title + '</div></div><div class="wpgmp_iw_content">' + place.content + '</div></div>'; 4233 else 4234 content = '<div class="wpgmp_infowindow '+post_info_class+'"><div class="wpgmp_iw_content">' + place.content + '</div></div>'; 4235 } else { 4236 if (map_obj.settings.map_infowindow_customisations === true && map_obj.settings.show_infowindow_header === true) 4237 content = '<div class="wpgmp_infowindow '+post_info_class+'"><div class="wpgmp_iw_head"><div class="wpgmp_iw_head_content">' + place.title + '</div></div><div class="wpgmp_iw_content">' + content + '</div></div>'; 4238 else 4239 content = '<div class="wpgmp_infowindow '+post_info_class+'"><div class="wpgmp_iw_content">' + content + '</div></div>'; 4240 4241 } 4242 place.infowindow_data = content; 4243 place.infowindow = map_obj.infowindow_marker; 4244 4245 if (place.location.infowindow_default_open === true) { 4246 map_obj.openInfoWindow(place); 4247 } else if (map_obj.settings.default_infowindow_open === true) { 4248 map_obj.openInfoWindow(place); 4249 } 4250 var on_event = map_obj.settings.infowindow_open_event; 4251 var bounce_on_event = map_obj.settings.infowindow_bounce_animation; 4252 map_obj.event_listener(place.marker, on_event, function() { 4253 $.each(map_obj.places, function(key, prev_place) { 4254 prev_place.infowindow.close(); 4255 prev_place.marker.setAnimation(null); 4256 }); 4257 map_obj.openInfoWindow(place); 4258 if (bounce_on_event == 'click') { 4259 map_obj.toggle_bounce(place.marker); 4260 } 4261 }); 4262 if (bounce_on_event == 'mouseover' && on_event != 'mouseover') { 4263 map_obj.event_listener(place.marker, 'mouseover', function() { 4264 place.marker.setAnimation(google.maps.Animation.BOUNCE); 4265 }); 4266 4267 map_obj.event_listener(place.marker, 'mouseout', function() { 4268 place.marker.setAnimation(null); 4269 }); 4270 } 4271 4272 if (bounce_on_event != '') { 4273 google.maps.event.addListener(place.infowindow, 'closeclick', function() { 4274 place.marker.setAnimation(null); 4275 }); 4276 } 4277 4278 map_obj.places.push(place); 4279 } else { 4280 remove_keys.push(key); 4281 } 4282 }); 4283 $.each(remove_keys, function(index, value) { 4284 places.splice(value, 1); 4285 }); 4286 4287 }, 4288 toggle_bounce: function(marker) { 4289 if (marker.getAnimation() !== null) { 4290 marker.setAnimation(null); 4291 } else { 4292 marker.setAnimation(google.maps.Animation.BOUNCE); 4293 } 4294 }, 4295 display_markers: function() { 4296 4297 var map_obj = this; 4298 map_obj.show_places = []; 4299 map_obj.categories = []; 4300 var categories = {}; 4301 for (var i = 0; i < map_obj.places.length; i++) {
4302 map_obj.places[i].marker.setMap(map_obj.map); 4303 if (map_obj.places[i].marker.visible === true) { 4304 map_obj.show_places.push(this.places[i]); 4305 } 4306 4307 if (typeof map_obj.places[i].categories != 'undefined') { 4308 $.each(map_obj.places[i].categories, function(index, category) { 4309 4310 if (typeof categories[category.name] == 'undefined') { 4311 categories[category.name] = category; 4312 } 4313 }); 4314 } 4315 } 4316 4317 this.categories = categories; 4318 }, 4319 show_center_circle: function() { 4320 var map_obj = this; 4321 if( map_obj.settings.center_circle_radius == '' ) { 4322 map_obj.settings.center_circle_radius = 5; 4323 } 4324 map_obj.set_center_circle = new google.maps.Circle({ 4325 map: map_obj.map, 4326 center: map_obj.map.getCenter(), 4327 fillColor: map_obj.settings.center_circle_fillcolor, 4328 fillOpacity: map_obj.settings.center_circle_fillopacity, 4329 strokeColor: map_obj.settings.center_circle_strokecolor, 4330 strokeOpacity: map_obj.settings.center_circle_strokeopacity, 4331 strokeWeight: map_obj.settings.center_circle_strokeweight, 4332 radius: parseInt(map_obj.settings.center_circle_radius) * 1000 4333 }); 4334 4335 }, 4336 show_center_marker: function() { 4337 4338 var map_obj = this; 4339 var clickable = false; 4340 if (map_obj.settings.center_marker_infowindow != '') { 4341 clickable = true; 4342 } 4343 4344 map_obj.map_center_marker = new google.maps.Marker({ 4345 position: map_obj.map.getCenter(), 4346 title: map_obj.settings.center_marker_infowindow, 4347 map: map_obj.map, 4348 icon: map_obj.settings.center_marker_icon, 4349 clickable: clickable 4350 }); 4351 if (typeof map_obj.map_center_info == 'undefined') { 4352 map_obj.map_center_info = map_obj.infowindow_marker; 4353 } 4354 if (map_obj.settings.center_marker_infowindow != '') { 4355 google.maps.event.addListener(map_obj.map_center_marker, 'click', function() { 4356 map_obj.map_center_info.setPosition(map_obj.map.getCenter()); 4357 if (map_obj.settings.map_infowindow_customisations === true) 4358 map_obj.map_center_info.setContent('<div class="wpgmp_infowindow"><div class="wpgmp_iw_content">' + map_obj.settings.center_marker_infowindow + '</div></div>'); 4359 else 4360 map_obj.map_center_info.setContent(map_obj.settings.center_marker_infowindow); 4361 map_obj.map_center_info.open(map_obj.map, this); 4362 4363 }); 4364 } 4365 }, 4366 center_by_nearest: function() { 4367 var map_obj = this; 4368 this.get_current_location(function(user_position) { 4369 if (!map_obj.user_location_marker) { 4370 map_obj.user_location_marker = new google.maps.Marker({ 4371 position: user_position, 4372 title: wpgmp_local.center_location_message, 4373 map: map_obj.map, 4374 icon: map_obj.settings.marker_default_icon 4375 }); 4376 4377 } 4378 map_obj.user_location_marker.setVisible(true); 4379 if (typeof map_obj.map_center_info == 'undefined') { 4380 map_obj.map_center_info = map_obj.infowindow_marker; 4381 } 4382 if (map_obj.settings.center_marker_infowindow != '') { 4383 google.maps.event.addListener(map_obj.user_location_marker, 'click', function() { 4384 map_obj.map_center_info.setPosition(user_position); 4385 if (map_obj.settings.map_infowindow_customisations === true) 4386 map_obj.map_center_info.setContent('<div class="wpgmp_infowindow"><div class="wpgmp_iw_content">' + map_obj.settings.center_marker_infowindow + '</div></div>'); 4387 else 4388 map_obj.map_center_info.setContent(map_obj.settings.center_marker_infowindow); 4389 map_obj.map_center_info.open(map_obj.map, this); 4390 4391 }); 4392 } 4393 map_obj.map.setCenter(user_position); 4394 if (map_obj.settings.show_center_circle === true) { 4395 map_obj.show_center_circle(); 4396 } 4397 4398 if( map_obj.map_data.listing && map_obj.map_data.listing.a
4398pply_default_radius == true ) { 4399 4400 map_obj.search_area = user_position; 4401 } 4402 4403 4404 4405 }); 4406 }, 4407 4408 get_current_location: function(success_func, error_func) { 4409 4410 var map = this; 4411 4412 if (typeof map.user_location == 'undefined') { 4413 4414 navigator.geolocation.getCurrentPosition(function(position) { 4415 map.user_location = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); 4416 4417 if (success_func) 4418 success_func(map.user_location); 4419 4420 }, function(ErrorPosition) { 4421 4422 if (error_func) 4423 error_func(ErrorPosition); 4424 4425 }, { 4426 enableHighAccuracy: true, 4427 timeout: 5000, 4428 maximumAge: 0 4429 }); 4430 } else { 4431 if (success_func) 4432 success_func(map.user_location); 4433 } 4434 }, 4435 4436 openInfoWindow: function(place) { 4437 var map_obj = this; 4438 var skin = 'default'; 4439 if( place.source == 'post' ) { 4440 skin = map_obj.settings.infowindow_post_skin.name; 4441 } else if (map_obj.map_data.page != 'edit_location' && map_obj.settings.infowindow_skin){ 4442 skin = map_obj.settings.infowindow_skin.name; 4443 } 4444 4445 if(skin != 'default'){ 4446 var infoboxText = document.createElement("div"); 4447 infoboxText.className = 'wpgmp_infobox' 4448 var infoboxOptions = { 4449 content: infoboxText, 4450 disableAutoPan: false, 4451 alignBottom: true, 4452 maxWidth: 0, 4453 pixelOffset: (skin == 'fano') ? new google.maps.Size(-150, -40) : new google.maps.Size(-150, -55) , 4454 zIndex: null, 4455 boxStyle: { 4456 width : "300px" 4457 }, 4458 closeBoxMargin: "0", 4459 closeBoxURL: "", 4460 infoBoxClearance: new google.maps.Size(25, 25), 4461 isHidden: false, 4462 pane: "floatPane", 4463 enableEventPropagation: false, 4464 }; 4465 place.infowindow = map_obj.infobox; 4466 place.infowindow.setOptions(infoboxOptions); 4467 infoboxText.innerHTML = place.infowindow_data; 4468 }else{ 4469 place.infowindow = map_obj.infowindow_marker; 4470 place.infowindow.setContent(place.infowindow_data); 4471 } 4472 4473 if (place.location.onclick_action == "post") { 4474 if (place.location.open_new_tab == 'yes') 4475 window.open(place.location.redirect_permalink, '_blank'); 4476 else 4477 window.open(place.location.redirect_permalink, '_self'); 4478 } 4479 else if (place.location.onclick_action == "custom_link") { 4480 if (place.location.open_new_tab == 'yes') 4481 window.open(place.location.redirect_custom_link, '_blank'); 4482 else 4483 window.open(place.location.redirect_custom_link, '_self'); 4484 } else { 4485 place.infowindow.open(this.map, place.marker); 4486 if (typeof map_obj.settings.infowindow_click_change_center != 'undefined' && map_obj.settings.infowindow_click_change_center == true) { 4487 map_obj.map.setCenter(place.marker.getPosition()); 4488 } 4489 if (typeof map_obj.settings.infowindow_click_change_zoom != 'undefined' && map_obj.settings.infowindow_click_change_zoom > 0) { 4490 map_obj.map.setZoom(map_obj.settings.infowindow_click_change_zoom); 4491 } 4492 if (this.map_data.map_tabs && this.map_data.map_tabs.direction_tab && this.map_data.map_tabs.direction_tab.dir_tab === true) { 4493 $(this.container).find('.start_point').val(place.address); 4494 } 4495 } 4496 4497 $(map_obj.container).find(".wpgmp_empty").prev().remove(); 4498 $(map_obj.container).find(".wpgmp_empty").remove(); 4499 4500 }, 4501 }; 4502 4503 $.fn.maps = function(options, places) { 4504 4505 this.each(function() { 4506 4507 if (!$.data(this, "wpgmp_maps")) { 4508 $.data(this, "wpgmp_maps", new GoogleMaps(this, options, places)); 4509 } 4510 4511 }); 4512 // chain jQuery functions 4513 return this; 4514 }; 4515 4516}(jQuery, window, document));
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.