1/* Activ'Map Plugin 2.0.0 2 * Copyright (c) 2015-2017 Pandao 3 * Documentation : https://activmap.pandao.eu/doc 4 */ 5(function($){ 6 7 $.activmap = { 8 // Default values (if not modified in the plugin init) 9 // DON'T CHANGE THE VALUES HERE, overwrite the options in your HTML file 10 defaults: { 11 places: [], //list of places objects {title, address, phone, tags, lat, lng, img}, 12 lat: 40.34722514779102, //latitude of the center 13 lng: -3.7044303678376878, //longitude of the center 14 zoom: 15, //default zoom level between 0 and 21 15 cluster: true, //enables / disables clustering for large amounts of markers 16 mapType: 'roadmap', //map type : "roadmap", "satellite", "perspective" 17 posPanel: 'left', //position of the removable panel : "left" or "right" 18 showPanel: true, //shows / hides the removable panel 19 radius: 0, //max radius in kilometers 20 unit: 'km', //distance unit (km or mile) 21 country: null, //country limit for location input (ex. "ca": Canada, "us": United States, "fr": France...) 22 autogeolocate: false, //auto geolocation to set the center of the map 23 allowMultiSelect: true,//allow user to select multiple filters 24 // icon: 'http://paseo17.bitmac.es/wp-content/themes/salient-child/images/icons/marker-paseo-17.png', 25 // center_icon: 'http://paseo17.bitmac.es/wp-content/themes/salient-child/images/icons/marker-paseo-17.png', 26 styles: [ 27 { 28 "featureType": "administrative", 29 "elementType": "geometry", 30 "stylers": [ 31 { 32 "saturation": "2" 33 }, 34 { 35 "visibility": "simplified" 36 } 37 ] 38 }, 39 { 40 "featureType": "administrative", 41 "elementType": "labels", 42 "stylers": [ 43 { 44 "saturation": "-28" 45 }, 46 { 47 "lightness": "-10" 48 }, 49 { 50 "visibility": "on" 51 } 52 ] 53 }, 54 { 55 "featureType": "administrative", 56 "elementType": "labels.text.fill", 57 "stylers": [ 58 { 59 "color": "#444444" 60 } 61 ] 62 }, 63 { 64 "featureType": "landscape", 65 "elementType": "all", 66 "stylers": [ 67 { 68 "color": "#f2f2f2" 69 } 70 ] 71 }, 72 { 73 "featureType": "landscape", 74 "elementType": "geometry.fill", 75 "stylers": [ 76 { 77 "saturation": "-1" 78 }, 79 { 80 "lightness": "-12" 81 } 82 ] 83 }, 84 { 85 "featureType": "landscape.natural", 86 "elementType": "labels.text", 87 "stylers": [ 88 { 89 "lightness": "-31" 90 } 91 ] 92 }, 93 { 94 "featureType": "landscape.natural", 95 "elementType": "labels.text.fill", 96 "stylers": [ 97 { 98 "lightness": "-74" 99 } 100 ] 101 }, 102 { 103 "featureType": "landscape.natural", 104 "elementType": "labels.text.stroke", 105 "stylers": [ 106 { 107 "lightness": "65" 108 } 109 ] 110 }, 111 { 112 "featureType": "landscape.natural.landcover", 113 "elementType": "geometry", 114 "stylers": [ 115 { 116 "lightness": "-15" 117 } 118 ] 119 }, 120 { 121 "featureType": "landscape.natural.landcover", 122 "elementType": "geometry.fill", 123 "stylers": [ 124 { 125 "lightness": "0" 126 } 127 ] 128 }, 129 { 130 "featureType": "poi", 131 "elementType": "all", 132 "stylers": [ 133 { 134 "visibility": "off" 135 } 136 ] 137 }, 138 { 139 "featureType": "road", 140 "elementType": "all", 141 "stylers": [ 142 { 143 "saturation": -100 144 }, 145 { 146 "lightness": 45 147 } 148 ] 149 }, 150 { 151 "featureType": "road", 152 "elementType": "geometry", 153 "stylers": [ 154 { 155 "visibility": "on" 156 }, 157 { 158 "saturation": "0" 159 }, 160 { 161 "lightness": "-9" 162 } 163 ] 164 }, 165 { 166 "featureType": "road", 167 "elementType": "geometry.stroke", 168 "stylers": [ 169 { 170 "lightness": "-14" 171 } 172 ] 173 }, 174 { 175 "featureType": "road", 176 "elementType": "labels", 177 "stylers": [ 178 { 179 "lightness": "-35" 180 }, 181 { 182 "gamma": "1" 183 }, 184 { 185 "weight": "1.39" 186 } 187 ] 188 }, 189 { 190 "featureType": "road", 191 "elementType": "labels.text.fill", 192 "stylers": [ 193 { 194 "lightness": "-19" 195 } 196 ] 197 }, 198 { 199 "featureType": "road", 200 "elementType": "labels.text.stroke", 201 "stylers": [ 202 { 203 "lightness": "46" 204 } 205 ] 206 }, 207 { 208 "featureType": "road.highway", 209 "elementType": "all", 210 "stylers": [ 211 { 212 "visibility": "simplified" 213 } 214 ] 215 }, 216 { 217 "featureType": "road.highway", 218 "elementType": "labels.icon", 219 "stylers": [ 220 { 221 "lightness": "-13" 222 }, 223 { 224 "weight": "1.23" 225 }, 226 { 227 "invert_lightness": true 228 }, 229 { 230 "visibility": "simplified" 231 }, 232 { 233 "hue": "#ff0000" 234 } 235 ] 236 }, 237 { 238 "featureType": "road.arterial", 239 "elementType": "labels.icon", 240 "stylers": [ 241 { 242 "visibility": "off" 243 } 244 ] 245 }, 246 { 247 "featureType": "transit", 248 "elementType": "all", 249 "stylers": [ 250 { 251 "visibility": "off" 252 } 253 ] 254 }, 255 { 256 "featureType": "water", 257 "elementType": "all", 258 "stylers": [ 259 { 260 "color": "#adadad" 261 }, 262 { 263 "visibility": "on" 264 } 265 ] 266 } 267], 268 request: 'large', //type of request "large" (show results of each filter) or "strict" (show results of all filters) 269 locationTypes: ['geocode','establishment'] //types of locations returned by autocomplete requests 270 } 271 }; 272 273 $.arrayIntersect = function(a, b) 274 { 275 return $.grep(a, function(i) 276 { 277 return $.inArray(i, b) > -1; 278 }); 279 }; 280 281 $.fn.extend({ 282 283 activmap : function(settings){ 284 285 var s = $.extend({}, $.activmap.defaults, settings); 286 287 //Map init 288 var init_latlng = new google.maps.LatLng(s.lat,s.lng) 289 var latlng = init_latlng; 290 var opendInfoWindow = null; 291 var markers = []; 292 var infoWindow = []; 293 var ids = []; 294 var markerCluster; 295 var centerMarker; 296 var bounds = new google.maps.LatLngBounds(); 297 var num_places = 0; 298 var old_results = 0; 299 var mapTypeId = google.maps.MapTypeId.ROADMAP; 300 if(s.mapType == 'satellite' || s.mapType == 'perspective') mapT
300ypeId = google.maps.MapTypeId.HYBRID; 301 var map = new google.maps.Map(document.getElementById('activmap-canvas'), { 302 zoom: s.zoom, 303 center: latlng, 304 mapTypeId: mapTypeId, 305 styles: s.styles, 306 mapTypeControl: true, 307 mapTypeControlOptions: { 308 style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR, 309 position: google.maps.ControlPosition.BOTTOM_CENTER 310 }, 311 zoomControl: true, 312 zoomControlOptions: { 313 position: google.maps.ControlPosition.LEFT_CENTER 314 }, 315 scaleControl: true, 316 streetViewControl: true, 317 streetViewControlOptions: { 318 position: google.maps.ControlPosition.RIGHT_BOTTOM 319 }, 320 fullscreenControl: false 321 }); 322 bounds.extend(init_latlng); 323 var init_latlngBounds = map.getBounds(); 324 if(s.mapType == 'perspective') map.setTilt(45); 325 326 //Containers 327 var activmap_canvas = $('#activmap-container'); 328 var activmap_places = $('#activmap-places'); 329 var map_w = activmap_canvas.width(); 330 var cont_w = activmap_places.outerWidth(); 331 332 //Panel 333 if(!s.showPanel) activmap_places.hide(); 334 else{ 335 if(s.posPanel == 'left'){ 336 activmap_places.css({ 337 left: -cont_w, 338 right: 'auto' 339 }); 340 activmap_canvas.css({ 341 float: 'right' 342 }); 343 } 344 if(s.posPanel == 'right'){ 345 activmap_places.css({ 346 right: -cont_w, 347 left: 'auto' 348 }); 349 activmap_canvas.css({ 350 float: 'left' 351 }); 352 } 353 } 354 355 //if($('input[name="marker_type[]"]').length) $('input[name="marker_type[]"]').prop('checked',false); 356 357 if($('input[name="activmap_radius"]').length){ 358 $('input[name="activmap_radius"]').prop('checked', false).each(function(){ 359 if(s.radius == $(this).val()) $(this).prop('checked', true); 360 }); 361 } 362 363 _init = function(){ 364 365 //Places init 366 $.each(s.places, function(i, place){ 367 place.num_tags = 0; 368 place.id = i; 369 //Marker init 370 var myLatlng = new google.maps.LatLng(place.lat, place.lng); 371 var myIcon = (place.icon != '' && place.icon != undefined) ? place.icon : s.icon; 372 var marker = new google.maps.Marker({ 373 map: map, 374 position: myLatlng, 375 icon: myIcon, 376 title: place.title 377 }); 378 //Info window content building 379 var mycontent = '<div class="activmap-infowindow">'; 380 if(place.img != undefined && place.img != '') mycontent += '<div class="activmap-brand"><img src="'+place.img+'"></div>'; 381 mycontent += '<div class="activmap-details"><h4 class="activmap-title">'+place.title+'</h4>'; 382 if(place.address != undefined && place.address != '') mycontent += '<div class="activmap-address">'+place.address+'</div>'; 383 if(place.phone != undefined && place.phone != '') mycontent += '<div class="activmap-phone">'+place.phone+'</div>'; 384 if(place.url != undefined && place.url != '') mycontent += '<a href="'+place.url+'" target="_blank" class="activmap-url">'+place.url+'</a>'; 385 mycontent += '</div><div style="clear: both;"></div></div>'; 386 387 //Info window init 388 infoWindow[i] = new google.maps.InfoWindow({ 389 content : mycontent, 390 position : myLatlng 391 }); 392 393 //infoWindow close event 394 google.maps.event.addListener(infoWindow[i], 'closeclick', function(){ 395 $('.activmap-place').removeClass('active'); 396 activmap_places.scrollTop(); 397 }); 398 399 //Marker click event 400 google.maps.event.addListener(marker, 'click', function(){ 401 if(opendInfoWindow != null) opendInfoWindow.close(); 402 infoWindow[i].open(map, marker); 403 404 map.setCenter(marker.getPosition()); 405 var padbnds = _paddedBounds(20, 280, 50, 50); 406 map.fitBounds(padbnds); 407 408 opendInfoWindow = infoWindow[i]; 409 410 $('.activmap-place').removeClass('active'); 411 $('#activmap-place_'+i).addClass('active'); 412 activmap_places.scrollTop(activmap_places.scrollTop()+$('#activmap-place_'+i).position().top); 413 }); 414 415 marker.setVisible(false); 416 place.marker = marker; 417 markers.push(marker); 418 419 place.html = '<div class="activmap-place" id="activmap-place_'+i+'"><h3>'+place.title+'</h3><p>'+place.address+'</p></div>'; 420 421 //Places indexed by tag name (checkbox name) 422 $.each(place.tags, function(j, tag){ 423 if(ids[tag] === undefined) ids[tag] = []; 424 ids[tag].push(place.id); 425 }); 426 }); 427 428 429 //Cluster init 430 if(s.cluster){ 431 markerCluster = new MarkerClusterer(map, markers, { 432 maxZoom: 12, 433 gridSize: 40 434 }); 435 } 436 437 //Center marker init 438 centerMarker = new google.maps.Marker({ 439 map: map, 440 position: latlng, 441 icon: (s.center_icon != '' && s.center_icon != undefined) ? s.center_icon : s.icon 442 }); 443 centerMarker.setVisible(true); 444 markers.push(centerMarker); 445 446 //Order places in the panel 447 _order(); 448 449 //Auto geolocation 450 if(s.autogeolocate == true){ 451 _geolocate(); 452 } 453 454 //Geolocate event 455 if($('#activmap-geolocate').length){ 456 $('#activmap-geolocate').on('click', function(){ 457 _geolocate(); 458 }); 459 } 460 461 //Target results event 462 if($('#activmap-target').length){ 463 $('#activmap-target').on('click', function(){ 464 latlng = init_latlng; 465 _update_places_bounds(); 466 _update_map(); 467 }); 468 } 469 470 //Location field change event 471 if($('#activmap-location').length){ 472 if(s.country !== null){ 473 var options = { 474 types: s.locationTypes, 475 componentRestrictions: {country: s.country} 476 }; 477 }else{ 478 var options = { 479 types: s.locationTypes 480 }; 481 } 482 var input = document.getElementById('activmap-location'); 483 autocomplete = new google.maps.places.Autocomplete(input, options); 484 485 google.maps.event.addListener(autocomplete, 'place_changed', function(){ 486 var place = autocomplete.getPlace(); 487 latlng = place.geometry.location; 488 //map.setCenter(place.geometry.location); 489 if($('.activmap-place').length) _order(); 490 $('input[name="marker_type[]"], select[name="marker_type[]"]').each(function(){ 491 _update_places_tag($(this), false); 492 }); 493 _update_center_marker(); 494 //bounds = map.getBounds(); 495 _update_map(); 496 }); 497 } 498 499 //Radius change event
500 $('input[name="activmap_radius"]').on('change', function(){ 501 s.radius = $(this).val(); 502 $('input[name="marker_type[]"], select[name="marker_type[]"]').each(function(){ 503 _update_places_tag($(this), false); 504 }); 505 _update_map(); 506 }); 507 508 //Filter change event 509 $('input[name="marker_type[]"], select[name="marker_type[]"]').on('change', function(){ 510 _update_places_tag($(this), true); 511 _update_map(); 512 }); 513 514 //Reset click event 515 $('#activmap-reset').on('click', function(){ 516 $('input[name="marker_type[]"]').prop('checked',false); 517 $('select[name="marker_type[]"] > option').prop('selected', false); 518 $('input[name="marker_type[]"], select[name="marker_type[]"]').each(function(){ 519 _update_places_tag($(this), false); 520 }); 521 latlng = init_latlng; 522 _update_center_marker(); 523 _update_map(); 524 return false; 525 }); 526 527 //Place (panel with results) click event 528 $(document).on('click', '.activmap-place', function(){ 529 var id = $(this).attr('id').replace('activmap-place_',''); 530 google.maps.event.trigger(markers[id], 'click'); 531 }); 532 533 //Window resize event 534 $(window).on('resize', function(){ 535 setTimeout('_update_map()', 300); 536 }); 537 538 //For each selected tags on page loading 539 $('input[name="marker_type[]"]:checked').add($('select[name="marker_type[]"]').prop('selected', true)).each(function(){ 540 _update_places_tag($(this), false); 541 }); 542 543 _update_map(); 544 } 545 546 /* _sort_by_dist() compares 2 distances 547 * 548 * @param a coordinates of point 1 549 * @param b coordinates of point 2 550 */ 551 _sort_by_dist = function(a, b){ 552 return ((a.dist < b.dist) ? -1 : ((a.dist > b.dist) ? 1 : 0)); 553 } 554 555 /* _order() sorts the places in the panel 556 * 557 */ 558 _order = function(){ 559 $.each(s.places, function(i, place){ 560 place.dist = _get_distance(place.marker.position, latlng); 561 }); 562 s.places.sort(_sort_by_dist); 563 $('.activmap-place').remove(); 564 $.each(s.places, function(i, place){ 565 activmap_places.append(place.html); 566 if(place.isVisible) $('#activmap-place_'+place.id).show(); 567 }); 568 } 569 570 /* _update_center_marker() modifies the position of the center marker 571 * 572 */ 573 _update_center_marker = function(){ 574 centerMarker.setPosition(latlng); 575 _update_places_bounds(); 576 } 577 578 /* _geolocate() geolocates the user 579 * 580 */ 581 _geolocate = function(){ 582 if(navigator.geolocation){ 583 browserSupportFlag = true; 584 navigator.geolocation.getCurrentPosition(function(position){ 585 initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude); 586 latlng = initialLocation; 587 //map.setCenter(latlng); 588 if($('.activmap-place').length) _order(); 589 $('input[name="marker_type[]"], select[name="marker_type[]"]').each(function(){ 590 _update_places_tag($(this), false); 591 }); 592 _update_center_marker(); 593 //bounds = map.getBounds(); 594 _update_map(); 595 }, function(){ 596 handleNoGeolocation(browserSupportFlag); 597 }); 598 }else{ 599 browserSupportFlag = false; 600 handleNoGeolocation(browserSupportFlag); 601 } 602 } 603 604 /* _handleNoGeolocation() handles the geolocation errors 605 * 606 */ 607 _handleNoGeolocation = function(errorFlag){ 608 if(errorFlag == true){ 609 console.log('Geolocation service failed.'); 610 initialLocation = latlng; 611 }else{ 612 console.log('Your browser doesn\'t support geolocation.'); 613 initialLocation = latlng; 614 } 615 map.setCenter(initialLocation); 616 } 617 618 /* _rad() gets the radius distance 619 * 620 * @param a distance 621 * 622 */ 623 _rad = function(a){ 624 return a * Math.PI / 180; 625 } 626 627 /* _paddedBounds() adds offsets all around the map 628 * 629 * @param npad north padding in pixels 630 * @param spad south padding in pixels 631 * @param epad east padding in pixels 632 * @param wpad west padding in pixels 633 * 634 */
635 _paddedBounds = function(npad, spad, epad, wpad) { 636 var SW = map.getBounds().getSouthWest(); 637 var NE = map.getBounds().getNorthEast(); 638 var topRight = map.getProjection().fromLatLngToPoint(NE); 639 var bottomLeft = map.getProjection().fromLatLngToPoint(SW); 640 var scale = Math.pow(2, map.getZoom()); 641 642 var SWtopoint = map.getProjection().fromLatLngToPoint(SW); 643 var SWpoint = new google.maps.Point(((SWtopoint.x - bottomLeft.x) * scale) + wpad, ((SWtopoint.y - topRight.y) * scale) - spad); 644 var SWworld = new google.maps.Point(SWpoint.x / scale + bottomLeft.x, SWpoint.y / scale + topRight.y); 645 var pt1 = map.getProjection().fromPointToLatLng(SWworld); 646 647 var NEtopoint = map.getProjection().fromLatLngToPoint(NE); 648 var NEpoint = new google.maps.Point(((NEtopoint.x - bottomLeft.x) * scale) - epad, ((NEtopoint.y - topRight.y) * scale) + npad); 649 var NEworld = new google.maps.Point(NEpoint.x / scale + bottomLeft.x, NEpoint.y / scale + topRight.y); 650 var pt2 = map.getProjection().fromPointToLatLng(NEworld); 651 652 return new google.maps.LatLngBounds(pt1, pt2); 653 } 654 655 /* _getDistance() returns the distance between 2 points in meters 656 * 657 * @param p1 coordinates of point 1 658 * @param p2 coordinates of point 2 659 * 660 */ 661 _get_distance = function(p1, p2){ 662 var R = (s.unit == 'km') ? 6378137 : 3963190; 663 var dLat = _rad(p2.lat() - p1.lat()); 664 var dLong = _rad(p2.lng() - p1.lng()); 665 var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + 666 Math.cos(_rad(p1.lat())) * Math.cos(_rad(p2.lat())) * 667 Math.sin(dLong / 2) * Math.sin(dLong / 2); 668 var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); 669 var d = R * c; 670 return d; 671 } 672 673 /* _update_map() hides or shows the places panel. Shrinks, enlarges and refresh the map 674 * 675 */ 676 _update_map = function(){ 677 map_w = $('#activmap-wrapper').width(); 678 cont_w = activmap_places.outerWidth(); 679 if(num_places > 0){ 680 //results found 681 if(old_results == 0){ 682 //no previous result 683 //side panel displaying for 1st time => shows places 684 if(s.showPanel){ 685 if(s.posPanel == 'left'){ 686 activmap_places.stop(true,true).animate({ 687 left: 0 688 },400); 689 } 690 if(s.posPanel == 'right'){ 691 activmap_places.stop(true,true).animate({ 692 right: 0 693 },400); 694 } 695 //side panel is visible on screen device only => shrinks map 696 if(activmap_places.is(':visible')){ 697 activmap_canvas.animate({ 698 width: map_w-cont_w 699 },400); 700 } 701 } 702 }else{ 703 if(s.showPanel && activmap_places.is(':visible') && $(window).width()+17 > 1190) activmap_canvas.width(map_w-cont_w); 704 else activmap_canvas.width(map_w); 705 } 706 }else{ 707 //no result found 708 if(opendInfoWindow != null) opendInfoWindow.close(); 709 if(s.showPanel){ 710 if(activmap_places.is(':visible') && $(window).width()+17 > 1190){ 711 //there were previous results 712 //side panel is visible on screen device only => hides places, enlarges map 713 activmap_canvas.animate({ 714 width: map_w 715 },400); 716 if(s.posPanel == 'left'){ 717 activmap_places.animate({ 718 left: -cont_w 719 },400); 720 } 721 if(s.posPanel == 'right'){ 722 activmap_places.animate({ 723 right: -cont_w 724 },400); 725 } 726 }else 727 activmap_canvas.width(map_w); 728 }else 729 activmap_canvas.width(map_w); 730 } 731 old_results = num_places; 732 setTimeout('_map_resize()',400);
733 } 734 735 /* _map_resize() updates bounds and clusters on map resize 736 * 737 */ 738 _map_resize = function() { 739 google.maps.event.trigger(map, 'resize'); 740 741 var listener = google.maps.event.addListenerOnce(map, 'idle', function(){ 742 if(map.getZoom() > 16) map.setZoom(16); 743 }); 744 745 if(num_places > 0){ 746 map.fitBounds(bounds); 747 var padbnds = _paddedBounds(10, 150, 50, 50); 748 map.fitBounds(padbnds); 749 if(s.cluster) markerCluster.repaint(); 750 }else{ 751 map.setZoom(s.zoom); 752 map.setCenter(latlng); 753 } 754 } 755 756 /* _update_places_bounds() updates map bounds according to visible places 757 * 758 */ 759 _update_places_bounds = function(){ 760 bounds = new google.maps.LatLngBounds(); 761 var i = 0; 762 $.each(s.places, function(j, place){ 763 if(place.isVisible == true){ 764 bounds.extend(place.marker.getPosition()); 765 i++; 766 } 767 }); 768 bounds.extend(centerMarker.getPosition()); 769 num_places = i; 770 } 771 772 /* _update_places_tag(input) updates the array of places and the map's bounds 773 * 774 * @param input checkbox object 775 * 776 */ 777 _update_places_tag = function(input, uncheck){ 778 779 //Checkbox selection 780 if(!s.allowMultiSelect){ 781 if(uncheck){ 782 $('.marker-selector').removeClass('active'); 783 $('input[name="marker_type[]"]').not(input).prop('checked',false); 784 $('select[name="marker_type[]"]').not(input).find('option').prop('selected', false); 785 } 786 } 787 var checked = (input.prop('tagName') == 'SELECT') ? input.prop('selected') : input.prop('checked'); 788 789 if(checked == true) 790 input.parents('.marker-selector').addClass('active'); 791 else 792 input.parents('.marker-selector').removeClass('active'); 793 794 var val; 795 var i = 0; 796 var p_ids = []; 797 var ids_copy = []; 798 $('input[name="marker_type[]"]:checked').add($('select[name="marker_type[]"]').prop('selected', true)).each(function(){ 799 val = $(this).val(); 800 if(val != ''){ 801 if(ids[val] === undefined) ids[val] = []; 802 if(i == 0) p_ids = $.merge([], ids[val]); 803 else{ 804 if(s.request == 'strict') p_ids = $.arrayIntersect(ids[val], p_ids); 805 if(s.request == 'large'){ 806 ids_copy = $.merge([], ids[val]); 807 p_ids = $.merge(ids_copy, p_ids); 808 } 809 } 810 i++; 811 } 812 }); 813 814 if(opendInfoWindow != null) opendInfoWindow.close(); 815 816 $.each(s.places, function(j, place){ 817 place.num_tags = 0; 818 place.dist = 0; 819 if($.inArray(place.id, p_ids) >= 0){ 820 place.dist = _get_distance(place.marker.position, latlng); 821 //the place is in all tags => set visible 822 if(s.radius == 0 || place.dist <= s.radius*1000){ 823 place.num_tags++; 824 place.marker.setVisible(true); 825 place.isVisible = true; 826 $('#activmap-place_'+place.id).show(); 827 }else{ 828 //perform only if a checkbox is clicked 829 if(place.num_tags > 0) place.num_tags--; 830 if(place.num_tags == 0){ 831 place.marker.setVisible(false); 832 place.isVisible = false; 833 place.isVisible = false; 834 $('#activmap-place_'+place.id).hide(); 835 } 836 } 837 }else{ 838 //perform only if a checkbox is clicked 839 if(place.num_tags > 0) place.num_tags--; 840 if(place.num_tags == 0){ 841 place.marker.setVisible(false); 842 place.isVisible = false; 843 $('#activmap-place_'+place.id).hide(); 844 } 845 } 846 }); 847 848 _update_places_bounds(); 849 850 $('#activmap-results-num').html(num_places+' result(s)'); 851 } 852 853 if(!Array.isArray(s.places)){ 854 $.ajax({
855 url: s.places, 856 dataType: 'json', 857 cache: false, 858 error: function (jqXHR, textStatus, errorThrown) { 859 console.log(jqXHR); 860 console.log(textStatus); 861 console.log(errorThrown); 862 }, 863 success: function(data){ 864 var obj = eval(data); 865 s.places = obj.places; 866 _init(); 867 } 868 }); 869 }else 870 _init(); 871 } 872 }); 873})(jQuery);
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.