1var g_gmpLibJsLoaded = false; 2function gmpLoadGoogleLib() { 3 if (!g_gmpLibJsLoaded) { 4 jQuery('head').append('<script src="' + GMP_DATA.gmapApiUrl + '"></script>'); 5 g_gmpLibJsLoaded = true; 6 } 7} 8// Maps 9function gmpGoogleMap(elementId, params, additionalData) { 10 if (typeof google === 'undefined') { 11 gmpLoadGoogleLib(); 12 //alert('Please check your Internet connection - we need it to load Google Maps Library from Google Server'); 13 //return false; 14 } 15 16 params = params ? params : {}; 17 additionalData = additionalData ? additionalData : {}; 18 var defaults = { 19 center: new google.maps.LatLng(40.69847032728747, -73.9514422416687), 20 zoom: 8, 21 //, mapTypeId: google.maps.MapTypeId.ROADMAP 22 }; 23 if (params.map_center && params.map_center.coord_x && params.map_center.coord_y) { 24 params.center = new google.maps.LatLng(params.map_center.coord_x, params.map_center.coord_y); 25 } 26 if (params.zoom) { 27 params.zoom = parseInt(params.zoom); 28 } 29 if (!GMP_DATA.isAdmin && params.zoom_type == 'zoom_level' && params.zoom_mobile && jQuery(document).width() < 768) { 30 params.zoom = parseInt(params.zoom_mobile); 31 } 32 if (typeof elementId === 'string') { 33 elementId = jQuery(elementId)[0]; 34 } 35 this._elementId = elementId; 36 this._mapParams = jQuery.extend({}, defaults, params); 37 this._mapObj = null; 38 this._markers = []; 39 this._shapes = []; 40 this._heatmap = []; 41 this._clasterer = null; 42 this._clastererEnabled = false; 43 this._clastererMarkersGroupsStyles = []; 44 this._eventListeners = {}; 45 this._layers = {}; 46 this.mapMarkersGroups = additionalData.markerGroups ? additionalData.markerGroups : []; 47 this.init(); 48} 49gmpGoogleMap.prototype.init = function () { 50 this._beforeInit(); 51 this._mapObj = new google.maps.Map(this._elementId, this._mapParams); 52 this._afterInit(); 53}; 54gmpGoogleMap.prototype._beforeInit = function () { 55 if (typeof this._mapParams.mapId !== 'undefined') { 56 this._mapParams.mapId = jQuery.trim(this._mapParams.mapId); 57 if (!this._mapParams.mapId) { 58 delete this._mapParams.mapId; 59 } 60 } 61 if (typeof this._mapParams.type_control !== 'undefined') { 62 if (typeof google.maps.MapTypeControlStyle[this._mapParams.type_control] !== 'undefined') { 63 this._mapParams.mapTypeControlOptions = { 64 style: google.maps.MapTypeControlStyle[this._mapParams.type_control], 65 }; 66 this._mapParams.mapTypeControl = true; 67 } else { 68 this._mapParams.mapTypeControl = false; 69 } 70 } 71 if (typeof this._mapParams.zoom_control !== 'undefined') { 72 if (typeof google.maps.ZoomControlStyle[this._mapParams.zoom_control] !== 'undefined') { 73 this._mapParams.zoomControlOptions = { 74 style: google.maps.ZoomControlStyle[this._mapParams.zoom_control], 75 }; 76 this._mapParams.zoomControl = true; 77 } else { 78 this._mapParams.zoomControl = false; 79 } 80 } 81 if (typeof this._mapParams.street_view_control !== 'undefined') { 82 this._mapParams.streetViewControl = parseInt(this._mapParams.street_view_control) ? true : false; 83 } 84 if (typeof this._mapParams.pan_control !== 'undefined') { 85 this._mapParams.panControl = parseInt(this._mapParams.pan_control) ? true : false; 86 } 87 if (typeof this._mapParams.overview_control !== 'undefined') { 88 if (this._mapParams.overview_control !== 'none') { 89 this._mapParams.overviewMapControlOptions = { 90 opened: this._mapParams.overview_control === 'opened' ? true : false, 91 }; 92 this._mapParams.overviewMapControl = true; 93 } else { 94 this._mapParams.overviewMapControl = false; 95 } 96 } 97 if (typeof this._mapParams.dbl_click_zoom !== 'undefined') { 98 this._mapParams.disableDoubleClickZoom = parseInt(this._mapParams.dbl_click_zoom) ? false : true; // False/true in revert order - because option actually is for disabling this feature 99 } 100 if (typeof this._mapParams.mouse_wheel_zoom !== 'undefined') { 101 this._mapParams.scrollwheel = parseInt(this._mapParams.mouse_wheel_zoom) ? true : false; 102 } 103 if (typeof this._mapParams.map_type !== 'undefined' && typeof google.maps.MapTypeId[this._mapParams.map_type] !== 'undefined') { 104 this._mapParams.mapTypeId = google.maps.MapTypeId[this._mapParams.map_type]; 105 } 106 if (!this._mapParams.mapId && typeof this._mapParams.map_stylization_data !== 'undefined' && this._mapParams.map_stylization_data) { 107 this._mapParams.styles = this._mapParams.map_stylization_data; 108 } else if (this._mapParams.mapId && typeof this._mapParams.styles !== 'undefined') { 109 delete this._mapParams.styles; 110 } 111 jQuery(document).trigger('gmapBeforeMapInit', this); 112}; 113gmpGoogleMap.prototype.getParams = function () { 114 return this._mapParams; 115}; 116gmpGoogleMap.prototype.getParam = function (key) { 117 return this._mapParams[key]; 118}; 119gmpGoogleMap.prototype.setParam = function (key, value) { 120 this._mapParams[key] = value; 121 return this; 122};
123gmpGoogleMap.prototype._afterInit = function () { 124 if (typeof this._mapParams.marker_clasterer !== 'undefined' && this._mapParams.marker_clasterer) { 125 this.enableClasterization(this._mapParams.marker_clasterer); 126 } 127 this.applyZoomType(); 128 if (typeof this._mapParams.zoom_min !== 'undefined' && typeof this._mapParams.zoom_max !== 'undefined') { 129 this._setMinZoomLevel(); 130 this._setMaxZoomLevel(); 131 this._fixZoomLevel(); 132 } 133 this.resizeMapByHeight(); 134 jQuery(window).bind('resize', jQuery.proxy(this.resizeMapByHeight, this)); 135 jQuery(window).bind('orientationchange', jQuery.proxy(this.resizeMapByHeight, this)); 136 jQuery(document).trigger('gmapAfterMapInit', this); 137}; 138gmpGoogleMap.prototype._setMinZoomLevel = function () { 139 var curZoom = this.getZoom(); 140 var minZoom = parseInt(this._mapParams.zoom_min) ? parseInt(this._mapParams.zoom_min) : null; 141 this.getRawMapInstance().setOptions({ minZoom: minZoom }); 142 // Compare only against a real limit: in JS "curZoom < null" / "zoom > null" coerce null to 0. 143 if (minZoom !== null && curZoom < minZoom) this.getRawMapInstance().setOptions({ zoom: minZoom }); 144}; 145gmpGoogleMap.prototype._setMaxZoomLevel = function () { 146 var maxZoom = parseInt(this._mapParams.zoom_max) ? parseInt(this._mapParams.zoom_max) : null; 147 this.getRawMapInstance().setOptions({ maxZoom: maxZoom }); 148 // Without this guard an unset max zoom reset the map zoom to null (grey map without Map ID). 149 if (maxZoom !== null && this.getRawMapInstance().zoom > maxZoom) this.getRawMapInstance().setOptions({ zoom: maxZoom }); 150}; 151gmpGoogleMap.prototype._fixZoomLevel = function () { 152 var eventHandle = this._getEventListenerHandle('zoom_changed', 'zoomChanged'); 153 if (!eventHandle) { 154 eventHandle = google.maps.event.addListener( 155 this.getRawMapInstance(), 156 'zoom_changed', 157 jQuery.proxy(function () { 158 var minZoom = parseInt(this.getParam('zoom_min')), 159 maxZoom = parseInt(this.getParam('zoom_max')); 160 if (this.getZoom() < minZoom) { 161 this.setZoom(minZoom); 162 if (GMP_DATA.isAdmin && this._getEventListenerHandle('idle', 'enableClasterization')) google.maps.event.trigger(this.getRawMapInstance(), 'idle'); 163 } 164 if (this.getZoom() > maxZoom) { 165 this.setZoom(maxZoom); 166 if (GMP_DATA.isAdmin && this._getEventListenerHandle('idle', 'enableClasterization')) google.maps.event.trigger(this.getRawMapInstance(), 'idle'); 167 } 168 }, this) 169 ); 170 this._addEventListenerHandle('zoom_changed', 'zoomChanged', eventHandle); 171 } 172}; 173gmpGoogleMap.prototype.enableClasterization = function (clasterType, needTrigger) { 174 needTrigger = needTrigger ? needTrigger : false; 175 176 switch (clasterType) { 177 case 'MarkerClusterer': // Support only this one for now 178 var self = this; 179 180 self.setClastererMarkersGroupsStyles(); 181 182 var eventHandle = google.maps.event.addListenerOnce(self.getRawMapInstance(), 'idle', function (a, b, c) { 183 var clasterGridSize = self.getParam('marker_clasterer_grid_size'), 184 markerGroupsStyles = self.getClastererMarkersGroupsStyles(); 185 186 // Enable clasterization 187 var allMapMarkers = self.getAllRawMarkers(), 188 allVisibleMapMarkers = [], 189 clasterer = self.getClasterer(); 190 191 for (var i = 0; i < allMapMarkers.length; i++) { 192 if (allMapMarkers[i].getVisible() && !parseInt(allMapMarkers[i].params.clasterer_exclude)) { 193 allVisibleMapMarkers.push(allMapMarkers[i]); 194 } 195 } 196 if (clasterer) { 197 clasterer.clearMarkers(); 198 clasterer.addMarkers(allVisibleMapMarkers); 199 clasterer.setStyles(markerGroupsStyles); 200 201 self.setClastererGridSize(clasterGridSize); 202 203 clasterer.resetViewport(); 204 clasterer.redraw(); 205 } else { 206 clasterer = new MarkerClusterer(self.getRawMapInstance(), allVisibleMapMarkers, { styles: markerGroupsStyles, clusterClass: 'cluster' }); 207 208 clasterer.setCalculator(self.customClastererCalculatorFunction(markerGroupsStyles)); 209 self.setClasterer(clasterer); 210 self.setClastererGridSize(clasterGridSize); 211 212 clasterer = self.getClasterer(); 213 } 214 }); 215 this._addEventListenerHandle('idle', 'enableClasterization', eventHandle); 216 if (GMP_DATA.isAdmin || needTrigger) { 217 google.maps.event.trigger(self.getRawMapInstance(), 'idle'); 218 } 219 this._clastererEnabled = true; 220 break; 221 } 222}; 223gmpGoogleMap.prototype.disableClasterization = function () { 224 var eventHandle = this._getEventListenerHandle('idle', 'enableClasterization'); 225 if (eventHandle) { 226 var clasterer = this.getClasterer(); 227 if (clasterer) { 228 clasterer.clearMarkers(); 229 var markers = this.getAllRawMarkers(); 230 for (var i = 0; i < markers.length; i++) { 231 markers[i].setMap(this.getRawMapInstance()); 232 } 233 } 234 google.maps.event.removeListener(eventHandle); 235 google.maps.event.trigger(this.getRawMapInstance(), 'idle'); 236 this._clastererEnabled = false; 237 } 238}; 239gmpGoogleMap.prototype.customClastererCalculatorFunction = function (markerGroupsStyles) { 240 return function (markers, numStyles) { 241 var styleIndex = 1, 242 markersGroupsStyles = markerGroupsStyles, 243 markersGroupsIds = {}, 244 maxCount = 0, 245 groupId = 0, 246 curStyle = []; 247 248 for (var i = 0; i < markers.length; i++) { 249 if (markers[i].marker_group_id) { 250 if (typeof markersGroupsIds[markers[i].marker_group_id] == 'undefined') { 251 markersGroupsIds[markers[i].marker_group_id] = 1; 252 } else { 253 markersGroupsIds[markers[i].marker_group_id]++; 254 } 255 } 256 } 257 for (var currGroupId in markersGroupsIds) { 258 if (markersGroupsIds[currGroupId] > maxCount) { 259 maxCount = markersGroupsIds[currGroupId]; 260 groupId = currGroupId; 261 } 262 } 263 curStyle = jQuery.grep(markersGroupsStyles, function (e, i) { 264 if (e.marker_group_id == groupId) { 265 return e; 266 } 267 });
268 269 if (curStyle && curStyle[0]) styleIndex = markersGroupsStyles.indexOf(curStyle[0]) + 1; 270 271 return { 272 text: markers.length, 273 index: styleIndex, 274 }; 275 }; 276}; 277gmpGoogleMap.prototype.getClasterer = function () { 278 if (this._clasterer) { 279 return this._clasterer; 280 } 281 return false; 282}; 283gmpGoogleMap.prototype.setClasterer = function (clasterer) { 284 this._clasterer = clasterer; 285}; 286gmpGoogleMap.prototype.setMapMarkersGroups = function (groups) { 287 this.mapMarkersGroups = groups; 288}; 289gmpGoogleMap.prototype.getMapMarkersGroups = function () { 290 return this.mapMarkersGroups; 291}; 292gmpGoogleMap.prototype.setClastererMarkersGroupsStyles = function () { 293 var mapMarkersGroups = this.getMapMarkersGroups(), 294 markersGroupsStyles = this.getClastererMarkersGroupsStyles(), 295 defClasterIcon = GMP_DATA.modPath + 'gmap/img/m1.png', 296 oldDefClasterIcon = 'https://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/images/m1.png', // Prevent to use old default claster icon cdn icon because it is missing 297 clasterIcon = this.getParam('marker_clasterer_icon'), 298 iconWidth = this.getParam('marker_clasterer_icon_width'), 299 iconHeight = this.getParam('marker_clasterer_icon_height'); 300 301 // Set claster base icon 302 clasterIcon = clasterIcon && clasterIcon != oldDefClasterIcon ? clasterIcon : defClasterIcon; 303 iconWidth = iconWidth ? iconWidth : 53; 304 iconHeight = iconHeight ? iconHeight : 52; 305 306 markersGroupsStyles.push({ 307 marker_group_id: 0, 308 url: clasterIcon, 309 width: iconWidth, 310 height: iconHeight, 311 }); 312 313 if (mapMarkersGroups) { 314 for (var i = 0; i < mapMarkersGroups.length; i++) { 315 var markerGroupId = mapMarkersGroups[i].id, 316 markerGroupClasterIcon = mapMarkersGroups[i].params.claster_icon, 317 markerGroupClasterIconWidth = mapMarkersGroups[i].params.claster_icon_width, 318 markerGroupClasterIconHeight = mapMarkersGroups[i].params.claster_icon_height; 319 320 if (markerGroupClasterIcon && markerGroupClasterIcon != clasterIcon) { 321 markersGroupsStyles.push({ 322 marker_group_id: markerGroupId, 323 url: markerGroupClasterIcon ? markerGroupClasterIcon : defClasterIcon, 324 width: markerGroupClasterIconWidth ? markerGroupClasterIconWidth : 53, 325 height: markerGroupClasterIconHeight ? markerGroupClasterIconHeight : 52, 326 className: 'cluster', 327 }); 328 } 329 } 330 } 331}; 332gmpGoogleMap.prototype.getClastererMarkersGroupsStyles = function () { 333 return this._clastererMarkersGroupsStyles; 334}; 335gmpGoogleMap.prototype.setClastererGridSize = function (size) { 336 var clasterer = this.getClasterer(); 337 338 size = size && parseInt(size) ? parseInt(size) : null; 339 340 if (clasterer && size) { 341 clasterer.setGridSize(size); 342 } 343}; 344gmpGoogleMap.prototype.getClastererGridSize = function () { 345 var clasterer = this.getClasterer(), 346 clusterGridSize = null; 347 348 if (clasterer) { 349 clusterGridSize = clasterer.getGridSize(); 350 } 351 return clusterGridSize; 352}; 353/** 354 * Should trigger after added or modified markers 355 */ 356gmpGoogleMap.prototype.markersRefresh = function () { 357 var clasterer = this.getClasterer(); 358 359 if (this._clastererEnabled && clasterer) { 360 clasterer.clearMarkers(); 361 clasterer.addMarkers(this.getAllRawMarkers()); 362 } 363 jQuery(document).trigger('gmapAfterMarkersRefresh', this); 364}; 365gmpGoogleMap.prototype._addEventListenerHandle = function (event, code, handle) { 366 if (!this._eventListeners[event]) this._eventListeners[event] = {}; 367 this._eventListeners[event][code] = handle; 368}; 369gmpGoogleMap.prototype._getEventListenerHandle = function (event, code) { 370 return this._eventListeners[event] && this._eventListeners[event][code] ? this._eventListeners[event][code] : false; 371}; 372gmpGoogleMap.prototype.getRawMapInstance = function () { 373 return this._mapObj; 374}; 375gmpGoogleMap.prototype.setCenter = function (lat, lng) { 376 if (typeof lng == 'undefined') { 377 this.getRawMapInstance().setCenter(lat); 378 } else this.getRawMapInstance().setCenter(new google.maps.LatLng(lat, lng)); 379 return this; 380};
381gmpGoogleMap.prototype.getCenter = function () { 382 return this.getRawMapInstance().getCenter(); 383}; 384gmpGoogleMap.prototype.setZoom = function (zoomLevel) { 385 this.getRawMapInstance().setZoom(parseInt(zoomLevel)); 386}; 387gmpGoogleMap.prototype.getZoom = function () { 388 return this.getRawMapInstance().getZoom(); 389}; 390gmpGoogleMap.prototype.getBounds = function () { 391 return this.getRawMapInstance().getBounds(); 392}; 393gmpGoogleMap.prototype.fitBounds = function (bounds) { 394 this.getRawMapInstance().fitBounds(bounds); 395}; 396gmpGoogleMap.prototype.addMarker = function (params) { 397 params.clusterClass = 'cluster'; 398 var newMarker = new gmpGoogleMarker(this, params); 399 this._markers.push(newMarker); 400 return newMarker; 401}; 402gmpGoogleMap.prototype.addShape = function (params) { 403 var newShape = new gmpGoogleShape(this, params); 404 this._shapes.push(newShape); 405 return newShape; 406}; 407gmpGoogleMap.prototype.addHeatmap = function (params) { 408 var heatmap = new gmpGoogleHeatmap(this, params); 409 this._heatmap.push(heatmap); 410 return heatmap; 411}; 412gmpGoogleMap.prototype.addRouter = function (params) { 413 var router = new gmpGoogleRouter(this, params); 414 return router; 415}; 416gmpGoogleMap.prototype.getMarkerById = function (id) { 417 if (this._markers && this._markers.length) { 418 for (var i in this._markers) { 419 if (this._markers[i].getId && this._markers[i].getId() == id) return this._markers[i]; 420 } 421 } 422 return false; 423}; 424gmpGoogleMap.prototype.getShapeById = function (id) { 425 if (this._shapes && this._shapes.length) { 426 for (var i in this._shapes) { 427 if (this._shapes[i].getId() == id) return this._shapes[i]; 428 } 429 } 430 return false; 431}; 432gmpGoogleMap.prototype.getHeatmap = function () { 433 if (this._heatmap && this._heatmap.length) { 434 // There is only one heatmap layer on the map 435 return this._heatmap[0]; 436 } 437 return false; 438}; 439gmpGoogleMap.prototype.removeMarker = function (id) { 440 var marker = this.getMarkerById(id); 441 if (marker) { 442 marker.removeFromMap(); 443 } 444}; 445gmpGoogleMap.prototype.removeShape = function (id) { 446 var shape = this.getShapeById(id); 447 448 if (shape) { 449 shape.removeFromMap(); 450 } 451}; 452gmpGoogleMap.prototype.getAllMarkers = function () { 453 return this._markers; 454}; 455gmpGoogleMap.prototype.getAllShapes = function () { 456 return this._shapes; 457}; 458/** 459 * Retrive original Map marker objects (Marker objects from Google API) 460 */ 461gmpGoogleMap.prototype.getAllRawMarkers = function () { 462 var res = []; 463 if (this._markers && this._markers.length) { 464 for (var i = 0; i < this._markers.length; i++) { 465 res.push(this._markers[i].getRawMarkerInstance()); 466 } 467 } 468 return res; 469}; 470gmpGoogleMap.prototype.setMarkersParams = function (markers) { 471 if (this._markers && this._markers.length) { 472 for (var i = 0; i < this._markers.length; i++) { 473 for (var j = 0; j < markers.length; j++) { 474 if (this._markers[i].getId() == markers[j].id) { 475 this._markers[i].setMarkerParams(markers[j]); 476 break; 477 } 478 } 479 } 480 } 481}; 482gmpGoogleMap.prototype.get = function (key) { 483 return this.getRawMapInstance().get(key); 484}; 485// Set option for RAW MAP 486gmpGoogleMap.prototype.set = function (key, value) { 487 this.getRawMapInstance().set(key, value); 488 return this; 489}; 490gmpGoogleMap.prototype.clearMarkers = function () { 491 if (this._markers && this._markers.length) { 492 for (var i = 0; i < this._markers.length; i++) { 493 this._markers[i].setMap(null); 494 } 495 this._markers = []; 496 } 497}; 498gmpGoogleMap.prototype.clearMarkersByParam = function (param) { 499 if (this._markers && this._markers.length) { 500 for (var i = 0; i < this._markers.length; i++) { 501 if (this._markers[i].getMarkerParam(param)) { 502 this._markers[i].setMap(null); 503 this._markers.splice(i, 1); 504 this.clearMarkersByParam(param); 505 break; 506 } 507 } 508 } 509}; 510gmpGoogleMap.prototype.clearShapes = function () { 511 if (this._shapes && this._shapes.length) { 512 for (var i = 0; i < this._shapes.length; i++) { 513 this._shapes[i].setMap(null); 514 } 515 this._shapes = []; 516 } 517}; 518gmpGoogleMap.prototype.getViewId = function () { 519 return this._mapParams.view_id; 520}; 521gmpGoogleMap.prototype.getViewHtmlId = function () { 522 return this._mapParams.view_html_id; 523}; 524gmpGoogleMap.prototype.getId = function () { 525 return this._mapParams.id; 526}; 527gmpGoogleMap.prototype.refresh = function () { 528 return google.maps.event.trigger(this.getRawMapInstance(), 'resize'); 529};
530gmpGoogleMap.prototype.refreshWithCenter = function (lat, lng, zoom) { 531 var res = google.maps.event.trigger(this.getRawMapInstance(), 'resize'); 532 if (zoom) { 533 this.setZoom(zoom); 534 } else { 535 this.setZoom(this.getZoom()); 536 } 537 if (lat && lng) { 538 this.setCenter(lat, lng); 539 } else { 540 this.setCenter(this.getCenter().lat(), this.getCenter().lng()); 541 } 542 return res; 543}; 544gmpGoogleMap.prototype.fullRefresh = function () { 545 this.refresh(); 546 this.checkMarkersParams(this._markers, false); 547 this.setCenter(this._mapParams.center); 548}; 549gmpGoogleMap.prototype.checkMarkersParams = function (markers, needToShow) { 550 if (markers && markers.length) { 551 for (var i = 0; i < markers.length; i++) { 552 var markerParams = markers[i].getMarkerParam('params'), 553 showDescription = parseInt(markerParams.show_description); 554 if (showDescription || needToShow) { 555 markers[i].showInfoWnd(true, showDescription); 556 } 557 } 558 } 559}; 560gmpGoogleMap.prototype.resizeMapByHeight = function (e, elem, withoutAfter) { 561 if (!GMP_DATA.isAdmin && parseInt(this.getParam('adapt_map_to_screen_height')) && this.getRawMapInstance().map_display_mode != 'popup') { 562 var viewId = this.getParam('view_id'), 563 selectors = this.getParam('selectors'), 564 windowObj = jQuery(window), 565 mapContainer = jQuery('#gmpMapDetailsContainer_' + viewId), 566 mapContainerWrap = jQuery('#mapConElem_' + viewId), 567 height; 568 569 withoutAfter = withoutAfter ? withoutAfter : mapContainerWrap.data('rmh-without-after') ? mapContainerWrap.data('rmh-without-after') : false; 570 elem = elem ? elem : mapContainerWrap.data('rmh-additional-elem') ? jQuery(mapContainerWrap.data('rmh-additional-elem')) : null; 571 572 if (!selectors || (!selectors.content_before && !selectors.content_after)) { 573 var mapContainerOffset = mapContainer.length ? mapContainer.offset() : false, 574 windowHeight = windowObj.height(); 575 height = mapContainerOffset.top < windowHeight ? windowHeight - mapContainerOffset.top : windowHeight; 576 } else { 577 var viewportData = this.getViewportData(0, withoutAfter), 578 proControlsCon = jQuery('#gmpMapProControlsCon_' + viewId); 579 height = viewportData.height; 580 mapContainer.parents('.gmp_map_opts:first').css({ 581 position: 'fixed', 582 top: viewportData.contentBeforeHeight, 583 left: '0', 584 width: windowObj.width(), 585 height: height, 586 'z-index': 1, 587 }); 588 if (proControlsCon.find('.gmpMarkersListCollapseShell').length) { 589 mapContainer.parents('.gmp_map_opts:first').css({ 590 'overflow-x': 'hidden', 591 'overflow-y': 'auto', 592 }); 593 } 594 jQuery(selectors.content_before).css({ 595 'z-index': 2, 596 }); 597 if (!withoutAfter) { 598 jQuery(selectors.content_after).css({ 599 position: 'fixed', 600 bottom: '0', 601 left: '0', 602 width: windowObj.width(), 603 'z-index': 1, 604 }); 605 } 606 if (elem && elem.length) { 607 height -= elem.outerHeight(true); 608 } 609 } 610 jQuery('#gmpMapDetailsContainer_' + viewId + ', #' + this.getParam('view_html_id')).each(function () { 611 jQuery(this).height(height); 612 }); 613 this.refresh(); 614 } 615}; 616gmpGoogleMap.prototype.getViewportData = function (additionalHeight, withoutAfter) { 617 withoutAfter = withoutAfter ? withoutAfter : false; 618 additionalHeight = additionalHeight ? additionalHeight : 0; 619 var selectors = this.getParam('selectors'), 620 adminBar = jQuery('#wpadminbar'), // fix for pages with admin bar 621 viewportData = { 622 height: jQuery(window).height(), 623 contentBeforeHeight: 0, 624 contentAfterHeight: 0, 625 }, 626 i; 627 628 if (typeof selectors !== 'undefined' && selectors != null) { 629 var contentBefore = typeof selectors.content_before !== 'undefined' ? jQuery(selectors.content_before) : 0, 630 contentAfter = typeof selectors.content_after !== 'undefined' ? jQuery(selectors.content_after) : 0; 631 632 if (adminBar.length) { 633 viewportData.contentBeforeHeight += adminBar.outerHeight(true); 634 } 635 if (contentBefore.length) { 636 for (i = 0; i < contentBefore.length; i++) { 637 viewportData.contentBeforeHeight += jQuery(contentBefore[i]).outerHeight(true); 638 } 639 } 640 if (contentAfter.length && !withoutAfter) { 641 for (i = 0; i < contentAfter.length; i++) { 642 viewportData.contentAfterHeight += jQuery(contentAfter[i]).outerHeight(true); 643 } 644 } 645 } 646 viewportData.height = viewportData.height - viewportData.contentBeforeHeight - viewportData.contentAfterHeight - additionalHeight; 647 return viewportData; 648}; 649gmpGoogleMap.prototype.applyZoomType = function () { 650 if (!GMP_DATA.isAdmin && this.getParam('zoom_type') == 'fit_bounds') { 651 var eventHandle = google.maps.event.addListenerOnce(this.getRawMapInstance(), 'tilesloaded', jQuery.proxy(this._getBoundsHandler, this)); 652 this._addEventListenerHandle('tilesloaded', 'fitBounds', eventHandle); 653 } 654}; 655gmpGoogleMap.prototype.applyZoomTypeAdmin = function () { 656 if (GMP_DATA.isAdmin && this.getParam('zoom_type') == 'fit_bounds') { 657 // Call applyZoomTypeAdmin after refresh all map objects in admin area (markers, shapes, etc.) 658 this._getBoundsHandler(); 659 } 660}; 661// Free version of method 662// see pro version here - google-maps-easy-pro/add_map_options/js/core.add_map_options.js 663gmpGoogleMap.prototype._getBoundsHandler = function () { 664 var bounds = new google.maps.LatLngBounds(); 665 666 bounds = this._getMapMarkersBounds(bounds); 667 this._setMapBounds(bounds); 668}; 669gmpGoogleMap.prototype._getMapMarkersBounds = function (bounds) { 670 var markers = this.getAllMarkers(); 671 672 for (var i = 0; i < markers.length; i++) { 673 bounds.extend(markers[i].getPosition()); 674 } 675 return bounds; 676}; 677gmpGoogleMap.prototype._setMapBounds = function (bounds) {
678 // fit bounds only if map has more than one object 679 if (!bounds.getNorthEast().equals(bounds.getSouthWest())) { 680 this.fitBounds(bounds); 681 } 682}; 683 684// Common functions 685var g_gmpGeocoder = null; 686jQuery.fn.mapSearchAutocompleateGmp = function (params) { 687 params = params || {}; 688 689 jQuery(this).keyup(function (event) { 690 // Ignore tab, enter, caps, end, home, arrows 691 if (toeInArrayGmp(event.keyCode, [9, 13, 20, 35, 36, 37, 38, 39, 40])) return; 692 var searchData = jQuery.trim(jQuery(this).val()); 693 694 if (searchData && searchData != '') { 695 if (typeof params.msgEl === 'string') { 696 params.msgEl = jQuery(params.msgEl); 697 } 698 params.msgEl.showLoaderGmp(); 699 var self = this; 700 701 jQuery(this).autocomplete( 702 jQuery.extend({}, params.autocompleteParams, { 703 source: function (request, response) { 704 var autocomleateData = typeof params.additionalData != 'undefined' ? gmpAutocomleateData(params.additionalData, request.term) : [], 705 geocoder = gmpGetGeocoder(), 706 geocoderData = { address: searchData }; 707 708 if (typeof params.geocoderParams != 'undefined' && params.geocoderParams) { 709 geocoderData = jQuery.extend({}, geocoderData, params.geocoderParams); 710 } 711 geocoder.geocode(geocoderData, function (results, status) { 712 params.msgEl.html(''); 713 714 if (status == google.maps.GeocoderStatus.OK && results.length) { 715 for (var i = 0; i < results.length; i++) { 716 autocomleateData.push({ 717 label: results[i].formatted_address, 718 lat: results[i].geometry.location.lat(), 719 lng: results[i].geometry.location.lng(), 720 category: toeLangGmp('Plases'), 721 }); 722 } 723 response(autocomleateData); 724 } else { 725 if (autocomleateData) { 726 response(autocomleateData); 727 } else { 728 //var notFoundMsg = toeLangGmp('Google can\'t find requested address coordinates, please try to modify search criterias.'); 729 var notFoundMsg = toeLangGmp('Nothing was found'); 730 731 if (jQuery(self).parent().find('.ui-helper-hidden-accessible').length) { 732 jQuery(self).parent().find('.ui-helper-hidden-accessible').html(notFoundMsg); 733 } else { 734 params.msgEl.html(notFoundMsg); 735 } 736 } 737 } 738 }); 739 }, 740 select: function (event, ui) { 741 if (params.onSelect) { 742 params.onSelect(ui.item, event, ui); 743 } 744 }, 745 }) 746 ); 747 748 // Force imidiate search right after creation 749 jQuery(this).autocomplete('search'); 750 } 751 }); 752}; 753function gmpAutocomleateData(data, needle) { 754 var autocomleateData = []; 755 756 for (var i = 0; i < data.length; i++) { 757 for (var j = 0; j < data[i].length; j++) { 758 if (data[i][j]) { 759 var label = data[i][j].label.toString().toLowerCase(), 760 desc = data[i][j].marker_desc != 'undefined' ? data[i][j].marker_desc : '', 761 term = needle.toLowerCase(); 762 763 if (label.indexOf(term) !== -1 || (desc && desc.indexOf(term) !== -1)) { 764 autocomleateData.push(data[i][j]); 765 } 766 } 767 } 768 } 769 return autocomleateData; 770} 771function gmpGetGeocoder() { 772 if (!g_gmpGeocoder) { 773 g_gmpGeocoder = new google.maps.Geocoder(); 774 } 775 return g_gmpGeocoder; 776} 777function changeInfoWndType(map) { 778 //This is a standart google maps api class 779 var infowndContent = jQuery('#' + map._elementId.id).find('.gm-style-iw'), 780 type = map.getParam('marker_infownd_type'), 781 hideInfoWndBtn = parseInt(map.getParam('marker_infownd_hide_close_btn')); 782 switch (type) { 783 case '': 784 if (infowndContent && infowndContent.length) { 785 infowndContent.each(function () { 786 var $this = jQuery(this),
787 wndBody = $this.prev().children().last(), 788 wndBodyShadow = $this.prev().children(':nth-child(2)'), 789 wndTail = $this.prev().children(':nth-child(3)'), 790 wndTailShadow = $this.prev().children().first(); 791 $this.css({ 792 'border-radius': '0px', 793 }); 794 }); 795 } 796 break; 797 case 'rounded_edges': 798 if (infowndContent && infowndContent.length) { 799 infowndContent.each(function () { 800 var $this = jQuery(this), 801 wndBody = $this.prev().children().last(), 802 wndBodyShadow = $this.prev().children(':nth-child(2)'), 803 wndTail = $this.prev().children(':nth-child(3)'), 804 wndTailShadow = $this.prev().children().first(); 805 806 if (hideInfoWndBtn !== 0) { 807 //$this.next('div').hide(); 808 $this.find('.gm-ui-hover-effect').hide(); 809 } 810 $this.find('.gmpInfoWindowtitle').css({ 811 padding: '0', 812 left: '0', 813 }); 814 wndBody.css({ 815 'border-radius': '10px', 816 }); 817 wndBodyShadow.css({ 818 'background-color': 'transparent', 819 '-moz-box-shadow': 'none', 820 '-webkit-box-shadow': 'none', 821 'box-shadow': 'none', 822 }); 823 wndTail.children().each(function (index) { 824 var $this = jQuery(this), 825 degrees = !index ? 'skewX(50.6deg)' : 'skewX(-50.6deg)', 826 left = !index ? '-2px' : '0'; 827 828 $this.css({ 829 height: '15px', 830 }); 831 $this.children().css({ 832 width: '20px', 833 left: left, 834 transform: degrees, 835 '-moz-box-shadow': 'none', 836 '-webkit-box-shadow': 'none', 837 'box-shadow': 'none', 838 }); 839 }); 840 wndTailShadow.css({ 841 'border-right': 'none', 842 'border-left': 'none', 843 'border-top': 'none', 844 left: '38px', 845 top: '74px', 846 }); 847 }); 848 } 849 break; 850 default: 851 break; 852 } 853} 854function changeInfoWndBgColor(map) { 855 g_gmpMarkerBgColorTimeoutSet = false; 856 var color = map.getParam('marker_infownd_bg_color'); 857 858 //This is a standart google maps api class 859 var infowndContent = jQuery('#' + map._elementId.id).find('.gm-style-iw'), 860 styleId = 'gmpInfoWindowStyle'; 861 862 if (infowndContent && infowndContent.length) { 863 infowndContent.each(function () { 864 var wndBody = jQuery(this).prev().children().last(), 865 wndTail = jQuery(this).prev().children(':nth-child(3)').children().last(); 866 //wndBody.css('background-color', color); 867 //wndTail.prev().children().last().css('background-color', color); 868 //wndTail.children().css('background-color', color); 869 infowndContent.css('background-color', color); 870 infowndContent.prev().children().last().css('background-color', color); 871 infowndContent.children().css('background-color', color); 872 var styleTag = jQuery('#' + styleId), 873 styles = '.gm-style-iw-t::after { background:' + color + ' !important; }'; 874 875 styles += '.gm-style .gm-style-iw-d::-webkit-scrollbar-track, .gm-style .gm-style-iw-d::-webkit-scrollbar-track-piece { background: ' + color + ' !important; }'; 876 if (styleTag.length) { 877 styleTag.html(styles); 878 } else { 879 jQuery('<style>' + styles + '</style>') 880 .attr('id', styleId) 881 .appendTo('head'); 882 } 883 }); 884 } 885} 886 887window.gmpGoogleMap = gmpGoogleMap;
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.