PageSourceSearch

https://autorentsaudi.com/js/gmap.js

js autorentsaudi.com collected 2026-10-04 02:14:26 UTC 5,649 bytes, 183 lines download raw bytes

1/*
2 *  google maps wrapper
3 */
4;( function( $, window, document, undefined ) {
5
6	"use strict";
7
8		// Create the defaults once
9		var pluginName = "gmap",
10			defaults = {
11				mapStyle: [{"featureType":"water","elementType":"geometry","stylers":[{"color":"#e9e9e9"},{"lightness":17}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#f5f5f5"},{"lightness":20}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#ffffff"},{"lightness":17}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#ffffff"},{"lightness":29},{"weight":0.2}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#ffffff"},{"lightness":18}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#ffffff"},{"lightness":16}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#f5f5f5"},{"lightness":21}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#dedede"},{"lightness":21}]},{"elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#ffffff"},{"lightness":16}]},{"elementType":"labels.text.fill","stylers":[{"saturation":36},{"color":"#333333"},{"lightness":40}]},{"elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#f2f2f2"},{"lightness":19}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#fefefe"},{"lightness":20}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#fefefe"},{"lightness":17},{"weight":1.2}]}],
12				zoom: 14,
13				mapIcon: 'img/map-marker.png',
14				google: null,
15				tabMap: true,
16				nearbySearch: false
17			},
18			mapStyle,
19			service,
20			tabItem,
21			markers,
22			markersExists = false;
23
24		function Plugin ( element, options ) {
25			this.element = element;
26
27			this.settings = $.extend( {}, defaults, options );
28			this._defaults = defaults;
29			this._name = pluginName;
30			this.init();
31		}
32
33		$.extend( Plugin.prototype, {
34			map: null,
35			loc: null,
36			init: function() {
37
38				tabItem = $(this.element).attr('data-tab'),
39				markers = $(this.element).attr('data-markers');
40
41				if(typeof markers !== typeof undefined && markers !== false) {
42					markers = $.parseJSON(markers);
43					markersExists = true;
44				}
45
46
47				this.loc();
48				if(tabItem === 'false') {
49					this.setMap();
50				} else {
51					this.tabBnt();
52				};
53
54			},
55			setMap: function() {
56				this.map = new google.maps.Map(this.element, {
57					zoom: this.settings.zoom,
58					center: this.loc,
59					mapTypeControl: false
60				});
61
62				if(markersExists) {
63					this.setMarkers();
64				} else {
65					this.marker();
66				}
67				
68				
69				
70				this.mapStyle();
71				if(this.settings.nearbySearch) {
72					this.service();
73				}
74			},
75			tabBnt: function() {
76				var parent = $(this.element).closest('.tab-pane'),
77					id = parent.attr('id'),
78					href = '#' + id,
79					$tab = $('a[href="'+href+'"]'),
80					self = this;
81
82					$tab.on('shown.bs.tab', function(e){
83						if(!self.map) {
84							self.setMap();
85						}
86					});
87
88			},
89			loc: function() {
90				var lng = $(this.element).data('lng'),
91					lat = $(this.element).data('lat');
92
93				this.loc = new google.maps.LatLng(lat, lng);
94			},
95			mapStyle: function() {
96				mapStyle = new google.maps.StyledMapType(this.settings.mapStyle);
97				this.map.mapTypes.set('styled_map', mapStyle);
98    			this.map.setMapTypeId('styled_map');
99			},
100			setMarkers: function() {
101				for (var i = markers.length - 1; i >= 0; i--) {
102					new google.maps.Marker({
103						position: new google.maps.LatLng(markers[i].lat, markers[i].lng),
104						map: this.map,
105						icon: {
106							path: google.maps.SymbolPath.CIRCLE,
107							scale: 5,
108							fillColor: '#ff6c2d',
109							fillOpacity: 1,
110							strokeColor: 'white',
111							strokeWeight: 2
112						}
113					});
114				}
115			},
116			marker: function() {
117				new google.maps.Marker({
118					position: this.loc,
119					map: this.map,
120					icon: this.settings.mapIcon
121				});
122			},
123			service: function() {
124				service = new google.maps.places.PlacesService(map);
125				service.nearbySearch({
126					location: loc,
127					radius: 300,
128					type: ['store']
129					// this: this
130				}, this.processService);
131			},
132			processService: function(results, status, pagination) {
133				if(status !== google.maps.places.PlacesServiceStatus.OK) {
134					return;
135				} else {
136					self.serviceMarkers(results);
137				}
138			},
139			serviceMarkers: function(places) {
140				var bounds = new google.maps.LatLngBounds();
141
142				for (var i = 0, place; place = places[i]; i++) {
143					var infowindow = new google.maps.InfoWindow;
144					// console.log(map);
145					var infoMarker = new google.maps.Marker({
146						map: map,
147						icon: {
148							path: google.maps.SymbolPath.CIRCLE,
149							strokeOpacity: 0,
150							fillColor: '#0093d2',
151							fillOpacity: 0.5,
152							scale: 2.5
153						},
154						title: place.name,
155						position: place.geometry.location
156					});
157
158					google.maps.event.addListener(infoMarker, 'mouseover', function() {
159			            infowindow.setContent(this.title);
160			            infowindow.open(map, this);
161			        });
162
163			        google.maps.event.addListener(infoMarker, 'mouseout', function() {
164			            infowindow.close(map, this);
165			        });
166
167					bounds.extend(place.geometry.location);
168				}
169				map.fitBounds(bounds);
170			}
171		});
172
173		$.fn[ pluginName ] = function( options ) {
174			return this.each( function() {
175				if ( !$.data( this, "plugin_" + pluginName ) ) {
176					$.data( this, "plugin_" +
177						pluginName, new Plugin( this, options ) );
178				}
179			} );
180		};
181
182} )( jQuery, window, document );
183

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.