1jQuery(window).load(function($) { 2 if (jQuery(".lp_home").is("#homeMap")) { 3 jQuery('#homeMap').empty(); 4 $defLat = jQuery('body').data('defaultmaplat'); 5 $defLong = jQuery('body').data('defaultmaplot'); 6 L.Google = L.Class.extend({ 7 includes: L.Mixin.Events, 8 options: { 9 minZoom: 0, 10 maxZoom: 18, 11 tileSize: 256, 12 subdomains: 'abc', 13 errorTileUrl: '', 14 attribution: '', 15 opacity: 1, 16 continuousWorld: false, 17 noWrap: false, 18 }, 19 // Possible types: SATELLITE, ROADMAP, HYBRID 20 initialize: function(type, options) { 21 L.Util.setOptions(this, options); 22 this._type = google.maps.MapTypeId[type || 'SATELLITE']; 23 }, 24 onAdd: function(map, insertAtTheBottom) { 25 this._map = map; 26 this._insertAtTheBottom = insertAtTheBottom; 27 // create a container div for tiles 28 this._initContainer(); 29 this._initMapObject(); 30 // set up events 31 map.on('viewreset', this._resetCallback, this); 32 this._limitedUpdate = L.Util.limitExecByInterval(this._update, 150, this); 33 map.on('move', this._update, this); 34 //map.on('moveend', this._update, this); 35 this._reset(); 36 this._update(); 37 }, 38 onRemove: function(map) { 39 this._map._container.removeChild(this._container); 40 //this._container = null; 41 this._map.off('viewreset', this._resetCallback, this); 42 this._map.off('move', this._update, this); 43 //this._map.off('moveend', this._update, this); 44 }, 45 getAttribution: function() { 46 return this.options.attribution; 47 }, 48 setOpacity: function(opacity) { 49 this.options.opacity = opacity; 50 if (opacity < 1) { 51 L.DomUtil.setOpacity(this._container, opacity); 52 } 53 }, 54 _initContainer: function() { 55 var tilePane = this._map._container 56 first = tilePane.firstChild; 57 if (!this._container) { 58 this._container = L.DomUtil.create('div', 'leaflet-google-layer leaflet-top leaflet-left'); 59 this._container.id = "_GMapContainer"; 60 } 61 if (true) { 62 tilePane.insertBefore(this._container, first); 63 this.setOpacity(this.options.opacity); 64 var size = this._map.getSize(); 65 this._container.style.width = size.x + 'px'; 66 this._container.style.height = size.y + 'px'; 67 } 68 }, 69 _initMapObject: function() { 70 this._google_center = new google.maps.LatLng(0, 0); 71 var map = new google.maps.Map(this._container, { 72 center: this._google_center, 73 zoom: 0, 74 mapTypeId: this._type, 75 disableDefaultUI: true, 76 keyboardShortcuts: false, 77 draggable: false, 78 disableDoubleClickZoom: true, 79 scrollwheel: false, 80 streetViewControl: false 81 }); 82 var _this = this; 83 this._reposition = google.maps.event.addListenerOnce(map, "center_changed", 84 function() { _this.onReposition(); }); 85 map.backgroundColor = '#ff0000'; 86 this._google = map; 87 }, 88 _resetCallback: function(e) { 89 this._reset(e.hard); 90 }, 91 _reset: function(clearOldContainer) { 92 this._initContainer(); 93 }, 94 _update: function() { 95 this._resize(); 96 var bounds = this._map.getBounds(); 97 var ne = bounds.getNorthEast();
98 var sw = bounds.getSouthWest(); 99 var google_bounds = new google.maps.LatLngBounds( 100 new google.maps.LatLng(sw.lat, sw.lng), 101 new google.maps.LatLng(ne.lat, ne.lng) 102 ); 103 var center = this._map.getCenter(); 104 var _center = new google.maps.LatLng(center.lat, center.lng); 105 this._google.setCenter(_center); 106 this._google.setZoom(this._map.getZoom()); 107 this._google.fitBounds(google_bounds); 108 }, 109 _resize: function() { 110 var size = this._map.getSize(); 111 if (this._container.style.width == size.x && 112 this._container.style.height == size.y) 113 return; 114 this._container.style.width = size.x + 'px'; 115 this._container.style.height = size.y + 'px'; 116 google.maps.event.trigger(this._google, "resize"); 117 }, 118 onReposition: function() { 119 //google.maps.event.trigger(this._google, "resize"); 120 } 121 }); 122 L.HtmlIcon = L.Icon.extend({ 123 options: { 124 /* 125 html: (String) (required) 126 iconAnchor: (Point) 127 popupAnchor: (Point) 128 */ 129 }, 130 initialize: function(options) { 131 L.Util.setOptions(this, options); 132 }, 133 createIcon: function() { 134 var div = document.createElement('div'); 135 div.innerHTML = this.options.html; 136 if (div.classList) 137 div.classList.add('leaflet-marker-icon'); 138 else 139 div.className += ' ' + 'leaflet-marker-icon'; 140 return div; 141 }, 142 createShadow: function() { 143 return null; 144 } 145 }); 146 var maplistingby = jQuery('body').data('maplistingby'); 147 if (maplistingby == null || maplistingby == "" || maplistingby == "geolocaion") { 148 lpGetGpsLocName(function(lpgetcurrentcityvalue) { 149 lpgpsclocation = lpgetcurrentcityvalue; 150 // console.log(lpgpsclocation); 151 callhomemapajax(lpgpsclocation, maplistingby); 152 console.log(lpgpsclocation); 153 }); 154 } else { 155 callhomemapajax('', maplistingby); 156 } 157 158 function callhomemapajax(lpcity, maplistingby) { 159 jQuery('#homeMap').addClass('loading'); 160 jQuery.ajax({ 161 type: 'POST', 162 dataType: 'json', 163 url: listingpro_home_map_object.ajaxurl, 164 data: { 165 'action': 'listingpro_home_map_content', 166 'listingby': maplistingby, 167 'lpcity': lpcity, 168 'trig': 'home_map', 169 }, 170 success: function(data) { 171 if (data) { 172 jQuery('#homeMap').removeClass('loading'); 173 var map = null; 174 $mtoken = jQuery('#page').data("mtoken"); 175 $mtype = jQuery('#page').data("mtype"); 176 $mapboxDesign = jQuery('#page').data("mstyle"); 177 if ($mtoken != '' && $mtype == 'mapbox') { 178 L.mapbox.accessToken = $mtoken; 179 map = L.mapbox.map('homeMap'); 180 L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', { 181 id: jQuery('#page').data("mstyle"), 182 accessToken: jQuery('#page').data("mtoken") 183 }).addTo(map); 184 var markers = new L.MarkerClusterGroup(); 185 hasgetbouts = false; 186 jQuery.each(data, function(i, v) { 187 $vlatitude = v.latitude; 188 $vlongitude = v.longitude; 189 var $pinicon = "<i class='" + v.icon + "'></i>"; 190 if (v.icon.startsWith("data:image/png")) { 191 $pinicon = "<img alt='image' src='" + v.icon + "' />"; 192 } 193 if ($vlatitude != null && $vlongitude != null && v.noresult == null) { 194 hasgetbouts = true; 195 //alert(v.latitude); 196 var markerLocation = new L.LatLng($vlatitude, $vlongitude); // London 197 var CustomHtmlIcon = L.HtmlIcon.extend({ 198 options: { 199 html: "<div class='lpmap-icon-shape pin card" + i + "'><div class='lpmap-icon-contianer'>" + $pinicon + "</div></div>", 200 } 201 }); 202 var customHtmlIcon = new CustomHtmlIcon(); 203 var marker = new L.Marker(markerLocation, { icon: customHtmlIcon }).bindPopup('<div class="map-post"><div class="map-post-thumb"><a target="_blank" href="' + v.url + '">' + v.image + '</a></div><div class="map-post-des"><div class="map-post-title"><h5><a target="_blank" href="' + v.url + '">' + v.title + '</a></h5></div><div class="map-post-address"><p><i class="fa fa-map-marker"></i> ' + v.address + '</p></div></div></div>').addTo(map); 204 markers.addLayer(marker); 205 map.addLayer(markers); 206 } 207 }); 208 if (hasgetbouts) { 209 map.fitBounds(markers.getBounds()); 210 } else { 211 map.fitBounds([ 212 [$defLat, $defLong], 213 [$defLat, $defLong] 214 ]); 215 } 216 map.scrollWheelZoom.disable(); 217 } else { 218 var map = new L.Map('homeMap', { 219 dragging: true, 220 tap: false 221 }); 222 if ($mtype == 'google') { 223 var googleLayer = new L.Google('ROADMAP'); 224 map.addLayer(googleLayer); 225 } else { 226 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map); 227 } 228 var markers = new L.MarkerClusterGroup(); 229 hasgetbouts = false;
230 jQuery.each(data, function(i, v) { 231 $vlatitude = v.latitude; 232 $vlongitude = v.longitude; 233 var $pinicon = "<i class='" + v.icon + "'></i>"; 234 if (v.icon.startsWith("data:image/png")) { 235 $pinicon = "<img alt='image' src='" + v.icon + "' />"; 236 } 237 if (($vlatitude != '' || $vlatitude != 0) && ($vlongitude != '' || $vlongitude != 0) && v.noresult == null) { 238 hasgetbouts = true; 239 var markerLocation = new L.LatLng($vlatitude, $vlongitude); // London 240 var CustomHtmlIcon = L.HtmlIcon.extend({ 241 options: { 242 html: "<div class='lpmap-icon-shape pin card" + i + "'><div class='lpmap-icon-contianer'>" + $pinicon + "</div></div>", 243 } 244 }); 245 var customHtmlIcon = new CustomHtmlIcon(); 246 var marker = new L.Marker(markerLocation, { icon: customHtmlIcon }).bindPopup('<div class="map-post"><div class="map-post-thumb"><a target="_blank" href="' + v.url + '">' + v.image + '</a></div><div class="map-post-des"><div class="map-post-title"><h5><a target="_blank" href="' + v.url + '">' + v.title + '</a></h5></div><div class="map-post-address"><p><i class="fa fa-map-marker"></i> ' + v.address + '</p></div></div></div>').addTo(map); 247 markers.addLayer(marker); 248 map.addLayer(markers); 249 } 250 }); 251 if (hasgetbouts) { 252 map.fitBounds(markers.getBounds()); 253 } else { 254 map.fitBounds([ 255 [$defLat, $defLong], 256 [$defLat, $defLong] 257 ]); 258 } 259 map.scrollWheelZoom.disable(); 260 map.invalidateSize(); 261 } 262 } 263 }, 264 error: function(request, status, error) { 265 jQuery('#homeMap').removeClass('loading'); 266 console.log(request.responseText); 267 } 268 }); 269 }; 270 } 271});
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.