PageSourceSearch

https://transitplanningtx.org/wp-content/themes/rctp/js/map.js?ver=0.35

js transitplanningtx.org collected 2026-10-09 22:52:48 UTC 13,159 bytes, 417 lines download raw bytes

1jQuery(document).ready(function($) {
2		
3	var url = window.location.origin + '/wp-content/themes/rctp/geojson/Texas_County_Boundaries.geojson';  
4
5	var cityBoundaries = 	window.location.origin + '/wp-content/themes/rctp/geojson/TxDOT_City_Boundaries.geojson';
6	var urbanizedAreas = 	window.location.origin + '/wp-content/themes/rctp/geojson/TxDOT_Urbanized_Areas.geojson';
7	var texoma = 					window.location.origin + '/wp-content/themes/rctp/geojson/Texoma.geojson';
8	var southplains = 		window.location.origin + '/wp-content/themes/rctp/geojson/South_Plains.geojson';
9	var southtexas = 			window.location.origin + '/wp-content/themes/rctp/geojson/South_Texas.geojson';
10	var middleriogrande = window.location.origin + '/wp-content/themes/rctp/geojson/Middle_Rio_Grande.geojson';
11	var alamoarea = 			window.location.origin + '/wp-content/themes/rctp/geojson/AACOG.geojson';
12	var westcentraltx = 	window.location.origin + '/wp-content/themes/rctp/geojson/AMPO.geojson';
13	var arktex = 					window.location.origin + '/wp-content/themes/rctp/geojson/ARK-TEX.geojson';
14	var bvcog = 					window.location.origin + '/wp-content/themes/rctp/geojson/BVCOG.geojson';
15	var campo = 					window.location.origin + '/wp-content/themes/rctp/geojson/CAMPO.geojson';
16	var ctcog = 					window.location.origin + '/wp-content/themes/rctp/geojson/CTCOG.geojson';
17	var cvtd = 						window.location.origin + '/wp-content/themes/rctp/geojson/CVTD.geojson';
18	var detcog = 					window.location.origin + '/wp-content/themes/rctp/geojson/DETCOG2.geojson';
19	var etcog = 					window.location.origin + '/wp-content/themes/rctp/geojson/ETCOG.geojson';
20	var gcrpc = 					window.location.origin + '/wp-content/themes/rctp/geojson/GCRPC.geojson';
21	var hgac = 						window.location.origin + '/wp-content/themes/rctp/geojson/HGAC.geojson';
22	var hotcog =					window.location.origin + '/wp-content/themes/rctp/geojson/HOTCOG.geojson';
23	var lrgvdc =					window.location.origin + '/wp-content/themes/rctp/geojson/LRGVDC.geojson';
24	var lulac =						window.location.origin + '/wp-content/themes/rctp/geojson/LULAC.geojson';
25	var nctcog =					window.location.origin + '/wp-content/themes/rctp/geojson/NCTCOG.geojson';
26	var nortex =					window.location.origin + '/wp-content/themes/rctp/geojson/NORTEX.geojson';
27	var pbmpo =						window.location.origin + '/wp-content/themes/rctp/geojson/PBMPO.geojson';
28	var coastalbend =			window.location.origin + '/wp-content/themes/rctp/geojson/CoastalBend.geojson';
29	var setrpc =					window.location.origin + '/wp-content/themes/rctp/geojson/SETRPC.geojson';
30	var prpc =						window.location.origin + '/wp-content/themes/rctp/geojson/PRPC.geojson';
31
32	var texasCounties = 	window.location.origin + '/wp-content/themes/rctp/geojson/Texas_County_Boundaries.geojson';
33
34
35	var map = L.map('map').setView([31.33, -99.9018], 6); 
36
37	var osm = new L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png',{ 
38					attribution: '&copy; <a href="https://osm.org/copyright">OpenStreetMap</a> contributors'}).addTo(map);
39
40	var currentFeature;		
41		
42	// Set style function that sets fill color property
43	function style(feature) {
44	    return {
45	        fillColor: 'green', 
46	        fillOpacity: 0.25,  
47	        weight: 1,
48	        opacity: 0.5,
49	        color: '#000000',
50	        dashArray: '3'
51	    };
52	}
53
54	function styleClear(feature) {
55	    return {
56	        fillColor: 'white', 
57	        fillOpacity: 0.125,  
58	        weight: 1,
59	        opacity: 0.5,
60	        color: '#000000',
61	        dashArray: '3'
62	    };
63	}
64
65	function styleBlue(feature) {
66	    return {
67	        fillColor: '#3bb1ff', 
68	        fillOpacity: 0.25,  
69	        weight: 1,
70	        opacity: 0.5,
71	        color: '#000000',
72	        dashArray: '3'
73	    };
74	}
75
76	function styleYellow(feature) {
77	    return {
78	        fillColor: '#ffeb3b', 
79	        fillOpacity: 0.25,  
80	        weight: 1,
81	        opacity: 0.5,
82	        color: '#000000',
83	        dashArray: '3'
84	    };
85	}
86
87	function styleRed(feature) {
88	    return {
89	        fillColor: '#ff0000', 
90	        fillOpacity: 0.25,  
91	        weight: 1,
92	        opacity: 0.5,
93	        color: '#000000',
94	        dashArray: '3'
95	    };
96	}
97
98	function styleGreen(feature) {
99	    return {
100	        fillColor: '#8bc34a', 
101	        fillOpacity: 0.3,  
102	        weight: 1,
103	        opacity: 0.5,
104	        color: '#000000',
105	        dashArray: '3'
106	    };
107	}
108
109
110	function styleOrange(feature) {
111	    return {
112	        fillColor: '#FF8000', 
113	        fillOpacity: 0.25,  
114	        weight: 1,
115	        opacity: 0.5,
116	        color: '#000000',
117	        dashArray: '3'
118	    };
119	}
120
121
122	var highlight = {
123		'fillColor': 'yellow',
124		'weight': 2,
125		'opacity': 1
126	};
127
128
129	/// Store markers
130	function storeMarker(marker) {
131	  localStorage.setItem('markers', JSON.stringify(marker));
132	}
133
134
135	function letPassEvents(layer) {
136		layer.on('click', function(e) {
137			alert('ya clicked');
138		});
139	}
140
141
142	function forEachFeature(feature, layer) {
143
144		//var popupData = ["CNTY_NM",].map(key => feature.properties[key]);
145		var popupData = ["Region", "Name"].map(key => feature.properties[key]);
146
147
148		//if ( ! null == popupData[0] ) {
149			var counties = $('.counties-' + popupData[0]);
150			//console.log('counties.html(): ' + counties.html());
151			if ( typeof counties.html() !== 'undefined' ) {
152				var countyMarkup = '<b>Counties: </b>' + counties.html() + "<br/>";
153			} else {
154				countyMarkup = '';
155			}
156			
157
158			var popupDisplay = "<div class=\"region-popup\"><p>Region: <b>" + popupData[0] + 
159			"</b></p><h4>" + popupData[1] + "</h4>" +
160			"<p>" + countyMarkup +
161			"<a href=\"#region-" + popupData[0] + "\">MORE</a>"
162			"</p>";
163	      
164	    var popupContent = "<div class=\"region-popup\"><p>Region: <b>" + popupData[0] + 
165			"</b></p><h4>" + popupData[1] + "</h4>" +
166			"<p>" + countyMarkup +
167			"<a href=\"#region-" + popupData[0] + "\">MORE</a>"
168			"</p>";
169
170	    //layer.bindPopup(popupContent);
171
172
173	    if ( popupData[0] ) { // don't show a pop if no data
174	    	layer.bindPopup(popupDisplay);
175	    }
176			
177			
178
179			layer.on("click", function (e) { 
180
181				// if ( null == popupData[0] ) {
182				// 	this.removeEventListener("click");
183				// 	console.log(this);
184
185				// 	return false;
186
187				// }
188
189				currentFeature = feature;
190				//console.log("currentFeature", currentFeature);
191	      stateLayer.setStyle(style); //resets layer colors
192				//layer.setStyle(highlight);  //highlights selected.
193		
194				//Take current popupContent and remove html (janky)
195				var popupCleaned = popupContent.replace(/<(.|\n)*?>/g, '');
196
197				var popupCleanedNumeric = popupCleaned.replace(/[^0-9\.]+/g, '');
198
199				//console.log("Cleaned popup", popupCleaned);
200				//console.log("Cleaned popup Numeric:", popupCleanedNumeric);
201				storeMarker(popupData);	
202	     });
203		// } else {
204		// 	layer.on('click', function(e) {
205		// 		alert('ya clicked');
206		// 	});
207		// }
208	}
209		
210	// Null variable that will hold county boundary layer in memory
211	var stateLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: style});
212
213	$.getJSON(url, function(data) {
214  	//stateLayer.addData(data);
215  });
216
217	// var cityBoundaryLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: style}); 
218	// 	$.getJSON(cityBoundaries, function(data) {
219	// 		cityBoundaryLayer.addData(data);
220	// 	});
221
222	var cityBoundaryLayer = L.geoJSON(null, {style: style}); 
223	$.getJSON(cityBoundaries, function(data) {
224		cityBoundaryLayer.addData(data);
225	});
226
227	// cityBoundaryLayer.on('click', function() {
228	// 	letPassEvents(this);
229	// });
230
231	var urbanizedAreaLayer = L.geoJSON(null, {style: style});
232	$.getJSON(urbanizedAreas, function(data) {
233		urbanizedAreaLayer.addData(data);
234	});
235
236	var texomaAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleYellow});
237	$.getJSON(texoma, function(data) {
238		texomaAreaLayer.addData(data);
239	});
240
241	var southplainsAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleBlue});
242	$.getJSON(southplains, function(data) {
243		southplainsAreaLayer.addData(data);
244	});
245
246	var southtexasAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleBlue});
247	$.getJSON(southtexas, function(data) {
248		southtexasAreaLayer.addData(data);
249	});
250
251	var middleriograndeAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleYellow});
252	$.getJSON(middleriogrande, function(data) {
253		middleriograndeAreaLayer.addData(data);
254	});
255
256	var alamoAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleOrange});
257	$.getJSON(alamoarea, function(data) {
258		alamoAreaLayer.addData(data);
259	});
260
261	var westcentraltxAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleYellow});
262	$.getJSON(westcentraltx, function(data) {
263		westcentraltxAreaLayer.addData(data);
264	});
265
266	var arktexAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleGreen});
267	$.getJSON(arktex, function(data) {
268		arktexAreaLayer.addData(data);
269	});
270
271	var bvcogAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleGreen});
272	$.getJSON(bvcog, function(data) {
273		bvcogAreaLayer.addData(data);
274	});
275
276	var campoAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleBlue});
277	$.getJSON(campo, function(data) {
278		campoAreaLayer.addData(data);
279	});
280
281	var ctcogAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleOrange});
282	$.getJSON(ctcog, function(data) {
283		ctcogAreaLayer.addData(data);
284	});
285
286	var cvtdAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleRed});
287	$.getJSON(cvtd, function(data) {
288		cvtdAreaLayer.addData(data);
289	});
290
291	var detcogAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleBlue});
292	$.getJSON(detcog, function(data) {
293		detcogAreaLayer.addData(data);
294	});
295
296	var etcogAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleYellow});
297	$.getJSON(etcog, function(data) {
298		etcogAreaLayer.addData(data);
299	});
300
301	var gcrpcAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleGreen});
302	$.getJSON(gcrpc, function(data) {
303		gcrpcAreaLayer.addData(data);
304	});
305
306	var hgacAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleOrange});
307	$.getJSON(hgac, function(data) {
308		hgacAreaLayer.addData(data);
309	});
310
311	var hotcogAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleBlue});
312	$.getJSON(hotcog, function(data) {
313		hotcogAreaLayer.addData(data);
314	});
315
316	var lrgvdcAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleOrange});
317	$.getJSON(lrgvdc, function(data) {
318		lrgvdcAreaLayer.addData(data);
319	});
320
321	var lulacAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleGreen});
322	$.getJSON(lulac, function(data) {
323		lulacAreaLayer.addData(data);
324	});
325
326	var nctcogAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleRed});
327	$.getJSON(nctcog, function(data) {
328		nctcogAreaLayer.addData(data);
329	});
330
331	var nortexAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleOrange});
332	$.getJSON(nortex, function(data) {
333		nortexAreaLayer.addData(data);
334	});
335
336	var pbmpoAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleOrange});
337	$.getJSON(pbmpo, function(data) {
338		pbmpoAreaLayer.addData(data);
339	});
340
341	var coastalbendAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleRed});
342	$.getJSON(coastalbend, function(data) {
343		coastalbendAreaLayer.addData(data);
344	});
345
346	var setrpcAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleYellow});
347	$.getJSON(setrpc, function(data) {
348		setrpcAreaLayer.addData(data);
349	});
350
351	var prpcAreaLayer = L.geoJSON(null, {onEachFeature: forEachFeature, style: styleGreen});
352	$.getJSON(prpc, function(data) {
353		prpcAreaLayer.addData(data);
354	});
355
356
357
358	var texasCountyLayer = L.geoJSON(null, {interactive: false, style: styleClear});
359	$.getJSON(texasCounties, function(data) {
360		texasCountyLayer.addData(data);
361	});
362
363
364
365	/* ====  COMMENT ANY OF THE FOLLOWING TO START TURNED OFF  ==== */ 
366	stateLayer.addTo(map);
367	//cityBoundaryLayer.addTo(map);
368	//urbanizedAreaLayer.addTo(map);
369	//texasCountyLayer.addTo(map);
370
371	texomaAreaLayer.addTo(map);
372	southplainsAreaLayer.addTo(map);
373	southtexasAreaLayer.addTo(map);
374	middleriograndeAreaLayer.addTo(map);
375	alamoAreaLayer.addTo(map);
376	westcentraltxAreaLayer.addTo(map);
377	arktexAreaLayer.addTo(map);
378	bvcogAreaLayer.addTo(map);
379	campoAreaLayer.addTo(map);
380	ctcogAreaLayer.addTo(map);
381	cvtdAreaLayer.addTo(map);
382	detcogAreaLayer.addTo(map);
383	etcogAreaLayer.addTo(map);
384	gcrpcAreaLayer.addTo(map);
385	hgacAreaLayer.addTo(map);
386	hotcogAreaLayer.addTo(map);
387	lrgvdcAreaLayer.addTo(map);
388	lulacAreaLayer.addTo(map);
389	nctcogAreaLayer.addTo(map);
390	nortexAreaLayer.addTo(map);
391	pbmpoAreaLayer.addTo(map);
392	coastalbendAreaLayer.addTo(map);
393	setrpcAreaLayer.addTo(map);
394	prpcAreaLayer.addTo(map);
395
396
397	// for Layer Control	
398	var baseMaps = {
399	    "<strong>Texas Map Layers</strong>": osm  	
400	};
401
402	var overlayMaps = {
403		"Texas County Boundaries":texasCountyLayer,
404		"City Boundaries":cityBoundaryLayer,
405		"Urbanized Areas":urbanizedAreaLayer,
406	};	
407		
408	//Add layer control
409	L.control.layers(baseMaps, overlayMaps).addTo(map);
410
411	//L.control.setPosition([31.9686, -99.9018], 6); 
412
413	function refresh() {
414		map.setView([31.9686, -99.9018], 6);
415	}
416
417});

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.