PageSourceSearch

https://www.pueblo.us/Assets/Scripts/GoogleMaps.js

js pueblo.us collected 2026-09-24 18:34:11 UTC 10,786 bytes, 301 lines download raw bytes

1var CivicPlus = {};
2CivicPlus.Maps = {};
3var map = null;
4var mapOptions = null;
5var geoCoder = null;
6var markerBounds = null;
7var enums = null;
8var mapMode = { 'Dynamic': 1, 'DynamicButLazyLoaded': 2, 'Static': 3, 'Embedded': 4 };
9var markerBounds = new google.maps.LatLngBounds();
10
11CivicPlus.Maps = function (canvas, options) {
12	this.infoWindow = null;
13	this.Map = (canvas && options) ? new google.maps.Map(document.getElementById(canvas), options) : null;
14	this.Markers = new Array();
15}
16
17CivicPlus.Maps.prototype = {
18	AddMarker: function (marker) { this.Markers[this.Markers.length] = marker; }, //end AddMarker
19
20	ClearMarkers: function () {
21		for (i = 0; i < this.Markers.length; i++)
22			this.Markers[i].set_map(null);
23	}, //end ClearMarkers
24
25	CreateMarker: function (lat, lng, content, title, icon) {
26		var marker = new google.maps.Marker({ position: new google.maps.LatLng(lat, lng, false), map: map.Map });
27		var cLat = map.Map.center.lat();
28		var cLng = map.Map.center.lng();
29		marker.setTitle(title);
30		marker.setIcon('/common/images/maps/marker-' + icon + '.png');
31		if (content && content != '') {
32			google.maps.event.addListener(marker, "click", function () {
33				if (map.infoWindow) map.infoWindow.close();
34				map.infoWindow = new google.maps.InfoWindow({ content: content });
35				map.infoWindow.open(map.Map, marker);
36				google.maps.event.addListener(map.infoWindow, "closeclick", function () {
37					//marker.map.panTo(new google.maps.LatLng(cLat, cLng))
38				});
39			});
40		} else
41			marker.setClickable(false); //marker not clickable not content
42		var i = new google.maps.LatLng(lat, lng);
43		markerBounds.extend(i);
44		return marker;
45	}, //end CreateMarker
46
47	RemoveMarker: function (address, title) {
48		if (!geoCoder) { geoCoder = new google.maps.Geocoder(); }
49		geoCoder.geocode({ 'address': address }, function (results, status) {
50			if (status == google.maps.GeocoderStatus.OK) {
51				var lat = results[0].geometry.location.lat();
52				var lng = results[0].geometry.location.lng();
53				var tempArray = map.Markers;
54				for (i = 0; i < tempArray.length; i++) {
55					if (tempArray[i].getPosition().lat() == lat && tempArray[i].getPosition().lng() == lng && (tempArray[i].getTitle() == title || title == 'assignee')) {
56						tempArray[i].set_map(null);
57					}
58				}
59			}
60		});
61	},
62
63	HideMarker: function (title, address) {
64		if (address != '') {
65			if (!geoCoder) { geoCoder = new google.maps.Geocoder(); }
66			geoCoder.geocode({ 'address': address }, function (results, status) {
67				if (status == google.maps.GeocoderStatus.OK) {
68					var lat = results[0].geometry.location.lat();
69					var lng = results[0].geometry.location.lng();
70					var tempArray = map.Markers;
71					for (i = 0; i < tempArray.length; i++) {
72						if (tempArray[i].getPosition().lat() == lat && tempArray[i].getPosition().lng() == lng && (tempArray[i].getTitle() == title || title == 'assignee')) {
73							tempArray[i].setVisible(false);
74						}
75					}
76				}
77			});
78		}
79		else {
80			var tempArray = map.Markers;
81			for (i = 0; i < tempArray.length; i++) {
82				if (tempArray[i].getTitle() == title) {
83					tempArray[i].setVisible(false);
84				}
85			}
86		}
87	},
88
89	ShowMarker: function (title, address) {
90		if (address != '') {
91			if (!geoCoder) { geoCoder = new google.maps.Geocoder(); }
92			geoCoder.geocode({ 'address': address }, function (results, status) {
93				if (status == google.maps.GeocoderStatus.OK) {
94					var lat = results[0].geometry.location.lat();
95					var lng = results[0].geometry.location.lng();
96					var tempArray = map.Markers;
97					for (i = 0; i < tempArray.length; i++) {
98						if (tempArray[i].getPosition().lat() == lat && tempArray[i].getPosition().lng() == lng && (tempArray[i].getTitle() == title || title == 'assignee')) {
99							tempArray[i].setVisible(true);
100						}
101					}
102				}
103			});
104		}
105		else {
106			var tempArray = map.Markers;
107			for (i = 0; i < tempArray.length; i++) {
108				if (tempArray[i].getTitle() == title) {
109					tempArray[i].setVisible(true);
110				}
111			}
112		}
113	},
114
115	HideAllMarkers: function (address, title) {
116		var tempArray = map.Markers;
117		for (i = 0; i < tempArray.length; i++) {
118			tempArray[i].setVisible(false);
119		}
120	},
121
122	ShowAllMarkers: function (address, title) {
123		var tempArray = map.Markers;
124		for (i = 0; i < tempArray.length; i++) {
125			tempArray[i].setVisible(true);
126		}
127	},
128
129	GeoCode: function (address, content, title, icon, zoomLevel) {
130		if (!geoCoder) { geoCoder = new google.maps.Geocoder(); }
131		geoCoder.geocode({ 'address': address }, function (results, status) {
132			if (status == google.maps.GeocoderStatus.OK) {
133				var marker = map.CreateMarker(results[0].geometry.location.lat(), results[0].geometry.location.lng(), content, title, icon);
134				map.AddMarker(marker);
135				if (!zoomLevel)
136					map.Map.fitBounds(markerBounds);
137				else {
138					map.Map.setCenter(results[0].geometry.location);
139					map.Map.setZoom(16);
140				}
141			}
142		});
143	}, //end GeoCode
144	GeoCode2: function (lat, lng, content, title, icon, zoomLevel) {
145		// if lat/lng are stored as 0,0 in the db it is assumed to be unknown
146		// rather than the actual location on the map that has 0,0 lat/lng.
147		if (lat && lat != "0") {
148			document.getElementById("map_canvas").style.display = "block";
149			var marker = map.CreateMarker(lat, lng, content, title, icon);
150			map.AddMarker(marker);
151			if (!zoomLevel)
152				map.Map.fitBounds(markerBounds);
153			else {
154				var location = new google.maps.LatLng(lat, lng);
155				map.Map.setCenter(location);
156				map.Map.setZoom(16);
157			}
158		} else {
159			document.getElementById("map_canvas").style.display = "none";
160		}
161	},
162	ReverseGeoCode: function (lat, lng, content, title) {
163		if (!geoCoder) { geoCoder = new google.maps.Geocoder(); }
164		var latlng = new google.maps.LatLng(lat, lng);
165		if (geoCoder) {
166			geoCoder.geocode({ 'latLng': latlng }, function (results, status) {
167				if (status == google.maps.GeocoderStatus.OK) {
168					if (status == google.maps.GeocoderStatus.OK) {
169						var marker = map.CreateMarker(results[0].geometry.location.lat(), results[0].geometry.location.lng(), content, title);
170						map.AddMarker(marker);
171						map.Map.fitBounds(markerBounds);
172					}
173				}
174			});
175		}
176	}, //end ReverseGeoCode
177	LoadMap: function (item, paddingBottom, address) {
178		var $infotext = $(item).next('.infotext');
179		if(paddingBottom)
180			$(item).parent('.mapWrapLazyLoaded').css('padding-bottom', paddingBottom);
181		var mapOptions = {
182			zoom: 15,
183			'mapTypeId': google.maps.MapTypeId.ROADMAP
184		};
185		var map;
186		var marker;
187		if (!address)
188			address = $infotext.children('.address').text();
189		if (!geoCoder) { geoCoder = new google.maps.Geocoder(); }
190		geoCoder.geocode({ 'address': address }, function (results, status) {
191			if (status == google.maps.GeocoderStatus.OK) {
192				$(item).show("fast", function () {
193					$(this).css('overflow', 'hidden');
194				});
195				$(item).parent().show("fast", function () {
196					$(this).css('overflow', 'hidden');
197				});
198				mapOptions.center = results[0].geometry.location;
199				map = new google.maps.Map(item, mapOptions);
200				marker = new google.maps.Marker({
201					map: map,
202					position: results[0].geometry.location
203				});
204				if (window.Pages != null && window.Pages.tabChangeHandlers != null) {
205					window.Pages.tabChangeHandlers.push(function () {
206						google.maps.event.trigger(map, 'resize');
207						map.setCenter(mapOptions.center);
208					});
209				}
210			} else {
211				$(item).parent().hide();
212				$(item).hide();
213			}
214		});
215	},
216	ScriptSourceUrl: function (mode, callback) {
217		var apiKey = document.getElementById('GoogleMapsKey').value;
218		var scriptSrc = 'https://maps.googleapis.com/maps/api/js?v=3.exp';
219		if (apiKey != undefined)
220			scriptSrc += '&key=' + encodeURIComponent(apiKey);
221		if (mode !== mapMode.DynamicButLazyLoaded)
222			scriptSrc += '&callback=' + encodeURIComponent(callback);
223		return scriptSrc;
224	},
225	LoadMaps: function () {
226		var googleMap = this;
227		$('.googleMap').each(function (index, item) {
228			googleMap.LoadMap(item);
229		});
230	},
231	LoadGoogleMapsScript: function (mode, callback, preRenderCheckValid) {
232		var googleMap = this;
233		if (preRenderCheckValid) {
234			if ($('#GoogleMapsJS').length == 0) {
235				var script = document.createElement('script');
236				script.id = 'GoogleMapsJS';
237				script.type = 'text/javascript';
238				script.src = googleMap.ScriptSourceUrl(mode, callback);
239				document.body.appendChild(script);
240			} else {
241				if (window.google && window.google.maps) {
242					this.LoadMaps();
243				}
244			}
245		}
246	}
247
248}//end CivicPlus.Maps.prototype
249
250/*******MapOptions*********/
251CivicPlus.MapOptions = function (lat, lng) {
252	this.noClear = null,
253		this.backgroundColor = null,
254		this.draggableCursor = null,
255		this.draggingCursor = null,
256		this.draggable = true,
257		this.scrollwheel = true,
258		this.keyboardShortcuts = true,
259		this.center = (lat && lng) ? new google.maps.LatLng(lat, lng) : null,
260		this.zoom = this.Enums.ZoomLevels.Eight,
261		this.mapTypeId = this.Enums.MapTypes.ROADMAP,
262		this.disableDefaultUI = false,
263		this.mapTypeControl = true;
264		this.mapTypeControlOptions = { style: this.Enums.MapTypeControlStyles.DEFAULT },
265		this.scaleControl = false,
266		this.scaleControlOptions = null,
267		this.navigationControl = true,
268		this.navigationControlOptions = { style: this.Enums.NavigationControlStyle.DEFAULT }
269}
270
271CivicPlus.MapOptions.prototype = {
272	SetCenter: function (lat, lng) { this.center = google.maps.LatLng(lat, lng); } //end SetCenter
273}
274
275CivicPlus.MapOptions.prototype.Enums = {
276	MapTypeControlStyles: {
277		DEFAULT: google.maps.MapTypeControlStyle.DEFAULT,
278		HORIZONTAL_BAR: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
279		DROPDOWN_MENU: google.maps.MapTypeControlStyle.DROPDOWN_MENU
280	},
281	MapTypes: {
282		ROADMAP: google.maps.MapTypeId.ROADMAP,
283		HYBRID: google.maps.MapTypeId.HYBRID,
284		SATELLITE: google.maps.MapTypeId.SATELLITE,
285		TERRAIN: google.maps.MapTypeId.TERRAIN
286	},
287	NavigationControlStyle: {
288		DEFAULT: google.maps.NavigationControlStyle.DEFAULT,
289		SMALL: google.maps.NavigationControlStyle.SMALL,
290		ANDROID: google.maps.NavigationControlStyle.ANDROID,
291		ZOOM_PAN: google.maps.NavigationControlStyle.ZOOM_PAN
292	},
293	ZoomLevels: { 'One': 1, 'Two': 2, 'Three': 3, 'Four': 4, 'Five': 5, 'Six': 6, 'Seven': 7, 'Eight': 8, 'Nine': 9, 'Ten': 10, 'Eleven': 11, 'Twelve': 12, 'Thirteen': 13, 'Fourteen': 14, 'Fifteen': 15, 'Sixteen': 16, 'Seventeen': 17 }
294}
295
296function initialize() {
297	mapOptions = new CivicPlus.MapOptions(38.88136305363343, -94.78023817494775);
298	mapOptions.zoom = mapOptions.Enums.ZoomLevels.Five;
299	map = new CivicPlus.Maps("map_canvas", mapOptions);
300}
301

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.