TweenMax.js
4 years ago
iscroll.js
4 years ago
isotope.js
4 years ago
jquery-countdown.js
4 years ago
jquery-slimscroll.js
4 years ago
lottie.js
4 years ago
modal.js
4 years ago
premium-addons.js
4 years ago
premium-eq-height.js
4 years ago
premium-maps.js
4 years ago
premium-vscroll.js
4 years ago
prettyPhoto.js
4 years ago
slick.js
4 years ago
typed.js
4 years ago
universal-tilt.js
4 years ago
vticker.js
4 years ago
premium-maps.js
180 lines
| 1 | jQuery(window).on("elementor/frontend/init", function () { |
| 2 | |
| 3 | elementorFrontend.hooks.addAction( |
| 4 | "frontend/element_ready/premium-addon-maps.default", |
| 5 | function ($scope, $) { |
| 6 | |
| 7 | var mapElement = $scope.find(".premium_maps_map_height"); |
| 8 | |
| 9 | var mapSettings = mapElement.data("settings"); |
| 10 | |
| 11 | var mapStyle = mapElement.data("style"); |
| 12 | |
| 13 | var premiumMapMarkers = []; |
| 14 | |
| 15 | premiumMap = newMap(mapElement, mapSettings, mapStyle); |
| 16 | |
| 17 | var markerCluster = JSON.parse(mapSettings["cluster"]); |
| 18 | |
| 19 | function newMap(map, settings, mapStyle) { |
| 20 | var scrollwheel = JSON.parse(settings["scrollwheel"]); |
| 21 | var streetViewControl = JSON.parse(settings["streetViewControl"]); |
| 22 | var fullscreenControl = JSON.parse(settings["fullScreen"]); |
| 23 | var zoomControl = JSON.parse(settings["zoomControl"]); |
| 24 | var mapTypeControl = JSON.parse(settings["typeControl"]); |
| 25 | var centerLat = JSON.parse(settings["centerlat"]); |
| 26 | var centerLong = JSON.parse(settings["centerlong"]); |
| 27 | var autoOpen = JSON.parse(settings["automaticOpen"]); |
| 28 | var hoverOpen = JSON.parse(settings["hoverOpen"]); |
| 29 | var hoverClose = JSON.parse(settings["hoverClose"]); |
| 30 | var args = { |
| 31 | zoom: settings["zoom"], |
| 32 | mapTypeId: settings["maptype"], |
| 33 | center: { lat: centerLat, lng: centerLong }, |
| 34 | scrollwheel: scrollwheel, |
| 35 | streetViewControl: streetViewControl, |
| 36 | fullscreenControl: fullscreenControl, |
| 37 | zoomControl: zoomControl, |
| 38 | mapTypeControl: mapTypeControl, |
| 39 | styles: mapStyle |
| 40 | }; |
| 41 | |
| 42 | if ("yes" === mapSettings.drag) |
| 43 | args.gestureHandling = "none"; |
| 44 | |
| 45 | var markers = map.find(".premium-pin"); |
| 46 | |
| 47 | var map = new google.maps.Map(map[0], args); |
| 48 | |
| 49 | map.markers = []; |
| 50 | // add markers |
| 51 | markers.each(function (index) { |
| 52 | add_marker(jQuery(this), map, autoOpen, hoverOpen, hoverClose, index); |
| 53 | }); |
| 54 | |
| 55 | return map; |
| 56 | } |
| 57 | |
| 58 | function add_marker(pin, map, autoOpen, hoverOpen, hoverClose, zIndex) { |
| 59 | var latlng = new google.maps.LatLng( |
| 60 | pin.attr("data-lat"), |
| 61 | pin.attr("data-lng") |
| 62 | ), |
| 63 | icon_img = pin.attr("data-icon"), |
| 64 | maxWidth = pin.attr("data-max-width"), |
| 65 | customID = pin.attr("data-id"), |
| 66 | iconSize = parseInt(pin.attr("data-icon-size")); |
| 67 | |
| 68 | if (icon_img != "") { |
| 69 | var icon = { |
| 70 | url: pin.attr("data-icon") |
| 71 | }; |
| 72 | |
| 73 | if (iconSize) { |
| 74 | |
| 75 | icon.scaledSize = new google.maps.Size(iconSize, iconSize); |
| 76 | icon.origin = new google.maps.Point(0, 0); |
| 77 | icon.anchor = new google.maps.Point(iconSize / 2, iconSize); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | |
| 82 | |
| 83 | // create marker |
| 84 | var marker = new google.maps.Marker({ |
| 85 | position: latlng, |
| 86 | map: map, |
| 87 | icon: icon, |
| 88 | zIndex: zIndex |
| 89 | }); |
| 90 | |
| 91 | |
| 92 | // add to array |
| 93 | map.markers.push(marker); |
| 94 | |
| 95 | premiumMapMarkers.push(marker); |
| 96 | |
| 97 | //Used with Carousel Custom Navigation option |
| 98 | if (customID) { |
| 99 | google.maps.event.addListener(marker, "click", function () { |
| 100 | |
| 101 | var $carouselWidget = $(".premium-carousel-wrapper"); |
| 102 | |
| 103 | if ($carouselWidget.length) { |
| 104 | $carouselWidget.map(function (index, item) { |
| 105 | var carouselSettings = $(item).data("settings"); |
| 106 | |
| 107 | if (carouselSettings.navigation) { |
| 108 | if (-1 != carouselSettings.navigation.indexOf("#" + customID)) { |
| 109 | var slideIndex = carouselSettings.navigation.indexOf("#" + customID); |
| 110 | $(item).find(".premium-carousel-inner").slick("slickGoTo", slideIndex); |
| 111 | } |
| 112 | } |
| 113 | }) |
| 114 | |
| 115 | } |
| 116 | |
| 117 | }); |
| 118 | } |
| 119 | |
| 120 | // if marker contains HTML, add it to an infoWindow |
| 121 | if ( |
| 122 | pin.find(".premium-maps-info-title").html() || |
| 123 | pin.find(".premium-maps-info-desc").html() |
| 124 | ) { |
| 125 | // create info window |
| 126 | var infowindow = new google.maps.InfoWindow({ |
| 127 | maxWidth: maxWidth, |
| 128 | content: pin.html() |
| 129 | }); |
| 130 | if (autoOpen) { |
| 131 | infowindow.open(map, marker); |
| 132 | } |
| 133 | if (hoverOpen) { |
| 134 | google.maps.event.addListener(marker, "mouseover", function () { |
| 135 | infowindow.open(map, marker); |
| 136 | }); |
| 137 | if (hoverClose) { |
| 138 | google.maps.event.addListener(marker, "mouseout", function () { |
| 139 | infowindow.close(map, marker); |
| 140 | }); |
| 141 | } |
| 142 | } |
| 143 | // show info window when marker is clicked |
| 144 | google.maps.event.addListener(marker, "click", function () { |
| 145 | |
| 146 | //Used with Carousel Custom Navigation option |
| 147 | if (customID) { |
| 148 | |
| 149 | var $carouselWidget = $(".premium-carousel-wrapper"); |
| 150 | |
| 151 | if ($carouselWidget.length) { |
| 152 | $carouselWidget.map(function (index, item) { |
| 153 | var carouselSettings = $(item).data("settings"); |
| 154 | |
| 155 | if (carouselSettings.navigation) { |
| 156 | if (-1 != carouselSettings.navigation.indexOf("#" + customID)) { |
| 157 | var slideIndex = carouselSettings.navigation.indexOf("#" + customID); |
| 158 | $carouselWidget.find(".premium-carousel-inner").slick("slickGoTo", slideIndex); |
| 159 | } |
| 160 | } |
| 161 | }) |
| 162 | |
| 163 | } |
| 164 | |
| 165 | } |
| 166 | infowindow.open(map, marker); |
| 167 | }); |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | if (markerCluster) { |
| 172 | var markerCluster = new MarkerClusterer(premiumMap, premiumMapMarkers, { |
| 173 | imagePath: |
| 174 | "https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m" |
| 175 | }); |
| 176 | } |
| 177 | } |
| 178 | ); |
| 179 | }); |
| 180 |