WME GIS Layers

Adds GIS layers in WME

目前为 2025-05-07 提交的版本,查看 最新版本

  1. /* eslint-disable camelcase */
  2. /* eslint-disable brace-style, curly, nonblock-statement-body-position, no-template-curly-in-string, func-names */
  3. // ==UserScript==
  4. // @name WME GIS Layers
  5. // @namespace https://greasyfork.org/users/45389
  6. // @version 2025.05.03.000
  7. // @description Adds GIS layers in WME
  8. // @author MapOMatic
  9. // @match *://*.waze.com/*editor*
  10. // @exclude *://*.waze.com/user/editor*
  11. // @require https://greasyfork.org/scripts/24851-wazewrap/code/WazeWrap.js
  12. // @require https://cdn.jsdelivr.net/npm/@turf/turf@7/turf.min.js
  13. // @require https://update.greasyfork.org/scripts/506614/1441195/ESTreeProcessor.js
  14. // @require https://update.greasyfork.org/scripts/509664/WME%20Utils%20-%20Bootstrap.js
  15. // @require https://update.greasyfork.org/scripts/516445/1480246/Make%20GM%20xhr%20more%20parallel%20again.js
  16. // @connect greasyfork.org
  17. // @grant GM_xmlhttpRequest
  18. // @grant GM_info
  19. // @grant GM_setClipboard
  20. // @license GNU GPLv3
  21. // @contributionURL https://github.com/WazeDev/Thank-The-Authors
  22. // @connect *
  23. // @connect tigerweb.geo.census.gov
  24. // @connect 136.234.13.165
  25. // @connect 216.167.160.20
  26. // @connect 35.172.145.31
  27. // @connect 52.37.30.30
  28. // @connect 54.213.14.253
  29. // @connect 72.10.206.73
  30. // @connect a2maps.a2gov.org
  31. // @connect adairgis.integritygis.com
  32. // @connect agis.charlottecountyfl.gov
  33. // @connect ago.clarkcountyohio.gov
  34. // @connect agomaps.larimer.org
  35. // @connect ags.agdmaps.com
  36. // @connect ags.bhamaps.com
  37. // @connect ags.kitsapgov.com
  38. // @connect ags.myokaloosa.com
  39. // @connect ags.roseville.ca.us
  40. // @connect ags1.wgxtreme.com
  41. // @connect ags10s1.dot.illinois.gov
  42. // @connect ags2maps.srcity.org
  43. // @connect ags3.scgov.net
  44. // @connect aldotgis.dot.state.al.us
  45. // @connect alleganygis.allconet.org
  46. // @connect alphagis.alpharetta.ga.us
  47. // @connect andrewgis.integritygis.com
  48. // @connect anrmaps.vermont.gov
  49. // @connect ansoncountygis.com
  50. // @connect apnsgis1.apsu.edu
  51. // @connect apnsgis4.apsu.edu
  52. // @connect app.mdt.mt.gov
  53. // @connect apps.alamance-nc.com
  54. // @connect apps.douglas.co.us
  55. // @connect apps.fs.usda.gov
  56. // @connect apps.lickingcounty.gov
  57. // @connect apps.vernoncounty.org
  58. // @connect apps.wyoroad.info
  59. // @connect arcgis-morrowarcgis-1015369042.us-east-1.elb.amazonaws.com
  60. // @connect arcgis-web.chinohills.org
  61. // @connect arcgis.atlantaregional.com
  62. // @connect arcgis.c3gov.com
  63. // @connect arcgis.cityofcapegirardeau.org
  64. // @connect arcgis.cityofwatsonville.org
  65. // @connect arcgis.co.beltrami.mn.us
  66. // @connect arcgis.co.henry.ga.us
  67. // @connect arcgis.co.lancaster.pa.us
  68. // @connect arcgis.forneytx.gov
  69. // @connect arcgis.gis.lacounty.gov
  70. // @connect arcgis.kingsporttn.gov
  71. // @connect arcgis.leaguecitytx.gov
  72. // @connect arcgis.lewiscountywa.gov
  73. // @connect arcgis.mobile311.com
  74. // @connect arcgis.racinecounty.com
  75. // @connect arcgis.tampagov.net
  76. // @connect arcgis.tuscco.com
  77. // @connect arcgis.vgsi.com
  78. // @connect arcgis.water.nv.gov
  79. // @connect arcgis.waxahachie.com
  80. // @connect arcgis.yumacountyaz.gov
  81. // @connect arcgis4.roktech.net
  82. // @connect arcgis5.roktech.net
  83. // @connect arcgisce.co.valencia.nm.us
  84. // @connect arcgisserver.digital.mass.gov
  85. // @connect arcgisserver.lincolncounty.org
  86. // @connect arcgisserver.maine.gov
  87. // @connect arcgisserver2.morpc.org
  88. // @connect arcgissrv.cityofbartlesville.org
  89. // @connect arcgiswap01.ci.temple.tx.us
  90. // @connect arcgisweb.carteretcountync.gov
  91. // @connect arcgisweb.countyofnewaygo.com
  92. // @connect arcmobile.co.albany.wy.us
  93. // @connect arcportal.florenceco.org
  94. // @connect arcserv.co.washington.ar.us
  95. // @connect arcserver.madisoncountyky.us
  96. // @connect arcserver2.oconeesc.com
  97. // @connect arcweb.hcad.org
  98. // @connect ardmoregis.ardmorecity.org
  99. // @connect arlgis.arlingtonva.us
  100. // @connect atchisongis.integritygis.com
  101. // @connect atlas.co.chelan.wa.us
  102. // @connect atlas.geoportalmaps.com
  103. // @connect audraingis.integritygis.com
  104. // @connect batesgis.integritygis.com
  105. // @connect bcgis.baltimorecountymd.gov
  106. // @connect bcgis.brunswickcountync.gov
  107. // @connect bcgishub.broward.org
  108. // @connect bcmaps.bradfordco.org
  109. // @connect bentongis.integritygis.com
  110. // @connect biamaps.geoplatform.gov
  111. // @connect bocagis.ci.boca-raton.fl.us
  112. // @connect bonneville.esriemcs.com
  113. // @connect bpagis.bossierparish.org
  114. // @connect bryangis.bryan-county.org
  115. // @connect buchanangis.integritygis.com
  116. // @connect butlergis.integritygis.com
  117. // @connect c39gisserver.co.richland.nd.us
  118. // @connect ca.dep.state.fl.us
  119. // @connect cagisonline.hamilton-co.org
  120. // @connect calmaps.co.calumet.wi.us
  121. // @connect caltrans-gis.dot.ca.gov
  122. // @connect cama.shelbycountyauditors.com
  123. // @connect camdengis.integritygis.com
  124. // @connect cassweb3.co.cass.mn.us
  125. // @connect cceo.co.comal.tx.us
  126. // @connect ccmap.cccounty.us
  127. // @connect cecilmaps.org
  128. // @connect charitongis.integritygis.com
  129. // @connect christiangis.integritygis.com
  130. // @connect clearfieldco.org
  131. // @connect cloud.longviewtexas.gov
  132. // @connect cloudgis.bonnercountyid.gov
  133. // @connect co.knox.il.us
  134. // @connect coagisweb.cabq.gov
  135. // @connect com.blountgis.org
  136. // @connect conservationgis.alabama.gov
  137. // @connect coopergis.integritygis.com
  138. // @connect covgis.cityofvacaville.com
  139. // @connect coweta-gis-web.coweta.ga.us
  140. // @connect cowlitzgis.net
  141. // @connect crgis.cedar-rapids.org
  142. // @connect cteco.uconn.edu
  143. // @connect currituckncgov.com
  144. // @connect cw.townofclaytonnc.org
  145. // @connect dadegis.integritygis.com
  146. // @connect dallasgis.integritygis.com
  147. // @connect data.wsdot.wa.gov
  148. // @connect data1.digitaldataservices.com
  149. // @connect dc-web-2.co.douglas.mn.us
  150. // @connect dcgis.dekalbcountyga.gov
  151. // @connect dcimapapps.countyofdane.com
  152. // @connect dekalbgis.integritygis.com
  153. // @connect delta.co.clatsop.or.us
  154. // @connect dev.wilsonvillemaps.com
  155. // @connect doniphangis.integritygis.com
  156. // @connect dotapp9.dot.state.mn.us
  157. // @connect douglasgis.integritygis.com
  158. // @connect dtdapps.coloradodot.info
  159. // @connect dungis.dunwoodyga.gov
  160. // @connect dunklingis.integritygis.com
  161. // @connect ecgis.co.ellis.tx.us
  162. // @connect egis.baltimorecity.gov
  163. // @connect egis.pinellas.gov
  164. // @connect elb.elevatemaps.io
  165. // @connect emapsplus.com
  166. // @connect enigma.accgov.com
  167. // @connect enterprise.firstmap.delaware.gov
  168. // @connect eoc.franklin-gov.com
  169. // @connect epv.ci.juneau.ak.us
  170. // @connect eservices.co.crook.or.us
  171. // @connect essex-gis.co.essex.ny.us
  172. // @connect fcgis.franklincountypa.gov
  173. // @connect feature.geographic.texas.gov
  174. // @connect feature.tnris.org
  175. // @connect fieldstone.orangecountync.gov
  176. // @connect firstmap.gis.delaware.gov
  177. // @connect fremontgis.com
  178. // @connect gasconadegis.integritygis.com
  179. // @connect gateway.maps.rlid.org
  180. // @connect gcgis.guilfordcountync.gov
  181. // @connect geaugarealink.co.geauga.oh.us
  182. // @connect geo.co.butler.pa.us
  183. // @connect geo.co.harrison.ms.us
  184. // @connect geo.dentoncad.com
  185. // @connect geo.forsythco.com
  186. // @connect geo.friscotexas.gov
  187. // @connect geo.oit.ohio.gov
  188. // @connect geo.sandag.org
  189. // @connect geo.sanjoseca.gov
  190. // @connect geo.statcan.gc.ca
  191. // @connect geo.tompkins-co.org
  192. // @connect geo.vbgov.com
  193. // @connect geo1.oit.ohio.gov
  194. // @connect geo2.co.dodge.wi.us
  195. // @connect geodata.hawaii.gov
  196. // @connect geodata.md.gov
  197. // @connect geodata.sarpy.com
  198. // @connect geodataportal.net
  199. // @connect geonb.snb.ca
  200. // @connect geopower.jws.com
  201. // @connect geoweb.martin.fl.us
  202. // @connect geoweb02.ci.richmond.ca.us
  203. // @connect gis-2.warrencountyny.gov
  204. // @connect gis-server.co.becker.mn.us
  205. // @connect gis-server.co.montezuma.co.us
  206. // @connect gis.aacounty.org
  207. // @connect gis.abilenetx.com
  208. // @connect gis.adamscounty.org
  209. // @connect gis.addisontx.gov
  210. // @connect gis.aecomonline.net
  211. // @connect gis.allegancounty.org
  212. // @connect gis.allencountyohio.com
  213. // @connect gis.apachejunctionaz.gov
  214. // @connect gis.arapahoegov.com
  215. // @connect gis.arkansas.gov
  216. // @connect gis.arlingtonva.us
  217. // @connect gis.ashecountygov.com
  218. // @connect gis.ashevillenc.gov
  219. // @connect gis.atlantaga.gov
  220. // @connect gis.auburnalabama.org
  221. // @connect gis.auglaizecounty.org
  222. // @connect gis.azdot.gov
  223. // @connect gis.bakersfieldcity.us
  224. // @connect gis.baycountyfl.gov
  225. // @connect gis.beaufortcountysc.gov
  226. // @connect gis.beaumonttexas.gov
  227. // @connect gis.belmont.gov
  228. // @connect gis.bentoncountyar.gov
  229. // @connect gis.berkeleycountysc.gov
  230. // @connect gis.bgky.org
  231. // @connect gis.bigstonecounty.gov
  232. // @connect gis.bladenco.org
  233. // @connect gis.blairco.org
  234. // @connect gis.blm.gov
  235. // @connect gis.blueearthcountymn.gov
  236. // @connect gis.bransonmo.gov
  237. // @connect gis.brevardfl.gov
  238. // @connect gis.browncountywi.gov
  239. // @connect gis.buncombecounty.org
  240. // @connect gis.burkenc.org
  241. // @connect gis.burleighco.com
  242. // @connect gis.buttecounty.net
  243. // @connect gis.caldwellcountync.org
  244. // @connect gis.calhouncounty.org
  245. // @connect gis.campbellca.gov
  246. // @connect gis.carboncounty.com
  247. // @connect gis.cayugacounty.us
  248. // @connect gis.cccounty.us
  249. // @connect gis.ccgisonline.com
  250. // @connect gis.ccgov.net
  251. // @connect gis.ccpa.net
  252. // @connect gis.cedarhilltx.com
  253. // @connect gis.cherokeega.com
  254. // @connect gis.chippewa.mn
  255. // @connect gis.chisagocountymn.gov
  256. // @connect gis.ci.janesville.wi.us
  257. // @connect gis.ci.mcminnville.or.us
  258. // @connect gis.ci.waco.tx.us
  259. // @connect gis.citruspa.org
  260. // @connect gis.cityofaikensc.gov
  261. // @connect gis.cityofberkeley.info
  262. // @connect gis.cityofboston.gov
  263. // @connect gis.cityofdenton.com
  264. // @connect gis.cityofirvine.org
  265. // @connect gis.cityofmiddletown.com
  266. // @connect gis.cityofmoore.com
  267. // @connect gis.cityofsanmateo.org
  268. // @connect gis.cityofwestsacramento.org
  269. // @connect gis.clevelandtn.gov
  270. // @connect gis.cmpdd.org
  271. // @connect gis.co.benton.or.us
  272. // @connect gis.co.berks.pa.us
  273. // @connect gis.co.carlton.mn.us
  274. // @connect gis.co.carver.mn.us
  275. // @connect gis.co.clarion.pa.us
  276. // @connect gis.co.cumberland.nc.us
  277. // @connect gis.co.douglas.or.us
  278. // @connect gis.co.eau-claire.wi.us
  279. // @connect gis.co.fairfield.oh.us
  280. // @connect gis.co.fillmore.mn.us
  281. // @connect gis.co.grand.co.us
  282. // @connect gis.co.grant.mn.us
  283. // @connect gis.co.grant.wi.gov
  284. // @connect gis.co.green-lake.wi.us
  285. // @connect gis.co.holmes.oh.us
  286. // @connect gis.co.hubbard.mn.us
  287. // @connect gis.co.isanti.mn.us
  288. // @connect gis.co.josephine.or.us
  289. // @connect gis.co.kittitas.wa.us
  290. // @connect gis.co.linn.or.us
  291. // @connect gis.co.mille-lacs.mn.us
  292. // @connect gis.co.nezperce.id.us
  293. // @connect gis.co.oneida.wi.us
  294. // @connect gis.co.pepin.wi.us
  295. // @connect gis.co.pierce.wi.us
  296. // @connect gis.co.polk.mn.us
  297. // @connect gis.co.richland.wi.us
  298. // @connect gis.co.roseau.mn.us
  299. // @connect gis.co.sangamon.il.us
  300. // @connect gis.co.sauk.wi.us
  301. // @connect gis.co.sherburne.mn.us
  302. // @connect gis.co.stearns.mn.us
  303. // @connect gis.co.stevens.mn.us
  304. // @connect gis.co.tuscarawas.oh.us
  305. // @connect gis.co.wadena.mn.us
  306. // @connect gis.co.waseca.mn.us
  307. // @connect gis.co.waushara.wi.us
  308. // @connect gis.co.wood.wi.us
  309. // @connect gis.co.ym.mn.gov
  310. // @connect gis.colorado.gov
  311. // @connect gis.coloradosprings.gov
  312. // @connect gis.columbiacountyga.gov
  313. // @connect gis.columbiacountymaps.com
  314. // @connect gis.columbiasc.gov
  315. // @connect gis.columbusga.org
  316. // @connect gis.concordnh.gov
  317. // @connect gis.cookeville-tn.org
  318. // @connect gis.corvallisoregon.gov
  319. // @connect gis.cosb.us
  320. // @connect gis.countyofriverside.us
  321. // @connect gis.cowleycounty.org
  322. // @connect gis.cranstonri.org
  323. // @connect gis.cravencountync.gov
  324. // @connect gis.crcog.org
  325. // @connect gis.crookcounty.wy.gov
  326. // @connect gis.crowwing.us
  327. // @connect gis.cstx.gov
  328. // @connect gis.danville-va.gov
  329. // @connect gis.dauphincounty.org
  330. // @connect gis.deerparktx.gov
  331. // @connect gis.dekalbcountyga.gov
  332. // @connect gis.delcopa.gov
  333. // @connect gis.dentoncounty.gov
  334. // @connect gis.districtiii.org
  335. // @connect gis.dogis.org
  336. // @connect gis.donaanacounty.org
  337. // @connect gis.dot.nh.gov
  338. // @connect gis.dot.nv.gov
  339. // @connect gis.dot.state.oh.us
  340. // @connect gis.douglascountyks.org
  341. // @connect gis.dubuquecounty.us
  342. // @connect gis.dupageco.org
  343. // @connect gis.duplincountync.com
  344. // @connect gis.dutchessny.gov
  345. // @connect gis.eastgreenwichri.com
  346. // @connect gis.ebparks.org
  347. // @connect gis.edgecombecountync.gov
  348. // @connect gis.edmondok.gov
  349. // @connect gis.elkocountynv.net
  350. // @connect gis.elpasotexas.gov
  351. // @connect gis.emmetcounty.org
  352. // @connect gis.eriecountypa.gov
  353. // @connect gis.fortlauderdale.gov
  354. // @connect gis.franklincountyohio.gov
  355. // @connect gis.fultoncountyoh.com
  356. // @connect gis.fwb.org
  357. // @connect gis.fwp.mt.gov
  358. // @connect gis.gallatin.mt.gov
  359. // @connect gis.gallupnm.us
  360. // @connect gis.garrettcounty.org
  361. // @connect gis.gastongov.com
  362. // @connect gis.gcrc.org
  363. // @connect gis.gilacountyaz.gov
  364. // @connect gis.gocolumbiamo.com
  365. // @connect gis.goshencounty.org
  366. // @connect gis.gptx.org
  367. // @connect gis.grandcountyutah.net
  368. // @connect gis.greenecountyohio.gov
  369. // @connect gis.greenegovernment.com
  370. // @connect gis.greensboro-nc.gov
  371. // @connect gis.gscplanning.com
  372. // @connect gis.hardeecounty.net
  373. // @connect gis.harnett.org
  374. // @connect gis.hartford.gov
  375. // @connect gis.hawaiicounty.gov
  376. // @connect gis.hcpafl.org
  377. // @connect gis.hennepin.us
  378. // @connect gis.huntingtonbeachca.gov
  379. // @connect gis.iberiagov.net
  380. // @connect gis.indot.in.gov
  381. // @connect gis.interdev.com
  382. // @connect gis.iowadot.gov
  383. // @connect gis.itd.idaho.gov
  384. // @connect gis.jacksonnc.org
  385. // @connect gis.jccal.org
  386. // @connect gis.johnson-county.com
  387. // @connect gis.johnsoncitytn.org
  388. // @connect gis.kalamazoocity.org
  389. // @connect gis.kanawhacountyassessor.com
  390. // @connect gis.kaufmancounty.net
  391. // @connect gis.kcgov.us
  392. // @connect gis.kcmn.us
  393. // @connect gis.kentcountyde.gov
  394. // @connect gis.kentcountymi.gov
  395. // @connect gis.kleinfelder.com
  396. // @connect gis.lacrossecounty.org
  397. // @connect gis.lafayettecountywi.org
  398. // @connect gis.lakecountyfl.gov
  399. // @connect gis.lakecountyohio.gov
  400. // @connect gis.lapazcountyaz.org
  401. // @connect gis.laplata.co.us
  402. // @connect gis.lasallecounty.org
  403. // @connect gis.latah.id.us
  404. // @connect gis.leecountyil.com
  405. // @connect gis.lehighcounty.org
  406. // @connect gis.leoc.net
  407. // @connect gis.littleelm.org
  408. // @connect gis.livingstoncounty.us
  409. // @connect gis.lja.com
  410. // @connect gis.lojic.org
  411. // @connect gis.losalamosnm.us
  412. // @connect gis.luzernecounty.org
  413. // @connect gis.lyco.org
  414. // @connect gis.lyon-county.org
  415. // @connect gis.macombgov.org
  416. // @connect gis.maconnc.org
  417. // @connect gis.maderacounty.com
  418. // @connect gis.marinpublic.com
  419. // @connect gis.marionfl.org
  420. // @connect gis.masoncountywa.gov
  421. // @connect gis.massdot.state.ma.us
  422. // @connect gis.mbakerintl.com
  423. // @connect gis.mcgtn.org
  424. // @connect gis.mckeancountypa.gov
  425. // @connect gis.mcohio.org
  426. // @connect gis.mendocinocounty.org
  427. // @connect gis.mercercountypa.gov
  428. // @connect gis.mesaaz.gov
  429. // @connect gis.mifflincountypa.gov
  430. // @connect gis.minnehahacounty.org
  431. // @connect gis.miottawa.org
  432. // @connect gis.missoulacounty.us
  433. // @connect gis.modestogov.com
  434. // @connect gis.mono.ca.gov
  435. // @connect gis.montgomeryal.gov
  436. // @connect gis.moorecountync.gov
  437. // @connect gis.mytoddcounty.com
  438. // @connect gis.napa.ca.gov
  439. // @connect gis.nashcountync.gov
  440. // @connect gis.nassaucountyny.gov
  441. // @connect gis.nccde.org
  442. // @connect gis.ne.gov
  443. // @connect gis.neccog.org
  444. // @connect gis.newedgeservices.com
  445. // @connect gis.newhavenct.gov
  446. // @connect gis.nhcgov.com
  447. // @connect gis.niagaracounty.com
  448. // @connect gis.nola.gov
  449. // @connect gis.norrycopa.net
  450. // @connect gis.northamptoncounty.org
  451. // @connect gis.odot.state.or.us
  452. // @connect gis.ohiodnr.gov
  453. // @connect gis.okc.gov
  454. // @connect gis.orangecountygov.com
  455. // @connect gis.orangecountyva.gov
  456. // @connect gis.osceola.org
  457. // @connect gis.outagamie.org
  458. // @connect gis.owensboro.org
  459. // @connect gis.pandai.com
  460. // @connect gis.pendercountync.gov
  461. // @connect gis.pendoreilleco.org
  462. // @connect gis.penndot.gov
  463. // @connect gis.penndot.pa.gov
  464. // @connect gis.peoriacounty.gov
  465. // @connect gis.personcountync.gov
  466. // @connect gis.pgatlas.com
  467. // @connect gis.pikepa.org
  468. // @connect gis.pinal.gov
  469. // @connect gis.pittcountync.gov
  470. // @connect gis.pittsburgca.gov
  471. // @connect gis.polk-county.net
  472. // @connect gis.popecountymn.gov
  473. // @connect gis.port-orange.org
  474. // @connect gis.pottcounty-ia.gov
  475. // @connect gis.putnam-fl.com
  476. // @connect gis.qac.org
  477. // @connect gis.randolphcountync.gov
  478. // @connect gis.rapides911.org
  479. // @connect gis.rcgov.org
  480. // @connect gis.renvillecountymn.com
  481. // @connect gis.rileycountyks.gov
  482. // @connect gis.rocklin.ca.us
  483. // @connect gis.rowancountync.gov
  484. // @connect gis.rrnm.gov
  485. // @connect gis.rtcsnv.com
  486. // @connect gis.rutherfordcountync.gov
  487. // @connect gis.salkeiz.k12.or.us
  488. // @connect gis.sanjuanco.com
  489. // @connect gis.santa-clarita.com
  490. // @connect gis.santacruzcounty.us
  491. // @connect gis.santamonica.gov
  492. // @connect gis.sawyerwi.org
  493. // @connect gis.sccwi.gov
  494. // @connect gis.shastacounty.gov
  495. // @connect gis.sheboygancounty.com
  496. // @connect gis.shelbycountytn.gov
  497. // @connect gis.showmeboone.com
  498. // @connect gis.siouxfalls.gov
  499. // @connect gis.slocounty.ca.gov
  500. // @connect gis.sncoapps.us
  501. // @connect gis.southkingstownri.com
  502. // @connect gis.steele.mn
  503. // @connect gis.stlouiscountymn.gov
  504. // @connect gis.sullivanny.us
  505. // @connect gis.sumtercountyfl.gov
  506. // @connect gis.surryinfo.net
  507. // @connect gis.talbotdes.org
  508. // @connect gis.tazewell.com
  509. // @connect gis.texoma.cog.tx.us
  510. // @connect gis.thecolonytx.gov
  511. // @connect gis.thomsonreuters.com
  512. // @connect gis.transportation.wv.gov
  513. // @connect gis.transylvaniacounty.org
  514. // @connect gis.traviscountytx.gov
  515. // @connect gis.tularecounty.ca.gov
  516. // @connect gis.ucdavis.edu
  517. // @connect gis.ulstercountyny.gov
  518. // @connect gis.unioncountync.gov
  519. // @connect gis.vernon-ct.gov
  520. // @connect gis.victorvilleca.gov
  521. // @connect gis.warrensburg-mo.com
  522. // @connect gis.washingtoncountyny.gov
  523. // @connect gis.watertownwi.gov
  524. // @connect gis.waukesha-wi.gov
  525. // @connect gis.waukeshacounty.gov
  526. // @connect gis.weatherfordtx.gov
  527. // @connect gis.westmorelandcountypa.gov
  528. // @connect gis.westplains.net
  529. // @connect gis.whatcomcounty.us
  530. // @connect gis.whitfieldcountyga.com
  531. // @connect gis.wilco.org
  532. // @connect gis.wilkescounty.net
  533. // @connect gis.willcountyillinois.com
  534. // @connect gis.wilson-co.com
  535. // @connect gis.wilsonnc.org
  536. // @connect gis.wiu.edu
  537. // @connect gis.worldviewsolutions.com
  538. // @connect gis.wyo.gov
  539. // @connect gis.yadkincountync.gov
  540. // @connect gis.yanceycountync.org
  541. // @connect gis.yavapaiaz.gov
  542. // @connect gis.yolocounty.gov
  543. // @connect gis.yolocounty.org
  544. // @connect gis.yuba.org
  545. // @connect gis1.acimap.us
  546. // @connect gis1.georgetowncountysc.org
  547. // @connect gis1.hamiltoncounty.in.gov
  548. // @connect gis11.cama.io
  549. // @connect gis11.services.ncdot.gov
  550. // @connect gis12.cookcountyil.gov
  551. // @connect gis2.arlingtontx.gov
  552. // @connect gis2.arlingtonva.us
  553. // @connect gis2.co.dakota.mn.us
  554. // @connect gis2.co.marathon.wi.us
  555. // @connect gis2.co.ozaukee.wi.us
  556. // @connect gis2.erie.gov
  557. // @connect gis2.gworks.com
  558. // @connect gis2.idaho.gov
  559. // @connect gis2.lawrenceks.org
  560. // @connect gis2.orangeburgcounty.org
  561. // @connect gis2.sandyspringsga.gov
  562. // @connect gis2.totaland.com
  563. // @connect gis21svweb.lincolnparish.org
  564. // @connect gis3.cdmsmithgis.com
  565. // @connect gis3.cmpdd.org
  566. // @connect gis3.gwinnettcounty.com
  567. // @connect gis3.gworks.com
  568. // @connect gis3.montgomerycountymd.gov
  569. // @connect gis3.richmondnc.com
  570. // @connect gis4.montgomerycountymd.gov
  571. // @connect gisago-qa.mcgi.state.mi.us
  572. // @connect gisago.mcgi.state.mi.us
  573. // @connect gisapp.adcogov.org
  574. // @connect gisapp.mahoningcountyoh.gov
  575. // @connect gisapps.cityofchicago.org
  576. // @connect gisapps.glendaleca.gov
  577. // @connect gisapps.rileycountyks.gov
  578. // @connect gisapps.wicomicocounty.org
  579. // @connect gisapps1.mapoakland.com
  580. // @connect gisarcweb.jeffersoncountywv.org
  581. // @connect gisccapps.charlestoncounty.org
  582. // @connect gisdata.alleghenycounty.us
  583. // @connect gisdata.dot.ca.gov
  584. // @connect gisdata.farrwestengineering.com
  585. // @connect gisdata.in.gov
  586. // @connect gisdata.jeffersoncountyoh.com
  587. // @connect gisdata.kingcounty.gov
  588. // @connect gisdata.pandai.com
  589. // @connect gisdata.pima.gov
  590. // @connect gisdata.seattle.gov
  591. // @connect gisdemo1.cdmsmith.com
  592. // @connect gisdemo2.cdmsmith.com
  593. // @connect gisentapp01.highpointnc.gov
  594. // @connect gisext.lincoln.ne.gov
  595. // @connect gishost.cdmsmithgis.com
  596. // @connect gisinfo.co.portage.wi.gov
  597. // @connect gisinfo.co.walworth.wi.us
  598. // @connect gisinfo.lawrencevillega.org
  599. // @connect gismap.augustaga.gov
  600. // @connect gismap.cityofboise.org
  601. // @connect gismap.co.juneau.wi.us
  602. // @connect gismap.co.marshall.mn.us
  603. // @connect gismap.co.norman.mn.us
  604. // @connect gismap.co.red-lake.mn.us
  605. // @connect gismapping.stafford.va.us
  606. // @connect gismaps.cityofboise.org
  607. // @connect gismaps.cityofgreer.org
  608. // @connect gismaps.co.cerro-gordo.ia.us
  609. // @connect gismaps.coconino.az.gov
  610. // @connect gismaps.columbiapa.org
  611. // @connect gismaps.flower-mound.com
  612. // @connect gismaps.fultoncountyga.gov
  613. // @connect gismaps.hctra.org
  614. // @connect gismaps.kingcounty.gov
  615. // @connect gismaps.redwoodcity.org
  616. // @connect gismaps.sedgwickcounty.org
  617. // @connect gismaps.wichita.gov
  618. // @connect gismapserver.leegov.com
  619. // @connect gismo.spokanecounty.org
  620. // @connect gisonline.greenvillenc.gov
  621. // @connect gisp.co.genesee.ny.us
  622. // @connect gisp.mcgi.state.mi.us
  623. // @connect gisportal.champaignil.gov
  624. // @connect gisportal.co.calaveras.ca.us
  625. // @connect gisportal.co.madison.il.us
  626. // @connect gisportal.co.warren.oh.us
  627. // @connect gisportal.dorchestercounty.net
  628. // @connect gisportal.dot.ct.gov
  629. // @connect gisportal.fnsb.gov
  630. // @connect gisportal.ircgov.com
  631. // @connect gisportal.ontarioca.gov
  632. // @connect gisportal.stocktonca.gov
  633. // @connect gisportal.stpgov.org
  634. // @connect gispro.porterco.org
  635. // @connect gisprod10.co.fresno.ca.us
  636. // @connect gisprodops.chesco.org
  637. // @connect gispub.cityofaspen.com
  638. // @connect gispub.co.washington.or.us
  639. // @connect gispublic.co.lake.ca.us
  640. // @connect gispw.coloradosprings.gov
  641. // @connect gisrevprxy.seattle.gov
  642. // @connect giss3.cmpdd.org
  643. // @connect gisserver.christiancountymo.gov
  644. // @connect gisservice.cityofmesquite.com
  645. // @connect gisservicemt.gov
  646. // @connect gisservices.chathamcountync.gov
  647. // @connect gisservices.chathamnc.org
  648. // @connect gisservices.co.anoka.mn.us
  649. // @connect gisservices.douglasnv.us
  650. // @connect gisservices.its.ny.gov
  651. // @connect gisservices.oakgov.com
  652. // @connect gisservices2.suffolkcountyny.gov
  653. // @connect gissites4.centrecountypa.gov
  654. // @connect gissvr.watgov.org
  655. // @connect gisweb-18.ci.killeen.tx.us
  656. // @connect gisweb-adapters.bcpa.net
  657. // @connect gisweb.albemarle.org
  658. // @connect gisweb.birminghamal.gov
  659. // @connect gisweb.casscountynd.gov
  660. // @connect gisweb.champaignil.gov
  661. // @connect gisweb.ci.manteca.ca.us
  662. // @connect gisweb.co.aitkin.mn.us
  663. // @connect gisweb.co.mower.mn.us
  664. // @connect gisweb.co.wilkin.mn.us
  665. // @connect gisweb.fdlco.wi.gov
  666. // @connect gisweb.fortbendcountytx.gov
  667. // @connect gisweb.jeffcowa.us
  668. // @connect gisweb.miamidade.gov
  669. // @connect gisweb.pwcva.gov
  670. // @connect gisweb.wycokck.org
  671. // @connect gisweb2014.gordoncounty.org
  672. // @connect giswww.westchestergov.com
  673. // @connect git.co.tioga.ny.us
  674. // @connect gmdnags.colliercountyfl.gov
  675. // @connect grant.co.jefferson.id.us
  676. // @connect gweb01.co.olmsted.mn.us
  677. // @connect harpergis.integritygis.com
  678. // @connect harrisonms.geopowered.com
  679. // @connect haslet.halff.com
  680. // @connect hazards.fema.gov
  681. // @connect hdgis.ingham.org
  682. // @connect heartlandmpo.com
  683. // @connect helenamontanamaps.org
  684. // @connect henrygis.integritygis.com
  685. // @connect hgis.hialeahfl.gov
  686. // @connect holtgis.integritygis.com
  687. // @connect host.cdmsmithgis.com
  688. // @connect hostingdata2.tighebond.com
  689. // @connect hostingdata3.tighebond.com
  690. // @connect huntsvillegis.com
  691. // @connect ifgis.idahofallsidaho.gov
  692. // @connect ihost.tularecounty.ca.gov
  693. // @connect imap.klickitatcounty.org
  694. // @connect ims.districtiii.org
  695. // @connect intervector.leoncountyfl.gov
  696. // @connect iowagis.integritygis.com
  697. // @connect ira.property-appraiser.org
  698. // @connect jeffarcgis.jeffersoncountywi.gov
  699. // @connect joplingis.org
  700. // @connect k3gis.com
  701. // @connect kanplan.ksdot.gov
  702. // @connect kcgis.kentoncounty.org
  703. // @connect kenhagis.kenha.co.ke
  704. // @connect kygisserver.ky.gov
  705. // @connect lacledegis.integritygis.com
  706. // @connect lafayettegis.integritygis.com
  707. // @connect landrecords.greencountywi.org
  708. // @connect lawrencegis.integritygis.com
  709. // @connect lcapps.co.lucas.oh.us
  710. // @connect lcmaps.lanecounty.org
  711. // @connect lee-arcgis.leecountync.gov
  712. // @connect lincolngis.integritygis.com
  713. // @connect linngis.integritygis.com
  714. // @connect lio.milwaukeecountywi.gov
  715. // @connect livingstongis.integritygis.com
  716. // @connect location.cabarruscounty.us
  717. // @connect logis.loudoun.gov
  718. // @connect loraincountyauditor.com
  719. // @connect lrs.co.columbia.wi.us
  720. // @connect lucity.sbpg.net
  721. // @connect macongis.integritygis.com
  722. // @connect madison.rexburg.org
  723. // @connect madisongis.cityofalbany.net
  724. // @connect manitowocmaps.info
  725. // @connect map.claycountymn.gov
  726. // @connect map.co.clear-creek.co.us
  727. // @connect map.co.clearwater.mn.us
  728. // @connect map.co.merced.ca.us
  729. // @connect map.co.thurston.wa.us
  730. // @connect map.co.trempealeau.wi.us
  731. // @connect map.coppelltx.gov
  732. // @connect map.eaglecounty.us
  733. // @connect map.newberrycounty.net
  734. // @connect map.opkansas.org
  735. // @connect map.pikepass.com
  736. // @connect map.stclairco.com
  737. // @connect map.sussexcountyde.gov
  738. // @connect map.wyoroad.info
  739. // @connect map9.incog.org
  740. // @connect mapd.kcmo.org
  741. // @connect mapdata.baytown.org
  742. // @connect mapdata.lasvegasnevada.gov
  743. // @connect mapit.fortworthtexas.gov
  744. // @connect mapitwest.fortworthtexas.gov
  745. // @connect mapping.adamscountypa.gov
  746. // @connect mapping.kenoshacountywi.gov
  747. // @connect mapping.mitchellcounty.org
  748. // @connect mapping.modot.org
  749. // @connect maps.adaok.com
  750. // @connect maps.alexandercountync.gov
  751. // @connect maps.alexandriava.gov
  752. // @connect maps.austintexas.gov
  753. // @connect maps.bannockcounty.us
  754. // @connect maps.bayfieldcounty.wi.gov
  755. // @connect maps.bcad.org
  756. // @connect maps.berkeleywv.org
  757. // @connect maps.boonecountyil.org
  758. // @connect maps.bossierparishgis.org
  759. // @connect maps.bouldercounty.org
  760. // @connect maps.brazoriacountytx.gov
  761. // @connect maps.brla.gov
  762. // @connect maps.brookhavenga.gov
  763. // @connect maps.bryantx.gov
  764. // @connect maps.burlesontx.com
  765. // @connect maps.butlercountyauditor.org
  766. // @connect maps.canyonco.org
  767. // @connect maps.capturecama.com
  768. // @connect maps.casperwy.gov
  769. // @connect maps.chautauquacounty.com
  770. // @connect maps.cherokeecounty-nc.gov
  771. // @connect maps.ci.longmont.co.us
  772. // @connect maps.ci.nacogdoches.tx.us
  773. // @connect maps.cityhs.net
  774. // @connect maps.cityofconroe.org
  775. // @connect maps.cityofhenderson.com
  776. // @connect maps.cityofls.net
  777. // @connect maps.cityofmadison.com
  778. // @connect maps.cityofmobile.org
  779. // @connect maps.cityofsherman.com
  780. // @connect maps.cityoftulsa.org
  781. // @connect maps.cityofwaterlooiowa.com
  782. // @connect maps.clarkcountynv.gov
  783. // @connect maps.claycountygov.com
  784. // @connect maps.clermontauditor.org
  785. // @connect maps.clintoncountypa.com
  786. // @connect maps.co.blaine.id.us
  787. // @connect maps.co.forsyth.nc.us
  788. // @connect maps.co.goodhue.mn.us
  789. // @connect maps.co.gov
  790. // @connect maps.co.grayson.tx.us
  791. // @connect maps.co.itasca.mn.us
  792. // @connect maps.co.kendall.il.us
  793. // @connect maps.co.kern.ca.us
  794. // @connect maps.co.lincoln.wi.us
  795. // @connect maps.co.palm-beach.fl.us
  796. // @connect maps.co.polk.or.us
  797. // @connect maps.co.pueblo.co.us
  798. // @connect maps.co.ramsey.mn.us
  799. // @connect maps.co.shawano.wi.us
  800. // @connect maps.co.warren.oh.us
  801. // @connect maps.co.washington.mn.us
  802. // @connect maps.co.yellowstone.mt.gov
  803. // @connect maps.coj.net
  804. // @connect maps.collincountytx.gov
  805. // @connect maps.countyofmerced.com
  806. // @connect maps.crc.ga.gov
  807. // @connect maps.ctmetro.org
  808. // @connect maps.dancgis.org
  809. // @connect maps.dcad.org
  810. // @connect maps.delco-gis.org
  811. // @connect maps.deltacountyco.gov
  812. // @connect maps.deschutes.org
  813. // @connect maps.desotocountyms.gov
  814. // @connect maps.dmgov.org
  815. // @connect maps.dotd.la.gov
  816. // @connect maps.douglascountyga.gov
  817. // @connect maps.douglascountywa.net
  818. // @connect maps.dsm.city
  819. // @connect maps.elbertcounty-co.gov
  820. // @connect maps.escpa.org
  821. // @connect maps.etcog.org
  822. // @connect maps.evansvillegis.com
  823. // @connect maps.fayetteville-ar.gov
  824. // @connect maps.fishers.in.us
  825. // @connect maps.flathead.mt.gov
  826. // @connect maps.floridadisaster.org
  827. // @connect maps.frederickcountymd.gov
  828. // @connect maps.fredericksburgva.gov
  829. // @connect maps.garfield-county.com
  830. // @connect maps.garlandtx.gov
  831. // @connect maps.gov.bc.ca
  832. // @connect maps.grcity.us
  833. // @connect maps.groton-ct.gov
  834. // @connect maps.grundyco.org
  835. // @connect maps.hayward-ca.gov
  836. // @connect maps.haywoodnc.net
  837. // @connect maps.highlandvillage.org
  838. // @connect maps.hokecounty.org
  839. // @connect maps.huerfano.us
  840. // @connect maps.huntsvilleal.gov
  841. // @connect maps.iredellcountync.gov
  842. // @connect maps.itos.uga.edu
  843. // @connect maps.jocogov.org
  844. // @connect maps.kytc.ky.gov
  845. // @connect maps.lacity.org
  846. // @connect maps.lagrange-ga.org
  847. // @connect maps.lakecountyil.gov
  848. // @connect maps.laramiecounty.com
  849. // @connect maps.lcwy.org
  850. // @connect maps.lebanontn.org
  851. // @connect maps.lex-co.com
  852. // @connect maps.lexingtonky.gov
  853. // @connect maps.libertymo.gov
  854. // @connect maps.lincolncountysd.org
  855. // @connect maps.linkgis.org
  856. // @connect maps.matsugov.us
  857. // @connect maps.mckinneytexas.org
  858. // @connect maps.meshekgis.com
  859. // @connect maps.miamigov.com
  860. // @connect maps.midlandtexas.gov
  861. // @connect maps.muskegoncountygis.com
  862. // @connect maps.nashville.gov
  863. // @connect maps.ncpafl.com
  864. // @connect maps.nevadacountyca.gov
  865. // @connect maps.nj.gov
  866. // @connect maps.normanok.gov
  867. // @connect maps.northaugustasc.gov
  868. // @connect maps.ocgov.net
  869. // @connect maps.opkansas.org
  870. // @connect maps.orcity.org
  871. // @connect maps.palmcoastgov.com
  872. // @connect maps.parkco.us
  873. // @connect maps.phoenix.gov
  874. // @connect maps.pitkincounty.com
  875. // @connect maps.planogis.org
  876. // @connect maps.pottercountypa.net
  877. // @connect maps.raleighnc.gov
  878. // @connect maps.richlandcountyoh.us
  879. // @connect maps.rutherfordcountytn.gov
  880. // @connect maps.santa-clarita.com
  881. // @connect maps.santabarbaraca.gov
  882. // @connect maps.sccmo.org
  883. // @connect maps.semogis.com
  884. // @connect maps.sfdpw.org
  885. // @connect maps.sgcity.org
  886. // @connect maps.shelbyal.com
  887. // @connect maps.slocity.org
  888. // @connect maps.spartanburgcounty.org
  889. // @connect maps.springfieldmo.gov
  890. // @connect maps.steamboatsprings.net
  891. // @connect maps.stlouisco.com
  892. // @connect maps.swaincountync.gov
  893. // @connect maps.tippecanoe.in.gov
  894. // @connect maps.townofcary.org
  895. // @connect maps.udot.utah.gov
  896. // @connect maps.vcgi.vermont.gov
  897. // @connect maps.ventura.org
  898. // @connect maps.victoriatx.org
  899. // @connect maps.vilascountywi.gov
  900. // @connect maps.vtrans.vermont.gov
  901. // @connect maps.wake.gov
  902. // @connect maps.washco-md.net
  903. // @connect maps.washcowisco.gov
  904. // @connect maps1.eriecounty.oh.gov
  905. // @connect maps1.larimer.org
  906. // @connect maps11.eriecounty.oh.gov
  907. // @connect maps2.bgadd.org
  908. // @connect maps2.cattco.org
  909. // @connect maps2.ci.euless.tx.us
  910. // @connect maps2.columbus.gov
  911. // @connect maps2.dcgis.dc.gov
  912. // @connect maps2.san-marcos.net
  913. // @connect maps2.timmons.com
  914. // @connect maps2.tucsonaz.gov
  915. // @connect maps2.vcgov.org
  916. // @connect maps6.stlouis-mo.gov
  917. // @connect maps7.eriecounty.oh.gov
  918. // @connect maps8.eriecounty.oh.gov
  919. // @connect mapsdev.hamiltontn.gov
  920. // @connect mapserv.cityofloveland.org
  921. // @connect mapserv.mesquitenv.gov
  922. // @connect mapservice.nmstatelands.org
  923. // @connect mapservices.gis.saccounty.net
  924. // @connect mapservices.gov.yk.ca
  925. // @connect mapservices.pasda.psu.edu
  926. // @connect mapservices.santacruzcountyaz.gov
  927. // @connect mapservices.sccgov.org
  928. // @connect mapservices.weather.noaa.gov
  929. // @connect mapservices1.jeffco.us
  930. // @connect mapservices2.jeffco.us
  931. // @connect mariesgis.integritygis.com
  932. // @connect mariongis.integritygis.com
  933. // @connect mcdonaldgis.integritygis.com
  934. // @connect mcgis.mesacounty.us
  935. // @connect mcgis.mohave.gov
  936. // @connect mcgis4.monroecounty-fl.gov
  937. // @connect mcmap.montrosecounty.net
  938. // @connect mcogis.co.marion.oh.us
  939. // @connect millergis.integritygis.com
  940. // @connect mms.hursttx.gov
  941. // @connect mndotgis.dot.state.mn.us
  942. // @connect moberlygis.integritygis.com
  943. // @connect mobile.alamedaca.gov
  944. // @connect moniteaugis.integritygis.com
  945. // @connect morgangis.integritygis.com
  946. // @connect msdisweb.missouri.edu
  947. // @connect mycity2.houstontx.gov
  948. // @connect navigator.state.or.us
  949. // @connect ndgishub.nd.gov
  950. // @connect newtongis.integritygis.com
  951. // @connect nhgeodata.unh.edu
  952. // @connect northlake.halff.com
  953. // @connect nspdcwebsrv.csuchico.edu
  954. // @connect oak.co.lake-of-the-woods.mn.us
  955. // @connect oc17maps.co.oconto.wi.us
  956. // @connect ocgis4.ocfl.net
  957. // @connect oncorng.co.ontario.ny.us
  958. // @connect operationserver.ci.henderson.nc.us
  959. // @connect orfmaps.norfolk.gov
  960. // @connect osagegis.integritygis.com
  961. // @connect pagis.org
  962. // @connect pamap.putnam-fl.gov
  963. // @connect parcelmap.ashtabulacounty.us
  964. // @connect parcels.rsdigital.com
  965. // @connect parcelviewer.geodecisions.com
  966. // @connect pascogis.pascocountyfl.net
  967. // @connect pgis.plantation.org
  968. // @connect phelpsgis.integritygis.com
  969. // @connect polaris2.mecklenburgcountync.gov
  970. // @connect polkgis.integritygis.com
  971. // @connect portal.carolinabeach.org
  972. // @connect portal.carson.org
  973. // @connect portal.henrico.us
  974. // @connect programs.iowadnr.gov
  975. // @connect propaccess.wadtx.com
  976. // @connect propertyviewer.andersoncountysc.org
  977. // @connect proxy2.roktech.net
  978. // @connect psportal.harrisoncountywv.com
  979. // @connect pubgis.ci.lubbock.tx.us
  980. // @connect public.co.wasco.or.us
  981. // @connect public1.co.waupaca.wi.us
  982. // @connect publicmap01.co.st-clair.il.us
  983. // @connect publicmaps.txkusa.org
  984. // @connect pulaskigis.integritygis.com
  985. // @connect putnamcountygis.com
  986. // @connect pwmaps.cityofloveland.org
  987. // @connect pwmaps.reno.gov
  988. // @connect rallsgis.integritygis.com
  989. // @connect raygis.integritygis.com
  990. // @connect rc-arcgis01.co.rice.mn.us
  991. // @connect rdsgis.nctgis.nct911.org
  992. // @connect renogis3.renogov.org
  993. // @connect roads.udot.utah.gov
  994. // @connect rockgis.co.rock.wi.us
  995. // @connect rockgis.rockfordil.gov
  996. // @connect romefloyd.agdmaps.com
  997. // @connect rptsgisweb.oswegocounty.com
  998. // @connect salinegis.integritygis.com
  999. // @connect saludacountysc.net
  1000. // @connect scgis.summitoh.net
  1001. // @connect scgisa.starkcountyohio.gov
  1002. // @connect sdgis.sd.gov
  1003. // @connect secure.boonecountygis.com
  1004. // @connect sedaliagis.integritygis.com
  1005. // @connect see-eldorado.edcgov.us
  1006. // @connect seminolearcgis.seminolecountyfl.gov
  1007. // @connect server.boundarycountyid.org
  1008. // @connect server1.mapxpress.net
  1009. // @connect server2.mapxpress.net
  1010. // @connect services.arcgis.com
  1011. // @connect services.gis.ca.gov
  1012. // @connect services.gisqatar.org.qa
  1013. // @connect services.mh-gis.com
  1014. // @connect services.nconemap.gov
  1015. // @connect services.putnamco.org
  1016. // @connect services.sagis.org
  1017. // @connect services.wvgis.wvu.edu
  1018. // @connect services1.arcgis.com
  1019. // @connect services2.arcgis.com
  1020. // @connect services2.integritygis.com
  1021. // @connect services3.arcgis.com
  1022. // @connect services5.arcgis.com
  1023. // @connect services6.arcgis.com
  1024. // @connect services7.arcgis.com
  1025. // @connect services8.arcgis.com
  1026. // @connect services9.arcgis.com
  1027. // @connect showlowmaps.com
  1028. // @connect skyview.hornershifrin.com
  1029. // @connect slcgis.stlucieco.gov
  1030. // @connect slco.org
  1031. // @connect smgis.sanmarcostx.gov
  1032. // @connect smithvillegis.integritygis.com
  1033. // @connect smpesri.scdot.org
  1034. // @connect socogis.sonomacounty.ca.gov
  1035. // @connect spatial.gishost.com
  1036. // @connect spatial.jacksoncountyor.gov
  1037. // @connect spatialags.vhb.com
  1038. // @connect stclairgis.integritygis.com
  1039. // @connect stmgis.stmarysmd.com
  1040. // @connect stokescountygis.com
  1041. // @connect stonegis.integritygis.com
  1042. // @connect svr4.sumtercountysc.org
  1043. // @connect tcgisws.tooeleco.gov
  1044. // @connect tcweb.co.teller.co.us
  1045. // @connect tfportal.tfid.org
  1046. // @connect tharcgis2.thewoodlands-tx.gov
  1047. // @connect tigerweb.geo.census.gov
  1048. // @connect tiogagis.tiogacountypa.us
  1049. // @connect tnmap.tn.gov
  1050. // @connect tpwd.texas.gov
  1051. // @connect tsc-gis-ags101a.schneidercorp.com
  1052. // @connect twu.newedgeservices.com
  1053. // @connect utility.arcgis.com
  1054. // @connect vernongis.integritygis.com
  1055. // @connect vginmaps.vdem.virginia.gov
  1056. // @connect vtransmap01.aot.state.vt.us
  1057. // @connect wallawallagis.com
  1058. // @connect warrengis.integritygis.com
  1059. // @connect warrensburggis.integritygis.com
  1060. // @connect wcg-gisweb.co.worcester.md.us
  1061. // @connect wcgis3.co.winnebago.wi.us
  1062. // @connect wcgisweb.washoecounty.us
  1063. // @connect wcoh.geopowered.com
  1064. // @connect web.binghamid.gov
  1065. // @connect web2.co.ottertail.mn.us
  1066. // @connect web2.kcsgis.com
  1067. // @connect web3.kcsgis.com
  1068. // @connect web4.kcsgis.com
  1069. // @connect web5.kcsgis.com
  1070. // @connect webadaptor.glynncounty-ga.gov
  1071. // @connect webgis.bedfordcountyva.gov
  1072. // @connect webgis.co.davidson.nc.us
  1073. // @connect webgis.co.humboldt.ca.us
  1074. // @connect webgis.durhamnc.gov
  1075. // @connect webgis.lafayetteassessor.com
  1076. // @connect webgis.providenceri.gov
  1077. // @connect webgis.waterburyct.org
  1078. // @connect webgis.yorbalindaca.gov
  1079. // @connect webmap.co.jackson.ms.us
  1080. // @connect webmap.jeffparish.net
  1081. // @connect webmap.trueautomation.com
  1082. // @connect webmaps.elkgrovecity.org
  1083. // @connect webmaps.sjcounty.net
  1084. // @connect webportal.co.marquette.wi.us
  1085. // @connect websrv31.clallamcountywa.gov
  1086. // @connect webstergis.integritygis.com
  1087. // @connect wfs.ksdot.org
  1088. // @connect wfs.schneidercorp.com
  1089. // @connect ws.lioservices.lrc.gov.on.ca
  1090. // @connect wvsams.mapwv.org
  1091. // @connect ww1.bucoks.com
  1092. // @connect www.1stdistrict.org
  1093. // @connect www.adacountyassessor.org
  1094. // @connect www.adamscountyarcserver.com
  1095. // @connect www.ancgis.com
  1096. // @connect www.bartowgis.org
  1097. // @connect www.bcgis.com
  1098. // @connect www.bcpao.us
  1099. // @connect www.centralilmaps.com
  1100. // @connect www.cmbgis.com
  1101. // @connect www.colesco.illinois.gov
  1102. // @connect www.ctgismaps2.ct.gov
  1103. // @connect www.denvergov.org
  1104. // @connect www.dmcwebgis.com
  1105. // @connect www.efsedge.com
  1106. // @connect www.finneycountygis.com
  1107. // @connect www.franklinmo.net
  1108. // @connect www.gcgis.org
  1109. // @connect www.gfgis.com
  1110. // @connect www.gis.hctx.net
  1111. // @connect www.gis.sjcfl.us
  1112. // @connect www.gismidwest.com
  1113. // @connect www.gisonline.ms.gov
  1114. // @connect www.greenwoodsc.gov
  1115. // @connect www.hernandocountygis-florida.us
  1116. // @connect www.hogarcmaps.org
  1117. // @connect www.horrycountysc.gov
  1118. // @connect www.landmarkgeospatial.com
  1119. // @connect www.laurenscountygis.org
  1120. // @connect www.mcgisweb.org
  1121. // @connect www.mchenrycountygis.org
  1122. // @connect www.midmogis.org
  1123. // @connect www.monroegis.org
  1124. // @connect www.mymanatee.org
  1125. // @connect www.ocgis.com
  1126. // @connect www.portlandmaps.com
  1127. // @connect www.sciotocountyengineer.org
  1128. // @connect www.semogis.com
  1129. // @connect www.sgrcmaps.com
  1130. // @connect www.sjmap.org
  1131. // @connect www.skagitcounty.net
  1132. // @connect www.smithcountymapsite.org
  1133. // @connect www.tgisites.com
  1134. // @connect www.valorgis.com
  1135. // @connect www.waynecounty.com
  1136. // @connect www.webgis.net
  1137. // @connect www1.cityofwebster.com
  1138. // @connect www2.ci.lancaster.oh.us
  1139. // @connect www2.pottcounty.org
  1140. // @connect www3.multco.us
  1141. // @connect www7.co.union.oh.us
  1142. // @connect xara1-4.cityofpetaluma.net
  1143. // @connect xmaps.indy.gov
  1144. // ==/UserScript==
  1145.  
  1146. /* global WazeWrap */
  1147. /* global _ */
  1148. /* global turf */
  1149. /* global ESTreeProcessor */
  1150. /* global bootstrap */
  1151. /* global W, OpenLayers */
  1152.  
  1153. (async function main() {
  1154. 'use strict';
  1155.  
  1156. const SHOW_UPDATE_MESSAGE = true;
  1157. const SCRIPT_VERSION_CHANGES = ['Added a setting to display a popup with layer labels which can be used to copy label text (thanks to JS55CT for creating this!).'];
  1158.  
  1159. // **************************************************************************************************************
  1160. // IMPORTANT: Update this when releasing a new version of script that includes changes to the spreadsheet format
  1161. // that may cause old code to break. This # should match the version listed in the spreadsheet
  1162. // i.e. update them at the same time.
  1163.  
  1164. // const LAYER_DEF_VERSION = '2018.04.27.001'; // NOT ACTUALLY USED YET
  1165.  
  1166. // **************************************************************************************************************
  1167. // const UPDATE_MESSAGE = 'Bug fix due to WME update';
  1168. // const UPDATE_MESSAGE = `<ul>${[
  1169. // 'Added ability to shift layers. Right click a layer in the list to bring up the layer settings window.'
  1170. // ].map(item => `<li>${item}</li>`).join('')}</ul><br>`;
  1171. const GF_URL = 'https://greasyfork.org/scripts/369632-wme-gis-layers';
  1172. // Used in tooltips to tell people who to report issues to. Update if a new author takes ownership of this script.
  1173. const SCRIPT_AUTHOR = 'MapOMatic';
  1174. // const LAYER_INFO_URL = 'https://spreadsheets.google.com/feeds/list/1cEG3CvXSCI4TOZyMQTI50SQGbVhJ48Xip-jjWg4blWw/o7gusx3/public/values?alt=json';
  1175. const LAYER_DEF_SPREADSHEET_URL = 'https://sheets.googleapis.com/v4/spreadsheets/1cEG3CvXSCI4TOZyMQTI50SQGbVhJ48Xip-jjWg4blWw/values/layerDefs';
  1176. const API_KEY = 'YTJWNVBVRkplbUZUZVVGTlNXOWlVR1pWVjIxcE9VdHJNbVY0TTFoeWNrSlpXbFZuVmtWelRrMVVWUT09';
  1177. const REQUEST_FORM_URL = 'https://docs.google.com/forms/d/e/1FAIpQLSevPQLz2ohu_LTge9gJ9Nv6PURmCmaSSjq0ayOJpGdRr2xI0g/viewform?usp=pp_url&entry.2116052852={username}';
  1178. const DEC = s => atob(atob(s));
  1179. const PRIVATE_LAYERS = { 'nc-henderson-sl-signs': ['the_cre8r', 'mapomatic'] }; // case sensitive -- use all lower case
  1180. // const COUNTRIES = {
  1181. // 'United States': {
  1182. // sheetId: '1cEG3CvXSCI4TOZyMQTI50SQGbVhJ48Xip-jjWg4blWw',
  1183. // sheetLayerRange: 'layerDefs'
  1184. // }
  1185. // };
  1186. const DEFAULT_STYLE = {
  1187. fillColor: '#000',
  1188. pointRadius: 4,
  1189. label: '${label}',
  1190. strokeColor: '#ffa500',
  1191. strokeOpacity: '0.95',
  1192. strokeWidth: 1.5,
  1193. fontColor: '#ffc520',
  1194. fontSize: '13',
  1195. labelOutlineColor: 'black',
  1196. labelOutlineWidth: 3
  1197. };
  1198. const LAYER_STYLES = {
  1199. cities: {
  1200. fillOpacity: 0.3,
  1201. fillColor: '#f65',
  1202. strokeColor: '#f65',
  1203. fontColor: '#f62'
  1204. },
  1205. forests_parks: {
  1206. fillOpacity: 0.4,
  1207. fillColor: '#585',
  1208. strokeColor: '#484',
  1209. fontColor: '#8b8'
  1210. },
  1211. milemarkers: {
  1212. strokeColor: '#fff',
  1213. fontColor: '#fff',
  1214. fontWeight: 'bold',
  1215. fillOpacity: 0,
  1216. labelYOffset: 10,
  1217. pointRadius: 2,
  1218. fontSize: 12
  1219. },
  1220. parcels: {
  1221. fillOpacity: 0,
  1222. fillColor: '#ffa500'
  1223. },
  1224. points: {
  1225. strokeColor: '#000',
  1226. fontColor: '#0ff',
  1227. fillColor: '#0ff',
  1228. labelYOffset: -10,
  1229. labelAlign: 'ct'
  1230. },
  1231. post_offices: {
  1232. strokeColor: '#000',
  1233. fontColor: '#f84',
  1234. fillColor: '#f84',
  1235. fontWeight: 'bold',
  1236. labelYOffset: -10,
  1237. labelAlign: 'ct'
  1238. },
  1239. state_parcels: {
  1240. fillOpacity: 0,
  1241. strokeColor: '#e62',
  1242. fillColor: '#e62',
  1243. fontColor: '#e73'
  1244. },
  1245. state_points: {
  1246. strokeColor: '#000',
  1247. fontColor: '#3cf',
  1248. fillColor: '#3cf',
  1249. labelYOffset: -10,
  1250. labelAlign: 'ct'
  1251. },
  1252. road_labels: {
  1253. strokeOpacity: 0,
  1254. fillOpacity: 0,
  1255. fontColor: '#faf'
  1256. },
  1257. structures: {
  1258. fillOpacity: 0,
  1259. strokeColor: '#f7f',
  1260. fontColor: '#f7f'
  1261. }
  1262. };
  1263. let ROAD_STYLE;
  1264. function initRoadStyle() {
  1265. // SDK: Need styles that allow parameters
  1266. ROAD_STYLE = new OpenLayers.Style({
  1267. pointRadius: 12,
  1268. fillColor: '#369',
  1269. pathLabel: '${label}',
  1270. label: '',
  1271. fontColor: '#faf',
  1272. labelSelect: true,
  1273. pathLabelYOffset: '${getOffset}',
  1274. pathLabelCurve: '${getSmooth}',
  1275. pathLabelReadable: '${getReadable}',
  1276. labelAlign: '${getAlign}',
  1277. labelOutlineWidth: 3,
  1278. labelOutlineColor: '#000',
  1279. strokeWidth: 3,
  1280. stroke: true,
  1281. strokeColor: '#f0f',
  1282. strokeOpacity: 0.4,
  1283. fontWeight: 'bold',
  1284. fontSize: 11
  1285. }, {
  1286. context: {
  1287. getOffset() { return -(sdk.Map.getZoomLevel() + 5); },
  1288. getSmooth() { return ''; },
  1289. getReadable() { return '1'; },
  1290. getAlign() { return 'cb'; }
  1291. }
  1292. });
  1293. }
  1294.  
  1295. // eslint-disable-next-line no-unused-vars
  1296. const _regexReplace = {
  1297. // Strip leading zeros or blank full label for any label starting with a non-digit or
  1298. // is a Zero Address, use with '' as replace.
  1299. r0: /^(0+(\s.*)?|\D.*)/,
  1300. // Strip Everything After Street Type to end of the string by use $1 and $2 capture
  1301. // groups, use with replace '$1$2'
  1302. // eslint-disable-next-line max-len
  1303. r1: /^(.* )(Ave(nue)?|Dr(ive)?|St(reet)?|C(our)?t|Cir(cle)?|Blvd|Boulevard|Pl(ace)?|Ln|Lane|Fwy|Freeway|R(oa)?d|Ter(r|race)?|Tr(ai)?l|Way|Rte \d+|Route \d+)\b.*/gi,
  1304. // Strip SPACE 5 Digits from end of string, use with replace ''
  1305. r2: /\s\d{5}$/,
  1306. // Strip Everything after a "~", ",", ";" to the end of the string, use with replace ''
  1307. r3: /(~|,|;|\s?\r\n).*$/,
  1308. // Move the digits after the last space to before the rest of the string using, use with
  1309. // replace '$2 $1'
  1310. r4: /^(.*)\s(\d+).*/,
  1311. // Insert newline between digits (including "-") and everything after the digits,
  1312. // except(and before) a ",", use with replace '$1\n$2'
  1313. r5: /^([-\d]+)\s+([^,]+).*/,
  1314. // Insert newline between digits and everything after the digits, use with
  1315. // replace '$1\n$2'
  1316. r6: /^(\d+)\s+(.*)/
  1317. };
  1318.  
  1319. let _gisLayers = [];
  1320.  
  1321. const _layerRefinements = [
  1322. {
  1323. id: 'us-post-offices',
  1324. labelHeaderFields: ['LOCALE_NAME']
  1325. }
  1326. ];
  1327.  
  1328. const STATES = {
  1329. _states: [
  1330. ['US (Country)', 'US', -1], ['Alabama', 'AL', 1], ['Alaska', 'AK', 2],
  1331. ['American Samoa', 'AS', 60], ['Arizona', 'AZ', 4], ['Arkansas', 'AR', 5],
  1332. ['California', 'CA', 6], ['Colorado', 'CO', 8], ['Connecticut', 'CT', 9],
  1333. ['Delaware', 'DE', 10], ['District of Columbia', 'DC', 11], ['Florida', 'FL', 12],
  1334. ['Georgia', 'GA', 13], ['Guam', 'GU', 66], ['Hawaii', 'HI', 15], ['Idaho', 'ID', 16],
  1335. ['Illinois', 'IL', 17], ['Indiana', 'IN', 18], ['Iowa', 'IA', 19],
  1336. ['Kansas', 'KS', 20], ['Kentucky', 'KY', 21], ['Louisiana', 'LA', 22],
  1337. ['Maine', 'ME', 23], ['Maryland', 'MD', 24], ['Massachusetts', 'MA', 25],
  1338. ['Michigan', 'MI', 26], ['Minnesota', 'MN', 27], ['Mississippi', 'MS', 28],
  1339. ['Missouri', 'MO', 29], ['Montana', 'MT', 30], ['Nebraska', 'NE', 31],
  1340. ['Nevada', 'NV', 32], ['New Hampshire', 'NH', 33], ['New Jersey', 'NJ', 34],
  1341. ['New Mexico', 'NM', 35], ['New York', 'NY', 36], ['North Carolina', 'NC', 37],
  1342. ['North Dakota', 'ND', 38], ['Northern Mariana Islands', 'MP', 69], ['Ohio', 'OH', 39],
  1343. ['Oklahoma', 'OK', 40], ['Oregon', 'OR', 41], ['Pennsylvania', 'PA', 42],
  1344. ['Puerto Rico', 'PR', 72], ['Rhode Island', 'RI', 44], ['South Carolina', 'SC', 45],
  1345. ['South Dakota', 'SD', 46], ['Tennessee', 'TN', 47], ['Texas', 'TX', 48],
  1346. ['Utah', 'UT', 49], ['Vermont', 'VT', 50], ['Virgin Islands', 'VI', 78],
  1347. ['Virginia', 'VA', 51], ['Washington', 'WA', 53], ['West Virginia', 'WV', 54],
  1348. ['Wisconsin', 'WI', 55], ['Wyoming', 'WY', 56]
  1349. ],
  1350. toAbbr(fullName) {
  1351. return this._states.find(a => a[0] === fullName)?.[1]; // Returns undefined if not found
  1352. },
  1353. toFullName(abbr) {
  1354. return this._states.find(a => a[1] === abbr)?.[0]; // Returns undefined if not found
  1355. },
  1356. toFullNameArray() {
  1357. return this._states.map(a => a[0]);
  1358. },
  1359. toAbbrArray() {
  1360. return this._states.map(a => a[1]);
  1361. },
  1362. fromId(id) {
  1363. return this._states.find(a => a[2] === id); // Returns undefined if not found
  1364. }
  1365. };
  1366. const DEFAULT_VISIBLE_AT_ZOOM = 18;
  1367. const SETTINGS_STORE_NAME = 'wme_gis_layers_fl';
  1368. const COUNTIES_URL = 'https://tigerweb.geo.census.gov/arcgis/rest/services/Census2020/State_County/MapServer/1/';
  1369. const scriptName = GM_info.script.name;
  1370. const scriptVersion = GM_info.script.version;
  1371. const downloadUrl = 'https://greasyfork.org/scripts/369632-wme-gis-layers/code/WME%20GIS%20Layers.user.js';
  1372. const sdk = await bootstrap({ scriptUpdateMonitor: { downloadUrl } });
  1373. let mapLayer = null;
  1374. let roadLayer = null;
  1375. let settings = {};
  1376. let ignoreFetch = false;
  1377. let lastToken = {};
  1378. let userInfo;
  1379.  
  1380. // Variables to store Label popup position and selected layer
  1381. const layerLabels = {};
  1382. let isPopupVisible = null;
  1383. const popupPosition = { left: '50%', top: '50%' };
  1384. let popupActiveLayer = null;
  1385. let useAcronyms = false;
  1386. let useTitleCase = false;
  1387. let useStateHwy = false;
  1388. let removeNewLines = false;
  1389.  
  1390. const DEBUG = true;
  1391. // function log(message) { console.log('GIS Layers:', message); }
  1392. function logError(message, args = []) { console.error(`${scriptName}:`, message, ...args); }
  1393. function logDebug(message, args = []) { if (DEBUG) console.debug(`${scriptName}:`, message, ...args); }
  1394. // function logWarning(message) { console.warn('GIS Layers:', message); }
  1395.  
  1396. let _layerSettingsDialog;
  1397.  
  1398. class LayerSettingsDialog {
  1399. #gisLayer;
  1400. #minVisibleAtZoom = 12;
  1401. #maxVisibleAtZoom = 22;
  1402. #titleText;
  1403. #shiftUpButton;
  1404. #visibleAtZoomInput;
  1405.  
  1406. constructor() {
  1407. this.#titleText = $('<span>');
  1408. const closeButton = $('<span>', {
  1409. style: 'cursor:pointer;padding-left:4px;font-size:17px;color:#d6e6f3;float:right;',
  1410. class: 'fa fa-window-close'
  1411. }).click(() => this.#onCloseButtonClick());
  1412. const shiftUpButton = LayerSettingsDialog.#createShiftButton('fa-angle-up').click(() => this.#onShiftButtonClick(0, 1));
  1413. const shiftLeftButton = LayerSettingsDialog.#createShiftButton('fa-angle-left').click(() => this.#onShiftButtonClick(-1, 0));
  1414. const shiftRightButton = LayerSettingsDialog.#createShiftButton('fa-angle-right').click(() => this.#onShiftButtonClick(1, 0));
  1415. const shiftDownButton = LayerSettingsDialog.#createShiftButton('fa-angle-down').click(() => this.#onShiftButtonClick(0, -1));
  1416. const resetOffsetButton = $('<button>', {
  1417. class: 'form-control',
  1418. style: 'height: 24px; width: auto; padding: 2px 6px 0px 6px; display: inline-block; float: right;'
  1419. }).text('Reset').click(() => this.#onResetOffsetButtonClick());
  1420.  
  1421. this._dialogDiv = $('<div>', {
  1422. style: 'position: fixed; top: 15%; left: 400px; width: 200px; z-index: 100; background-color: #73a9bd; border-width: 1px; border-style: solid;'
  1423. + 'border-radius: 10px; box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.7); border-color: #50667b; padding: 4px;'
  1424. }).append($('<div>').append( // The extra div is needed here. When the header text wraps, the main dialog div won't expand properly without it.
  1425. // HEADER
  1426. $('<div>', { style: 'border-radius:5px 5px 0px 0px; padding: 4px; color: #fff; font-weight: bold; text-align:left; cursor: default;' }).append(
  1427. closeButton,
  1428. this.#titleText
  1429. ),
  1430. // BODY
  1431. $('<div>').append(
  1432. $('<div>', { style: 'border-radius: 5px; width: 100%; padding: 4px; background-color:#d6e6f3; display:inline-block; margin-right:5px;' }).append(
  1433. resetOffsetButton,
  1434. $('<input>', {
  1435. type: 'radio', id: 'gisLayerShiftAmt1', name: 'gisLayerShiftAmt', value: '1', checked: 'checked'
  1436. }),
  1437. $('<label>', { for: 'gisLayerShiftAmt1' }).text('1m'),
  1438. $('<input>', {
  1439. type: 'radio', id: 'gisLayerShiftAmt10', name: 'gisLayerShiftAmt', value: '10', style: 'margin-left: 6px'
  1440. }),
  1441. $('<label>', { for: 'gisLayerShiftAmt10' }).text('10m'),
  1442. $('<div>', { style: 'padding: 4px' }).append(
  1443. $('<table>', { style: 'table-layout:fixed; width:60px; height:84px; margin-left:auto;margin-right:auto;' }).append(
  1444. $('<tr>', { style: 'width: 20px; height: 28px;' }).append(
  1445. $('<td>', { align: 'center' }),
  1446. $('<td>', { align: 'center' }).append(shiftUpButton),
  1447. $('<td>', { align: 'center' })
  1448. ),
  1449. $('<tr>', { style: 'width: 20px; height: 28px;' }).append(
  1450. $('<td>', { align: 'center' }).append(shiftLeftButton),
  1451. $('<td>', { align: 'center' }),
  1452. $('<td>', { align: 'center' }).append(shiftRightButton)
  1453. ),
  1454. $('<tr>', { style: 'width: 20px; height: 28px;' }).append(
  1455. $('<td>', { align: 'center' }),
  1456. $('<td>', { align: 'center' }).append(shiftDownButton),
  1457. $('<td>', { align: 'center' })
  1458. )
  1459. )
  1460. )
  1461. ),
  1462. $('<div>', { style: 'border-radius: 5px; width: 100%; padding: 4px; background-color: #d6e6f3; display: inline-block; margin-right: 5px; margin-top: 2px;' }).append(
  1463. $('<div>', { style: 'display: flex; justify-content: flex-end; margin-bottom: 4px;' }).append(
  1464. $('<button>', { class: 'form-control', style: 'height: 24px; width: auto; padding: 2px 6px 0px 6px;' })
  1465. .text('Reset')
  1466. .click(this.#onResetVisibleAtZoomClick.bind(this))
  1467. ),
  1468. $('<div>').append(
  1469. $('<label>', { for: 'visible-at-zoom-input' }).text('Visible at zoom:'),
  1470. this.#visibleAtZoomInput = $('<input>', {
  1471. type: 'number',
  1472. id: 'visible-at-zoom-input',
  1473. min: this.#minVisibleAtZoom,
  1474. max: this.#maxVisibleAtZoom,
  1475. style: 'margin-left: 4px;'
  1476. }).change(v => this.#onVisibleAtZoomChange(v))
  1477. ),
  1478. $('<div>', { style: 'font-size: 13px; color: gray' }).text('Pan or zoom the map to refresh after changing.\n\nSetting this value too low may cause performance issues.')
  1479. )
  1480. )
  1481. ));
  1482.  
  1483. this.hide();
  1484. this._dialogDiv.appendTo('body');
  1485.  
  1486. if (typeof jQuery.ui !== 'undefined') {
  1487. const that = this;
  1488. this._dialogDiv.draggable({
  1489. // Gotta nuke the height setting the dragging inserts otherwise the panel cannot dynamically resize
  1490. stop() { that._dialogDiv.css('height', ''); }
  1491. });
  1492. }
  1493. }
  1494.  
  1495. get gisLayer() {
  1496. return this.#gisLayer;
  1497. }
  1498.  
  1499. set gisLayer(value) {
  1500. if (value !== this.#gisLayer) {
  1501. this.#gisLayer = value;
  1502. this.#titleText.text(this.#gisLayer.name);
  1503. this.#initVisibleAtZoomInput();
  1504. }
  1505. }
  1506.  
  1507. #initVisibleAtZoomInput() {
  1508. this.#visibleAtZoomInput.val(getGisLayerVisibleAtZoom(this.#gisLayer));
  1509. }
  1510.  
  1511. // eslint-disable-next-line class-methods-use-this
  1512. getShiftAmount() {
  1513. return $('input[name=gisLayerShiftAmt]:checked').val();
  1514. }
  1515.  
  1516. show() {
  1517. this._dialogDiv.show();
  1518. }
  1519.  
  1520. hide() {
  1521. this._dialogDiv.hide();
  1522. }
  1523.  
  1524. #onResetVisibleAtZoomClick() {
  1525. settings.removeLayerSetting(this.#gisLayer.id, 'visibleAtZoom');
  1526. this.#initVisibleAtZoomInput();
  1527. }
  1528.  
  1529. #onCloseButtonClick() {
  1530. this.hide();
  1531. }
  1532.  
  1533. #onVisibleAtZoomChange() {
  1534. const min = this.#minVisibleAtZoom;
  1535. const max = this.#maxVisibleAtZoom;
  1536. let value = parseInt(this.#visibleAtZoomInput.val(), 10);
  1537.  
  1538. if (value < min) {
  1539. value = min;
  1540. this.#visibleAtZoomInput.val(value);
  1541. } else if (value > max) {
  1542. value = max;
  1543. this.#visibleAtZoomInput.val(value);
  1544. }
  1545.  
  1546. settings.setLayerSetting(this.#gisLayer.id, 'visibleAtZoom', value);
  1547. saveSettingsToStorage();
  1548. }
  1549.  
  1550. #onShiftButtonClick(x, y) {
  1551. const shiftAmount = this.getShiftAmount();
  1552. x *= shiftAmount;
  1553. y *= shiftAmount;
  1554. this.#shiftLayerFeatures(x, y);
  1555. const { id } = this.gisLayer;
  1556. let offset = settings.getLayerSetting(id, 'offset');
  1557. if (!offset) {
  1558. offset = { x: 0, y: 0 };
  1559. settings.setLayerSetting(id, 'offset', offset);
  1560. }
  1561. offset.x += x;
  1562. offset.y += y;
  1563. saveSettingsToStorage();
  1564. }
  1565.  
  1566. #onResetOffsetButtonClick() {
  1567. const offset = settings.getLayerSetting(this.gisLayer.id, 'offset');
  1568. if (offset) {
  1569. this.#shiftLayerFeatures(offset.x * -1, offset.y * -1);
  1570. delete settings.layers[this.gisLayer.id].offset;
  1571. saveSettingsToStorage();
  1572. }
  1573. }
  1574.  
  1575. #shiftLayerFeatures(x, y) {
  1576. const layer = this.gisLayer.isRoadLayer ? roadLayer : mapLayer;
  1577. layer.getFeaturesByAttribute('layerID', this.gisLayer.id).forEach(f => f.geometry.move(x, y));
  1578. layer.redraw();
  1579. }
  1580.  
  1581. static #createShiftButton(fontAwesomeClass) {
  1582. return $('<button>', {
  1583. class: 'form-control',
  1584. style: 'cursor:pointer;font-size:14px;padding: 3px;border-radius: 5px;width: 21px;height: 21px;'
  1585. }).append(
  1586. $('<i>', { class: 'fa', style: 'vertical-align: super' }).addClass(fontAwesomeClass)
  1587. );
  1588. }
  1589. }
  1590.  
  1591. function loadSettingsFromStorage() {
  1592. const defaultSettings = {
  1593. lastVersion: null,
  1594. visibleLayers: [],
  1595. onlyShowApplicableLayers: false,
  1596. selectedStates: [],
  1597. enabled: true,
  1598. fillParcels: false,
  1599. oneTimeAlerts: {},
  1600. layers: {},
  1601. shortcuts: {},
  1602. isPopupVisible: false,
  1603. useAcronyms: false,
  1604. useTitleCase: false,
  1605. useStateHwy: false,
  1606. removeNewLines: false
  1607. };
  1608.  
  1609. let loadedSettings = {}; // Initialize as an empty object
  1610. const storedSettings = localStorage.getItem(SETTINGS_STORE_NAME);
  1611.  
  1612. if (storedSettings) {
  1613. try {
  1614. const parsed = JSON.parse(storedSettings);
  1615. if (parsed && typeof parsed === 'object') {
  1616. loadedSettings = parsed;
  1617. } else {
  1618. logDebug(`Stored settings under key "${SETTINGS_STORE_NAME}" were not a valid object.`);
  1619. }
  1620. } catch (e) {
  1621. logError(`Failed to parse settings from localStorage key "${SETTINGS_STORE_NAME}":`, e);
  1622. // loadedSettings remains {}
  1623. }
  1624. }
  1625.  
  1626. // Merge defaultSettings and loadedSettings.
  1627. // If loadedSettings is empty (due to error or no storage), it effectively uses defaults.
  1628. settings = { ...defaultSettings, ...loadedSettings };
  1629.  
  1630. isPopupVisible = settings.isPopupVisible;
  1631. useAcronyms = settings.useAcronyms;
  1632. useTitleCase = settings.useTitleCase;
  1633. useStateHwy = settings.useStateHwy;
  1634. removeNewLines = settings.removeNewLines;
  1635.  
  1636. settings.getLayerSetting = function getLayerSetting(layerID, settingName) {
  1637. const layerSettings = this.layers[layerID];
  1638. if (!layerSettings) {
  1639. return undefined;
  1640. }
  1641. return layerSettings[settingName];
  1642. };
  1643. settings.setLayerSetting = function setLayerSetting(layerID, settingName, value) {
  1644. let layerSettings = this.layers[layerID];
  1645. if (!layerSettings) {
  1646. layerSettings = {};
  1647. this.layers[layerID] = layerSettings;
  1648. }
  1649. layerSettings[settingName] = value;
  1650. };
  1651. settings.removeLayerSetting = function removeLayerSetting(layerID, settingName) {
  1652. const layerSettings = this.layers[layerID];
  1653. if (layerSettings) {
  1654. delete layerSettings[settingName];
  1655. }
  1656. };
  1657.  
  1658. // Handle legacy shortcut keys settings.
  1659. // TODO: Delete this later, after most users have updated.
  1660. if (settings.toggleHnsOnlyShortcut) {
  1661. settings.shortcuts.toggleHnsOnly = settings.toggleHnsOnlyShortcut;
  1662. delete settings.toggleHnsOnlyShortcut;
  1663. }
  1664. if (settings.toggleEnabledShortcut) {
  1665. settings.shortcuts.toggleEnabled = settings.toggleEnabledShortcut;
  1666. delete settings.toggleEnabledShortcut;
  1667. }
  1668. }
  1669.  
  1670. function saveSettingsToStorage() {
  1671. settings.shortcuts = {};
  1672. sdk.Shortcuts.getAllShortcuts().forEach(shortcut => {
  1673. settings.shortcuts[shortcut.shortcutId] = shortcut.shortcutKeys;
  1674. });
  1675. settings.lastVersion = scriptVersion;
  1676. settings.isPopupVisible = isPopupVisible;
  1677. settings.useAcronyms = useAcronyms;
  1678. settings.useTitleCase = useTitleCase;
  1679. settings.useStateHwy = useStateHwy;
  1680. settings.removeNewLines = removeNewLines;
  1681. localStorage.setItem(SETTINGS_STORE_NAME, JSON.stringify(settings));
  1682. logDebug('Settings saved');
  1683. }
  1684.  
  1685. function getUrl(extent, gisLayer) {
  1686. // if (gisLayer.spatialReference) {
  1687. // const proj = new OpenLayers.Projection(`EPSG:${gisLayer.spatialReference}`);
  1688. // extent.transform(W.map.getProjectionObject(), proj);
  1689. // }
  1690. const layerOffset = settings.getLayerSetting(gisLayer.id, 'offset') ?? { x: 0, y: 0 };
  1691. const geometry = {
  1692. xmin: extent[0] - layerOffset.x,
  1693. ymin: extent[1] - layerOffset.y,
  1694. xmax: extent[2] - layerOffset.x,
  1695. ymax: extent[3] - layerOffset.y,
  1696. spatialReference: {
  1697. wkid: /* gisLayer.spatialReference ? gisLayer.spatialReference : */ 102100,
  1698. latestWkid: /* gisLayer.spatialReference ? gisLayer.spatialReference : */ 3857
  1699. }
  1700. };
  1701. const geometryStr = JSON.stringify(geometry);
  1702. let fields = gisLayer.labelFields;
  1703. if (gisLayer.labelHeaderFields) {
  1704. fields = fields.concat(gisLayer.labelHeaderFields);
  1705. }
  1706. if (gisLayer.distinctFields) {
  1707. fields = fields.concat(gisLayer.distinctFields);
  1708. }
  1709. let url = `${gisLayer.url}/query?geometry=${encodeURIComponent(geometryStr)}`;
  1710. url += gisLayer.token ? `&token=${gisLayer.token}` : '';
  1711. url += `&outFields=${encodeURIComponent(fields.join(','))}`;
  1712. url += '&returnGeometry=true&spatialRel=esriSpatialRelIntersects&geometryType=esriGeometryEnvelope';
  1713. url += `&inSR=${/* gisLayer.spatialReference ? gisLayer.spatialReference : */ '102100'}`;
  1714. url += '&outSR=3857&f=json';
  1715. url += gisLayer.where ? `&where=${encodeURIComponent(gisLayer.where)}` : '';
  1716.  
  1717. logDebug(`Request URL: ${url}`);
  1718. return url;
  1719. }
  1720.  
  1721. function hashString(value) {
  1722. let hash = 0;
  1723. if (value.length === 0) return hash;
  1724. for (let i = 0; i < value.length; i++) {
  1725. const chr = value.charCodeAt(i);
  1726. // eslint-disable-next-line no-bitwise
  1727. hash = ((hash << 5) - hash) + chr;
  1728. // eslint-disable-next-line no-bitwise
  1729. hash |= 0; // Convert to 32bit integer
  1730. }
  1731. return hash;
  1732. }
  1733.  
  1734. function getMercatorMapExtent() {
  1735. const wgs84Extent = sdk.Map.getMapExtent();
  1736. const wgs84LeftBottom = [wgs84Extent[0], wgs84Extent[1]];
  1737. const wgs84RightTop = [wgs84Extent[2], wgs84Extent[3]];
  1738. const mercatorLeftBottom = turf.toMercator(wgs84LeftBottom);
  1739. const mercatorRightTop = turf.toMercator(wgs84RightTop);
  1740. return [mercatorLeftBottom[0], mercatorLeftBottom[1], mercatorRightTop[0], mercatorRightTop[1]];
  1741. }
  1742.  
  1743. function getArcGisMapExtentGeometry() {
  1744. const extent = getMercatorMapExtent();
  1745. const geometry = {
  1746. xmin: extent[0],
  1747. ymin: extent[1],
  1748. xmax: extent[2],
  1749. ymax: extent[3],
  1750. spatialReference: {
  1751. wkid: 102100,
  1752. latestWkid: 3857
  1753. }
  1754. };
  1755. return geometry;
  1756. }
  1757.  
  1758. function getCountiesUrl() {
  1759. const geometry = getArcGisMapExtentGeometry();
  1760. const url = `${COUNTIES_URL}/query?geometry=${encodeURIComponent(JSON.stringify(geometry))}`;
  1761. return `${url}&outFields=BASENAME%2CSTATE&returnGeometry=false&spatialRel=esriSpatialRelIntersects`
  1762. + '&geometryType=esriGeometryEnvelope&inSR=102100&outSR=3857&f=json';
  1763. }
  1764.  
  1765. let _countiesInExtent = [];
  1766.  
  1767. function getGisLayerVisibleAtZoom(gisLayer) {
  1768. const overrideVisibleAtZoom = settings.getLayerSetting(gisLayer.id, 'visibleAtZoom');
  1769. if (overrideVisibleAtZoom) return overrideVisibleAtZoom;
  1770. return (gisLayer.hasOwnProperty('visibleAtZoom')
  1771. ? gisLayer.visibleAtZoom : DEFAULT_VISIBLE_AT_ZOOM);
  1772. }
  1773.  
  1774. function getGisLayerLabelsVisibleAtZoom(gisLayer, layerVisibleAtZoom) {
  1775. let labelsVisibleAtZoom;
  1776. layerVisibleAtZoom = +layerVisibleAtZoom;
  1777. if (gisLayer.hasOwnProperty('labelsVisibleAtZoom')) {
  1778. labelsVisibleAtZoom = layerVisibleAtZoom + (+gisLayer.labelsVisibleAtZoom - (+gisLayer.visibleAtZoom ?? DEFAULT_VISIBLE_AT_ZOOM));
  1779. } else {
  1780. labelsVisibleAtZoom = layerVisibleAtZoom + 1;
  1781. }
  1782. if (labelsVisibleAtZoom < 1) labelsVisibleAtZoom = 1;
  1783. return labelsVisibleAtZoom;
  1784. }
  1785.  
  1786. function getFetchableLayers(getInvisible) {
  1787. const zoom = sdk.Map.getZoomLevel();
  1788. if (zoom < 12) return [];
  1789. return _gisLayers.filter(gisLayer => {
  1790. const isValidUrl = gisLayer.url && gisLayer.url.trim().length > 0;
  1791. const isVisible = (getInvisible || settings.visibleLayers.includes(gisLayer.id))
  1792. && settings.selectedStates.includes(gisLayer.state);
  1793. const isInState = gisLayer.state === 'US' || _countiesInExtent.some(county => county.stateInfo[1] === gisLayer.state);
  1794. // Be sure to use hasOwnProperty when checking this, since 0 is a valid value.
  1795. const isValidZoom = getInvisible || zoom >= getGisLayerVisibleAtZoom(gisLayer);
  1796. return isValidUrl && isInState && isVisible && isValidZoom;
  1797. });
  1798. }
  1799.  
  1800. function filterLayerCheckboxes() {
  1801. const applicableLayers = getFetchableLayers(true).filter(layer => {
  1802. const hasCounties = layer.hasOwnProperty('counties');
  1803. return (hasCounties && layer.counties.some(countyName => _countiesInExtent.some(county => county.name === countyName.toLowerCase()
  1804. && layer.state === county.stateInfo[1]))) || !hasCounties;
  1805. });
  1806. const statesToHide = STATES.toAbbrArray();
  1807.  
  1808. _gisLayers.forEach(gisLayer => {
  1809. const id = `#gis-layer-${gisLayer.id}-container`;
  1810. if (!settings.onlyShowApplicableLayers || applicableLayers.includes(gisLayer)) {
  1811. $(id).show();
  1812. $(`#gis-layers-for-${gisLayer.state}`).show();
  1813. const idx = statesToHide.indexOf(gisLayer.state);
  1814. if (idx > -1) statesToHide.splice(idx, 1);
  1815. } else {
  1816. $(id).hide();
  1817. }
  1818. });
  1819. if (settings.onlyShowApplicableLayers) {
  1820. statesToHide.forEach(st => $(`#gis-layers-for-${st}`).hide());
  1821. }
  1822. }
  1823.  
  1824. const ROAD_ABBR = [
  1825. [/\bAVENUE$/, 'AVE'], [/\bCIRCLE$/, 'CIR'], [/\bCOURT$/, 'CT'], [/\bDRIVE$/, 'DR'],
  1826. [/\bLANE$/, 'LN'], [/\bPARK$/, 'PK'], [/\bPLACE$/, 'PL'], [/\bROAD$/, 'RD'], [/\bSTREET$/, 'ST'],
  1827. [/\bTERRACE$/, 'TER']
  1828. ];
  1829.  
  1830. const labelProcessingGlobalVariables = {
  1831. Number,
  1832. Math,
  1833. Boolean,
  1834. parseInt,
  1835. Date,
  1836. _regexReplace: {
  1837. // Strip leading zeros or blank full label for any label starting with a non-digit or
  1838. // is a Zero Address, use with '' as replace.
  1839. r0: /^(0+(\s.*)?|\D.*)/,
  1840. // Strip Everything After Street Type to end of the string by use $1 and $2 capture
  1841. // groups, use with replace '$1$2'
  1842. // eslint-disable-next-line max-len
  1843. r1: /^(.* )(Ave(nue)?|Dr(ive)?|St(reet)?|C(our)?t|Cir(cle)?|Blvd|Boulevard|Pl(ace)?|Ln|Lane|Fwy|Freeway|R(oa)?d|Ter(r|race)?|Tr(ai)?l|Way|Rte \d+|Route \d+)\b.*/gi,
  1844. // Strip SPACE 5 Digits from end of string, use with replace ''
  1845. r2: /\s\d{5}$/,
  1846. // Strip Everything after a "~", ",", ";" to the end of the string, use with replace ''
  1847. r3: /(~|,|;|\s?\r\n).*$/,
  1848. // Move the digits after the last space to before the rest of the string using, use with
  1849. // replace '$2 $1'
  1850. r4: /^(.*)\s(\d+).*/,
  1851. // Insert newline between digits (including "-") and everything after the digits,
  1852. // except(and before) a ",", use with replace '$1\n$2'
  1853. r5: /^([-\d]+)\s+([^,]+).*/,
  1854. // Insert newline between digits and everything after the digits, use with
  1855. // replace '$1\n$2'
  1856. r6: /^(\d+)\s+(.*)/
  1857. }
  1858. };
  1859.  
  1860. function processLabel(gisLayer, item, displayLabelsAtZoom, area, isPolyLine = false) {
  1861. let label = '';
  1862. if (gisLayer.labelHeaderFields) {
  1863. label = `${gisLayer.labelHeaderFields.map(
  1864. fieldName => item.attributes[fieldName]
  1865. ).join(' ').trim()}\n`;
  1866. }
  1867. if (sdk.Map.getZoomLevel() >= displayLabelsAtZoom || area >= 5000) {
  1868. label += gisLayer.labelFields.map(
  1869. fieldName => item.attributes[fieldName]
  1870. ).join(' ').trim();
  1871. if (gisLayer.processLabel) {
  1872. if (gisLayer.labelProcessingError) {
  1873. label = 'ERROR';
  1874. } else {
  1875. labelProcessingGlobalVariables.label = label;
  1876. labelProcessingGlobalVariables.fieldValues = item.attributes;
  1877. const result = ESTreeProcessor.execute(gisLayer.processLabel, labelProcessingGlobalVariables);
  1878. label = result.output?.trim() ?? '';
  1879. }
  1880. }
  1881. }
  1882.  
  1883. if (!isPolyLine) {
  1884. if (label && [
  1885. LAYER_STYLES.points, LAYER_STYLES.parcels, LAYER_STYLES.state_points,
  1886. LAYER_STYLES.state_parcels
  1887. ].includes(gisLayer.style)) {
  1888. if (settings.addrLabelDisplay === 'hn') {
  1889. const m = label.match(/^\d+/);
  1890. label = m ? m[0] : '';
  1891. } else if (settings.addrLabelDisplay === 'street') {
  1892. const m = label.match(/^(?:\d+\s)?(.*)/);
  1893. label = m ? m[1].trim() : '';
  1894. }
  1895. else if (settings.addrLabelDisplay === 'none') {
  1896. label = '';
  1897. }
  1898. }
  1899. }
  1900. return label;
  1901. }
  1902. function processFeatures(data, token, gisLayer) {
  1903. const features = [];
  1904. if (data.skipIt) {
  1905. // do nothing
  1906. } else if (data.error) {
  1907. logError(`Error in layer "${gisLayer.name}": ${data.error.message}`);
  1908. } else {
  1909. const items = data.features || [];
  1910. if (!token.cancel) {
  1911. let error = false;
  1912. const distinctValues = [];
  1913. items.forEach(item => {
  1914. let skipIt = false;
  1915. if (!token.cancel && !error) {
  1916. let feature;
  1917. let featureGeometry;
  1918. let area;
  1919. if (gisLayer.distinctFields) {
  1920. if (distinctValues.some(v => gisLayer.distinctFields.every(
  1921. fld => v[fld] === item.attributes[fld]
  1922. ))) {
  1923. skipIt = true;
  1924. } else {
  1925. const dist = {};
  1926. gisLayer.distinctFields.forEach(fld => (dist[fld] = item.attributes[fld]));
  1927. distinctValues.push(dist);
  1928. }
  1929. }
  1930. if (!skipIt) {
  1931. let isPolyLine = false;
  1932. const layerOffset = settings.getLayerSetting(gisLayer.id, 'offset') ?? { x: 0, y: 0 };
  1933. if (item.geometry) {
  1934. if (item.geometry.x) {
  1935. featureGeometry = new OpenLayers.Geometry.Point(
  1936. item.geometry.x + layerOffset.x,
  1937. item.geometry.y + layerOffset.y
  1938. );
  1939. // SDK
  1940. // featureGeometry = turf.point([item.geometry.x + layerOffset.x, item.geometry.y + layerOffset.y]);
  1941. // featureGeometry = turf.toWgs84(featureGeometry);
  1942. } else if (item.geometry.points) {
  1943. // @TODO Fix for multiple points instead of just grabbing first.
  1944. featureGeometry = new OpenLayers.Geometry.Point(
  1945. item.geometry.points[0][0] + layerOffset.x,
  1946. item.geometry.points[0][1] + layerOffset.y
  1947. );
  1948. } else if (item.geometry.rings) {
  1949. const rings = [];
  1950. item.geometry.rings.forEach(ringIn => {
  1951. const pnts = [];
  1952. for (let i = 0; i < ringIn.length; i++) {
  1953. pnts.push(new OpenLayers.Geometry.Point(
  1954. ringIn[i][0] + layerOffset.x,
  1955. ringIn[i][1] + layerOffset.y
  1956. ));
  1957. }
  1958. rings.push(new OpenLayers.Geometry.LinearRing(pnts));
  1959. });
  1960. featureGeometry = new OpenLayers.Geometry.Polygon(rings);
  1961. if (gisLayer.areaToPoint) {
  1962. featureGeometry = featureGeometry.getCentroid();
  1963. } else {
  1964. area = featureGeometry.getArea();
  1965. }
  1966. } else if (data.geometryType === 'esriGeometryPolyline') {
  1967. // We have to handle polylines differently since each item can have multiple features.
  1968. // In terms of ArcGIS, each feature's geometry can have multiple paths. For instance
  1969. // a single road can be broken into parts that are physically not connected to each other.
  1970.  
  1971. const displayLabelsAtZoom = getGisLayerLabelsVisibleAtZoom(gisLayer, getGisLayerVisibleAtZoom(gisLayer));
  1972. const label = processLabel(gisLayer, item, displayLabelsAtZoom, area, true);
  1973.  
  1974. // Use Turf library to clip the geometry to the screen bounds.
  1975. // This allows labels to stay in view on very long roads.
  1976. const mls = turf.multiLineString(item.geometry.paths);
  1977. const e = getMercatorMapExtent();
  1978. const bbox = [e.left, e.bottom, e.right, e.top];
  1979. const clipped = turf.bboxClip(mls, bbox);
  1980. if (clipped.geometry.type === 'LineString') {
  1981. item.geometry.paths = [clipped.geometry.coordinates];
  1982. } else if (clipped.geometry.type === 'MultiLineString') {
  1983. item.geometry.paths = clipped.geometry.coordinates;
  1984. }
  1985.  
  1986. item.geometry.paths.forEach(path => {
  1987. const pointList = [];
  1988. path.forEach(point => pointList.push(new OpenLayers.Geometry.Point(
  1989. point[0] + layerOffset.x,
  1990. point[1] + layerOffset.y
  1991. )));
  1992. featureGeometry = new OpenLayers.Geometry.LineString(pointList);
  1993. featureGeometry.skipDupeCheck = true;
  1994.  
  1995. const attributes = {
  1996. layerID: gisLayer.id,
  1997. label
  1998. };
  1999.  
  2000. const lineFeature = new OpenLayers.Feature.Vector(featureGeometry, attributes);
  2001. features.push(lineFeature);
  2002. if (isPopupVisible) {
  2003. addLabelToLayer(gisLayer.name, label);
  2004. }
  2005. });
  2006. isPolyLine = true;
  2007. } else {
  2008. logDebug(`Unexpected feature type in layer: ${JSON.stringify(item)}`);
  2009. logError(`Error: Unexpected feature type in layer "${gisLayer.name}"`);
  2010. error = true;
  2011. }
  2012. if (!error && !isPolyLine && featureGeometry) {
  2013. const displayLabelsAtZoom = getGisLayerLabelsVisibleAtZoom(gisLayer, getGisLayerVisibleAtZoom(gisLayer));
  2014. const label = processLabel(gisLayer, item, displayLabelsAtZoom, area);
  2015. const attributes = {
  2016. layerID: gisLayer.id,
  2017. label
  2018. };
  2019. // SDK
  2020. // featureGeometry.id = gisLayer.id;
  2021. // featureGeometry.properties = attributes;
  2022. // features.push(featureGeometry);
  2023. feature = new OpenLayers.Feature.Vector(featureGeometry, attributes);
  2024. features.push(feature);
  2025. if (isPopupVisible) {
  2026. addLabelToLayer(gisLayer.name, label);
  2027. }
  2028. }
  2029. }
  2030. }
  2031. }
  2032. });
  2033. }
  2034. }
  2035. if (!token.cancel) {
  2036. // Check for duplicate geometries.
  2037. for (let i = 0; i < features.length; i++) {
  2038. const f1 = features[i];
  2039. if (!f1.geometry.skipDupeCheck) {
  2040. const c1 = f1.geometry.getCentroid();
  2041. let labels = [f1.attributes.label];
  2042. for (let j = i + 1; j < features.length; j++) {
  2043. const f2 = features[j];
  2044. if (!f2.geometry.skipDupeCheck && f2.geometry.getCentroid().distanceTo(c1) < 1) {
  2045. features.splice(j, 1);
  2046. labels.push(f2.attributes.label);
  2047. j--;
  2048. }
  2049. }
  2050. labels = _.uniq(labels);
  2051. if (labels.length > 1) {
  2052. labels.forEach((label, idx) => {
  2053. label = label.replace(/\n/g, ' ').replace(/\s{2,}/, ' ').replace(/\bUNIT\s.{1,5}$/i, '').trim();
  2054. ROAD_ABBR.forEach(abbr => (label = label.replace(abbr[0], abbr[1])));
  2055. labels[idx] = label;
  2056. });
  2057. labels = _.uniq(labels);
  2058. labels.sort();
  2059. if (labels.length > 12) {
  2060. const len = labels.length;
  2061. labels = labels.slice(0, 10);
  2062. labels.push(`(${len - 10} more...)`);
  2063. }
  2064. f1.attributes.label = _.uniq(labels).join('\n');
  2065. } else {
  2066. let { label } = f1.attributes;
  2067. ROAD_ABBR.forEach(abbr => (label = label.replace(abbr[0], abbr[1])));
  2068. f1.attributes.label = label;
  2069. }
  2070. }
  2071. }
  2072.  
  2073. // SDK: Swap this when ready.
  2074. const layer = gisLayer.isRoadLayer ? roadLayer : mapLayer;
  2075. layer.removeFeatures(layer.getFeaturesByAttribute('layerID', gisLayer.id));
  2076. layer.addFeatures(features);
  2077. // sdk.Map.removeFeaturesFromLayer({ layerName: layer.name, featureIds: [gisLayer.id] });
  2078. // sdk.Map.addFeaturesToLayer({ layerName: layer.name, features });
  2079.  
  2080. if (features.length) {
  2081. $(`label[for="gis-layer-${gisLayer.id}"]`).css({ color: '#00a009' });
  2082. }
  2083. }
  2084. } // END processFeatures()
  2085.  
  2086. function copyTextToClipboard(text) {
  2087. try {
  2088. GM_setClipboard(text);
  2089. logDebug(`Copy Text To Clipboard: ${text}`);
  2090. } catch (err) {
  2091. logError(`Failed to Text To Clipboard: ${err}`);
  2092. }
  2093. }
  2094.  
  2095. function addLabelToLayer(layerName, label) {
  2096. if (!layerLabels[layerName]) {
  2097. layerLabels[layerName] = new Set();
  2098. }
  2099. layerLabels[layerName].add(label);
  2100. }
  2101.  
  2102. function replacePhrasesWithAcronyms(text) {
  2103. // Order phrases such that compound phrases come before individual words
  2104. const replacements = [
  2105. // compound phrases here
  2106. { phrase: 'Alternate Route', acronym: 'ALT' },
  2107. { phrase: 'Army Air Field', acronym: 'AAF' },
  2108. { phrase: 'County Highway', acronym: 'CH-' },
  2109. { phrase: 'County Road', acronym: 'CR-' },
  2110. { phrase: 'East Bound', acronym: 'EB' },
  2111. { phrase: 'North Bound', acronym: 'NB' },
  2112. { phrase: 'North East', acronym: 'NE' },
  2113. { phrase: 'North West', acronym: 'NW' },
  2114. { phrase: 'South Bound', acronym: 'SB' },
  2115. { phrase: 'South East', acronym: 'SE' },
  2116. { phrase: 'South West', acronym: 'SW' },
  2117. { phrase: 'State Highway', acronym: 'SH-' },
  2118. { phrase: 'State Route', acronym: 'SR-' },
  2119. { phrase: 'State Rte', acronym: 'SR-' },
  2120. { phrase: 'U.S. Highway', acronym: 'US-' },
  2121. { phrase: 'U.S. Route', acronym: 'US-' },
  2122. { phrase: 'U.S. Rte', acronym: 'US-' },
  2123. { phrase: 'U.S.Rte', acronym: 'US-' },
  2124. { phrase: 'US Highway', acronym: 'US-' },
  2125. { phrase: 'U S Highway', acronym: 'US-' },
  2126. { phrase: 'US Route', acronym: 'US-' },
  2127. { phrase: 'U S Route', acronym: 'US-' },
  2128. { phrase: 'US RTE', acronym: 'US-' },
  2129. { phrase: 'U S RTE', acronym: 'US-' },
  2130. { phrase: 'USRTE', acronym: 'US-' },
  2131. { phrase: 'West Bound', acronym: 'WB' },
  2132. // Start of single words list
  2133. { phrase: 'Alley', acronym: 'Aly' },
  2134. { phrase: 'Apartments', acronym: 'Apts' },
  2135. { phrase: 'Avenue', acronym: 'Ave' },
  2136. { phrase: 'Beach', acronym: 'Bch' },
  2137. { phrase: 'Boulevard', acronym: 'Blvd' },
  2138. { phrase: 'Bridge', acronym: 'Br' },
  2139. { phrase: 'Business', acronym: 'BUS' },
  2140. { phrase: 'Bypass', acronym: 'BYP' },
  2141. { phrase: 'Canyon', acronym: 'Cyn' },
  2142. { phrase: 'Captain', acronym: 'Capt' },
  2143. { phrase: 'Causeway', acronym: 'Cswy' },
  2144. { phrase: 'Center', acronym: 'Ctr' },
  2145. { phrase: 'Circle', acronym: 'Cir' },
  2146. { phrase: 'Colonel', acronym: 'Col.' },
  2147. { phrase: 'Commander', acronym: 'Cmdr.' },
  2148. { phrase: 'Connector', acronym: 'CONN' },
  2149. { phrase: 'Corners', acronym: 'Cors' },
  2150. { phrase: 'Corporal', acronym: 'Cpl.' },
  2151. { phrase: 'Court', acronym: 'Ct' },
  2152. { phrase: 'Cove', acronym: 'Cv' },
  2153. { phrase: 'Creek', acronym: 'Crk' },
  2154. { phrase: 'Crescent', acronym: 'Cres' },
  2155. { phrase: 'Crossing', acronym: 'X-ing' },
  2156. { phrase: 'Doctor', acronym: 'Dr.' },
  2157. { phrase: 'Drive', acronym: 'Dr' },
  2158. { phrase: 'East', acronym: 'E' },
  2159. { phrase: 'Eastbound', acronym: 'EB' },
  2160. { phrase: 'Eb', acronym: 'EB' },
  2161. { phrase: 'Express', acronym: 'EXP' },
  2162. { phrase: 'Expressway', acronym: 'Expwy' },
  2163. { phrase: 'Extension', acronym: 'Ext' },
  2164. { phrase: 'Fort', acronym: 'Ft.' },
  2165. { phrase: 'Freeway', acronym: 'Fwy' },
  2166. { phrase: 'General', acronym: 'Gen.' },
  2167. { phrase: 'Governor', acronym: 'Gov.' },
  2168. { phrase: 'Grove', acronym: 'Grv' },
  2169. { phrase: 'Heights', acronym: 'Hts' },
  2170. { phrase: 'Highway', acronym: 'Hwy' },
  2171. { phrase: 'Honerable', acronym: 'Hon.' },
  2172. { phrase: 'International', acronym: 'Intl' },
  2173. { phrase: 'Interstate', acronym: 'I-' },
  2174. { phrase: 'Junior', acronym: 'Jr.' },
  2175. { phrase: 'Landing', acronym: 'Lndg' },
  2176. { phrase: 'Lane', acronym: 'Ln' },
  2177. { phrase: 'Lieutenant', acronym: 'Lt.' },
  2178. { phrase: 'Loop', acronym: 'Lp' },
  2179. { phrase: 'Major', acronym: 'Maj.' },
  2180. { phrase: 'Manor', acronym: 'Mnr.' },
  2181. { phrase: 'Meadow', acronym: 'Mdw' },
  2182. { phrase: 'Mount', acronym: 'Mt' },
  2183. { phrase: 'Mountain', acronym: 'Mtn' },
  2184. { phrase: 'Mountains', acronym: 'Mtns' },
  2185. { phrase: 'National', acronym: "Nat'l" },
  2186. { phrase: 'North', acronym: 'N' },
  2187. { phrase: 'Northbound', acronym: 'NB' },
  2188. { phrase: 'Nb', acronym: 'NB' },
  2189. { phrase: 'Northeast', acronym: 'NE' },
  2190. { phrase: 'Northwest', acronym: 'NW' },
  2191. { phrase: 'Park', acronym: 'Pk' },
  2192. { phrase: 'Parkway', acronym: 'Pkwy' },
  2193. { phrase: 'Parkways', acronym: 'Pkwys' },
  2194. { phrase: 'Passage', acronym: 'Psge' },
  2195. { phrase: 'Place', acronym: 'Pl' },
  2196. { phrase: 'Plaza', acronym: 'Plz' },
  2197. { phrase: 'Point', acronym: 'Pt' },
  2198. { phrase: 'Points', acronym: 'Pts' },
  2199. { phrase: 'President', acronym: 'Pres.' },
  2200. { phrase: 'Professor', acronym: 'Prof.' },
  2201. { phrase: 'Railroad', acronym: 'R.R.' },
  2202. { phrase: 'Road', acronym: 'Rd' },
  2203. { phrase: 'Recreational', acronym: 'Rec.' },
  2204. { phrase: 'Reverend', acronym: 'Rev.' },
  2205. { phrase: 'Route', acronym: 'SR-' },
  2206. { phrase: 'Saint', acronym: 'St.' },
  2207. { phrase: 'Sainte', acronym: 'Ste.' },
  2208. { phrase: 'Senior', acronym: 'Sr.' },
  2209. { phrase: 'Sergeant', acronym: 'Sgt.' },
  2210. { phrase: 'Skyway', acronym: 'Skwy' },
  2211. { phrase: 'South', acronym: 'S' },
  2212. { phrase: 'Southbound', acronym: 'SB' },
  2213. { phrase: 'Sb', acronym: 'SB' },
  2214. { phrase: 'Southeast', acronym: 'SE' },
  2215. { phrase: 'Southwest', acronym: 'SW' },
  2216. { phrase: 'Springs', acronym: 'Spgs' },
  2217. { phrase: 'Square', acronym: 'Sq' },
  2218. { phrase: 'Station', acronym: 'Sta' },
  2219. { phrase: 'Street', acronym: 'St' },
  2220. { phrase: 'Terrace', acronym: 'Ter' },
  2221. { phrase: 'Throughway', acronym: 'Thwy' },
  2222. { phrase: 'Thruway', acronym: 'Thwy' },
  2223. { phrase: 'Tollway', acronym: 'Tlwy' },
  2224. { phrase: 'Township', acronym: 'Twp' },
  2225. { phrase: 'Trafficway', acronym: 'Trfy' },
  2226. { phrase: 'Trail', acronym: 'Trl' },
  2227. { phrase: 'Tunnel', acronym: 'Tun' },
  2228. { phrase: 'Turnpike', acronym: 'Tpk' },
  2229. { phrase: 'Upper', acronym: 'Upr' },
  2230. { phrase: 'U.S.', acronym: 'US' },
  2231. { phrase: 'Valley', acronym: 'Vly' },
  2232. { phrase: 'West', acronym: 'W' },
  2233. { phrase: 'Westbound', acronym: 'WB' },
  2234. { phrase: 'Wb', acronym: 'WB' },
  2235. { phrase: '--', acronym: '-' },
  2236. { phrase: ' -', acronym: '-' },
  2237. { phrase: '- ', acronym: '-' },
  2238. { phrase: '- -', acronym: '-' }
  2239. ];
  2240.  
  2241. let updatedText = text;
  2242.  
  2243. // Replace phrases with their acronyms, case insensitive
  2244. replacements.forEach(({ phrase, acronym }) => {
  2245. const regex = new RegExp(`\\b${phrase}\\b`, 'gi'); // Uses \\b to match words with word boundaries
  2246. updatedText = updatedText.replace(regex, acronym);
  2247. });
  2248.  
  2249. return updatedText;
  2250. }
  2251.  
  2252. function fixSateHwyRoadNames(text) {
  2253. // Regular expression to capture patterns like "XXX ###", "XXX-###", "XXX###", as well as "Us Route #", "Us Rte #", and "Route #", "Rte #"
  2254. const regex = /(?:([A-Z]{1,3})[-\s]?(\d{1,3})|(?:Us\s+(?:Rte|Route)\s+(\d{1,3}))|(?:Rte[-\s]?(\d{1,3})|Route\s+(\d{1,3})))\b/gi;
  2255.  
  2256. // Replacement function formats matched patterns
  2257. return text.replace(regex, (match, letters, numbers, usRouteNumber, rteNumber, routeNumber) => {
  2258. if (usRouteNumber) {
  2259. return `US-${usRouteNumber}`; // for "US Route"/s
  2260. }
  2261. if (rteNumber || routeNumber) {
  2262. return `SR-${rteNumber || routeNumber}`; // Change "Rte" or "Route" to "SR"
  2263. }
  2264. if (letters && numbers) {
  2265. return `${letters.toUpperCase()}-${numbers}`; // General format for other letter-number combos
  2266. }
  2267. return match;
  2268. });
  2269. }
  2270.  
  2271. function titleCaseLabel(text) {
  2272. // Read each line separately
  2273. const lines = text.split('\n');
  2274. return lines
  2275. .map(line => {
  2276. const trimmedLine = line.trim(); // Trim the line to remove leading/trailing spaces
  2277. const words = trimmedLine.split(' '); // Split the line into individual words
  2278. // Capitalize the first letter of each word and convert the rest to lowercase
  2279. const titleCasedLine = words
  2280. .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
  2281. .join(' '); // Recombine the words into a title-cased line
  2282. return titleCasedLine; // Return the formatted line
  2283. })
  2284. .join('\n'); // Combine all the lines back into a single string separated by new lines
  2285. }
  2286.  
  2287. function processedLabel(label) {
  2288. if (useTitleCase) {
  2289. label = titleCaseLabel(label);
  2290. }
  2291. if (useAcronyms) {
  2292. label = replacePhrasesWithAcronyms(label);
  2293. }
  2294. if (useStateHwy) {
  2295. label = fixSateHwyRoadNames(label);
  2296. }
  2297. if (removeNewLines) {
  2298. label = label.replace(/[\r\n]+/g, ' ');
  2299. }
  2300. return label;
  2301. }
  2302.  
  2303. function updatePopup(labels) {
  2304. let popup = document.getElementById('layerLabelPopup');
  2305. if (!popup) {
  2306. popup = document.createElement('div');
  2307. popup.id = 'layerLabelPopup';
  2308. popup.style = `position: absolute; background: #f5f5f5; border: 2px solid #007bff; border-radius: 5px;
  2309. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); z-index: 1000; width: 500px; max-width: 800px;
  2310. height: 300px; resize: both; overflow: hidden; max-height: 700px; left: ${popupPosition.left}; top: ${popupPosition.top}; `;
  2311.  
  2312. const header = document.createElement('div');
  2313. header.style = 'background: #007bff; color: #fff; padding: 5px; cursor: move; border-radius: 3px 3px 0 0; display: flex; justify-content: space-between; align-items: center; height: 30px; ';
  2314.  
  2315. const title = document.createElement('span');
  2316. title.innerText = 'GIS-L Layer Labels';
  2317. header.appendChild(title);
  2318.  
  2319. const closeButton = document.createElement('span');
  2320. closeButton.innerText = '×';
  2321. closeButton.style = 'cursor: pointer; font-size: 20px; margin-left: 10px; ';
  2322. closeButton.addEventListener('click', () => {
  2323. isPopupVisible = false;
  2324. togglePopupVisibility();
  2325. $('input[name="popupVisibility"][value="show"]').prop('checked', isPopupVisible);
  2326. $('input[name="popupVisibility"][value="hide"]').prop('checked', !isPopupVisible);
  2327. saveSettingsToStorage();
  2328. });
  2329. header.appendChild(closeButton);
  2330. popup.appendChild(header);
  2331.  
  2332. const formatOptionContainer = document.createElement('div');
  2333. formatOptionContainer.style = 'background: #72767d; color: #fff;';
  2334.  
  2335. const firstRow = document.createElement('div');
  2336. firstRow.style = 'display: flex; gap: 10px; align-items: flex-start; justify-content: flex-start;';
  2337.  
  2338. const formatCheckbox = document.createElement('input');
  2339. formatCheckbox.type = 'checkbox';
  2340. formatCheckbox.id = 'useTitleCaseCheckbox';
  2341. formatCheckbox.style = 'margin-left: 10px';
  2342. formatCheckbox.checked = useTitleCase;
  2343. formatCheckbox.addEventListener('change', () => {
  2344. useTitleCase = formatCheckbox.checked;
  2345. updatePopupContent(labels);
  2346. saveSettingsToStorage();
  2347. });
  2348. firstRow.appendChild(formatCheckbox);
  2349.  
  2350. const formatCheckboxLabel = document.createElement('label');
  2351. formatCheckboxLabel.htmlFor = 'useTitleCaseCheckbox';
  2352. formatCheckboxLabel.innerText = 'Use Title Case';
  2353. formatCheckboxLabel.style = 'font-weight: 100; width: 150px;';
  2354. firstRow.appendChild(formatCheckboxLabel);
  2355.  
  2356. const acronymCheckbox = document.createElement('input');
  2357. acronymCheckbox.type = 'checkbox';
  2358. acronymCheckbox.id = 'useacronymsCheckbox';
  2359. acronymCheckbox.checked = useAcronyms;
  2360. acronymCheckbox.addEventListener('change', () => {
  2361. useAcronyms = acronymCheckbox.checked;
  2362. updatePopupContent(labels);
  2363. saveSettingsToStorage();
  2364. });
  2365. firstRow.appendChild(acronymCheckbox);
  2366.  
  2367. const acronymCheckboxLabel = document.createElement('label');
  2368. acronymCheckboxLabel.htmlFor = 'useacronymsCheckbox';
  2369. acronymCheckboxLabel.innerText = 'Use Acronyms & Abbreviations';
  2370. acronymCheckboxLabel.style = 'font-weight: 100;';
  2371. firstRow.appendChild(acronymCheckboxLabel);
  2372. formatOptionContainer.appendChild(firstRow);
  2373.  
  2374. const secondRow = document.createElement('div');
  2375. secondRow.style = 'display: flex; gap: 10px; align-items: flex-start; justify-content: flex-start;';
  2376.  
  2377. const stateHwyCheckbox = document.createElement('input');
  2378. stateHwyCheckbox.type = 'checkbox';
  2379. stateHwyCheckbox.id = 'useStateHwyCheckbox';
  2380. stateHwyCheckbox.style = 'margin-left: 10px';
  2381. stateHwyCheckbox.checked = useStateHwy;
  2382. stateHwyCheckbox.addEventListener('change', () => {
  2383. useStateHwy = stateHwyCheckbox.checked;
  2384. updatePopupContent(labels);
  2385. saveSettingsToStorage();
  2386. });
  2387. secondRow.appendChild(stateHwyCheckbox);
  2388.  
  2389. const stateHwyCheckboxLabel = document.createElement('label');
  2390. stateHwyCheckboxLabel.htmlFor = 'useStateHwyCheckbox';
  2391. stateHwyCheckboxLabel.innerText = 'Fix Highway Labels';
  2392.  
  2393. stateHwyCheckboxLabel.style = 'font-weight: 100; width: 150px;';
  2394. secondRow.appendChild(stateHwyCheckboxLabel);
  2395.  
  2396. const removeNewLinesCheckbox = document.createElement('input');
  2397. removeNewLinesCheckbox.type = 'checkbox';
  2398. removeNewLinesCheckbox.id = 'removeNewLinesCheckbox';
  2399. removeNewLinesCheckbox.checked = removeNewLines;
  2400. removeNewLinesCheckbox.addEventListener('change', () => {
  2401. removeNewLines = removeNewLinesCheckbox.checked;
  2402. updatePopupContent(labels);
  2403. saveSettingsToStorage();
  2404. });
  2405. secondRow.appendChild(removeNewLinesCheckbox);
  2406.  
  2407. const removeNewLinesCheckboxLabel = document.createElement('label');
  2408. removeNewLinesCheckboxLabel.htmlFor = 'removeNewLinesCheckbox';
  2409. removeNewLinesCheckboxLabel.innerText = 'Remove New Lines';
  2410. removeNewLinesCheckboxLabel.style = 'font-weight: 100;';
  2411. secondRow.appendChild(removeNewLinesCheckboxLabel);
  2412.  
  2413. formatOptionContainer.appendChild(secondRow);
  2414. popup.appendChild(formatOptionContainer);
  2415.  
  2416. const dropdownContainer = document.createElement('div');
  2417. dropdownContainer.style = 'margin-bottom: 10px;';
  2418. popup.appendChild(dropdownContainer);
  2419.  
  2420. const contentContainer = document.createElement('div');
  2421. contentContainer.style = 'padding: 5px; overflow-y: auto; overflow-x: auto; height: calc(100% - 110px);';
  2422. popup.appendChild(contentContainer);
  2423.  
  2424. const mapElement = document.getElementsByTagName('wz-page-content')[0];
  2425. if (mapElement) {
  2426. mapElement.appendChild(popup);
  2427. }
  2428.  
  2429. header.onmousedown = function(event) {
  2430. event.preventDefault();
  2431. const parentRect = mapElement.getBoundingClientRect();
  2432. const initialX = event.clientX;
  2433. const initialY = event.clientY;
  2434. const offsetX = initialX - parentRect.left - popup.offsetLeft;
  2435. const offsetY = initialY - parentRect.top - popup.offsetTop;
  2436.  
  2437. document.onmousemove = function(ev) {
  2438. popup.style.left = `${ev.clientX - offsetX - parentRect.left}px`;
  2439. popup.style.top = `${ev.clientY - offsetY - parentRect.top}px`;
  2440.  
  2441. popupPosition.left = popup.style.left;
  2442. popupPosition.top = popup.style.top;
  2443. };
  2444.  
  2445. document.onmouseup = function() {
  2446. document.onmousemove = null;
  2447. document.onmouseup = null;
  2448. };
  2449. };
  2450. }
  2451.  
  2452. updatePopupContent(labels);
  2453. popup.style.display = isPopupVisible ? 'block' : 'none';
  2454. }
  2455.  
  2456. function updatePopupContent(labels) {
  2457. const dropdownContainer = document.querySelector('#layerLabelPopup div:nth-child(3)');
  2458. const contentContainer = document.querySelector('#layerLabelPopup div:nth-child(4)');
  2459.  
  2460. dropdownContainer.innerHTML = '';
  2461. contentContainer.innerHTML = '';
  2462.  
  2463. const select = document.createElement('select');
  2464. select.style = 'width: 100%; padding: 5px; border: 1px solid #ccc;';
  2465.  
  2466. const sortedLayerNames = Object.keys(labels).sort();
  2467. sortedLayerNames.forEach(layerName => {
  2468. const option = document.createElement('option');
  2469. option.value = layerName;
  2470. option.innerText = layerName;
  2471. select.appendChild(option);
  2472.  
  2473. const uniqueLabels = Array.from(labels[layerName]).sort();
  2474. const tabContent = document.createElement('div');
  2475. tabContent.style = 'display: none; width: 100%; white-space: pre;';
  2476.  
  2477. const processedLabels = uniqueLabels
  2478. .map(label => {
  2479. const text = processedLabel(label);
  2480. const copyIcon = '<span style="cursor: pointer; margin-left: 5px;" title="Copy to clipboard">📋</span>';
  2481. return `<li style="margin-bottom: 0.3em; color: #555;" data-label="${text}">${text}${copyIcon}</li>`;
  2482. })
  2483. .join('');
  2484.  
  2485. tabContent.innerHTML = `<ul style="padding-left: 20px; margin-top: 0;">${processedLabels}</ul>`;
  2486. contentContainer.appendChild(tabContent);
  2487.  
  2488. // Add copying functionality
  2489. tabContent.querySelectorAll('li').forEach(li => {
  2490. const icon = li.querySelector('span');
  2491. if (icon) {
  2492. icon.addEventListener('click', () => {
  2493. const textToCopy = li.getAttribute('data-label'); // Get the text from a custom data attribute
  2494. copyTextToClipboard(textToCopy);
  2495. });
  2496. }
  2497. });
  2498. });
  2499.  
  2500. dropdownContainer.appendChild(select);
  2501.  
  2502. let selectedLayerIndex = sortedLayerNames.indexOf(popupActiveLayer);
  2503.  
  2504. if (selectedLayerIndex === -1 && select.options.length > 0) {
  2505. selectedLayerIndex = 0;
  2506. popupActiveLayer = sortedLayerNames[selectedLayerIndex];
  2507. }
  2508. select.selectedIndex = selectedLayerIndex;
  2509.  
  2510. const allContents = contentContainer.querySelectorAll('div');
  2511. allContents.forEach((content, index) => {
  2512. content.style.display = index === select.selectedIndex ? 'block' : 'none';
  2513. });
  2514.  
  2515. select.addEventListener('change', () => {
  2516. const contents = contentContainer.querySelectorAll('div');
  2517. contents.forEach((content, index) => {
  2518. content.style.display = index === select.selectedIndex ? 'block' : 'none';
  2519. });
  2520. popupActiveLayer = select.value;
  2521. });
  2522. }
  2523.  
  2524. function fetchFeatures() {
  2525. if (isPopupVisible) {
  2526. Object.keys(layerLabels).forEach(key => delete layerLabels[key]);
  2527. }
  2528. if (ignoreFetch) return;
  2529. if (sdk.Map.getZoomLevel() < 12) {
  2530. filterLayerCheckboxes();
  2531. return;
  2532. }
  2533. lastToken.cancel = true;
  2534. lastToken = { cancel: false, features: [], layersProcessed: 0 };
  2535. $('.gis-state-layer-label').css({ color: '#777' });
  2536.  
  2537. let _layersCleared = false;
  2538.  
  2539. // if (layersToFetch.length) {
  2540. const extent = getMercatorMapExtent();
  2541. GM_xmlhttpRequest({
  2542. url: getCountiesUrl(extent),
  2543. method: 'GET',
  2544. onload(res) {
  2545. if (res.status < 400) {
  2546. const data = $.parseJSON(res.responseText);
  2547. if (data.error) {
  2548. logError(`Error in US Census counties data: ${data.error.message}`);
  2549. } else {
  2550. _countiesInExtent = data.features.map(feature => {
  2551. const name = feature.attributes.BASENAME.toLowerCase();
  2552. const stateInfo = STATES.fromId(parseInt(feature.attributes.STATE, 10));
  2553. return { name, stateInfo };
  2554. });
  2555. logDebug(`US Census counties: ${_countiesInExtent.map(c => `${c.name} ${c.stateInfo[1]}`).join(', ')}`);
  2556.  
  2557. let layersToFetch;
  2558. if (!_layersCleared) {
  2559. _layersCleared = true;
  2560. layersToFetch = getFetchableLayers();
  2561.  
  2562. // Remove features of any layers that won't be mapped.
  2563. _gisLayers.forEach(gisLayer => {
  2564. if (!layersToFetch.includes(gisLayer)) {
  2565. mapLayer.removeFeatures(mapLayer.getFeaturesByAttribute('layerID', gisLayer.id));
  2566. roadLayer.removeFeatures(roadLayer.getFeaturesByAttribute('layerID', gisLayer.id));
  2567. }
  2568. });
  2569. }
  2570.  
  2571. layersToFetch = layersToFetch.filter(layer => !layer.hasOwnProperty('counties')
  2572. || layer.counties.some(countyName => _countiesInExtent.some(county => county.name === countyName.toLowerCase()
  2573. && layer.state === county.stateInfo[1])));
  2574. filterLayerCheckboxes();
  2575. logDebug(`Fetching ${layersToFetch.length} layers...`);
  2576. logDebug(layersToFetch);
  2577. let layersProcessedCount = 0; // Track processed layers
  2578.  
  2579. layersToFetch.forEach(gisLayer => {
  2580. const url = getUrl(extent, gisLayer);
  2581. GM_xmlhttpRequest({
  2582. url,
  2583. context: lastToken,
  2584. method: 'GET',
  2585. onload(res2) {
  2586. if (res2.status < 400) { // Handle stupid issue where http 4## is considered success
  2587. processFeatures($.parseJSON(res2.responseText), res2.context, gisLayer);
  2588. // Update the popup only after all layers have been processed
  2589. layersProcessedCount += 1;
  2590. if (layersProcessedCount === layersToFetch.length && isPopupVisible) {
  2591. updatePopup(layerLabels);
  2592. }
  2593. } else {
  2594. logDebug(`HTTP request error: ${JSON.stringify(res2)}`);
  2595. logError(`Could not fetch layer "${gisLayer.id}". Request returned ${res2.status}`);
  2596. }
  2597. },
  2598. onerror(res3) {
  2599. logDebug(`xmlhttpRequest error:${JSON.stringify(res3)}`);
  2600. logError(`Could not fetch layer "${gisLayer.id}". An error was thrown.`);
  2601. }
  2602. });
  2603. });
  2604. }
  2605. } else {
  2606. logDebug(`HTTP request error: ${JSON.stringify(res)}`);
  2607. logError(`Could not fetch counties from US Census site. Request returned ${res.status}`);
  2608. }
  2609. },
  2610. onerror(res) {
  2611. logDebug(`xmlhttpRequest error:${JSON.stringify(res)}`);
  2612. logError('Could not fetch counties from US Census site. An error was thrown.');
  2613. }
  2614. });
  2615. }
  2616.  
  2617. function showScriptInfoAlert() {
  2618. /* Check version and alert on update */
  2619. if (SHOW_UPDATE_MESSAGE && scriptVersion !== settings.lastVersion) {
  2620. // alert(SCRIPT_VERSION_CHANGES);
  2621. let releaseNotes = '';
  2622. releaseNotes += '<p>What\'s New:</p>';
  2623. if (SCRIPT_VERSION_CHANGES.length > 0) {
  2624. releaseNotes += '<ul>';
  2625. for (let idx = 0; idx < SCRIPT_VERSION_CHANGES.length; idx++)
  2626. releaseNotes += `<li>${SCRIPT_VERSION_CHANGES[idx]}`;
  2627. releaseNotes += '</ul>';
  2628. }
  2629. else {
  2630. releaseNotes += '<ul><li>Nothing major.</ul>';
  2631. }
  2632. WazeWrap.Interface.ShowScriptUpdate(GM_info.script.name, scriptVersion, releaseNotes, GF_URL);
  2633. }
  2634. }
  2635.  
  2636. function setEnabled(value) {
  2637. settings.enabled = value;
  2638. saveSettingsToStorage();
  2639. mapLayer.setVisibility(value);
  2640. roadLayer.setVisibility(value);
  2641. const color = value ? '#00bd00' : '#ccc';
  2642. $('span#gis-layers-power-btn').css({ color });
  2643. if (value) fetchFeatures();
  2644. sdk.LayerSwitcher.setLayerCheckboxChecked({ name: 'GIS Layers', isChecked: value });
  2645.  
  2646. // Show/hide the popup based on the enabled state
  2647. const popup = document.getElementById('layerLabelPopup');
  2648. if (popup) {
  2649. popup.style.display = value ? 'block' : 'none';
  2650. isPopupVisible = value;
  2651. }
  2652. }
  2653.  
  2654. function onGisLayerToggleChanged() {
  2655. const checked = $(this).is(':checked');
  2656. const layerId = $(this).data('layer-id');
  2657. const idx = settings.visibleLayers.indexOf(layerId);
  2658. if (checked) {
  2659. const gisLayer = _gisLayers.find(l => l.id === layerId);
  2660. if (gisLayer.oneTimeAlert) {
  2661. const lastAlertHash = settings.oneTimeAlerts[layerId];
  2662. const newAlertHash = hashString(gisLayer.oneTimeAlert);
  2663. if (lastAlertHash !== newAlertHash) {
  2664. // alert(`Layer: ${gisLayer.name}\n\nMessage:\n${gisLayer.oneTimeAlert}`);
  2665. WazeWrap.Alerts.info(GM_info.script.name, `Layer: ${gisLayer.name}<br><br>Message:<br>${gisLayer.oneTimeAlert}`);
  2666. settings.oneTimeAlerts[layerId] = newAlertHash;
  2667. saveSettingsToStorage();
  2668. }
  2669. }
  2670. if (idx === -1) settings.visibleLayers.push(layerId);
  2671. } else if (idx > -1) settings.visibleLayers.splice(idx, 1);
  2672. if (!ignoreFetch) {
  2673. saveSettingsToStorage();
  2674. fetchFeatures();
  2675. }
  2676. }
  2677.  
  2678. function onOnlyShowApplicableLayersChanged() {
  2679. settings.onlyShowApplicableLayers = $(this).is(':checked');
  2680. saveSettingsToStorage();
  2681. fetchFeatures();
  2682. }
  2683.  
  2684. function onStateCheckChanged(evt) {
  2685. const state = evt.data;
  2686. const idx = settings.selectedStates.indexOf(state);
  2687. if (evt.target.checked) {
  2688. if (idx === -1) settings.selectedStates.push(state);
  2689. } else if (idx > -1) settings.selectedStates.splice(idx, 1);
  2690. if (!ignoreFetch) {
  2691. saveSettingsToStorage();
  2692. initLayersTab();
  2693. fetchFeatures();
  2694. }
  2695. }
  2696.  
  2697. function onLayerCheckboxChanged(args) {
  2698. setEnabled(args.checked);
  2699. }
  2700.  
  2701. function setFillParcels(doFill) {
  2702. [LAYER_STYLES.parcels, LAYER_STYLES.state_parcels].forEach(style => {
  2703. style.fillOpacity = doFill ? 0.2 : 0;
  2704. });
  2705. }
  2706.  
  2707. function onFillParcelsCheckedChanged(evt) {
  2708. const { checked } = evt.target;
  2709. setFillParcels(checked);
  2710. settings.fillParcels = checked;
  2711. saveSettingsToStorage();
  2712. fetchFeatures();
  2713. }
  2714.  
  2715. function onMapMove() {
  2716. if (settings.enabled) fetchFeatures();
  2717. }
  2718.  
  2719. function onRefreshLayersClick() {
  2720. const $btn = $('#gis-layers-refresh');
  2721. if (!$btn.hasClass('fa-spin')) {
  2722. $btn.css({ cursor: 'auto' });
  2723. $btn.addClass('fa-spin');
  2724. init(false);
  2725. }
  2726. }
  2727.  
  2728. function onChevronClick(evt) {
  2729. const $target = $(evt.currentTarget);
  2730. $($target.children()[0])
  2731. .toggleClass('fa fa-fw fa-chevron-down')
  2732. .toggleClass('fa fa-fw fa-chevron-right');
  2733. const $div = $($target.siblings()[0]);
  2734. if ($div.css('display') === 'none') {
  2735. $div.css('display', 'block');
  2736. } else {
  2737. $div.css('display', 'none');
  2738. }
  2739. }
  2740.  
  2741. function doToggleABunch(evt, checkState) {
  2742. ignoreFetch = true;
  2743. $(evt.target).closest('fieldset').find('input').prop('checked', !checkState).trigger('click');
  2744. ignoreFetch = false;
  2745. saveSettingsToStorage();
  2746. if (evt.data) initLayersTab();
  2747. fetchFeatures();
  2748. }
  2749.  
  2750. function onSelectAllClick(evt) {
  2751. doToggleABunch(evt, true);
  2752. }
  2753.  
  2754. function onSelectNoneClick(evt) {
  2755. doToggleABunch(evt, false);
  2756. }
  2757.  
  2758. function onGisAddrDisplayChange(evt) {
  2759. settings.addrLabelDisplay = evt.target.value;
  2760. saveSettingsToStorage();
  2761. fetchFeatures();
  2762. }
  2763.  
  2764. function onAddressDisplayShortcutKey() {
  2765. if (!$('#gisAddrDisplay-hn').is(':checked')) {
  2766. $('#gisAddrDisplay-hn').click();
  2767. } else {
  2768. $('#gisAddrDisplay-all').click();
  2769. }
  2770. }
  2771.  
  2772. function onToggleGisLayersShortcutKey() {
  2773. setEnabled(!settings.enabled);
  2774. }
  2775.  
  2776. function togglePopupVisibility() {
  2777. const popup = document.getElementById('layerLabelPopup');
  2778. if (popup) {
  2779. popup.style.display = isPopupVisible ? 'block' : 'none';
  2780. }
  2781. saveSettingsToStorage();
  2782. }
  2783.  
  2784. function initLayer() {
  2785. const rules = _gisLayers.map(gisLayer => new OpenLayers.Rule({
  2786. filter: new OpenLayers.Filter.Comparison({
  2787. type: OpenLayers.Filter.Comparison.EQUAL_TO,
  2788. property: 'layerID',
  2789. value: gisLayer.id
  2790. }),
  2791. symbolizer: gisLayer.style
  2792. }));
  2793.  
  2794. setFillParcels(settings.fillParcels);
  2795.  
  2796. const style = new OpenLayers.Style(DEFAULT_STYLE, { rules });
  2797. let existingLayer;
  2798. let uniqueName;
  2799.  
  2800. uniqueName = 'wmeGISLayersDefault';
  2801. existingLayer = W.map.layers.find(l => l.uniqueName === uniqueName); // Note: W.map.getLayerByUniqueName(...) isn't working.
  2802. if (existingLayer) W.map.removeLayer(existingLayer);
  2803. mapLayer = new OpenLayers.Layer.Vector('GIS Layers - Default', {
  2804. uniqueName,
  2805. styleMap: new OpenLayers.StyleMap(style)
  2806. });
  2807.  
  2808. uniqueName = 'wmeGISLayersRoads';
  2809. existingLayer = W.map.layers.find(l => l.uniqueName === uniqueName); // Note: W.map.getLayerByUniqueName(...) isn't wworking.
  2810. if (existingLayer) W.map.removeLayer(existingLayer);
  2811. roadLayer = new OpenLayers.Layer.Vector('GIS Layers - Roads', {
  2812. uniqueName,
  2813. styleMap: new OpenLayers.StyleMap(ROAD_STYLE)
  2814. });
  2815.  
  2816. mapLayer.setVisibility(settings.enabled);
  2817. roadLayer.setVisibility(settings.enabled);
  2818.  
  2819. W.map.addLayers([roadLayer, mapLayer]);
  2820. } // END InitLayer
  2821.  
  2822. function initLayersTab() {
  2823. const user = userInfo.userName.toLowerCase();
  2824. const states = _.uniq(_gisLayers.map(l => l.state)).filter(st => settings.selectedStates.includes(st));
  2825.  
  2826. $('#panel-gis-state-layers').empty().append(
  2827. $('<div>', { class: 'controls-container' }).css({ 'padding-top': '0px' }).append(
  2828. $('<input>', { type: 'checkbox', id: 'only-show-applicable-gis-layers' }).change(
  2829. onOnlyShowApplicableLayersChanged
  2830. ).prop('checked', settings.onlyShowApplicableLayers),
  2831. $('<label>', { for: 'only-show-applicable-gis-layers' })
  2832. .css({ 'white-space': 'pre-line' }).text('Only show applicable layers')
  2833. ),
  2834. $('.gis-layers-state-checkbox:checked').length === 0
  2835. ? $('<div>').text('Turn on layer categories in the Settings tab.')
  2836. : states.map(st => $('<fieldset>', {
  2837. id: `gis-layers-for-${st}`,
  2838. style: 'border:1px solid silver;padding:4px;border-radius:4px;-webkit-padding-before: 0;'
  2839. }).append(
  2840. $('<legend>', { style: 'margin-bottom:0px;border-bottom-style:none;width:auto;' })
  2841. .click(onChevronClick).append(
  2842. $('<i>', {
  2843. class: 'fa fa-fw fa-chevron-down',
  2844. style: 'cursor: pointer;font-size: 12px;margin-right: 4px'
  2845. }),
  2846. $('<span>', {
  2847. style: 'font-size:14px;font-weight:600;text-transform: uppercase; cursor: pointer'
  2848. }).text(STATES.toFullName(st))
  2849. ),
  2850. $('<div>', { id: `${st}_body` }).append(
  2851. $('<div>').css({ 'font-size': '11px' }).append(
  2852. $('<span>').append(
  2853. 'Select ',
  2854. $('<a>', { href: '#' })
  2855. .text('All')
  2856. .click(onSelectAllClick),
  2857. ' / ',
  2858. $('<a>', { href: '#' })
  2859. .text('None')
  2860. .click(onSelectNoneClick)
  2861. )
  2862. ),
  2863. $('<div>', { class: 'controls-container', style: 'padding-top:0px;' }).append(
  2864. _gisLayers.filter(l => (l.state === st && (!PRIVATE_LAYERS.hasOwnProperty(l.id)
  2865. || PRIVATE_LAYERS[l.id].includes(user))))
  2866. .map(gisLayer => {
  2867. const id = `gis-layer-${gisLayer.id}`;
  2868. return $('<div>', { class: 'controls-container', id: `${id}-container` })
  2869. .css({ 'padding-top': '0px', display: 'block' })
  2870. .append(
  2871. $('<input>', { type: 'checkbox', id })
  2872. .data('layer-id', gisLayer.id)
  2873. .change(onGisLayerToggleChanged)
  2874. .prop('checked', settings.visibleLayers.includes(gisLayer.id)),
  2875. $('<label>', { for: id, class: 'gis-state-layer-label' })
  2876. .css({ 'white-space': 'pre-line' })
  2877. .text(`${gisLayer.name}${gisLayer.restrictTo ? ' *' : ''}`)
  2878. .attr('title', gisLayer.restrictTo ? `Restricted to: ${gisLayer.restrictTo}` : '')
  2879. .contextmenu(evt => {
  2880. evt.preventDefault();
  2881. // TODO - enable the layer if it isn't already.
  2882. // Tried using click function on the evt target, but that didn't work.
  2883. _layerSettingsDialog.gisLayer = gisLayer;
  2884. _layerSettingsDialog.show();
  2885. })
  2886. );
  2887. })
  2888. )
  2889. )
  2890. ))
  2891. );
  2892. }
  2893.  
  2894. function initSettingsTab() {
  2895. const states = _.uniq(_gisLayers.map(l => l.state));
  2896. const createRadioBtn = (name, value, text, checked) => {
  2897. const id = `${name}-${value}`;
  2898. return [$('<input>', {
  2899. type: 'radio', id, name, value
  2900. }).prop('checked', checked), $('<label>', { for: id }).text(text).css({
  2901. paddingLeft: '15px', marginRight: '4px'
  2902. })];
  2903. };
  2904. $('#panel-gis-layers-settings').empty().append(
  2905. $('<fieldset>', {
  2906. style: 'border:1px solid silver;padding:8px;border-radius:4px;-webkit-padding-before: 0;margin-top:-8px;'
  2907. }).append(
  2908. $('<legend>', {
  2909. style: 'margin-bottom:0px;border-bottom-style:none;width:auto;'
  2910. }).append($('<span>', {
  2911. style: 'font-size:14px;font-weight:600;text-transform: uppercase;'
  2912. }).text('Labels')),
  2913. $('<div>', { id: 'labelSettings' }).append(
  2914. $('<div>', { class: 'controls-container' }).css({ 'padding-top': '2px' }).append(
  2915. $('<label>', { style: 'font-weight:normal;' }).text('Addresses:'),
  2916. createRadioBtn('gisAddrDisplay', 'hn', 'HN', settings.addrLabelDisplay === 'hn'),
  2917. createRadioBtn('gisAddrDisplay', 'street', 'Street', settings.addrLabelDisplay === 'street'),
  2918. createRadioBtn('gisAddrDisplay', 'all', 'Both', settings.addrLabelDisplay === 'all'),
  2919. createRadioBtn('gisAddrDisplay', 'none', 'None', settings.addrLabelDisplay === 'none'),
  2920. $('<i>', {
  2921. class: 'waze-tooltip',
  2922. id: 'gisAddrDisplayInfo',
  2923. 'data-toggle': 'tooltip',
  2924. style: 'margin-left:8px; font-size:12px',
  2925. 'data-placement': 'bottom',
  2926. title: `This may not work properly for all layers. Please report issues to ${SCRIPT_AUTHOR}.`
  2927. }).tooltip(),
  2928. $('<br>'),
  2929. $('<label>', { style: 'font-weight:normal; margin-left:8px;' }).text('Label Popup:'),
  2930. createRadioBtn('popupVisibility', 'show', 'Show', isPopupVisible),
  2931. createRadioBtn('popupVisibility', 'hide', 'Hide', !isPopupVisible)
  2932. )
  2933. )
  2934. ),
  2935. $('<fieldset>', {
  2936. style: 'border:1px solid silver;padding:8px;border-radius:4px;-webkit-padding-before: 0;'
  2937. }).append(
  2938. $('<legend>', {
  2939. style: 'margin-bottom:0px;border-bottom-style:none;width:auto;'
  2940. }).append($('<span>', {
  2941. style: 'font-size:14px;font-weight:600;text-transform: uppercase;'
  2942. }).text('Layer Categories')),
  2943. $('<div>', { id: 'states_body' }).append(
  2944. $('<div>').css({ 'font-size': '11px' }).append(
  2945. $('<span>').append(
  2946. 'Select ',
  2947. $('<a>', { href: '#' }).text('All').click(true, onSelectAllClick),
  2948. ' / ',
  2949. $('<a>', { href: '#' }).text('None').click(true, onSelectNoneClick)
  2950. )
  2951. ),
  2952. $('<div>', { class: 'controls-container', style: 'padding-top:0px;' }).append(
  2953. states.map(st => {
  2954. const fullName = STATES.toFullName(st);
  2955. const id = `gis-layer-enable-state-${st}`;
  2956. return $('<div>', { class: 'controls-container' })
  2957. .css({ 'padding-top': '0px', display: 'block' })
  2958. .append(
  2959. $('<input>', { type: 'checkbox', id, class: 'gis-layers-state-checkbox' })
  2960. .change(st, onStateCheckChanged)
  2961. .prop('checked', settings.selectedStates.includes(st)),
  2962. $('<label>', { for: id }).css({ 'white-space': 'pre-line', color: '#777' }).text(fullName)
  2963. );
  2964. })
  2965. )
  2966. )
  2967. )
  2968. );
  2969. $('#panel-gis-layers-settings').append(
  2970. $('<fieldset>', { style: 'border:1px solid silver;padding:8px;border-radius:4px;-webkit-padding-before: 0;' })
  2971. .append(
  2972. $('<legend>', { style: 'margin-bottom:0px;border-bottom-style:none;width:auto;' })
  2973. .append(
  2974. $('<span>', { style: 'font-size:14px;font-weight:600;text-transform: uppercase;' })
  2975. .text('Appearance')
  2976. ),
  2977. $('<div>', { class: 'controls-container' }).css({ 'padding-top': '2px' }).append(
  2978. $('<input>', { type: 'checkbox', id: 'fill-parcels' })
  2979. .change(onFillParcelsCheckedChanged)
  2980. .prop('checked', settings.fillParcels),
  2981. $('<label>', { for: 'fill-parcels' }).css({ 'white-space': 'pre-line', color: '#777' }).text('Fill parcels')
  2982. )
  2983. )
  2984. );
  2985. $('input[name="gisAddrDisplay"]').change(onGisAddrDisplayChange);
  2986. $('input[name="popupVisibility"]').change(function() {
  2987. isPopupVisible = $(this).val() === 'show';
  2988. togglePopupVisibility();
  2989. });
  2990. }
  2991.  
  2992. async function initTab(firstCall = true) {
  2993. if (firstCall) {
  2994. const content = $('<div>').append(
  2995. $('<span>', { style: 'font-size:14px;font-weight:600' }).text('GIS Layers'),
  2996. $('<span>', { style: 'font-size:11px;margin-left:10px;color:#aaa;' }).text(GM_info.script.version),
  2997. // <a href="https://docs.google.com/forms/d/e/1FAIpQLSevPQLz2ohu_LTge9gJ9Nv6PURmCmaSSjq0ayOJpGdRr2xI0g/viewform?usp=pp_url&entry.2116052852=test" target="_blank" style="color: #6290b7;font-size: 12px;margin-left: 8px;" title="Report broken layers, bugs, request new layers, script features">Report an issue</a>
  2998. $('<a>', {
  2999. href: REQUEST_FORM_URL.replace('{username}', userInfo.userName),
  3000. target: '_blank',
  3001. style: 'color: #6290b7;font-size: 12px;margin-left: 8px;',
  3002. title: 'Report broken layers, bugs, request new layers, script features'
  3003. }).text('Submit a request'),
  3004. $('<span>', {
  3005. id: 'gis-layers-refresh',
  3006. class: 'fa fa-refresh',
  3007. style: 'float: right;',
  3008. 'data-toggle': 'tooltip',
  3009. title: 'Pull new layer info from master sheet and refresh all layers.'
  3010. }),
  3011. '<ul class="nav nav-tabs">'
  3012. + '<li class="active"><a data-toggle="tab" href="#panel-gis-state-layers" aria-expanded="true">'
  3013. + 'Layers'
  3014. + '</a></li>'
  3015. + '<li><a data-toggle="tab" href="#panel-gis-layers-settings" aria-expanded="true">'
  3016. + 'Settings'
  3017. + '</a></li> '
  3018. + '</ul>',
  3019. $('<div>', { class: 'tab-content', style: 'padding:8px;padding-top:2px' }).append(
  3020. $('<div>', { class: 'tab-pane active', id: 'panel-gis-state-layers', style: 'padding: 4px 0px 0px 0px; width: auto' }),
  3021. $('<div>', { class: 'tab-pane', id: 'panel-gis-layers-settings', style: 'padding: 4px 0px 0px 0px; width: auto' })
  3022. )
  3023. ).html();
  3024.  
  3025. const powerButtonColor = settings.enabled ? '#00bd00' : '#ccc';
  3026. const labelText = $('<div>').append(
  3027. $('<span>', {
  3028. class: 'fa fa-power-off',
  3029. id: 'gis-layers-power-btn',
  3030. style: `margin-right: 5px;cursor: pointer;color: ${powerButtonColor};font-size: 13px;`,
  3031. title: 'Toggle GIS Layers'
  3032. }),
  3033. $('<span>', { title: 'GIS Layers' }).text('GIS-L')
  3034. ).html();
  3035.  
  3036. const { tabLabel, tabPane } = await sdk.Sidebar.registerScriptTab();
  3037. tabLabel.innerHTML = labelText;
  3038. tabPane.innerHTML = content;
  3039. // Fix tab content div spacing.
  3040. $(tabPane).parent().css({ width: 'auto', padding: '6px' });
  3041. $('#gis-layers-power-btn').click(() => {
  3042. setEnabled(!settings.enabled);
  3043.  
  3044. // return false to prevent event from bubbling up the DOM tree and causing the GIS-L tab to activate
  3045. return false;
  3046. });
  3047. $('#gis-layers-refresh').click(onRefreshLayersClick);
  3048. }
  3049.  
  3050. initSettingsTab();
  3051. initLayersTab();
  3052. }
  3053.  
  3054. function initGui(firstCall = true) {
  3055. initLayer();
  3056.  
  3057. if (firstCall) {
  3058. initTab(true);
  3059.  
  3060. sdk.LayerSwitcher.addLayerCheckbox({ name: 'GIS Layers' });
  3061. sdk.LayerSwitcher.setLayerCheckboxChecked({ name: 'GIS Layers', isChecked: settings.enabled });
  3062. sdk.Events.on({ eventName: 'wme-layer-checkbox-toggled', eventHandler: onLayerCheckboxChanged });
  3063. sdk.Events.on({ eventName: 'wme-map-move-end', eventHandler: onMapMove });
  3064. showScriptInfoAlert();
  3065. } else {
  3066. initTab(firstCall);
  3067. }
  3068. }
  3069.  
  3070. async function loadSpreadsheetAsync() {
  3071. let data;
  3072. try {
  3073. data = await $.getJSON(`${LAYER_DEF_SPREADSHEET_URL}?${DEC(API_KEY)}`);
  3074. } catch (err) {
  3075. throw new Error(`Spreadsheet call failed. (${err.status}: ${err.statusText})`);
  3076. }
  3077. const [[minVersion], fieldNames, ...layerDefRows] = data.values;
  3078. const REQUIRED_FIELD_NAMES = [
  3079. 'state', 'name', 'id', 'counties', 'url', 'where', 'labelFields',
  3080. 'processLabel', 'style', 'visibleAtZoom', 'labelsVisibleAtZoom', 'enabled',
  3081. 'restrictTo', 'oneTimeAlert'
  3082. ];
  3083. const result = { error: null };
  3084. const checkFieldNames = fldName => fieldNames.includes(fldName);
  3085.  
  3086. if (scriptVersion < minVersion) {
  3087. result.error = `Script must be updated to at least version ${
  3088. minVersion} before layer definitions can be loaded.`;
  3089. } else if (fieldNames.length < REQUIRED_FIELD_NAMES.length) {
  3090. result.error = `Expected ${
  3091. REQUIRED_FIELD_NAMES.length} columns in layer definition data. Spreadsheet returned ${
  3092. fieldNames.length}.`;
  3093. } else if (!REQUIRED_FIELD_NAMES.every(fldName => checkFieldNames(fldName))) {
  3094. result.error = 'Script expected to see the following column names in the layer '
  3095. + `definition spreadsheet:\n${REQUIRED_FIELD_NAMES.join(', ')}\n`
  3096. + `But the spreadsheet returned these:\n${fieldNames.join(', ')}`;
  3097. }
  3098. if (!result.error) {
  3099. layerDefRows.filter(row => row.length).forEach(layerDefRow => {
  3100. const layerDef = { enabled: '0' };
  3101. fieldNames.forEach((fldName, fldIdx) => {
  3102. let value = layerDefRow[fldIdx];
  3103. if (value !== undefined && value.trim().length > 0) {
  3104. value = value.trim();
  3105. if (fldName === 'counties' || fldName === 'labelFields') {
  3106. value = value.split(',').map(item => item.trim());
  3107. } else if (fldName === 'processLabel') {
  3108. try {
  3109. value = ESTreeProcessor.compile(`function __$proc(){${value}} __$proc();`);
  3110. } catch (ex) {
  3111. layerDef.labelProcessingError = true;
  3112. logError(`Error loading label processing function for layer "${layerDef.id}".`);
  3113. logDebug(ex);
  3114. }
  3115. } else if (fldName === 'style') {
  3116. layerDef.isRoadLayer = value === 'roads';
  3117. if (LAYER_STYLES.hasOwnProperty(value)) {
  3118. value = LAYER_STYLES[value];
  3119. } else if (!layerDef.isRoadLayer) {
  3120. // If style is not defined, try to read in as JSON (custom style)
  3121. try {
  3122. value = JSON.parse(value);
  3123. } catch (ex) {
  3124. // ignore error
  3125. }
  3126. }
  3127. } else if (fldName === 'state') {
  3128. value = value ? value.toUpperCase() : value;
  3129. } else if (fldName === 'restrictTo') {
  3130. try {
  3131. const values = value.split(',').map(v => v.trim().toLowerCase());
  3132. layerDef.notAllowed = !values.some(entry => {
  3133. const rankMatch = entry.match(/^r(\d)(\+am)?$/);
  3134. if (rankMatch) {
  3135. if (rankMatch[1] <= (userInfo.rank + 1) && (!rankMatch[2] || userInfo.isAreaManager)) {
  3136. return true;
  3137. }
  3138. } else if (entry === 'am' && userInfo.isAreaManager) {
  3139. return true;
  3140. } else if (entry === userInfo.userName.toLowerCase()) {
  3141. return true;
  3142. }
  3143. return false;
  3144. });
  3145. } catch (ex) {
  3146. logError(ex);
  3147. }
  3148. }
  3149. layerDef[fldName] = value;
  3150. } else if (fldName === 'labelFields') {
  3151. layerDef[fldName] = [''];
  3152. }
  3153. });
  3154. const enabled = layerDef.enabled && !['0', 'false', 'no', 'n'].includes(layerDef.enabled.toString().trim().toLowerCase());
  3155. if (!layerDef.notAllowed && enabled) {
  3156. _gisLayers.push(layerDef);
  3157. }
  3158. });
  3159. }
  3160.  
  3161. return result;
  3162. }
  3163.  
  3164. function createShortcut(shortcutId, description, callback) {
  3165. let shortcutKeys = settings.shortcuts?.[shortcutId] ?? null;
  3166. if (shortcutKeys && sdk.Shortcuts.areShortcutKeysInUse({ shortcutKeys })) {
  3167. shortcutKeys = null;
  3168. }
  3169. sdk.Shortcuts.createShortcut({
  3170. shortcutId,
  3171. shortcutKeys,
  3172. description,
  3173. callback
  3174. });
  3175. }
  3176.  
  3177. async function init(firstCall = true) {
  3178. _gisLayers = [];
  3179. if (firstCall) {
  3180. userInfo = sdk.State.getUserInfo();
  3181. labelProcessingGlobalVariables.W = W;
  3182. labelProcessingGlobalVariables.sdk = sdk;
  3183. initRoadStyle();
  3184. loadSettingsFromStorage();
  3185. createShortcut('toggleHnsOnly', 'Toggle HN-only address labels (GIS Layers)', onAddressDisplayShortcutKey);
  3186. createShortcut('toggleEnabled', 'Toggle display of GIS Layers', onToggleGisLayersShortcutKey);
  3187. installPathFollowingLabels();
  3188. window.addEventListener('beforeunload', saveSettingsToStorage, false);
  3189. _layerSettingsDialog = new LayerSettingsDialog();
  3190. }
  3191. const t0 = performance.now();
  3192. try {
  3193. const result = await loadSpreadsheetAsync();
  3194. if (result.error) {
  3195. logError(result.error);
  3196. return;
  3197. }
  3198. _layerRefinements.forEach(layerRefinement => {
  3199. const layerDef = _gisLayers.find(layerDef2 => layerDef2.id === layerRefinement.id);
  3200. if (layerDef) {
  3201. Object.keys(layerRefinement).forEach(fldName => {
  3202. const value = layerRefinement[fldName];
  3203. if (fldName !== 'id' && layerDef.hasOwnProperty(fldName)) {
  3204. logDebug(`The "${fldName}" property of layer "${
  3205. layerDef.id}" has a value hardcoded in the script, and also defined in the spreadsheet.`
  3206. + ' The spreadsheet value takes precedence.');
  3207. } else if (value) layerDef[fldName] = value;
  3208. });
  3209. } else {
  3210. logDebug(`Refined layer "${layerRefinement.id}" does not have a corresponding layer defined`
  3211. + ' in the spreadsheet. It can probably be removed from the script.');
  3212. }
  3213. });
  3214. logDebug(`Loaded ${_gisLayers.length} layer definitions in ${Math.round(performance.now() - t0)} ms.`);
  3215. initGui(firstCall);
  3216. fetchFeatures();
  3217. $('#gis-layers-refresh').removeClass('fa-spin').css({ cursor: 'pointer' });
  3218. logDebug('Initialized.');
  3219. } catch (err) {
  3220. logError(err);
  3221. }
  3222. }
  3223.  
  3224. init();
  3225.  
  3226. /*eslint-disable*/
  3227. function installPathFollowingLabels() {
  3228. // Copyright (c) 2015 by Jean-Marc.Viglino [at]ign.fr
  3229. // Dual-licensed under the CeCILL-B Licence (http://www.cecill.info/)
  3230. // and the Beerware license (http://en.wikipedia.org/wiki/Beerware),
  3231. // feel free to use and abuse it in your projects (the code, not the beer ;-).
  3232. //
  3233. //* Overwrite the SVG function to allow text along a path
  3234. //* setStyle function
  3235. //*
  3236. //* Add new options to the Openlayers.Style
  3237.  
  3238. // pathLabel: {String} Label to draw on the path
  3239. // pathLabelXOffset: {String} Offset along the line to start drawing text in pixel or %, default: "50%"
  3240. // pathLabelYOffset: {Number} Distance of the line to draw the text
  3241. // pathLabelCurve: {String} Smooth the line the label is drawn on (empty string for no)
  3242. // pathLabelReadable: {String} Make the label readable (empty string for no)
  3243.  
  3244. // * Extra standard values : all label and text values
  3245.  
  3246.  
  3247. // *
  3248. // * Method: removeChildById
  3249. // * Remove child in a node.
  3250. // *
  3251.  
  3252. function removeChildById(node, id) {
  3253. if (node.querySelector) {
  3254. var c = node.querySelector('#' + id);
  3255. if (c) node.removeChild(c);
  3256. return;
  3257. }
  3258. // For old browsers
  3259. var c = node.childNodes;
  3260. if (c) for (var i = 0; i < c.length; i++) {
  3261. if (c[i].id === id) {
  3262. node.removeChild(c[i]);
  3263. return;
  3264. }
  3265. }
  3266. }
  3267.  
  3268.  
  3269. // *
  3270. // * Method: setStyle
  3271. // * Use to set all the style attributes to a SVG node.
  3272. // *
  3273. // * Takes care to adjust stroke width and point radius to be
  3274. // * resolution-relative
  3275. // *
  3276. // * Parameters:
  3277. // * node - {SVGDomElement} An SVG element to decorate
  3278. // * style - {Object}
  3279. // * options - {Object} Currently supported options include
  3280. // * 'isFilled' {Boolean} and
  3281. // * 'isStroked' {Boolean}
  3282.  
  3283. var setStyle = OpenLayers.Renderer.SVG.prototype.setStyle;
  3284. OpenLayers.Renderer.SVG.LABEL_STARTOFFSET = { 'l': '0%', 'r': '100%', 'm': '50%' };
  3285.  
  3286. OpenLayers.Renderer.SVG.prototype.pathText = function (node, style, suffix) {
  3287. var label = this.nodeFactory(null, 'text');
  3288. label.setAttribute('id', node._featureId + '_' + suffix);
  3289. if (style.fontColor) label.setAttributeNS(null, 'fill', style.fontColor);
  3290. if (style.fontStrokeColor) label.setAttributeNS(null, 'stroke', style.fontStrokeColor);
  3291. if (style.fontStrokeWidth) label.setAttributeNS(null, 'stroke-width', style.fontStrokeWidth);
  3292. if (style.fontOpacity) label.setAttributeNS(null, 'opacity', style.fontOpacity);
  3293. if (style.fontFamily) label.setAttributeNS(null, 'font-family', style.fontFamily);
  3294. if (style.fontSize) label.setAttributeNS(null, 'font-size', style.fontSize);
  3295. if (style.fontWeight) label.setAttributeNS(null, 'font-weight', style.fontWeight);
  3296. if (style.fontStyle) label.setAttributeNS(null, 'font-style', style.fontStyle);
  3297. if (style.labelSelect === true) {
  3298. label.setAttributeNS(null, 'pointer-events', 'visible');
  3299. label._featureId = node._featureId;
  3300. } else {
  3301. label.setAttributeNS(null, 'pointer-events', 'none');
  3302. }
  3303.  
  3304. function getpath(pathStr, readeable) {
  3305. var npath = pathStr.split(',');
  3306. var pts = [];
  3307. if (!readeable || Number(npath[0]) - Number(npath[npath.length - 2]) < 0) {
  3308. while (npath.length) pts.push({ x: Number(npath.shift()), y: Number(npath.shift()) });
  3309. } else {
  3310. while (npath.length) pts.unshift({ x: Number(npath.shift()), y: Number(npath.shift()) });
  3311. }
  3312. return pts;
  3313. }
  3314.  
  3315. var path = this.nodeFactory(null, 'path');
  3316. var tpid = node._featureId + '_t' + suffix;
  3317. var tpath = node.getAttribute('points');
  3318. if (style.pathLabelCurve) {
  3319. var pts = getpath(tpath, style.pathLabelReadable);
  3320. var p = pts[0].x + ' ' + pts[0].y;
  3321. var dx, dy, s1, s2;
  3322. dx = (pts[0].x - pts[1].x) / 4;
  3323. dy = (pts[0].y - pts[1].y) / 4;
  3324. for (var i = 1; i < pts.length - 1; i++) {
  3325. p += ' C ' + (pts[i - 1].x - dx) + ' ' + (pts[i - 1].y - dy);
  3326. dx = (pts[i - 1].x - pts[i + 1].x) / 4;
  3327. dy = (pts[i - 1].y - pts[i + 1].y) / 4;
  3328. s1 = Math.sqrt(Math.pow(pts[i - 1].x - pts[i].x, 2) + Math.pow(pts[i - 1].y - pts[i].y, 2));
  3329. s2 = Math.sqrt(Math.pow(pts[i + 1].x - pts[i].x, 2) + Math.pow(pts[i + 1].y - pts[i].y, 2));
  3330. p += ' ' + (pts[i].x + s1 * dx / s2) + ' ' + (pts[i].y + s1 * dy / s2);
  3331. dx *= s2 / s1;
  3332. dy *= s2 / s1;
  3333. p += ' ' + pts[i].x + ' ' + pts[i].y;
  3334. }
  3335. p += ' C ' + (pts[i - 1].x - dx) + ' ' + (pts[i - 1].y - dy);
  3336. dx = (pts[i - 1].x - pts[i].x) / 4;
  3337. dy = (pts[i - 1].y - pts[i].y) / 4;
  3338. p += ' ' + (pts[i].x + dx) + ' ' + (pts[i].y + dy);
  3339. p += ' ' + pts[i].x + ' ' + pts[i].y;
  3340.  
  3341. path.setAttribute('d', 'M ' + p);
  3342. } else {
  3343. if (style.pathLabelReadable) {
  3344. var pts = getpath(tpath, style.pathLabelReadable);
  3345. var p = '';
  3346. for (var i = 0; i < pts.length; i++) p += ' ' + pts[i].x + ' ' + pts[i].y;
  3347. path.setAttribute('d', 'M ' + p);
  3348. } else path.setAttribute('d', 'M ' + tpath);
  3349. }
  3350. path.setAttribute('id', tpid);
  3351.  
  3352. var defs = this.createDefs();
  3353. removeChildById(defs, tpid);
  3354. defs.appendChild(path);
  3355.  
  3356. var textPath = this.nodeFactory(null, 'textPath');
  3357. textPath.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '#' + tpid);
  3358. var align = style.labelAlign || OpenLayers.Renderer.defaultSymbolizer.labelAlign;
  3359. label.setAttributeNS(null, 'text-anchor', OpenLayers.Renderer.SVG.LABEL_ALIGN[align[0]] || 'middle');
  3360. textPath.setAttribute('startOffset', style.pathLabelXOffset || OpenLayers.Renderer.SVG.LABEL_STARTOFFSET[align[0]] || '50%');
  3361. label.setAttributeNS(null, 'dominant-baseline', OpenLayers.Renderer.SVG.LABEL_ALIGN[align[1]] || 'central');
  3362. if (style.pathLabelYOffset) label.setAttribute('dy', style.pathLabelYOffset);
  3363. //textPath.setAttribute('method','stretch');
  3364. //textPath.setAttribute('spacing','auto');
  3365.  
  3366. textPath.textContent = style.pathLabel;
  3367. label.appendChild(textPath);
  3368.  
  3369. removeChildById(this.textRoot, node._featureId + '_' + suffix);
  3370. this.textRoot.appendChild(label);
  3371. };
  3372.  
  3373. OpenLayers.Renderer.SVG.prototype.setStyle = function (node, style, options) {
  3374. if (node._geometryClass === 'OpenLayers.Geometry.LineString' && style.pathLabel) {
  3375. if (node._geometryClass === 'OpenLayers.Geometry.LineString' && style.pathLabel) {
  3376. var drawOutline = (!!style.labelOutlineWidth);
  3377. // First draw text in halo color and size and overlay the
  3378. // normal text afterwards
  3379. if (drawOutline) {
  3380. var outlineStyle = OpenLayers.Util.extend({}, style);
  3381. outlineStyle.fontColor = outlineStyle.labelOutlineColor;
  3382. outlineStyle.fontStrokeColor = outlineStyle.labelOutlineColor;
  3383. outlineStyle.fontStrokeWidth = style.labelOutlineWidth;
  3384. if (style.labelOutlineOpacity) outlineStyle.fontOpacity = style.labelOutlineOpacity;
  3385. delete outlineStyle.labelOutlineWidth;
  3386. this.pathText(node, outlineStyle, 'txtpath0');
  3387. }
  3388. this.pathText(node, style, 'txtpath');
  3389. setStyle.apply(this, arguments);
  3390. }
  3391. } else setStyle.apply(this, arguments);
  3392. return node;
  3393. };
  3394.  
  3395. // *
  3396. // * Method: drawGeometry
  3397. // * Remove the textpath if no geometry is drawn.
  3398. // *
  3399. // * Parameters:
  3400. // * geometry - {<OpenLayers.Geometry>}
  3401. // * style - {Object}
  3402. // * featureId - {String}
  3403. // *
  3404. // * Returns:
  3405. // * {Boolean} true if the geometry has been drawn completely; null if
  3406. // * incomplete; false otherwise
  3407.  
  3408. var drawGeometry = OpenLayers.Renderer.SVG.prototype.drawGeometry;
  3409. OpenLayers.Renderer.SVG.prototype.drawGeometry = function (geometry, style, id) {
  3410. var rendered = drawGeometry.apply(this, arguments);
  3411. if (rendered === false) {
  3412. removeChildById(this.textRoot, id + '_txtpath');
  3413. removeChildById(this.textRoot, id + '_txtpath0');
  3414. }
  3415. return rendered;
  3416. };
  3417.  
  3418. // *
  3419. // * Method: eraseGeometry
  3420. // * Erase a geometry from the renderer. In the case of a multi-geometry,
  3421. // * we cycle through and recurse on ourselves. Otherwise, we look for a
  3422. // * node with the geometry.id, destroy its geometry, and remove it from
  3423. // * the DOM.
  3424. // *
  3425. // * Parameters:
  3426. // * geometry - {<OpenLayers.Geometry>}
  3427. // * featureId - {String}
  3428.  
  3429. var eraseGeometry = OpenLayers.Renderer.SVG.prototype.eraseGeometry;
  3430. OpenLayers.Renderer.SVG.prototype.eraseGeometry = function (geometry, featureId) {
  3431. eraseGeometry.apply(this, arguments);
  3432. removeChildById(this.textRoot, featureId + '_txtpath');
  3433. removeChildById(this.textRoot, featureId + '_txtpath0');
  3434. };
  3435.  
  3436. }
  3437. })();