|
10 | 10 | }
|
11 | 11 |
|
12 | 12 | // Variables used across multiple methods
|
13 |
| - var $this, listTemplate, infowindowTemplate, dataTypeRead, originalOrigin, originalData, originalZoom, dataRequest, searchInput, addressInput, olat, olng, storeNum, directionsDisplay, directionsService, prevSelectedMarkerBefore, prevSelectedMarkerAfter, firstRun; |
| 13 | + var $this, map, listTemplate, infowindowTemplate, dataTypeRead, originalOrigin, originalData, originalZoom, dataRequest, searchInput, addressInput, olat, olng, storeNum, directionsDisplay, directionsService, prevSelectedMarkerBefore, prevSelectedMarkerAfter, firstRun; |
14 | 14 | var featuredset = [], locationset = [], normalset = [], markers = [];
|
15 | 15 | var filters = {}, locationData = {}, GeoCodeCalc = {}, mappingObj = {};
|
16 | 16 |
|
|
382 | 382 | * @returns {Object} google.maps.Map instance
|
383 | 383 | */
|
384 | 384 | getMap: function() {
|
385 |
| - var myOptions = this.settings.mapSettings; |
386 |
| - var map = new google.maps.Map(document.getElementById(this.settings.mapID), myOptions); |
387 |
| - return map; |
| 385 | + return this.map; |
388 | 386 | },
|
389 | 387 |
|
390 | 388 | /**
|
|
610 | 608 | myOptions.center = latlng;
|
611 | 609 |
|
612 | 610 | // Create the map
|
613 |
| - var map = new google.maps.Map(document.getElementById(_this.settings.mapID), myOptions); |
| 611 | + _this.map = new google.maps.Map(document.getElementById(_this.settings.mapID), myOptions); |
614 | 612 |
|
615 | 613 | // Re-center the map when the browser is re-sized
|
616 | 614 | google.maps.event.addDomListener(window, 'resize', function() {
|
617 |
| - var center = map.getCenter(); |
618 |
| - google.maps.event.trigger(map, 'resize'); |
619 |
| - map.setCenter(center); |
| 615 | + var center = _this.map.getCenter(); |
| 616 | + google.maps.event.trigger(_this.map, 'resize'); |
| 617 | + _this.map.setCenter(center); |
620 | 618 | });
|
621 | 619 |
|
622 | 620 | // Only do this once
|
|
1968 | 1966 | noResults;
|
1969 | 1967 |
|
1970 | 1968 | // Create the map
|
1971 |
| - var map = new google.maps.Map(document.getElementById(this.settings.mapID), myOptions); |
| 1969 | + this.map = new google.maps.Map(document.getElementById(this.settings.mapID), myOptions); |
1972 | 1970 |
|
1973 | 1971 | // Callback
|
1974 | 1972 | if (this.settings.callbackNoResults) {
|
1975 |
| - this.settings.callbackNoResults.call(this, map, myOptions); |
| 1973 | + this.settings.callbackNoResults.call(this, this.map, myOptions); |
1976 | 1974 | }
|
1977 | 1975 |
|
1978 | 1976 | // Empty the location list
|
|
1989 | 1987 | center = new google.maps.LatLng(0, 0);
|
1990 | 1988 | }
|
1991 | 1989 |
|
1992 |
| - map.setCenter(center); |
| 1990 | + this.map.setCenter(center); |
1993 | 1991 |
|
1994 | 1992 | if (originalZoom) {
|
1995 |
| - map.setZoom(originalZoom); |
| 1993 | + this.map.setZoom(originalZoom); |
1996 | 1994 | }
|
1997 | 1995 | },
|
1998 | 1996 |
|
|
2510 | 2508 | }
|
2511 | 2509 |
|
2512 | 2510 | // Create the map
|
2513 |
| - var map = new google.maps.Map(document.getElementById(_this.settings.mapID), myOptions); |
| 2511 | + _this.map = new google.maps.Map(document.getElementById(_this.settings.mapID), myOptions); |
2514 | 2512 |
|
2515 | 2513 | // Re-center the map when the browser is re-sized
|
2516 | 2514 | google.maps.event.addDomListener(window, 'resize', function() {
|
2517 |
| - var center = map.getCenter(); |
2518 |
| - google.maps.event.trigger(map, 'resize'); |
2519 |
| - map.setCenter(center); |
| 2515 | + var center = _this.map.getCenter(); |
| 2516 | + google.maps.event.trigger(_this.map, 'resize'); |
| 2517 | + _this.map.setCenter(center); |
2520 | 2518 | });
|
2521 | 2519 |
|
2522 | 2520 |
|
2523 | 2521 | // Add map drag listener if setting is enabled and re-search on drag end
|
2524 | 2522 | if (_this.settings.dragSearch === true ) {
|
2525 |
| - map.addListener('dragend', function() { |
| 2523 | + _this.map.addListener('dragend', function() { |
2526 | 2524 | _this.dragSearch(map);
|
2527 | 2525 | });
|
2528 | 2526 | }
|
2529 | 2527 |
|
2530 | 2528 | // Load the map
|
2531 |
| - $this.data(_this.settings.mapID.replace('#', ''), map); |
| 2529 | + $this.data(_this.settings.mapID.replace('#', ''), _this.map); |
2532 | 2530 |
|
2533 | 2531 | // Map set callback.
|
2534 | 2532 | if (_this.settings.callbackMapSet) {
|
2535 |
| - _this.settings.callbackMapSet.call(this, map, originPoint, originalZoom, myOptions); |
| 2533 | + _this.settings.callbackMapSet.call(this, _this.map, originPoint, originalZoom, myOptions); |
2536 | 2534 | }
|
2537 | 2535 |
|
2538 | 2536 | // Initialize the infowondow
|
2539 | 2537 | if ( typeof InfoBubble !== 'undefined' && _this.settings.infoBubble !== null ) {
|
2540 | 2538 | var infoBubbleSettings = _this.settings.infoBubble;
|
2541 |
| - infoBubbleSettings.map = map; |
| 2539 | + infoBubbleSettings.map = _this.map; |
2542 | 2540 |
|
2543 | 2541 | infowindow = new InfoBubble(infoBubbleSettings);
|
2544 | 2542 | } else {
|
|
2547 | 2545 |
|
2548 | 2546 |
|
2549 | 2547 | // Add origin marker if the setting is set
|
2550 |
| - _this.originMarker(origin,originPoint,map); |
| 2548 | + _this.originMarker(origin,originPoint,_this.map); |
2551 | 2549 |
|
2552 | 2550 | // Handle pagination
|
2553 | 2551 | $(document).on('click.'+pluginName, '.bh-sl-pagination li', function (e) {
|
|
2557 | 2555 | });
|
2558 | 2556 |
|
2559 | 2557 | // Inline directions
|
2560 |
| - _this.inlineDirections(map, origin); |
| 2558 | + _this.inlineDirections(_this.map, origin); |
2561 | 2559 |
|
2562 | 2560 | // Add markers and infowindows loop
|
2563 | 2561 | for (var y = 0; y <= storeNumToShow - 1; y++) {
|
|
2571 | 2569 | }
|
2572 | 2570 |
|
2573 | 2571 | var point = new google.maps.LatLng(locationset[y].lat, locationset[y].lng);
|
2574 |
| - marker = _this.createMarker(point, locationset[y].name, locationset[y].address, letter, map, locationset[y].category); |
| 2572 | + marker = _this.createMarker(point, locationset[y].name, locationset[y].address, letter, _this.map, locationset[y].category); |
2575 | 2573 | marker.set('id', y);
|
2576 | 2574 | markers[y] = marker;
|
2577 | 2575 | if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined') || (distError === true)) {
|
|
2583 | 2581 |
|
2584 | 2582 | // Center and zoom if no origin or zoom was provided, or distance of first marker is greater than distanceAlert
|
2585 | 2583 | if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined') || (distError === true)) {
|
2586 |
| - map.fitBounds(bounds); |
| 2584 | + _this.map.fitBounds(bounds); |
2587 | 2585 | }
|
2588 | 2586 |
|
2589 | 2587 | // Create the links that focus on the related marker
|
|
2605 | 2603 |
|
2606 | 2604 | // MarkerClusterer setup
|
2607 | 2605 | if ( typeof MarkerClusterer !== 'undefined' && _this.settings.markerCluster !== null ) {
|
2608 |
| - var markerCluster = new MarkerClusterer(map, markers, _this.settings.markerCluster); |
| 2606 | + var markerCluster = new MarkerClusterer(_this.map, markers, _this.settings.markerCluster); |
2609 | 2607 | }
|
2610 | 2608 |
|
2611 | 2609 | // Handle clicks from the list
|
2612 |
| - _this.listClick(map, infowindow, storeStart, page); |
| 2610 | + _this.listClick(_this.map, infowindow, storeStart, page); |
2613 | 2611 |
|
2614 | 2612 | // Add the list li background colors - this wil be dropped in a future version in favor of CSS
|
2615 | 2613 | $('.' + _this.settings.locationList + ' ul > li:even').css('background', _this.settings.listColor1);
|
2616 | 2614 | $('.' + _this.settings.locationList + ' ul > li:odd').css('background', _this.settings.listColor2);
|
2617 | 2615 |
|
2618 | 2616 | // Visible markers list
|
2619 |
| - _this.visibleMarkersList(map, markers); |
| 2617 | + _this.visibleMarkersList(_this.map, markers); |
2620 | 2618 |
|
2621 | 2619 | // Modal ready callback
|
2622 | 2620 | if (_this.settings.modal === true && _this.settings.callbackModalReady) {
|
|
0 commit comments