1;(function ($, window, google, undefined) { 2 'use strict'; 3 4 /** 5 * Maplace.js 0.1.2c 6 * 7 * Copyright (c) 2013 Daniele Moraschi 8 * Licensed under the MIT license 9 * For all details and documentation: 10 * http://maplacejs.com 11 * 12 * @version 0.1.2c 13 */ 14 15 16 var html_dropdown, 17 html_ullist, 18 Maplace; 19 20 21 //dropdown menu type 22 html_dropdown = { 23 activateCurrent: function (index) { 24 this.html_element.find('select').val(index); 25 }, 26 27 getHtml: function () { 28 var self = this, 29 html = '', 30 title, 31 a; 32 33 if (this.ln > 1) { 34 html += '<select class="dropdown controls ' + this.o.controls_cssclass + '">'; 35 36 if (this.ShowOnMenu(this.view_all_key)) { 37 html += '<option value="' + this.view_all_key + '">' + this.o.view_all_text + '</option>'; 38 } 39 40 for (a = 0; a < this.ln; a += 1) { 41 if (this.ShowOnMenu(a)) { 42 html += '<option value="' + (a + 1) + '">' + (this.o.locations[a].title || ('#' + (a + 1))) + '</option>'; 43 } 44 } 45 html += '</select>'; 46 47 html = $(html).bind('change', function () { 48 self.ViewOnMap(this.value); 49 }); 50 } 51 52 title = this.o.controls_title; 53 if (this.o.controls_title) { 54 title = $('<div class="controls_title"></div>').css(this.o.controls_applycss ? { 55 fontWeight: 'bold', 56 fontSize: this.o.controls_on_map ? '12px' : 'inherit', 57 padding: '3px 10px 5px 0' 58 } : {}).append(this.o.controls_title); 59 } 60 61 this.html_element = $('<div class="wrap_controls"></div>').append(title).append(html); 62 63 return this.html_element; 64 } 65 }; 66 67 68 //ul list menu type 69 html_ullist = { 70 html_a: function (i, hash, ttl) { 71 var self = this, 72 index = hash || (i + 1), 73 title = ttl || this.o.locations[i].title, 74 el_a = $('<a data-load="' + index + '" id="ullist_a_' + index + '" href="#' + index + '" title="' + title + '"><span>' + (title || ('#' + (i + 1))) + '</span></a>'); 75 76 el_a.css(this.o.controls_applycss ? { 77 color: '#666', 78 display: 'block', 79 padding: '5px', 80 fontSize: this.o.controls_on_map ? '12px' : 'inherit', 81 textDecoration: 'none' 82 } : {}); 83 84 el_a.on('click', function (e) { 85 e.preventDefault(); 86 var i = $(this).attr('data-load'); 87 self.ViewOnMap(i); 88 }); 89 90 return el_a; 91 }, 92 93 activateCurrent: function (index) { 94 this.html_element.find('li').removeClass('active'); 95 this.html_element.find('#ullist_a_' + index).parent().addClass('active'); 96 }, 97 98 getHtml: function () { 99 var html = $("<ul class='ullist controls " + this.o.controls_cssclass + "'></ul>").css(this.o.controls_applycss ? { 100 margin: 0, 101 padding: 0, 102 listStyleType: 'none' 103 } : {}), 104 title, a; 105 106 if (this.ShowOnMenu(this.view_all_key)) { 107 html.append($('<li></li>').append(html_ullist.html_a.call(this, false, this.view_all_key, this.o.view_all_text))); 108 } 109 110 for (a = 0; a < this.ln; a++) { 111 if (this.ShowOnMenu(a)) { 112 html.append($('<li></li>').append(html_ullist.html_a.call(this, a))); 113 } 114 } 115 116 title = this.o.controls_title; 117 if (this.o.controls_title) { 118 title = $('<div class="controls_title"></div>').css(this.o.controls_applycss ? { 119 fontWeight: 'bold', 120 padding: '3px 10px 5px 0', 121 fontSize: this.o.controls_on_map ? '12px' : 'inherit' 122 } : {}).append(this.o.controls_title); 123 } 124 125 this.html_element = $('<div class="wrap_controls"></div>').append(title).append(html); 126 127 return this.html_element; 128 } 129 }; 130 131 132 Maplace = (function () { 133 134 /** 135 * Create a new instance 136 * @class Maplace 137 * @constructor 138 */ 139 function Maplace(args) { 140 this.VERSION = '0.1.2'; 141 this.errors = []; 142 this.loaded = false;
143 this.dev = true; 144 this.markers = []; 145 this.oMap = false; 146 this.view_all_key = 'all'; 147 148 this.infowindow = null; 149 this.ln = 0; 150 this.oMap = false; 151 this.oBounds = null; 152 this.map_div = null; 153 this.canvas_map = null; 154 this.controls_wrapper = null; 155 this.current_control = null; 156 this.current_index = null; 157 this.Polyline = null; 158 this.Polygon = null; 159 this.Fusion = null; 160 this.directionsService = null; 161 this.directionsDisplay = null; 162 163 //default options 164 this.o = { 165 map_div: '#gmap', 166 controls_div: '#controls', 167 generate_controls: true, 168 controls_type: 'dropdown', 169 controls_cssclass: '', 170 controls_title: '', 171 controls_on_map: true, 172 controls_applycss: true, 173 controls_position: google.maps.ControlPosition.RIGHT_TOP, 174 type: 'marker', 175 view_all: true, 176 view_all_text: 'View All', 177 start: 0, 178 locations: [], 179 commons: {}, 180 map_options: { 181 mapTypeId: google.maps.MapTypeId.ROADMAP, 182 zoom: 1 183 }, 184 stroke_options: { 185 strokeColor: '#0000FF', 186 strokeOpacity: 0.8, 187 strokeWeight: 2, 188 fillColor: '#0000FF', 189 fillOpacity: 0.4 190 }, 191 directions_options: { 192 travelMode: google.maps.TravelMode.DRIVING, 193 unitSystem: google.maps.UnitSystem.METRIC, 194 optimizeWaypoints: false, 195 provideRouteAlternatives: false, 196 avoidHighways: false, 197 avoidTolls: false 198 }, 199 styles: {}, 200 fusion_options: {}, 201 directions_panel: null, 202 draggable: false, 203 show_infowindows: true, 204 show_markers: true, 205 infowindow_type: 'bubble', 206 listeners: {}, 207 208 //events 209 beforeViewAll: function () {}, 210 afterViewAll: function () {}, 211 beforeShow: function (index, location, marker) {}, 212 afterShow: function (index, location, marker) {}, 213 afterCreateMarker: function (index, location, marker) {}, 214 beforeCloseInfowindow: function (index, location) {}, 215 afterCloseInfowindow: function (index, location) {}, 216 beforeOpenInfowindow: function (index, location, marker) {}, 217 afterOpenInfowindow: function (index, location, marker) {}, 218 afterRoute: function (distance, status, result) {}, 219 onPolylineClick: function (obj) {} 220 }; 221 222 //default menu types 223 this.AddControl('dropdown', html_dropdown); 224 this.AddControl('list', html_ullist); 225 226 //init 227 $.extend(true, this.o, args); 228 } 229 230 //where to store the menu types 231 Maplace.prototype.controls = {}; 232 233 //initialize google map object 234 Maplace.prototype.create_objMap = function () { 235 var self = this, 236 count = 0, 237 i; 238 239 //if styled 240 for (i in this.o.styles) { 241 if (this.o.styles.hasOwnProperty(i)) { 242 if (count === 0) { 243 this.o.map_options.mapTypeControlOptions = { 244 mapTypeIds: [google.maps.MapTypeId.ROADMAP] 245 }; 246 } 247 count++; 248 this.o.map_options.mapTypeControlOptions.mapTypeIds.push('map_style_' + count); 249 } 250 } 251 252 //if init 253 if (!this.loaded) { 254 try { 255 this.map_div.css({ 256 position: 'relative', 257 overflow: 'hidden' 258 }); 259 260 //create the container div into map_div 261 this.canvas_map = $('<div>').addClass('canvas_map').css({ 262 width: '100%', 263 height: '100%' 264 }).appendTo(this.map_div); 265 266 this.oMap = new google.maps.Map(this.canvas_map.get(0), this.o.map_options); 267 } catch (err) { 268 this.errors.push(err.toString()); 269 } 270 } else { //else loads the new options 271 self.oMap.setOptions(this.o.map_options); 272 } 273 274 //if styled 275 count = 0; 276 for (i in this.o.styles) { 277 if (this.o.styles.hasOwnProperty(i)) { 278 count++; 279 this.oMap.mapTypes.set('map_style_' + count, new google.maps.StyledMapType(this.o.styles[i], { 280 name: i 281 })); 282 this.oMap.setMapTypeId('map_style_' + count); 283 } 284 } 285 286 this.debug('01'); 287 }; 288 289 //adds markers to the map 290 Maplace.prototype.add_markers_to_objMap = function () { 291 var a, 292 type = this.o.type || 'marker'; 293 294 //switch how to display the locations 295 switch (type) { 296 case 'marker': 297 for (a = 0; a < this.ln; a++) { 298 this.create.marker.call(this, a); 299 } 300 break; 301 default: 302 this.create[type].apply(this); 303 break; 304 } 305 }; 306 307 //wrapper for the map types 308 Maplace.prototype.create = { 309 310 //single marker 311 marker: function (index) { 312 var self = this, 313 point = this.o.locations[index], 314 html = point.html || '', 315 marker, a, 316 point_infow, 317 image_w, 318 image_h, 319 latlng = new google.maps.LatLng(point.lat, point.lon), 320 orig_visible = point.visible === false ? false : true; 321 322 $.extend(point, { 323 position: latlng, 324 map: this.oMap, 325 zIndex: 10000, 326 //temp visible property 327 visible: (this.o.show_markers === false ? false : orig_visible) 328 }); 329 330 if (point.image) { 331 image_w = point.image_w || 32; 332 image_h = point.image_h || 32; 333 $.extend(point, { 334 icon: new google.maps.MarkerImage(point.image, new google.maps.Size(image_w, image_h), new google.maps.Point(0, 0), new google.maps.Point(image_w / 2, image_h / 2)) 335 }); 336 } 337 338 //create the marker and add click event 339 marker = new google.maps.Marker(point); 340 a = google.maps.event.addListener(marker, 'click', function () { 341 342 self.o.beforeShow(index, point, marker); 343 344 //show infowindow? 345 point_infow = point.show_infowindows === false ? false : true; 346 if (self.o.show_infowindows && point_infow) { 347 self.open_infowindow(index, marker); 348 } 349 350 //pan and zoom the map 351 self.oMap.panTo(latlng); 352 point.zoom && self.oMap.setZoom(point.zoom); 353 354 //activate related menu link 355 if (self.current_control && self.o.generate_controls && self.current_control.activateCurrent) { 356 self.current_control.activateCurrent.call(self, index + 1); 357 } 358 359 //update current location index 360 self.current_index = index; 361 362 self.o.afterShow(index, point, marker); 363 }); 364 365 //extends bounds with this location 366 this.oBounds.extend(latlng); 367 368 //store the new marker 369 this.markers.push(marker); 370 371 this.o.afterCreateMarker(index, point, marker); 372 373 //restore the visible property 374 point.visible = orig_visible; 375 376 return marker; 377 }, 378 379 380 //polyline mode 381 polyline: function () { 382 var self = this, 383 a, 384 latlng, 385 path = []; 386 387 //create the path and location marker 388 for (a = 0; a < this.ln; a++) { 389 latlng = new google.maps.LatLng(this.o.locations[a].lat, this.o.locations[a].lon); 390 path.push(latlng); 391 this.create.marker.call(this, a); 392 } 393 394 $.extend(this.o.stroke_options, { 395 path: path, 396 map: this.oMap 397 }); 398 399 this.Polyline ? this.Polyline.setOptions(this.o.stroke_options) : this.Polyline = new google.maps.Polyline(this.o.stroke_options); 400 }, 401 402 403 //polygon mode 404 polygon: function () { 405 var self = this, 406 a, 407 latlng, 408 path = []; 409 410 //create the path and location marker 411 for (a = 0; a < this.ln; a++) { 412 latlng = new google.maps.LatLng(this.o.locations[a].lat, this.o.locations[a].lon); 413 path.push(latlng); 414 this.create.marker.call(this, a); 415 } 416 417 $.extend(this.o.stroke_options, { 418 paths: path, 419 editable: this.o.draggable, 420 map: this.oMap 421 }); 422 423 this.Polygon ? this.Polygon.setOptions(this.o.stroke_options) : this.Polygon = new google.maps.Polygon(this.o.stroke_options); 424 425 google.maps.event.addListener(this.Polygon, 'click', function (obj) { 426 self.o.onPolylineClick(obj); 427 }); 428 }, 429 430 431 //fusion tables 432 fusion: function () { 433 $.extend(this.o.fusion_options, { 434 styles: [this.o.stroke_options], 435 map: this.oMap 436 }); 437 438 this.Fusion ? this.Fusion.setOptions(this.o.fusion_options) : this.Fusion = new google.maps.FusionTablesLayer(this.o.fusion_options); 439 }, 440 441 442 //directions mode 443 directions: function () { 444 var self = this, 445 a, 446 stopover, 447 latlng, 448 origin, 449 destination, 450 waypoints = [], 451 distance = 0; 452 453 //create the waypoints and location marker 454 for (a = 0; a < this.ln; a++) { 455 latlng = new google.maps.LatLng(this.o.locations[a].lat, this.o.locations[a].lon); 456 457 //first location start point 458 if (a === 0) { 459 origin = latlng; 460 } else if (a === (this.ln - 1)) { //last location end point 461 destination = latlng; 462 } else { //waypoints in the middle 463 stopover = this.o.locations[a].stopover === true ? true : false;
464 waypoints.push({ 465 location: latlng, 466 stopover: stopover 467 }); 468 } 469 this.create.marker.call(this, a); 470 } 471 472 $.extend(this.o.directions_options, { 473 origin: origin, 474 destination: destination, 475 waypoints: waypoints 476 }); 477 478 this.directionsService || (this.directionsService = new google.maps.DirectionsService()); 479 this.directionsDisplay ? this.directionsDisplay.setOptions({ draggable: this.o.draggable }) : this.directionsDisplay = new google.maps.DirectionsRenderer({ draggable: this.o.draggable }); 480 481 this.directionsDisplay.setMap(this.oMap); 482 483 //show the directions panel 484 if (this.o.directions_panel) { 485 this.o.directions_panel = $(this.o.directions_panel); 486 this.directionsDisplay.setPanel(this.o.directions_panel.get(0)); 487 } 488 489 if (this.o.draggable) { 490 google.maps.event.addListener(this.directionsDisplay, 'directions_changed', function () { 491 distance = self.compute_distance(self.directionsDisplay.directions); 492 self.o.afterRoute(distance); 493 }); 494 } 495 496 this.directionsService.route(this.o.directions_options, function (result, status) { 497 //when directions found 498 if (status === google.maps.DirectionsStatus.OK) { 499 distance = self.compute_distance(result); 500 self.directionsDisplay.setDirections(result); 501 } 502 self.o.afterRoute(distance, status, result); 503 }); 504 } 505 }; 506 507 //route distance 508 Maplace.prototype.compute_distance = function (result) { 509 var total = 0, 510 i, 511 myroute = result.routes[0], 512 rlen = myroute.legs.length; 513 514 for (i = 0; i < rlen; i++) { 515 total += myroute.legs[i].distance.value; 516 } 517 518 return total; 519 }; 520 521 //wrapper for the infowindow types 522 Maplace.prototype.type_to_open = { 523 //google default infowindow 524 bubble: function (location) { 525 this.infowindow = new google.maps.InfoWindow({ 526 content: location.html || '' 527 }); 528 } 529 }; 530 531 //open the infowindow 532 Maplace.prototype.open_infowindow = function (index, marker) { 533 //close if any open 534 this.CloseInfoWindow(); 535 var point = this.o.locations[index], 536 type = point.type || this.o.infowindow_type; 537 538 //show if content and valid infowindow type provided 539 if (point.html && this.type_to_open[type]) { 540 this.o.beforeOpenInfowindow(index, point, marker); 541 this.type_to_open[type].call(this, point); 542 this.infowindow.open(this.oMap, marker); 543 this.o.afterOpenInfowindow(index, point, marker); 544 } 545 }; 546 547 //gets the html for the menu 548 Maplace.prototype.get_html_controls = function () { 549 if (this.controls[this.o.controls_type] && this.controls[this.o.controls_type].getHtml) { 550 this.current_control = this.controls[this.o.controls_type]; 551 552 return this.current_control.getHtml.apply(this); 553 } 554 return ''; 555 }; 556 557 //creates the controls menu 558 Maplace.prototype.generate_controls = function () { 559 //append menu on the div container 560 if (!this.o.controls_on_map) { 561 this.controls_wrapper.empty(); 562 this.controls_wrapper.append(this.get_html_controls()); 563 return; 564 } 565 566 //else 567 //controls in map
568 var cntr = $('<div class="on_gmap ' + this.o.controls_type + ' gmap_controls"></div>').css(this.o.controls_applycss ? { 569 margin: '5px' 570 } : {}), 571 inner = $(this.get_html_controls()).css(this.o.controls_applycss ? { 572 background: '#fff', 573 padding: '5px', 574 border: '1px solid rgb(113,123,135)', 575 boxShadow: 'rgba(0, 0, 0, 0.4) 0px 2px 4px', 576 maxHeight: this.map_div.find('.canvas_map').outerHeight() - 80, 577 minWidth: 100, 578 overflowY: 'auto', 579 overflowX: 'hidden' 580 } : {}); 581 582 cntr.append(inner); 583 584 //attach controls 585 this.oMap.controls[this.o.controls_position].push(cntr.get(0)); 586 }; 587 588 //resets obj map, markers, bounds, listeners, controllers 589 Maplace.prototype.init_map = function () { 590 var self = this, 591 i = 0; 592 593 this.Polyline && this.Polyline.setMap(null); 594 this.Polygon && this.Polygon.setMap(null); 595 this.Fusion && this.Fusion.setMap(null); 596 this.directionsDisplay && this.directionsDisplay.setMap(null); 597 598 if (this.markers) { 599 for (i in this.markers) { 600 if (this.markers[i]) { 601 try { this.markers[i].setMap(null); } catch (err) { self.errors.push(err); } 602 } 603 } 604 this.markers.length = 0; 605 this.markers = []; 606 } 607 608 if (this.o.controls_on_map && this.oMap.controls) { 609 this.oMap.controls[this.o.controls_position].forEach(function (element, index) { 610 try { self.oMap.controls[this.o.controls_position].removeAt(index); } catch (err) { self.errors.push(err); } 611 }); 612 } 613 614 this.oBounds = new google.maps.LatLngBounds(); 615 616 this.debug('02'); 617 }; 618 619 //perform the first view of the map 620 Maplace.prototype.perform_load = function () { 621 //one location 622 if (this.ln === 1) { 623 this.oMap.setCenter(this.markers[0].getPosition()); 624 this.ViewOnMap(1); 625 } else if (this.ln === 0) { //no locations 626 if (this.o.map_options.set_center) { 627 this.oMap.setCenter(new google.maps.LatLng(this.o.map_options.set_center[0], this.o.map_options.set_center[1])); 628 } else { 629 this.oMap.fitBounds(this.oBounds); 630 } 631 this.oMap.setZoom(this.o.map_options.zoom); 632 } else { //n locations 633 this.oMap.fitBounds(this.oBounds); 634 //check the start option 635 if (typeof (this.o.start - 0) === 'number' && this.o.start > 0 && this.o.start <= this.ln) { 636 this.ViewOnMap(this.o.start); 637 } else { 638 this.ViewOnMap(this.view_all_key); 639 } 640 } 641 }; 642 643 Maplace.prototype.debug = function (msg) { 644 if (this.dev && this.errors.length) { 645 console.log(msg + ': ', this.errors); 646 } 647 }; 648 649 650
651 ///////////////////////////////////////////////////////////////////////// 652 ///////////////////////////////////////////////////////////////////////// 653 654 655 //adds a custom menu to the class 656 Maplace.prototype.AddControl = function (name, func) { 657 if (!name || !func) { 658 return false; 659 } 660 this.controls[name] = func; 661 return true; 662 }; 663 664 //close the infowindow 665 Maplace.prototype.CloseInfoWindow = function () { 666 if (this.infowindow && (this.current_index || this.current_index === 0)) { 667 this.o.beforeCloseInfowindow(this.current_index, this.o.locations[this.current_index]); 668 this.infowindow.close(); 669 this.infowindow = null; 670 this.o.afterCloseInfowindow(this.current_index, this.o.locations[this.current_index]); 671 } 672 }; 673 674 //checks if a location has to be in menu 675 Maplace.prototype.ShowOnMenu = function (index) { 676 if (index === this.view_all_key && this.o.view_all && this.ln > 1) { 677 return true; 678 } 679 680 index = parseInt(index, 10); 681 if (typeof (index - 0) === 'number' && index >= 0 && index < this.ln) { 682 var visible = this.o.locations[index].visible === false ? false : true, 683 on_menu = this.o.locations[index].on_menu === false ? false : true; 684 if (visible && on_menu) { 685 return true; 686 } 687 } 688 return false; 689 }; 690 691 //triggers to show a location in map 692 Maplace.prototype.ViewOnMap = function (index) { 693 //view all 694 if (index === this.view_all_key) { 695 this.o.beforeViewAll(); 696 this.current_index = index; 697 if (this.o.locations.length > 0 && this.o.generate_controls && this.current_control && this.current_control.activateCurrent) { 698 this.current_control.activateCurrent.apply(this, [index]); 699 } 700 this.oMap.fitBounds(this.oBounds); 701 this.CloseInfoWindow(); 702 this.o.afterViewAll(); 703 } else { //specific location 704 index = parseInt(index, 10); 705 if (typeof (index - 0) === 'number' && index > 0 && index <= this.ln) { 706 try { 707 google.maps.event.trigger(this.markers[index - 1], 'click'); 708 } catch (err) { 709 this.errors.push(err.toString()); 710 } 711 } 712 } 713 this.debug('03'); 714 }; 715 716 //replace current locations 717 Maplace.prototype.SetLocations = function (locs, reload) { 718 this.o.locations = locs; 719 reload && this.Load(); 720 }; 721 722 //adds one or more locations to the end of the array 723 Maplace.prototype.AddLocations = function (locs, reload) { 724 var self = this; 725 726 if ($.isArray(locs)) { 727 $.each(locs, function (index, value) { 728 self.o.locations.push(value); 729 }); 730 } 731 if ($.isPlainObject(locs)) { 732 this.o.locations.push(locs); 733 } 734 735 reload && this.Load(); 736 }; 737 738 //adds a location at the specific index 739 Maplace.prototype.AddLocation = function (location, index, reload) { 740 var self = this; 741 742 if ($.isPlainObject(location)) { 743 this.o.locations.splice(index, 0, location); 744 } 745 746 reload && this.Load(); 747 }; 748 749 //remove one or more locations 750 Maplace.prototype.RemoveLocations = function (locs, reload) { 751 var self = this, 752 k = 0; 753 754 if ($.isArray(locs)) { 755 $.each(locs, function (index, value) { 756 if ((value - k) < self.ln) { 757 self.o.locations.splice(value-k, 1); 758 } 759 k++; 760 }); 761 } else { 762 if (locs < this.ln) { 763 this.o.locations.splice(locs, 1); 764 } 765 } 766 767 reload && this.Load(); 768 }; 769
770 //check if already initialized with a Load() 771 Maplace.prototype.Loaded = function () { 772 return this.loaded; 773 }; 774 775 //loads the options 776 Maplace.prototype._init = function () { 777 //store the locations length 778 this.ln = this.o.locations.length; 779 780 //update all locations with commons 781 for (var i = 0; i < this.ln; i++) { 782 $.extend(this.o.locations[i], this.o.commons); 783 if(this.o.locations[i].html) { 784 this.o.locations[i].html = this.o.locations[i].html.replace('%index', i+1); 785 this.o.locations[i].html = this.o.locations[i].html.replace('%title', (this.o.locations[i].title || '')); 786 } 787 } 788 789 //store dom references 790 this.map_div = $(this.o.map_div); 791 this.controls_wrapper = $(this.o.controls_div); 792 }; 793 794 //creates the map and menu 795 Maplace.prototype.Load = function (args) { 796 $.extend(true, this.o, args); 797 args && args.locations && (this.o.locations = args.locations); 798 this._init(); 799 800 //reset/init google map objects 801 this.o.visualRefresh === false ? (google.maps.visualRefresh = false) : (google.maps.visualRefresh = true); 802 this.init_map(); 803 this.create_objMap(); 804 805 //add markers 806 this.add_markers_to_objMap(); 807 808 //generate controls 809 if ((this.ln > 1 && this.o.generate_controls) || this.o.force_generate_controls) { 810 this.o.generate_controls = true; 811 this.generate_controls(); 812 } 813 else { 814 this.o.generate_controls = false; 815 } 816 817 var self = this; 818 819 //first call 820 if (!this.loaded) { 821 google.maps.event.addListenerOnce(this.oMap, 'idle', function () { 822 self.perform_load(); 823 }); 824 825 //adapt the div size on resize 826 google.maps.event.addListener(this.oMap, 'resize', function () { 827 self.canvas_map.css({ 828 width: self.map_div.width(), 829 height: self.map_div.height() 830 }); 831 }); 832 833 //add custom listeners 834 var i; 835 for (i in this.o.listeners) { 836 var map = this.oMap, 837 myListener = this.o.listeners[i]; 838 if (this.o.listeners.hasOwnProperty(i)) { 839 google.maps.event.addListener(this.oMap, i, function (event) { 840 myListener(map, event); 841 }); 842 } 843 } 844 } 845 //any other calls 846 else { 847 this.perform_load(); 848 } 849 850 this.loaded = true; 851 }; 852 853 854 return Maplace; 855 856 })(); 857 858 859 if (typeof define == 'function' && define.amd) { 860 define(function() { return Maplace; }); 861 } 862 else { 863 window.Maplace = Maplace; 864 } 865 866})(jQuery, this, google);
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.