|
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 |
|
|
376 | 376 | }
|
377 | 377 | },
|
378 | 378 |
|
| 379 | + /** |
| 380 | + * Get google.maps.Map instance |
| 381 | + * |
| 382 | + * @returns {Object} google.maps.Map instance |
| 383 | + */ |
| 384 | + getMap: function() { |
| 385 | + return this.map; |
| 386 | + }, |
| 387 | + |
379 | 388 | /**
|
380 | 389 | * Load templates via Handlebars templates in /templates or inline via IDs - private
|
381 | 390 | */
|
|
599 | 608 | myOptions.center = latlng;
|
600 | 609 |
|
601 | 610 | // Create the map
|
602 |
| - 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); |
603 | 612 |
|
604 | 613 | // Re-center the map when the browser is re-sized
|
605 | 614 | google.maps.event.addDomListener(window, 'resize', function() {
|
606 |
| - var center = map.getCenter(); |
607 |
| - google.maps.event.trigger(map, 'resize'); |
608 |
| - map.setCenter(center); |
| 615 | + var center = _this.map.getCenter(); |
| 616 | + google.maps.event.trigger(_this.map, 'resize'); |
| 617 | + _this.map.setCenter(center); |
609 | 618 | });
|
610 | 619 |
|
611 | 620 | // Only do this once
|
|
1957 | 1966 | noResults;
|
1958 | 1967 |
|
1959 | 1968 | // Create the map
|
1960 |
| - 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); |
1961 | 1970 |
|
1962 | 1971 | // Callback
|
1963 | 1972 | if (this.settings.callbackNoResults) {
|
1964 |
| - this.settings.callbackNoResults.call(this, map, myOptions); |
| 1973 | + this.settings.callbackNoResults.call(this, this.map, myOptions); |
1965 | 1974 | }
|
1966 | 1975 |
|
1967 | 1976 | // Empty the location list
|
|
1978 | 1987 | center = new google.maps.LatLng(0, 0);
|
1979 | 1988 | }
|
1980 | 1989 |
|
1981 |
| - map.setCenter(center); |
| 1990 | + this.map.setCenter(center); |
1982 | 1991 |
|
1983 | 1992 | if (originalZoom) {
|
1984 |
| - map.setZoom(originalZoom); |
| 1993 | + this.map.setZoom(originalZoom); |
1985 | 1994 | }
|
1986 | 1995 | },
|
1987 | 1996 |
|
|
2499 | 2508 | }
|
2500 | 2509 |
|
2501 | 2510 | // Create the map
|
2502 |
| - 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); |
2503 | 2512 |
|
2504 | 2513 | // Re-center the map when the browser is re-sized
|
2505 | 2514 | google.maps.event.addDomListener(window, 'resize', function() {
|
2506 |
| - var center = map.getCenter(); |
2507 |
| - google.maps.event.trigger(map, 'resize'); |
2508 |
| - map.setCenter(center); |
| 2515 | + var center = _this.map.getCenter(); |
| 2516 | + google.maps.event.trigger(_this.map, 'resize'); |
| 2517 | + _this.map.setCenter(center); |
2509 | 2518 | });
|
2510 | 2519 |
|
2511 | 2520 |
|
2512 | 2521 | // Add map drag listener if setting is enabled and re-search on drag end
|
2513 | 2522 | if (_this.settings.dragSearch === true ) {
|
2514 |
| - map.addListener('dragend', function() { |
| 2523 | + _this.map.addListener('dragend', function() { |
2515 | 2524 | _this.dragSearch(map);
|
2516 | 2525 | });
|
2517 | 2526 | }
|
2518 | 2527 |
|
2519 | 2528 | // Load the map
|
2520 |
| - $this.data(_this.settings.mapID.replace('#', ''), map); |
| 2529 | + $this.data(_this.settings.mapID.replace('#', ''), _this.map); |
2521 | 2530 |
|
2522 | 2531 | // Map set callback.
|
2523 | 2532 | if (_this.settings.callbackMapSet) {
|
2524 |
| - _this.settings.callbackMapSet.call(this, map, originPoint, originalZoom, myOptions); |
| 2533 | + _this.settings.callbackMapSet.call(this, _this.map, originPoint, originalZoom, myOptions); |
2525 | 2534 | }
|
2526 | 2535 |
|
2527 | 2536 | // Initialize the infowondow
|
2528 | 2537 | if ( typeof InfoBubble !== 'undefined' && _this.settings.infoBubble !== null ) {
|
2529 | 2538 | var infoBubbleSettings = _this.settings.infoBubble;
|
2530 |
| - infoBubbleSettings.map = map; |
| 2539 | + infoBubbleSettings.map = _this.map; |
2531 | 2540 |
|
2532 | 2541 | infowindow = new InfoBubble(infoBubbleSettings);
|
2533 | 2542 | } else {
|
|
2536 | 2545 |
|
2537 | 2546 |
|
2538 | 2547 | // Add origin marker if the setting is set
|
2539 |
| - _this.originMarker(origin,originPoint,map); |
| 2548 | + _this.originMarker(origin,originPoint,_this.map); |
2540 | 2549 |
|
2541 | 2550 | // Handle pagination
|
2542 | 2551 | $(document).on('click.'+pluginName, '.bh-sl-pagination li', function (e) {
|
|
2546 | 2555 | });
|
2547 | 2556 |
|
2548 | 2557 | // Inline directions
|
2549 |
| - _this.inlineDirections(map, origin); |
| 2558 | + _this.inlineDirections(_this.map, origin); |
2550 | 2559 |
|
2551 | 2560 | // Add markers and infowindows loop
|
2552 | 2561 | for (var y = 0; y <= storeNumToShow - 1; y++) {
|
|
2560 | 2569 | }
|
2561 | 2570 |
|
2562 | 2571 | var point = new google.maps.LatLng(locationset[y].lat, locationset[y].lng);
|
2563 |
| - 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); |
2564 | 2573 | marker.set('id', y);
|
2565 | 2574 | markers[y] = marker;
|
2566 | 2575 | if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined') || (distError === true)) {
|
|
2572 | 2581 |
|
2573 | 2582 | // Center and zoom if no origin or zoom was provided, or distance of first marker is greater than distanceAlert
|
2574 | 2583 | if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined') || (distError === true)) {
|
2575 |
| - map.fitBounds(bounds); |
| 2584 | + _this.map.fitBounds(bounds); |
2576 | 2585 | }
|
2577 | 2586 |
|
2578 | 2587 | // Create the links that focus on the related marker
|
|
2594 | 2603 |
|
2595 | 2604 | // MarkerClusterer setup
|
2596 | 2605 | if ( typeof MarkerClusterer !== 'undefined' && _this.settings.markerCluster !== null ) {
|
2597 |
| - var markerCluster = new MarkerClusterer(map, markers, _this.settings.markerCluster); |
| 2606 | + var markerCluster = new MarkerClusterer(_this.map, markers, _this.settings.markerCluster); |
2598 | 2607 | }
|
2599 | 2608 |
|
2600 | 2609 | // Handle clicks from the list
|
2601 |
| - _this.listClick(map, infowindow, storeStart, page); |
| 2610 | + _this.listClick(_this.map, infowindow, storeStart, page); |
2602 | 2611 |
|
2603 | 2612 | // Add the list li background colors - this wil be dropped in a future version in favor of CSS
|
2604 | 2613 | $('.' + _this.settings.locationList + ' ul > li:even').css('background', _this.settings.listColor1);
|
2605 | 2614 | $('.' + _this.settings.locationList + ' ul > li:odd').css('background', _this.settings.listColor2);
|
2606 | 2615 |
|
2607 | 2616 | // Visible markers list
|
2608 |
| - _this.visibleMarkersList(map, markers); |
| 2617 | + _this.visibleMarkersList(_this.map, markers); |
2609 | 2618 |
|
2610 | 2619 | // Modal ready callback
|
2611 | 2620 | if (_this.settings.modal === true && _this.settings.callbackModalReady) {
|
|
0 commit comments