WME GIS Layers

Adds GIS layers in WME

目前为 2025-04-21 提交的版本。查看 最新版本

  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.04.20.001
  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) { return this._states.find(a => a[0] === fullName)[1]; },
  1351. toFullName(abbr) { return this._states.find(a => a[1] === abbr)[0]; },
  1352. toFullNameArray() { return this._states.map(a => a[0]); },
  1353. toAbbrArray() { return this._states.map(a => a[1]); },
  1354. fromId(id) { return this._states.find(a => a[2] === id); }
  1355. };
  1356. const DEFAULT_VISIBLE_AT_ZOOM = 18;
  1357. const SETTINGS_STORE_NAME = 'wme_gis_layers_fl';
  1358. const COUNTIES_URL = 'https://tigerweb.geo.census.gov/arcgis/rest/services/Census2020/State_County/MapServer/1/';
  1359. const scriptName = GM_info.script.name;
  1360. const scriptVersion = GM_info.script.version;
  1361. const downloadUrl = 'https://greasyfork.org/scripts/369632-wme-gis-layers/code/WME%20GIS%20Layers.user.js';
  1362. const sdk = await bootstrap({ scriptUpdateMonitor: { downloadUrl } });
  1363. let mapLayer = null;
  1364. let roadLayer = null;
  1365. let settings = {};
  1366. let ignoreFetch = false;
  1367. let lastToken = {};
  1368. let userInfo;
  1369.  
  1370. // Variables to store Label popup position and selected layer
  1371. const layerLabels = {};
  1372. let isPopupVisible = null;
  1373. const popupPosition = { left: '50%', top: '50%' };
  1374. let popupActiveLayer = null;
  1375. let useAcronyms = false;
  1376. let useTitleCase = false;
  1377. let useStateHwy = false;
  1378. let removeNewLines = false;
  1379.  
  1380. const DEBUG = true;
  1381. // function log(message) { console.log('GIS Layers:', message); }
  1382. function logError(message, args = []) { console.error(`${scriptName}:`, message, ...args); }
  1383. function logDebug(message, args = []) { if (DEBUG) console.debug(`${scriptName}:`, message, ...args); }
  1384. // function logWarning(message) { console.warn('GIS Layers:', message); }
  1385.  
  1386. let _layerSettingsDialog;
  1387.  
  1388. class LayerSettingsDialog {
  1389. #gisLayer;
  1390. #minVisibleAtZoom = 12;
  1391. #maxVisibleAtZoom = 22;
  1392. #titleText;
  1393. #shiftUpButton;
  1394. #visibleAtZoomInput;
  1395.  
  1396. constructor() {
  1397. this.#titleText = $('<span>');
  1398. const closeButton = $('<span>', {
  1399. style: 'cursor:pointer;padding-left:4px;font-size:17px;color:#d6e6f3;float:right;',
  1400. class: 'fa fa-window-close'
  1401. }).click(() => this.#onCloseButtonClick());
  1402. const shiftUpButton = LayerSettingsDialog.#createShiftButton('fa-angle-up').click(() => this.#onShiftButtonClick(0, 1));
  1403. const shiftLeftButton = LayerSettingsDialog.#createShiftButton('fa-angle-left').click(() => this.#onShiftButtonClick(-1, 0));
  1404. const shiftRightButton = LayerSettingsDialog.#createShiftButton('fa-angle-right').click(() => this.#onShiftButtonClick(1, 0));
  1405. const shiftDownButton = LayerSettingsDialog.#createShiftButton('fa-angle-down').click(() => this.#onShiftButtonClick(0, -1));
  1406. const resetOffsetButton = $('<button>', {
  1407. class: 'form-control',
  1408. style: 'height: 24px; width: auto; padding: 2px 6px 0px 6px; display: inline-block; float: right;'
  1409. }).text('Reset').click(() => this.#onResetOffsetButtonClick());
  1410.  
  1411. this._dialogDiv = $('<div>', {
  1412. style: 'position: fixed; top: 15%; left: 400px; width: 200px; z-index: 100; background-color: #73a9bd; border-width: 1px; border-style: solid;'
  1413. + 'border-radius: 10px; box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.7); border-color: #50667b; padding: 4px;'
  1414. }).append($('<div>').append( // The extra div is needed here. When the header text wraps, the main dialog div won't expand properly without it.
  1415. // HEADER
  1416. $('<div>', { style: 'border-radius:5px 5px 0px 0px; padding: 4px; color: #fff; font-weight: bold; text-align:left; cursor: default;' }).append(
  1417. closeButton,
  1418. this.#titleText
  1419. ),
  1420. // BODY
  1421. $('<div>').append(
  1422. $('<div>', { style: 'border-radius: 5px; width: 100%; padding: 4px; background-color:#d6e6f3; display:inline-block; margin-right:5px;' }).append(
  1423. resetOffsetButton,
  1424. $('<input>', {
  1425. type: 'radio', id: 'gisLayerShiftAmt1', name: 'gisLayerShiftAmt', value: '1', checked: 'checked'
  1426. }),
  1427. $('<label>', { for: 'gisLayerShiftAmt1' }).text('1m'),
  1428. $('<input>', {
  1429. type: 'radio', id: 'gisLayerShiftAmt10', name: 'gisLayerShiftAmt', value: '10', style: 'margin-left: 6px'
  1430. }),
  1431. $('<label>', { for: 'gisLayerShiftAmt10' }).text('10m'),
  1432. $('<div>', { style: 'padding: 4px' }).append(
  1433. $('<table>', { style: 'table-layout:fixed; width:60px; height:84px; margin-left:auto;margin-right:auto;' }).append(
  1434. $('<tr>', { style: 'width: 20px; height: 28px;' }).append(
  1435. $('<td>', { align: 'center' }),
  1436. $('<td>', { align: 'center' }).append(shiftUpButton),
  1437. $('<td>', { align: 'center' })
  1438. ),
  1439. $('<tr>', { style: 'width: 20px; height: 28px;' }).append(
  1440. $('<td>', { align: 'center' }).append(shiftLeftButton),
  1441. $('<td>', { align: 'center' }),
  1442. $('<td>', { align: 'center' }).append(shiftRightButton)
  1443. ),
  1444. $('<tr>', { style: 'width: 20px; height: 28px;' }).append(
  1445. $('<td>', { align: 'center' }),
  1446. $('<td>', { align: 'center' }).append(shiftDownButton),
  1447. $('<td>', { align: 'center' })
  1448. )
  1449. )
  1450. )
  1451. ),
  1452. $('<div>', { style: 'border-radius: 5px; width: 100%; padding: 4px; background-color: #d6e6f3; display: inline-block; margin-right: 5px; margin-top: 2px;' }).append(
  1453. $('<div>', { style: 'display: flex; justify-content: flex-end; margin-bottom: 4px;' }).append(
  1454. $('<button>', { class: 'form-control', style: 'height: 24px; width: auto; padding: 2px 6px 0px 6px;' })
  1455. .text('Reset')
  1456. .click(this.#onResetVisibleAtZoomClick.bind(this))
  1457. ),
  1458. $('<div>').append(
  1459. $('<label>', { for: 'visible-at-zoom-input' }).text('Visible at zoom:'),
  1460. this.#visibleAtZoomInput = $('<input>', {
  1461. type: 'number',
  1462. id: 'visible-at-zoom-input',
  1463. min: this.#minVisibleAtZoom,
  1464. max: this.#maxVisibleAtZoom,
  1465. style: 'margin-left: 4px;'
  1466. }).change(v => this.#onVisibleAtZoomChange(v))
  1467. ),
  1468. $('<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.')
  1469. )
  1470. )
  1471. ));
  1472.  
  1473. this.hide();
  1474. this._dialogDiv.appendTo('body');
  1475.  
  1476. if (typeof jQuery.ui !== 'undefined') {
  1477. const that = this;
  1478. this._dialogDiv.draggable({
  1479. // Gotta nuke the height setting the dragging inserts otherwise the panel cannot dynamically resize
  1480. stop() { that._dialogDiv.css('height', ''); }
  1481. });
  1482. }
  1483. }
  1484.  
  1485. get gisLayer() {
  1486. return this.#gisLayer;
  1487. }
  1488.  
  1489. set gisLayer(value) {
  1490. if (value !== this.#gisLayer) {
  1491. this.#gisLayer = value;
  1492. this.#titleText.text(this.#gisLayer.name);
  1493. this.#initVisibleAtZoomInput();
  1494. }
  1495. }
  1496.  
  1497. #initVisibleAtZoomInput() {
  1498. this.#visibleAtZoomInput.val(getGisLayerVisibleAtZoom(this.#gisLayer));
  1499. }
  1500.  
  1501. // eslint-disable-next-line class-methods-use-this
  1502. getShiftAmount() {
  1503. return $('input[name=gisLayerShiftAmt]:checked').val();
  1504. }
  1505.  
  1506. show() {
  1507. this._dialogDiv.show();
  1508. }
  1509.  
  1510. hide() {
  1511. this._dialogDiv.hide();
  1512. }
  1513.  
  1514. #onResetVisibleAtZoomClick() {
  1515. settings.removeLayerSetting(this.#gisLayer.id, 'visibleAtZoom');
  1516. this.#initVisibleAtZoomInput();
  1517. }
  1518.  
  1519. #onCloseButtonClick() {
  1520. this.hide();
  1521. }
  1522.  
  1523. #onVisibleAtZoomChange() {
  1524. const min = this.#minVisibleAtZoom;
  1525. const max = this.#maxVisibleAtZoom;
  1526. let value = parseInt(this.#visibleAtZoomInput.val(), 10);
  1527.  
  1528. if (value < min) {
  1529. value = min;
  1530. this.#visibleAtZoomInput.val(value);
  1531. } else if (value > max) {
  1532. value = max;
  1533. this.#visibleAtZoomInput.val(value);
  1534. }
  1535.  
  1536. settings.setLayerSetting(this.#gisLayer.id, 'visibleAtZoom', value);
  1537. saveSettingsToStorage();
  1538. }
  1539.  
  1540. #onShiftButtonClick(x, y) {
  1541. const shiftAmount = this.getShiftAmount();
  1542. x *= shiftAmount;
  1543. y *= shiftAmount;
  1544. this.#shiftLayerFeatures(x, y);
  1545. const { id } = this.gisLayer;
  1546. let offset = settings.getLayerSetting(id, 'offset');
  1547. if (!offset) {
  1548. offset = { x: 0, y: 0 };
  1549. settings.setLayerSetting(id, 'offset', offset);
  1550. }
  1551. offset.x += x;
  1552. offset.y += y;
  1553. saveSettingsToStorage();
  1554. }
  1555.  
  1556. #onResetOffsetButtonClick() {
  1557. const offset = settings.getLayerSetting(this.gisLayer.id, 'offset');
  1558. if (offset) {
  1559. this.#shiftLayerFeatures(offset.x * -1, offset.y * -1);
  1560. delete settings.layers[this.gisLayer.id].offset;
  1561. saveSettingsToStorage();
  1562. }
  1563. }
  1564.  
  1565. #shiftLayerFeatures(x, y) {
  1566. const layer = this.gisLayer.isRoadLayer ? roadLayer : mapLayer;
  1567. layer.getFeaturesByAttribute('layerID', this.gisLayer.id).forEach(f => f.geometry.move(x, y));
  1568. layer.redraw();
  1569. }
  1570.  
  1571. static #createShiftButton(fontAwesomeClass) {
  1572. return $('<button>', {
  1573. class: 'form-control',
  1574. style: 'cursor:pointer;font-size:14px;padding: 3px;border-radius: 5px;width: 21px;height: 21px;'
  1575. }).append(
  1576. $('<i>', { class: 'fa', style: 'vertical-align: super' }).addClass(fontAwesomeClass)
  1577. );
  1578. }
  1579. }
  1580.  
  1581. function loadSettingsFromStorage() {
  1582. const defaultSettings = {
  1583. lastVersion: null,
  1584. visibleLayers: [],
  1585. onlyShowApplicableLayers: false,
  1586. selectedStates: [],
  1587. enabled: true,
  1588. fillParcels: false,
  1589. oneTimeAlerts: {},
  1590. layers: {},
  1591. shortcuts: {},
  1592. isPopupVisible: false,
  1593. useAcronyms: false,
  1594. useTitleCase: false,
  1595. useStateHwy: false,
  1596. removeNewLines: false
  1597. };
  1598.  
  1599. let loadedSettings = {}; // Initialize as an empty object
  1600. const storedSettings = localStorage.getItem(SETTINGS_STORE_NAME);
  1601.  
  1602. if (storedSettings) {
  1603. try {
  1604. const parsed = JSON.parse(storedSettings);
  1605. if (parsed && typeof parsed === 'object') {
  1606. loadedSettings = parsed;
  1607. } else {
  1608. logDebug(`Stored settings under key "${SETTINGS_STORE_NAME}" were not a valid object.`);
  1609. }
  1610. } catch (e) {
  1611. logError(`Failed to parse settings from localStorage key "${SETTINGS_STORE_NAME}":`, e);
  1612. // loadedSettings remains {}
  1613. }
  1614. }
  1615.  
  1616. // Merge defaultSettings and loadedSettings.
  1617. // If loadedSettings is empty (due to error or no storage), it effectively uses defaults.
  1618. settings = { ...defaultSettings, ...loadedSettings };
  1619.  
  1620. isPopupVisible = settings.isPopupVisible;
  1621. useAcronyms = settings.useAcronyms;
  1622. useTitleCase = settings.useTitleCase;
  1623. useStateHwy = settings.useStateHwy;
  1624. removeNewLines = settings.removeNewLines;
  1625.  
  1626. settings.getLayerSetting = function getLayerSetting(layerID, settingName) {
  1627. const layerSettings = this.layers[layerID];
  1628. if (!layerSettings) {
  1629. return undefined;
  1630. }
  1631. return layerSettings[settingName];
  1632. };
  1633. settings.setLayerSetting = function setLayerSetting(layerID, settingName, value) {
  1634. let layerSettings = this.layers[layerID];
  1635. if (!layerSettings) {
  1636. layerSettings = {};
  1637. this.layers[layerID] = layerSettings;
  1638. }
  1639. layerSettings[settingName] = value;
  1640. };
  1641. settings.removeLayerSetting = function removeLayerSetting(layerID, settingName) {
  1642. const layerSettings = this.layers[layerID];
  1643. if (layerSettings) {
  1644. delete layerSettings[settingName];
  1645. }
  1646. };
  1647.  
  1648. // Handle legacy shortcut keys settings.
  1649. // TODO: Delete this later, after most users have updated.
  1650. if (settings.toggleHnsOnlyShortcut) {
  1651. settings.shortcuts.toggleHnsOnly = settings.toggleHnsOnlyShortcut;
  1652. delete settings.toggleHnsOnlyShortcut;
  1653. }
  1654. if (settings.toggleEnabledShortcut) {
  1655. settings.shortcuts.toggleEnabled = settings.toggleEnabledShortcut;
  1656. delete settings.toggleEnabledShortcut;
  1657. }
  1658. }
  1659.  
  1660. function saveSettingsToStorage() {
  1661. settings.shortcuts = {};
  1662. sdk.Shortcuts.getAllShortcuts().forEach(shortcut => {
  1663. settings.shortcuts[shortcut.shortcutId] = shortcut.shortcutKeys;
  1664. });
  1665. settings.lastVersion = scriptVersion;
  1666. settings.isPopupVisible = isPopupVisible;
  1667. settings.useAcronyms = useAcronyms;
  1668. settings.useTitleCase = useTitleCase;
  1669. settings.useStateHwy = useStateHwy;
  1670. settings.removeNewLines = removeNewLines;
  1671. localStorage.setItem(SETTINGS_STORE_NAME, JSON.stringify(settings));
  1672. logDebug('Settings saved');
  1673. }
  1674.  
  1675. function getUrl(extent, gisLayer) {
  1676. // if (gisLayer.spatialReference) {
  1677. // const proj = new OpenLayers.Projection(`EPSG:${gisLayer.spatialReference}`);
  1678. // extent.transform(W.map.getProjectionObject(), proj);
  1679. // }
  1680. const layerOffset = settings.getLayerSetting(gisLayer.id, 'offset') ?? { x: 0, y: 0 };
  1681. const geometry = {
  1682. xmin: extent[0] - layerOffset.x,
  1683. ymin: extent[1] - layerOffset.y,
  1684. xmax: extent[2] - layerOffset.x,
  1685. ymax: extent[3] - layerOffset.y,
  1686. spatialReference: {
  1687. wkid: /* gisLayer.spatialReference ? gisLayer.spatialReference : */ 102100,
  1688. latestWkid: /* gisLayer.spatialReference ? gisLayer.spatialReference : */ 3857
  1689. }
  1690. };
  1691. const geometryStr = JSON.stringify(geometry);
  1692. let fields = gisLayer.labelFields;
  1693. if (gisLayer.labelHeaderFields) {
  1694. fields = fields.concat(gisLayer.labelHeaderFields);
  1695. }
  1696. if (gisLayer.distinctFields) {
  1697. fields = fields.concat(gisLayer.distinctFields);
  1698. }
  1699. let url = `${gisLayer.url}/query?geometry=${encodeURIComponent(geometryStr)}`;
  1700. url += gisLayer.token ? `&token=${gisLayer.token}` : '';
  1701. url += `&outFields=${encodeURIComponent(fields.join(','))}`;
  1702. url += '&returnGeometry=true&spatialRel=esriSpatialRelIntersects&geometryType=esriGeometryEnvelope';
  1703. url += `&inSR=${/* gisLayer.spatialReference ? gisLayer.spatialReference : */ '102100'}`;
  1704. url += '&outSR=3857&f=json';
  1705. url += gisLayer.where ? `&where=${encodeURIComponent(gisLayer.where)}` : '';
  1706.  
  1707. logDebug(`Request URL: ${url}`);
  1708. return url;
  1709. }
  1710.  
  1711. function hashString(value) {
  1712. let hash = 0;
  1713. if (value.length === 0) return hash;
  1714. for (let i = 0; i < value.length; i++) {
  1715. const chr = value.charCodeAt(i);
  1716. // eslint-disable-next-line no-bitwise
  1717. hash = ((hash << 5) - hash) + chr;
  1718. // eslint-disable-next-line no-bitwise
  1719. hash |= 0; // Convert to 32bit integer
  1720. }
  1721. return hash;
  1722. }
  1723.  
  1724. function getMercatorMapExtent() {
  1725. const wgs84Extent = sdk.Map.getMapExtent();
  1726. const wgs84LeftBottom = [wgs84Extent[0], wgs84Extent[1]];
  1727. const wgs84RightTop = [wgs84Extent[2], wgs84Extent[3]];
  1728. const mercatorLeftBottom = turf.toMercator(wgs84LeftBottom);
  1729. const mercatorRightTop = turf.toMercator(wgs84RightTop);
  1730. return [mercatorLeftBottom[0], mercatorLeftBottom[1], mercatorRightTop[0], mercatorRightTop[1]];
  1731. }
  1732.  
  1733. function getArcGisMapExtentGeometry() {
  1734. const extent = getMercatorMapExtent();
  1735. const geometry = {
  1736. xmin: extent[0],
  1737. ymin: extent[1],
  1738. xmax: extent[2],
  1739. ymax: extent[3],
  1740. spatialReference: {
  1741. wkid: 102100,
  1742. latestWkid: 3857
  1743. }
  1744. };
  1745. return geometry;
  1746. }
  1747.  
  1748. function getCountiesUrl() {
  1749. const geometry = getArcGisMapExtentGeometry();
  1750. const url = `${COUNTIES_URL}/query?geometry=${encodeURIComponent(JSON.stringify(geometry))}`;
  1751. return `${url}&outFields=BASENAME%2CSTATE&returnGeometry=false&spatialRel=esriSpatialRelIntersects`
  1752. + '&geometryType=esriGeometryEnvelope&inSR=102100&outSR=3857&f=json';
  1753. }
  1754.  
  1755. let _countiesInExtent = [];
  1756.  
  1757. function getGisLayerVisibleAtZoom(gisLayer) {
  1758. const overrideVisibleAtZoom = settings.getLayerSetting(gisLayer.id, 'visibleAtZoom');
  1759. if (overrideVisibleAtZoom) return overrideVisibleAtZoom;
  1760. return (gisLayer.hasOwnProperty('visibleAtZoom')
  1761. ? gisLayer.visibleAtZoom : DEFAULT_VISIBLE_AT_ZOOM);
  1762. }
  1763.  
  1764. function getGisLayerLabelsVisibleAtZoom(gisLayer, layerVisibleAtZoom) {
  1765. let labelsVisibleAtZoom;
  1766. layerVisibleAtZoom = +layerVisibleAtZoom;
  1767. if (gisLayer.hasOwnProperty('labelsVisibleAtZoom')) {
  1768. labelsVisibleAtZoom = layerVisibleAtZoom + (+gisLayer.labelsVisibleAtZoom - (+gisLayer.visibleAtZoom ?? DEFAULT_VISIBLE_AT_ZOOM));
  1769. } else {
  1770. labelsVisibleAtZoom = layerVisibleAtZoom + 1;
  1771. }
  1772. if (labelsVisibleAtZoom < 1) labelsVisibleAtZoom = 1;
  1773. return labelsVisibleAtZoom;
  1774. }
  1775.  
  1776. function getFetchableLayers(getInvisible) {
  1777. const zoom = sdk.Map.getZoomLevel();
  1778. if (zoom < 12) return [];
  1779. return _gisLayers.filter(gisLayer => {
  1780. const isValidUrl = gisLayer.url && gisLayer.url.trim().length > 0;
  1781. const isVisible = (getInvisible || settings.visibleLayers.includes(gisLayer.id))
  1782. && settings.selectedStates.includes(gisLayer.state);
  1783. const isInState = gisLayer.state === 'US' || _countiesInExtent.some(county => county.stateInfo[1] === gisLayer.state);
  1784. // Be sure to use hasOwnProperty when checking this, since 0 is a valid value.
  1785. const isValidZoom = getInvisible || zoom >= getGisLayerVisibleAtZoom(gisLayer);
  1786. return isValidUrl && isInState && isVisible && isValidZoom;
  1787. });
  1788. }
  1789.  
  1790. function filterLayerCheckboxes() {
  1791. const applicableLayers = getFetchableLayers(true).filter(layer => {
  1792. const hasCounties = layer.hasOwnProperty('counties');
  1793. return (hasCounties && layer.counties.some(countyName => _countiesInExtent.some(county => county.name === countyName.toLowerCase()
  1794. && layer.state === county.stateInfo[1]))) || !hasCounties;
  1795. });
  1796. const statesToHide = STATES.toAbbrArray();
  1797.  
  1798. _gisLayers.forEach(gisLayer => {
  1799. const id = `#gis-layer-${gisLayer.id}-container`;
  1800. if (!settings.onlyShowApplicableLayers || applicableLayers.includes(gisLayer)) {
  1801. $(id).show();
  1802. $(`#gis-layers-for-${gisLayer.state}`).show();
  1803. const idx = statesToHide.indexOf(gisLayer.state);
  1804. if (idx > -1) statesToHide.splice(idx, 1);
  1805. } else {
  1806. $(id).hide();
  1807. }
  1808. });
  1809. if (settings.onlyShowApplicableLayers) {
  1810. statesToHide.forEach(st => $(`#gis-layers-for-${st}`).hide());
  1811. }
  1812. }
  1813.  
  1814. const ROAD_ABBR = [
  1815. [/\bAVENUE$/, 'AVE'], [/\bCIRCLE$/, 'CIR'], [/\bCOURT$/, 'CT'], [/\bDRIVE$/, 'DR'],
  1816. [/\bLANE$/, 'LN'], [/\bPARK$/, 'PK'], [/\bPLACE$/, 'PL'], [/\bROAD$/, 'RD'], [/\bSTREET$/, 'ST'],
  1817. [/\bTERRACE$/, 'TER']
  1818. ];
  1819.  
  1820. const labelProcessingGlobalVariables = {
  1821. Number,
  1822. Math,
  1823. Boolean,
  1824. parseInt,
  1825. Date,
  1826. _regexReplace: {
  1827. // Strip leading zeros or blank full label for any label starting with a non-digit or
  1828. // is a Zero Address, use with '' as replace.
  1829. r0: /^(0+(\s.*)?|\D.*)/,
  1830. // Strip Everything After Street Type to end of the string by use $1 and $2 capture
  1831. // groups, use with replace '$1$2'
  1832. // eslint-disable-next-line max-len
  1833. 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,
  1834. // Strip SPACE 5 Digits from end of string, use with replace ''
  1835. r2: /\s\d{5}$/,
  1836. // Strip Everything after a "~", ",", ";" to the end of the string, use with replace ''
  1837. r3: /(~|,|;|\s?\r\n).*$/,
  1838. // Move the digits after the last space to before the rest of the string using, use with
  1839. // replace '$2 $1'
  1840. r4: /^(.*)\s(\d+).*/,
  1841. // Insert newline between digits (including "-") and everything after the digits,
  1842. // except(and before) a ",", use with replace '$1\n$2'
  1843. r5: /^([-\d]+)\s+([^,]+).*/,
  1844. // Insert newline between digits and everything after the digits, use with
  1845. // replace '$1\n$2'
  1846. r6: /^(\d+)\s+(.*)/
  1847. }
  1848. };
  1849.  
  1850. function processLabel(gisLayer, item, displayLabelsAtZoom, area, isPolyLine = false) {
  1851. let label = '';
  1852. if (gisLayer.labelHeaderFields) {
  1853. label = `${gisLayer.labelHeaderFields.map(
  1854. fieldName => item.attributes[fieldName]
  1855. ).join(' ').trim()}\n`;
  1856. }
  1857. if (sdk.Map.getZoomLevel() >= displayLabelsAtZoom || area >= 5000) {
  1858. label += gisLayer.labelFields.map(
  1859. fieldName => item.attributes[fieldName]
  1860. ).join(' ').trim();
  1861. if (gisLayer.processLabel) {
  1862. if (gisLayer.labelProcessingError) {
  1863. label = 'ERROR';
  1864. } else {
  1865. labelProcessingGlobalVariables.label = label;
  1866. labelProcessingGlobalVariables.fieldValues = item.attributes;
  1867. const result = ESTreeProcessor.execute(gisLayer.processLabel, labelProcessingGlobalVariables);
  1868. label = result.output?.trim() ?? '';
  1869. }
  1870. }
  1871. }
  1872.  
  1873. if (!isPolyLine) {
  1874. if (label && [
  1875. LAYER_STYLES.points, LAYER_STYLES.parcels, LAYER_STYLES.state_points,
  1876. LAYER_STYLES.state_parcels
  1877. ].includes(gisLayer.style)) {
  1878. if (settings.addrLabelDisplay === 'hn') {
  1879. const m = label.match(/^\d+/);
  1880. label = m ? m[0] : '';
  1881. } else if (settings.addrLabelDisplay === 'street') {
  1882. const m = label.match(/^(?:\d+\s)?(.*)/);
  1883. label = m ? m[1].trim() : '';
  1884. }
  1885. else if (settings.addrLabelDisplay === 'none') {
  1886. label = '';
  1887. }
  1888. }
  1889. }
  1890. return label;
  1891. }
  1892. function processFeatures(data, token, gisLayer) {
  1893. const features = [];
  1894. if (data.skipIt) {
  1895. // do nothing
  1896. } else if (data.error) {
  1897. logError(`Error in layer "${gisLayer.name}": ${data.error.message}`);
  1898. } else {
  1899. const items = data.features || [];
  1900. if (!token.cancel) {
  1901. let error = false;
  1902. const distinctValues = [];
  1903. items.forEach(item => {
  1904. let skipIt = false;
  1905. if (!token.cancel && !error) {
  1906. let feature;
  1907. let featureGeometry;
  1908. let area;
  1909. if (gisLayer.distinctFields) {
  1910. if (distinctValues.some(v => gisLayer.distinctFields.every(
  1911. fld => v[fld] === item.attributes[fld]
  1912. ))) {
  1913. skipIt = true;
  1914. } else {
  1915. const dist = {};
  1916. gisLayer.distinctFields.forEach(fld => (dist[fld] = item.attributes[fld]));
  1917. distinctValues.push(dist);
  1918. }
  1919. }
  1920. if (!skipIt) {
  1921. let isPolyLine = false;
  1922. const layerOffset = settings.getLayerSetting(gisLayer.id, 'offset') ?? { x: 0, y: 0 };
  1923. if (item.geometry) {
  1924. if (item.geometry.x) {
  1925. featureGeometry = new OpenLayers.Geometry.Point(
  1926. item.geometry.x + layerOffset.x,
  1927. item.geometry.y + layerOffset.y
  1928. );
  1929. // SDK
  1930. // featureGeometry = turf.point([item.geometry.x + layerOffset.x, item.geometry.y + layerOffset.y]);
  1931. // featureGeometry = turf.toWgs84(featureGeometry);
  1932. } else if (item.geometry.points) {
  1933. // @TODO Fix for multiple points instead of just grabbing first.
  1934. featureGeometry = new OpenLayers.Geometry.Point(
  1935. item.geometry.points[0][0] + layerOffset.x,
  1936. item.geometry.points[0][1] + layerOffset.y
  1937. );
  1938. } else if (item.geometry.rings) {
  1939. const rings = [];
  1940. item.geometry.rings.forEach(ringIn => {
  1941. const pnts = [];
  1942. for (let i = 0; i < ringIn.length; i++) {
  1943. pnts.push(new OpenLayers.Geometry.Point(
  1944. ringIn[i][0] + layerOffset.x,
  1945. ringIn[i][1] + layerOffset.y
  1946. ));
  1947. }
  1948. rings.push(new OpenLayers.Geometry.LinearRing(pnts));
  1949. });
  1950. featureGeometry = new OpenLayers.Geometry.Polygon(rings);
  1951. if (gisLayer.areaToPoint) {
  1952. featureGeometry = featureGeometry.getCentroid();
  1953. } else {
  1954. area = featureGeometry.getArea();
  1955. }
  1956. } else if (data.geometryType === 'esriGeometryPolyline') {
  1957. // We have to handle polylines differently since each item can have multiple features.
  1958. // In terms of ArcGIS, each feature's geometry can have multiple paths. For instance
  1959. // a single road can be broken into parts that are physically not connected to each other.
  1960.  
  1961. const displayLabelsAtZoom = getGisLayerLabelsVisibleAtZoom(gisLayer, getGisLayerVisibleAtZoom(gisLayer));
  1962. const label = processLabel(gisLayer, item, displayLabelsAtZoom, area, true);
  1963.  
  1964. // Use Turf library to clip the geometry to the screen bounds.
  1965. // This allows labels to stay in view on very long roads.
  1966. const mls = turf.multiLineString(item.geometry.paths);
  1967. const e = getMercatorMapExtent();
  1968. const bbox = [e.left, e.bottom, e.right, e.top];
  1969. const clipped = turf.bboxClip(mls, bbox);
  1970. if (clipped.geometry.type === 'LineString') {
  1971. item.geometry.paths = [clipped.geometry.coordinates];
  1972. } else if (clipped.geometry.type === 'MultiLineString') {
  1973. item.geometry.paths = clipped.geometry.coordinates;
  1974. }
  1975.  
  1976. item.geometry.paths.forEach(path => {
  1977. const pointList = [];
  1978. path.forEach(point => pointList.push(new OpenLayers.Geometry.Point(
  1979. point[0] + layerOffset.x,
  1980. point[1] + layerOffset.y
  1981. )));
  1982. featureGeometry = new OpenLayers.Geometry.LineString(pointList);
  1983. featureGeometry.skipDupeCheck = true;
  1984.  
  1985. const attributes = {
  1986. layerID: gisLayer.id,
  1987. label
  1988. };
  1989.  
  1990. const lineFeature = new OpenLayers.Feature.Vector(featureGeometry, attributes);
  1991. features.push(lineFeature);
  1992. if (isPopupVisible) {
  1993. addLabelToLayer(gisLayer.name, label);
  1994. }
  1995. });
  1996. isPolyLine = true;
  1997. } else {
  1998. logDebug(`Unexpected feature type in layer: ${JSON.stringify(item)}`);
  1999. logError(`Error: Unexpected feature type in layer "${gisLayer.name}"`);
  2000. error = true;
  2001. }
  2002. if (!error && !isPolyLine && featureGeometry) {
  2003. const displayLabelsAtZoom = getGisLayerLabelsVisibleAtZoom(gisLayer, getGisLayerVisibleAtZoom(gisLayer));
  2004. const label = processLabel(gisLayer, item, displayLabelsAtZoom, area);
  2005. const attributes = {
  2006. layerID: gisLayer.id,
  2007. label
  2008. };
  2009. // SDK
  2010. // featureGeometry.id = gisLayer.id;
  2011. // featureGeometry.properties = attributes;
  2012. // features.push(featureGeometry);
  2013. feature = new OpenLayers.Feature.Vector(featureGeometry, attributes);
  2014. features.push(feature);
  2015. if (isPopupVisible) {
  2016. addLabelToLayer(gisLayer.name, label);
  2017. }
  2018. }
  2019. }
  2020. }
  2021. }
  2022. });
  2023. }
  2024. }
  2025. if (!token.cancel) {
  2026. // Check for duplicate geometries.
  2027. for (let i = 0; i < features.length; i++) {
  2028. const f1 = features[i];
  2029. if (!f1.geometry.skipDupeCheck) {
  2030. const c1 = f1.geometry.getCentroid();
  2031. let labels = [f1.attributes.label];
  2032. for (let j = i + 1; j < features.length; j++) {
  2033. const f2 = features[j];
  2034. if (!f2.geometry.skipDupeCheck && f2.geometry.getCentroid().distanceTo(c1) < 1) {
  2035. features.splice(j, 1);
  2036. labels.push(f2.attributes.label);
  2037. j--;
  2038. }
  2039. }
  2040. labels = _.uniq(labels);
  2041. if (labels.length > 1) {
  2042. labels.forEach((label, idx) => {
  2043. label = label.replace(/\n/g, ' ').replace(/\s{2,}/, ' ').replace(/\bUNIT\s.{1,5}$/i, '').trim();
  2044. ROAD_ABBR.forEach(abbr => (label = label.replace(abbr[0], abbr[1])));
  2045. labels[idx] = label;
  2046. });
  2047. labels = _.uniq(labels);
  2048. labels.sort();
  2049. if (labels.length > 12) {
  2050. const len = labels.length;
  2051. labels = labels.slice(0, 10);
  2052. labels.push(`(${len - 10} more...)`);
  2053. }
  2054. f1.attributes.label = _.uniq(labels).join('\n');
  2055. } else {
  2056. let { label } = f1.attributes;
  2057. ROAD_ABBR.forEach(abbr => (label = label.replace(abbr[0], abbr[1])));
  2058. f1.attributes.label = label;
  2059. }
  2060. }
  2061. }
  2062.  
  2063. // SDK: Swap this when ready.
  2064. const layer = gisLayer.isRoadLayer ? roadLayer : mapLayer;
  2065. layer.removeFeatures(layer.getFeaturesByAttribute('layerID', gisLayer.id));
  2066. layer.addFeatures(features);
  2067. // sdk.Map.removeFeaturesFromLayer({ layerName: layer.name, featureIds: [gisLayer.id] });
  2068. // sdk.Map.addFeaturesToLayer({ layerName: layer.name, features });
  2069.  
  2070. if (features.length) {
  2071. $(`label[for="gis-layer-${gisLayer.id}"]`).css({ color: '#00a009' });
  2072. }
  2073. }
  2074. } // END processFeatures()
  2075.  
  2076. function copyTextToClipboard(text) {
  2077. try {
  2078. GM_setClipboard(text);
  2079. logDebug(`Copy Text To Clipboard: ${text}`);
  2080. } catch (err) {
  2081. logError(`Failed to Text To Clipboard: ${err}`);
  2082. }
  2083. }
  2084.  
  2085. function addLabelToLayer(layerName, label) {
  2086. if (!layerLabels[layerName]) {
  2087. layerLabels[layerName] = new Set();
  2088. }
  2089. layerLabels[layerName].add(label);
  2090. }
  2091.  
  2092. function replacePhrasesWithAcronyms(text) {
  2093. // Order phrases such that compound phrases come before individual words
  2094. const replacements = [
  2095. // compound phrases here
  2096. { phrase: 'Alternate Route', acronym: 'ALT' },
  2097. { phrase: 'Army Air Field', acronym: 'AAF' },
  2098. { phrase: 'County Highway', acronym: 'CH-' },
  2099. { phrase: 'County Road', acronym: 'CR-' },
  2100. { phrase: 'East Bound', acronym: 'EB' },
  2101. { phrase: 'North Bound', acronym: 'NB' },
  2102. { phrase: 'North East', acronym: 'NE' },
  2103. { phrase: 'North West', acronym: 'NW' },
  2104. { phrase: 'South Bound', acronym: 'SB' },
  2105. { phrase: 'South East', acronym: 'SE' },
  2106. { phrase: 'South West', acronym: 'SW' },
  2107. { phrase: 'State Highway', acronym: 'SH-' },
  2108. { phrase: 'State Route', acronym: 'SR-' },
  2109. { phrase: 'State Rte', acronym: 'SR-' },
  2110. { phrase: 'U.S. Highway', acronym: 'US-' },
  2111. { phrase: 'U.S. Route', acronym: 'US-' },
  2112. { phrase: 'U.S. Rte', acronym: 'US-' },
  2113. { phrase: 'U.S.Rte', acronym: 'US-' },
  2114. { phrase: 'US Highway', acronym: 'US-' },
  2115. { phrase: 'U S Highway', acronym: 'US-' },
  2116. { phrase: 'US Route', acronym: 'US-' },
  2117. { phrase: 'U S Route', acronym: 'US-' },
  2118. { phrase: 'US RTE', acronym: 'US-' },
  2119. { phrase: 'U S RTE', acronym: 'US-' },
  2120. { phrase: 'USRTE', acronym: 'US-' },
  2121. { phrase: 'West Bound', acronym: 'WB' },
  2122. // Start of single words list
  2123. { phrase: 'Alley', acronym: 'Aly' },
  2124. { phrase: 'Apartments', acronym: 'Apts' },
  2125. { phrase: 'Avenue', acronym: 'Ave' },
  2126. { phrase: 'Beach', acronym: 'Bch' },
  2127. { phrase: 'Boulevard', acronym: 'Blvd' },
  2128. { phrase: 'Bridge', acronym: 'Br' },
  2129. { phrase: 'Business', acronym: 'BUS' },
  2130. { phrase: 'Bypass', acronym: 'BYP' },
  2131. { phrase: 'Canyon', acronym: 'Cyn' },
  2132. { phrase: 'Captain', acronym: 'Capt' },
  2133. { phrase: 'Causeway', acronym: 'Cswy' },
  2134. { phrase: 'Center', acronym: 'Ctr' },
  2135. { phrase: 'Circle', acronym: 'Cir' },
  2136. { phrase: 'Colonel', acronym: 'Col.' },
  2137. { phrase: 'Commander', acronym: 'Cmdr.' },
  2138. { phrase: 'Connector', acronym: 'CONN' },
  2139. { phrase: 'Corners', acronym: 'Cors' },
  2140. { phrase: 'Corporal', acronym: 'Cpl.' },
  2141. { phrase: 'Court', acronym: 'Ct' },
  2142. { phrase: 'Cove', acronym: 'Cv' },
  2143. { phrase: 'Creek', acronym: 'Crk' },
  2144. { phrase: 'Crescent', acronym: 'Cres' },
  2145. { phrase: 'Crossing', acronym: 'X-ing' },
  2146. { phrase: 'Doctor', acronym: 'Dr.' },
  2147. { phrase: 'Drive', acronym: 'Dr' },
  2148. { phrase: 'East', acronym: 'E' },
  2149. { phrase: 'Eastbound', acronym: 'EB' },
  2150. { phrase: 'Eb', acronym: 'EB' },
  2151. { phrase: 'Express', acronym: 'EXP' },
  2152. { phrase: 'Expressway', acronym: 'Expwy' },
  2153. { phrase: 'Extension', acronym: 'Ext' },
  2154. { phrase: 'Fort', acronym: 'Ft.' },
  2155. { phrase: 'Freeway', acronym: 'Fwy' },
  2156. { phrase: 'General', acronym: 'Gen.' },
  2157. { phrase: 'Governor', acronym: 'Gov.' },
  2158. { phrase: 'Grove', acronym: 'Grv' },
  2159. { phrase: 'Heights', acronym: 'Hts' },
  2160. { phrase: 'Highway', acronym: 'Hwy' },
  2161. { phrase: 'Honerable', acronym: 'Hon.' },
  2162. { phrase: 'International', acronym: 'Intl' },
  2163. { phrase: 'Interstate', acronym: 'I-' },
  2164. { phrase: 'Junior', acronym: 'Jr.' },
  2165. { phrase: 'Landing', acronym: 'Lndg' },
  2166. { phrase: 'Lane', acronym: 'Ln' },
  2167. { phrase: 'Lieutenant', acronym: 'Lt.' },
  2168. { phrase: 'Loop', acronym: 'Lp' },
  2169. { phrase: 'Major', acronym: 'Maj.' },
  2170. { phrase: 'Manor', acronym: 'Mnr.' },
  2171. { phrase: 'Meadow', acronym: 'Mdw' },
  2172. { phrase: 'Mount', acronym: 'Mt' },
  2173. { phrase: 'Mountain', acronym: 'Mtn' },
  2174. { phrase: 'Mountains', acronym: 'Mtns' },
  2175. { phrase: 'National', acronym: "Nat'l" },
  2176. { phrase: 'North', acronym: 'N' },
  2177. { phrase: 'Northbound', acronym: 'NB' },
  2178. { phrase: 'Nb', acronym: 'NB' },
  2179. { phrase: 'Northeast', acronym: 'NE' },
  2180. { phrase: 'Northwest', acronym: 'NW' },
  2181. { phrase: 'Park', acronym: 'Pk' },
  2182. { phrase: 'Parkway', acronym: 'Pkwy' },
  2183. { phrase: 'Parkways', acronym: 'Pkwys' },
  2184. { phrase: 'Passage', acronym: 'Psge' },
  2185. { phrase: 'Place', acronym: 'Pl' },
  2186. { phrase: 'Plaza', acronym: 'Plz' },
  2187. { phrase: 'Point', acronym: 'Pt' },
  2188. { phrase: 'Points', acronym: 'Pts' },
  2189. { phrase: 'President', acronym: 'Pres.' },
  2190. { phrase: 'Professor', acronym: 'Prof.' },
  2191. { phrase: 'Railroad', acronym: 'R.R.' },
  2192. { phrase: 'Road', acronym: 'Rd' },
  2193. { phrase: 'Recreational', acronym: 'Rec.' },
  2194. { phrase: 'Reverend', acronym: 'Rev.' },
  2195. { phrase: 'Route', acronym: 'SR-' },
  2196. { phrase: 'Saint', acronym: 'St.' },
  2197. { phrase: 'Sainte', acronym: 'Ste.' },
  2198. { phrase: 'Senior', acronym: 'Sr.' },
  2199. { phrase: 'Sergeant', acronym: 'Sgt.' },
  2200. { phrase: 'Skyway', acronym: 'Skwy' },
  2201. { phrase: 'South', acronym: 'S' },
  2202. { phrase: 'Southbound', acronym: 'SB' },
  2203. { phrase: 'Sb', acronym: 'SB' },
  2204. { phrase: 'Southeast', acronym: 'SE' },
  2205. { phrase: 'Southwest', acronym: 'SW' },
  2206. { phrase: 'Springs', acronym: 'Spgs' },
  2207. { phrase: 'Square', acronym: 'Sq' },
  2208. { phrase: 'Station', acronym: 'Sta' },
  2209. { phrase: 'Street', acronym: 'St' },
  2210. { phrase: 'Terrace', acronym: 'Ter' },
  2211. { phrase: 'Throughway', acronym: 'Thwy' },
  2212. { phrase: 'Thruway', acronym: 'Thwy' },
  2213. { phrase: 'Tollway', acronym: 'Tlwy' },
  2214. { phrase: 'Township', acronym: 'Twp' },
  2215. { phrase: 'Trafficway', acronym: 'Trfy' },
  2216. { phrase: 'Trail', acronym: 'Trl' },
  2217. { phrase: 'Tunnel', acronym: 'Tun' },
  2218. { phrase: 'Turnpike', acronym: 'Tpk' },
  2219. { phrase: 'Upper', acronym: 'Upr' },
  2220. { phrase: 'U.S.', acronym: 'US' },
  2221. { phrase: 'Valley', acronym: 'Vly' },
  2222. { phrase: 'West', acronym: 'W' },
  2223. { phrase: 'Westbound', acronym: 'WB' },
  2224. { phrase: 'Wb', acronym: 'WB' },
  2225. { phrase: '--', acronym: '-' },
  2226. { phrase: ' -', acronym: '-' },
  2227. { phrase: '- ', acronym: '-' },
  2228. { phrase: '- -', acronym: '-' }
  2229. ];
  2230.  
  2231. let updatedText = text;
  2232.  
  2233. // Replace phrases with their acronyms, case insensitive
  2234. replacements.forEach(({ phrase, acronym }) => {
  2235. const regex = new RegExp(`\\b${phrase}\\b`, 'gi'); // Uses \\b to match words with word boundaries
  2236. updatedText = updatedText.replace(regex, acronym);
  2237. });
  2238.  
  2239. return updatedText;
  2240. }
  2241.  
  2242. function fixSateHwyRoadNames(text) {
  2243. // Regular expression to capture patterns like "XXX ###", "XXX-###", "XXX###", as well as "Us Route #", "Us Rte #", and "Route #", "Rte #"
  2244. 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;
  2245.  
  2246. // Replacement function formats matched patterns
  2247. return text.replace(regex, (match, letters, numbers, usRouteNumber, rteNumber, routeNumber) => {
  2248. if (usRouteNumber) {
  2249. return `US-${usRouteNumber}`; // for "US Route"/s
  2250. }
  2251. if (rteNumber || routeNumber) {
  2252. return `SR-${rteNumber || routeNumber}`; // Change "Rte" or "Route" to "SR"
  2253. }
  2254. if (letters && numbers) {
  2255. return `${letters.toUpperCase()}-${numbers}`; // General format for other letter-number combos
  2256. }
  2257. return match;
  2258. });
  2259. }
  2260.  
  2261. function titleCaseLabel(text) {
  2262. // Read each line separately
  2263. const lines = text.split('\n');
  2264. return lines
  2265. .map(line => {
  2266. const trimmedLine = line.trim(); // Trim the line to remove leading/trailing spaces
  2267. const words = trimmedLine.split(' '); // Split the line into individual words
  2268. // Capitalize the first letter of each word and convert the rest to lowercase
  2269. const titleCasedLine = words
  2270. .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
  2271. .join(' '); // Recombine the words into a title-cased line
  2272. return titleCasedLine; // Return the formatted line
  2273. })
  2274. .join('\n'); // Combine all the lines back into a single string separated by new lines
  2275. }
  2276.  
  2277. function processedLabel(label) {
  2278. if (useTitleCase) {
  2279. label = titleCaseLabel(label);
  2280. }
  2281. if (useAcronyms) {
  2282. label = replacePhrasesWithAcronyms(label);
  2283. }
  2284. if (useStateHwy) {
  2285. label = fixSateHwyRoadNames(label);
  2286. }
  2287. if (removeNewLines) {
  2288. label = label.replace(/[\r\n]+/g, ' ');
  2289. }
  2290. return label;
  2291. }
  2292.  
  2293. function updatePopup(labels) {
  2294. let popup = document.getElementById('layerLabelPopup');
  2295. if (!popup) {
  2296. popup = document.createElement('div');
  2297. popup.id = 'layerLabelPopup';
  2298. popup.style = `position: absolute; background: #f5f5f5; border: 2px solid #007bff; border-radius: 5px;
  2299. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); z-index: 1000; width: 500px; max-width: 800px;
  2300. height: 300px; resize: both; overflow: hidden; max-height: 700px; left: ${popupPosition.left}; top: ${popupPosition.top}; `;
  2301.  
  2302. const header = document.createElement('div');
  2303. 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; ';
  2304.  
  2305. const title = document.createElement('span');
  2306. title.innerText = 'GIS-L Layer Labels';
  2307. header.appendChild(title);
  2308.  
  2309. const closeButton = document.createElement('span');
  2310. closeButton.innerText = '×';
  2311. closeButton.style = 'cursor: pointer; font-size: 20px; margin-left: 10px; ';
  2312. closeButton.addEventListener('click', () => {
  2313. isPopupVisible = false;
  2314. togglePopupVisibility();
  2315. $('input[name="popupVisibility"][value="show"]').prop('checked', isPopupVisible);
  2316. $('input[name="popupVisibility"][value="hide"]').prop('checked', !isPopupVisible);
  2317. saveSettingsToStorage();
  2318. });
  2319. header.appendChild(closeButton);
  2320. popup.appendChild(header);
  2321.  
  2322. const formatOptionContainer = document.createElement('div');
  2323. formatOptionContainer.style = 'background: #72767d; color: #fff;';
  2324.  
  2325. const firstRow = document.createElement('div');
  2326. firstRow.style = 'display: flex; gap: 10px; align-items: flex-start; justify-content: flex-start;';
  2327.  
  2328. const formatCheckbox = document.createElement('input');
  2329. formatCheckbox.type = 'checkbox';
  2330. formatCheckbox.id = 'useTitleCaseCheckbox';
  2331. formatCheckbox.style = 'margin-left: 10px';
  2332. formatCheckbox.checked = useTitleCase;
  2333. formatCheckbox.addEventListener('change', () => {
  2334. useTitleCase = formatCheckbox.checked;
  2335. updatePopupContent(labels);
  2336. saveSettingsToStorage();
  2337. });
  2338. firstRow.appendChild(formatCheckbox);
  2339.  
  2340. const formatCheckboxLabel = document.createElement('label');
  2341. formatCheckboxLabel.htmlFor = 'useTitleCaseCheckbox';
  2342. formatCheckboxLabel.innerText = 'Use Title Case';
  2343. formatCheckboxLabel.style = 'font-weight: 100; width: 150px;';
  2344. firstRow.appendChild(formatCheckboxLabel);
  2345.  
  2346. const acronymCheckbox = document.createElement('input');
  2347. acronymCheckbox.type = 'checkbox';
  2348. acronymCheckbox.id = 'useacronymsCheckbox';
  2349. acronymCheckbox.checked = useAcronyms;
  2350. acronymCheckbox.addEventListener('change', () => {
  2351. useAcronyms = acronymCheckbox.checked;
  2352. updatePopupContent(labels);
  2353. saveSettingsToStorage();
  2354. });
  2355. firstRow.appendChild(acronymCheckbox);
  2356.  
  2357. const acronymCheckboxLabel = document.createElement('label');
  2358. acronymCheckboxLabel.htmlFor = 'useacronymsCheckbox';
  2359. acronymCheckboxLabel.innerText = 'Use Acronyms & Abbreviations';
  2360. acronymCheckboxLabel.style = 'font-weight: 100;';
  2361. firstRow.appendChild(acronymCheckboxLabel);
  2362. formatOptionContainer.appendChild(firstRow);
  2363.  
  2364. const secondRow = document.createElement('div');
  2365. secondRow.style = 'display: flex; gap: 10px; align-items: flex-start; justify-content: flex-start;';
  2366.  
  2367. const stateHwyCheckbox = document.createElement('input');
  2368. stateHwyCheckbox.type = 'checkbox';
  2369. stateHwyCheckbox.id = 'useStateHwyCheckbox';
  2370. stateHwyCheckbox.style = 'margin-left: 10px';
  2371. stateHwyCheckbox.checked = useStateHwy;
  2372. stateHwyCheckbox.addEventListener('change', () => {
  2373. useStateHwy = stateHwyCheckbox.checked;
  2374. updatePopupContent(labels);
  2375. saveSettingsToStorage();
  2376. });
  2377. secondRow.appendChild(stateHwyCheckbox);
  2378.  
  2379. const stateHwyCheckboxLabel = document.createElement('label');
  2380. stateHwyCheckboxLabel.htmlFor = 'useStateHwyCheckbox';
  2381. stateHwyCheckboxLabel.innerText = 'Fix Highway Labels';
  2382.  
  2383. stateHwyCheckboxLabel.style = 'font-weight: 100; width: 150px;';
  2384. secondRow.appendChild(stateHwyCheckboxLabel);
  2385.  
  2386. const removeNewLinesCheckbox = document.createElement('input');
  2387. removeNewLinesCheckbox.type = 'checkbox';
  2388. removeNewLinesCheckbox.id = 'removeNewLinesCheckbox';
  2389. removeNewLinesCheckbox.checked = removeNewLines;
  2390. removeNewLinesCheckbox.addEventListener('change', () => {
  2391. removeNewLines = removeNewLinesCheckbox.checked;
  2392. updatePopupContent(labels);
  2393. saveSettingsToStorage();
  2394. });
  2395. secondRow.appendChild(removeNewLinesCheckbox);
  2396.  
  2397. const removeNewLinesCheckboxLabel = document.createElement('label');
  2398. removeNewLinesCheckboxLabel.htmlFor = 'removeNewLinesCheckbox';
  2399. removeNewLinesCheckboxLabel.innerText = 'Remove New Lines';
  2400. removeNewLinesCheckboxLabel.style = 'font-weight: 100;';
  2401. secondRow.appendChild(removeNewLinesCheckboxLabel);
  2402.  
  2403. formatOptionContainer.appendChild(secondRow);
  2404. popup.appendChild(formatOptionContainer);
  2405.  
  2406. const dropdownContainer = document.createElement('div');
  2407. dropdownContainer.style = 'margin-bottom: 10px;';
  2408. popup.appendChild(dropdownContainer);
  2409.  
  2410. const contentContainer = document.createElement('div');
  2411. contentContainer.style = 'padding: 5px; overflow-y: auto; overflow-x: auto; height: calc(100% - 110px);';
  2412. popup.appendChild(contentContainer);
  2413.  
  2414. const mapElement = document.getElementsByTagName('wz-page-content')[0];
  2415. if (mapElement) {
  2416. mapElement.appendChild(popup);
  2417. }
  2418.  
  2419. header.onmousedown = function(event) {
  2420. event.preventDefault();
  2421. const parentRect = mapElement.getBoundingClientRect();
  2422. const initialX = event.clientX;
  2423. const initialY = event.clientY;
  2424. const offsetX = initialX - parentRect.left - popup.offsetLeft;
  2425. const offsetY = initialY - parentRect.top - popup.offsetTop;
  2426.  
  2427. document.onmousemove = function(ev) {
  2428. popup.style.left = `${ev.clientX - offsetX - parentRect.left}px`;
  2429. popup.style.top = `${ev.clientY - offsetY - parentRect.top}px`;
  2430.  
  2431. popupPosition.left = popup.style.left;
  2432. popupPosition.top = popup.style.top;
  2433. };
  2434.  
  2435. document.onmouseup = function() {
  2436. document.onmousemove = null;
  2437. document.onmouseup = null;
  2438. };
  2439. };
  2440. }
  2441.  
  2442. updatePopupContent(labels);
  2443. popup.style.display = isPopupVisible ? 'block' : 'none';
  2444. }
  2445.  
  2446. function updatePopupContent(labels) {
  2447. const dropdownContainer = document.querySelector('#layerLabelPopup div:nth-child(3)');
  2448. const contentContainer = document.querySelector('#layerLabelPopup div:nth-child(4)');
  2449.  
  2450. dropdownContainer.innerHTML = '';
  2451. contentContainer.innerHTML = '';
  2452.  
  2453. const select = document.createElement('select');
  2454. select.style = 'width: 100%; padding: 5px; border: 1px solid #ccc;';
  2455.  
  2456. const sortedLayerNames = Object.keys(labels).sort();
  2457. sortedLayerNames.forEach(layerName => {
  2458. const option = document.createElement('option');
  2459. option.value = layerName;
  2460. option.innerText = layerName;
  2461. select.appendChild(option);
  2462.  
  2463. const uniqueLabels = Array.from(labels[layerName]).sort();
  2464. const tabContent = document.createElement('div');
  2465. tabContent.style = 'display: none; width: 100%; white-space: pre;';
  2466.  
  2467. const processedLabels = uniqueLabels
  2468. .map(label => {
  2469. const text = processedLabel(label);
  2470. const copyIcon = '<span style="cursor: pointer; margin-left: 5px;" title="Copy to clipboard">📋</span>';
  2471. return `<li style="margin-bottom: 0.3em; color: #555;" data-label="${text}">${text}${copyIcon}</li>`;
  2472. })
  2473. .join('');
  2474.  
  2475. tabContent.innerHTML = `<ul style="padding-left: 20px; margin-top: 0;">${processedLabels}</ul>`;
  2476. contentContainer.appendChild(tabContent);
  2477.  
  2478. // Add copying functionality
  2479. tabContent.querySelectorAll('li').forEach(li => {
  2480. const icon = li.querySelector('span');
  2481. if (icon) {
  2482. icon.addEventListener('click', () => {
  2483. const textToCopy = li.getAttribute('data-label'); // Get the text from a custom data attribute
  2484. copyTextToClipboard(textToCopy);
  2485. });
  2486. }
  2487. });
  2488. });
  2489.  
  2490. dropdownContainer.appendChild(select);
  2491.  
  2492. let selectedLayerIndex = sortedLayerNames.indexOf(popupActiveLayer);
  2493.  
  2494. if (selectedLayerIndex === -1 && select.options.length > 0) {
  2495. selectedLayerIndex = 0;
  2496. popupActiveLayer = sortedLayerNames[selectedLayerIndex];
  2497. }
  2498. select.selectedIndex = selectedLayerIndex;
  2499.  
  2500. const allContents = contentContainer.querySelectorAll('div');
  2501. allContents.forEach((content, index) => {
  2502. content.style.display = index === select.selectedIndex ? 'block' : 'none';
  2503. });
  2504.  
  2505. select.addEventListener('change', () => {
  2506. const contents = contentContainer.querySelectorAll('div');
  2507. contents.forEach((content, index) => {
  2508. content.style.display = index === select.selectedIndex ? 'block' : 'none';
  2509. });
  2510. popupActiveLayer = select.value;
  2511. });
  2512. }
  2513.  
  2514. function fetchFeatures() {
  2515. if (isPopupVisible) {
  2516. Object.keys(layerLabels).forEach(key => delete layerLabels[key]);
  2517. }
  2518. if (ignoreFetch) return;
  2519. if (sdk.Map.getZoomLevel() < 12) {
  2520. filterLayerCheckboxes();
  2521. return;
  2522. }
  2523. lastToken.cancel = true;
  2524. lastToken = { cancel: false, features: [], layersProcessed: 0 };
  2525. $('.gis-state-layer-label').css({ color: '#777' });
  2526.  
  2527. let _layersCleared = false;
  2528.  
  2529. // if (layersToFetch.length) {
  2530. const extent = getMercatorMapExtent();
  2531. GM_xmlhttpRequest({
  2532. url: getCountiesUrl(extent),
  2533. method: 'GET',
  2534. onload(res) {
  2535. if (res.status < 400) {
  2536. const data = $.parseJSON(res.responseText);
  2537. if (data.error) {
  2538. logError(`Error in US Census counties data: ${data.error.message}`);
  2539. } else {
  2540. _countiesInExtent = data.features.map(feature => {
  2541. const name = feature.attributes.BASENAME.toLowerCase();
  2542. const stateInfo = STATES.fromId(parseInt(feature.attributes.STATE, 10));
  2543. return { name, stateInfo };
  2544. });
  2545. logDebug(`US Census counties: ${_countiesInExtent.map(c => `${c.name} ${c.stateInfo[1]}`).join(', ')}`);
  2546.  
  2547. let layersToFetch;
  2548. if (!_layersCleared) {
  2549. _layersCleared = true;
  2550. layersToFetch = getFetchableLayers();
  2551.  
  2552. // Remove features of any layers that won't be mapped.
  2553. _gisLayers.forEach(gisLayer => {
  2554. if (!layersToFetch.includes(gisLayer)) {
  2555. mapLayer.removeFeatures(mapLayer.getFeaturesByAttribute('layerID', gisLayer.id));
  2556. roadLayer.removeFeatures(roadLayer.getFeaturesByAttribute('layerID', gisLayer.id));
  2557. }
  2558. });
  2559. }
  2560.  
  2561. layersToFetch = layersToFetch.filter(layer => !layer.hasOwnProperty('counties')
  2562. || layer.counties.some(countyName => _countiesInExtent.some(county => county.name === countyName.toLowerCase()
  2563. && layer.state === county.stateInfo[1])));
  2564. filterLayerCheckboxes();
  2565. logDebug(`Fetching ${layersToFetch.length} layers...`);
  2566. logDebug(layersToFetch);
  2567. let layersProcessedCount = 0; // Track processed layers
  2568.  
  2569. layersToFetch.forEach(gisLayer => {
  2570. const url = getUrl(extent, gisLayer);
  2571. GM_xmlhttpRequest({
  2572. url,
  2573. context: lastToken,
  2574. method: 'GET',
  2575. onload(res2) {
  2576. if (res2.status < 400) { // Handle stupid issue where http 4## is considered success
  2577. processFeatures($.parseJSON(res2.responseText), res2.context, gisLayer);
  2578. // Update the popup only after all layers have been processed
  2579. layersProcessedCount += 1;
  2580. if (layersProcessedCount === layersToFetch.length && isPopupVisible) {
  2581. updatePopup(layerLabels);
  2582. }
  2583. } else {
  2584. logDebug(`HTTP request error: ${JSON.stringify(res2)}`);
  2585. logError(`Could not fetch layer "${gisLayer.id}". Request returned ${res2.status}`);
  2586. }
  2587. },
  2588. onerror(res3) {
  2589. logDebug(`xmlhttpRequest error:${JSON.stringify(res3)}`);
  2590. logError(`Could not fetch layer "${gisLayer.id}". An error was thrown.`);
  2591. }
  2592. });
  2593. });
  2594. }
  2595. } else {
  2596. logDebug(`HTTP request error: ${JSON.stringify(res)}`);
  2597. logError(`Could not fetch counties from US Census site. Request returned ${res.status}`);
  2598. }
  2599. },
  2600. onerror(res) {
  2601. logDebug(`xmlhttpRequest error:${JSON.stringify(res)}`);
  2602. logError('Could not fetch counties from US Census site. An error was thrown.');
  2603. }
  2604. });
  2605. }
  2606.  
  2607. function showScriptInfoAlert() {
  2608. /* Check version and alert on update */
  2609. if (SHOW_UPDATE_MESSAGE && scriptVersion !== settings.lastVersion) {
  2610. // alert(SCRIPT_VERSION_CHANGES);
  2611. let releaseNotes = '';
  2612. releaseNotes += '<p>What\'s New:</p>';
  2613. if (SCRIPT_VERSION_CHANGES.length > 0) {
  2614. releaseNotes += '<ul>';
  2615. for (let idx = 0; idx < SCRIPT_VERSION_CHANGES.length; idx++)
  2616. releaseNotes += `<li>${SCRIPT_VERSION_CHANGES[idx]}`;
  2617. releaseNotes += '</ul>';
  2618. }
  2619. else {
  2620. releaseNotes += '<ul><li>Nothing major.</ul>';
  2621. }
  2622. WazeWrap.Interface.ShowScriptUpdate(GM_info.script.name, scriptVersion, releaseNotes, GF_URL);
  2623. }
  2624. }
  2625.  
  2626. function setEnabled(value) {
  2627. settings.enabled = value;
  2628. saveSettingsToStorage();
  2629. mapLayer.setVisibility(value);
  2630. roadLayer.setVisibility(value);
  2631. const color = value ? '#00bd00' : '#ccc';
  2632. $('span#gis-layers-power-btn').css({ color });
  2633. if (value) fetchFeatures();
  2634. $('#layer-switcher-item_gis_layers').prop('checked', value);
  2635.  
  2636. // Show/hide the popup based on the enabled state
  2637. const popup = document.getElementById('layerLabelPopup');
  2638. if (popup) {
  2639. popup.style.display = value ? 'block' : 'none';
  2640. isPopupVisible = value;
  2641. }
  2642. }
  2643.  
  2644. function onGisLayerToggleChanged() {
  2645. const checked = $(this).is(':checked');
  2646. const layerId = $(this).data('layer-id');
  2647. const idx = settings.visibleLayers.indexOf(layerId);
  2648. if (checked) {
  2649. const gisLayer = _gisLayers.find(l => l.id === layerId);
  2650. if (gisLayer.oneTimeAlert) {
  2651. const lastAlertHash = settings.oneTimeAlerts[layerId];
  2652. const newAlertHash = hashString(gisLayer.oneTimeAlert);
  2653. if (lastAlertHash !== newAlertHash) {
  2654. // alert(`Layer: ${gisLayer.name}\n\nMessage:\n${gisLayer.oneTimeAlert}`);
  2655. WazeWrap.Alerts.info(GM_info.script.name, `Layer: ${gisLayer.name}<br><br>Message:<br>${gisLayer.oneTimeAlert}`);
  2656. settings.oneTimeAlerts[layerId] = newAlertHash;
  2657. saveSettingsToStorage();
  2658. }
  2659. }
  2660. if (idx === -1) settings.visibleLayers.push(layerId);
  2661. } else if (idx > -1) settings.visibleLayers.splice(idx, 1);
  2662. if (!ignoreFetch) {
  2663. saveSettingsToStorage();
  2664. fetchFeatures();
  2665. }
  2666. }
  2667.  
  2668. function onOnlyShowApplicableLayersChanged() {
  2669. settings.onlyShowApplicableLayers = $(this).is(':checked');
  2670. saveSettingsToStorage();
  2671. fetchFeatures();
  2672. }
  2673.  
  2674. function onStateCheckChanged(evt) {
  2675. const state = evt.data;
  2676. const idx = settings.selectedStates.indexOf(state);
  2677. if (evt.target.checked) {
  2678. if (idx === -1) settings.selectedStates.push(state);
  2679. } else if (idx > -1) settings.selectedStates.splice(idx, 1);
  2680. if (!ignoreFetch) {
  2681. saveSettingsToStorage();
  2682. initLayersTab();
  2683. fetchFeatures();
  2684. }
  2685. }
  2686.  
  2687. function onLayerCheckboxChanged(checked) {
  2688. setEnabled(checked);
  2689. }
  2690.  
  2691. function setFillParcels(doFill) {
  2692. [LAYER_STYLES.parcels, LAYER_STYLES.state_parcels].forEach(style => {
  2693. style.fillOpacity = doFill ? 0.2 : 0;
  2694. });
  2695. }
  2696.  
  2697. function onFillParcelsCheckedChanged(evt) {
  2698. const { checked } = evt.target;
  2699. setFillParcels(checked);
  2700. settings.fillParcels = checked;
  2701. saveSettingsToStorage();
  2702. fetchFeatures();
  2703. }
  2704.  
  2705. function onMapMove() {
  2706. if (settings.enabled) fetchFeatures();
  2707. }
  2708.  
  2709. function onRefreshLayersClick() {
  2710. const $btn = $('#gis-layers-refresh');
  2711. if (!$btn.hasClass('fa-spin')) {
  2712. $btn.css({ cursor: 'auto' });
  2713. $btn.addClass('fa-spin');
  2714. init(false);
  2715. }
  2716. }
  2717.  
  2718. function onChevronClick(evt) {
  2719. const $target = $(evt.currentTarget);
  2720. $($target.children()[0])
  2721. .toggleClass('fa fa-fw fa-chevron-down')
  2722. .toggleClass('fa fa-fw fa-chevron-right');
  2723. const $div = $($target.siblings()[0]);
  2724. if ($div.css('display') === 'none') {
  2725. $div.css('display', 'block');
  2726. } else {
  2727. $div.css('display', 'none');
  2728. }
  2729. }
  2730.  
  2731. function doToggleABunch(evt, checkState) {
  2732. ignoreFetch = true;
  2733. $(evt.target).closest('fieldset').find('input').prop('checked', !checkState).trigger('click');
  2734. ignoreFetch = false;
  2735. saveSettingsToStorage();
  2736. if (evt.data) initLayersTab();
  2737. fetchFeatures();
  2738. }
  2739.  
  2740. function onSelectAllClick(evt) {
  2741. doToggleABunch(evt, true);
  2742. }
  2743.  
  2744. function onSelectNoneClick(evt) {
  2745. doToggleABunch(evt, false);
  2746. }
  2747.  
  2748. function onGisAddrDisplayChange(evt) {
  2749. settings.addrLabelDisplay = evt.target.value;
  2750. saveSettingsToStorage();
  2751. fetchFeatures();
  2752. }
  2753.  
  2754. function onAddressDisplayShortcutKey() {
  2755. if (!$('#gisAddrDisplay-hn').is(':checked')) {
  2756. $('#gisAddrDisplay-hn').click();
  2757. } else {
  2758. $('#gisAddrDisplay-all').click();
  2759. }
  2760. }
  2761.  
  2762. function onToggleGisLayersShortcutKey() {
  2763. setEnabled(!settings.enabled);
  2764. }
  2765.  
  2766. function togglePopupVisibility() {
  2767. const popup = document.getElementById('layerLabelPopup');
  2768. if (popup) {
  2769. popup.style.display = isPopupVisible ? 'block' : 'none';
  2770. }
  2771. saveSettingsToStorage();
  2772. }
  2773.  
  2774. function initLayer() {
  2775. const rules = _gisLayers.map(gisLayer => new OpenLayers.Rule({
  2776. filter: new OpenLayers.Filter.Comparison({
  2777. type: OpenLayers.Filter.Comparison.EQUAL_TO,
  2778. property: 'layerID',
  2779. value: gisLayer.id
  2780. }),
  2781. symbolizer: gisLayer.style
  2782. }));
  2783.  
  2784. setFillParcels(settings.fillParcels);
  2785.  
  2786. const style = new OpenLayers.Style(DEFAULT_STYLE, { rules });
  2787. let existingLayer;
  2788. let uniqueName;
  2789.  
  2790. uniqueName = 'wmeGISLayersDefault';
  2791. existingLayer = W.map.layers.find(l => l.uniqueName === uniqueName); // Note: W.map.getLayerByUniqueName(...) isn't working.
  2792. if (existingLayer) W.map.removeLayer(existingLayer);
  2793. mapLayer = new OpenLayers.Layer.Vector('GIS Layers - Default', {
  2794. uniqueName,
  2795. styleMap: new OpenLayers.StyleMap(style)
  2796. });
  2797.  
  2798. uniqueName = 'wmeGISLayersRoads';
  2799. existingLayer = W.map.layers.find(l => l.uniqueName === uniqueName); // Note: W.map.getLayerByUniqueName(...) isn't wworking.
  2800. if (existingLayer) W.map.removeLayer(existingLayer);
  2801. roadLayer = new OpenLayers.Layer.Vector('GIS Layers - Roads', {
  2802. uniqueName,
  2803. styleMap: new OpenLayers.StyleMap(ROAD_STYLE)
  2804. });
  2805.  
  2806. mapLayer.setVisibility(settings.enabled);
  2807. roadLayer.setVisibility(settings.enabled);
  2808.  
  2809. W.map.addLayers([roadLayer, mapLayer]);
  2810. } // END InitLayer
  2811.  
  2812. function initLayersTab() {
  2813. const user = userInfo.userName.toLowerCase();
  2814. const states = _.uniq(_gisLayers.map(l => l.state)).filter(st => settings.selectedStates.includes(st));
  2815.  
  2816. $('#panel-gis-state-layers').empty().append(
  2817. $('<div>', { class: 'controls-container' }).css({ 'padding-top': '0px' }).append(
  2818. $('<input>', { type: 'checkbox', id: 'only-show-applicable-gis-layers' }).change(
  2819. onOnlyShowApplicableLayersChanged
  2820. ).prop('checked', settings.onlyShowApplicableLayers),
  2821. $('<label>', { for: 'only-show-applicable-gis-layers' })
  2822. .css({ 'white-space': 'pre-line' }).text('Only show applicable layers')
  2823. ),
  2824. $('.gis-layers-state-checkbox:checked').length === 0
  2825. ? $('<div>').text('Turn on layer categories in the Settings tab.')
  2826. : states.map(st => $('<fieldset>', {
  2827. id: `gis-layers-for-${st}`,
  2828. style: 'border:1px solid silver;padding:4px;border-radius:4px;-webkit-padding-before: 0;'
  2829. }).append(
  2830. $('<legend>', { style: 'margin-bottom:0px;border-bottom-style:none;width:auto;' })
  2831. .click(onChevronClick).append(
  2832. $('<i>', {
  2833. class: 'fa fa-fw fa-chevron-down',
  2834. style: 'cursor: pointer;font-size: 12px;margin-right: 4px'
  2835. }),
  2836. $('<span>', {
  2837. style: 'font-size:14px;font-weight:600;text-transform: uppercase; cursor: pointer'
  2838. }).text(STATES.toFullName(st))
  2839. ),
  2840. $('<div>', { id: `${st}_body` }).append(
  2841. $('<div>').css({ 'font-size': '11px' }).append(
  2842. $('<span>').append(
  2843. 'Select ',
  2844. $('<a>', { href: '#' })
  2845. .text('All')
  2846. .click(onSelectAllClick),
  2847. ' / ',
  2848. $('<a>', { href: '#' })
  2849. .text('None')
  2850. .click(onSelectNoneClick)
  2851. )
  2852. ),
  2853. $('<div>', { class: 'controls-container', style: 'padding-top:0px;' }).append(
  2854. _gisLayers.filter(l => (l.state === st && (!PRIVATE_LAYERS.hasOwnProperty(l.id)
  2855. || PRIVATE_LAYERS[l.id].includes(user))))
  2856. .map(gisLayer => {
  2857. const id = `gis-layer-${gisLayer.id}`;
  2858. return $('<div>', { class: 'controls-container', id: `${id}-container` })
  2859. .css({ 'padding-top': '0px', display: 'block' })
  2860. .append(
  2861. $('<input>', { type: 'checkbox', id })
  2862. .data('layer-id', gisLayer.id)
  2863. .change(onGisLayerToggleChanged)
  2864. .prop('checked', settings.visibleLayers.includes(gisLayer.id)),
  2865. $('<label>', { for: id, class: 'gis-state-layer-label' })
  2866. .css({ 'white-space': 'pre-line' })
  2867. .text(`${gisLayer.name}${gisLayer.restrictTo ? ' *' : ''}`)
  2868. .attr('title', gisLayer.restrictTo ? `Restricted to: ${gisLayer.restrictTo}` : '')
  2869. .contextmenu(evt => {
  2870. evt.preventDefault();
  2871. // TODO - enable the layer if it isn't already.
  2872. // Tried using click function on the evt target, but that didn't work.
  2873. _layerSettingsDialog.gisLayer = gisLayer;
  2874. _layerSettingsDialog.show();
  2875. })
  2876. );
  2877. })
  2878. )
  2879. )
  2880. ))
  2881. );
  2882. }
  2883.  
  2884. function initSettingsTab() {
  2885. const states = _.uniq(_gisLayers.map(l => l.state));
  2886. const createRadioBtn = (name, value, text, checked) => {
  2887. const id = `${name}-${value}`;
  2888. return [$('<input>', {
  2889. type: 'radio', id, name, value
  2890. }).prop('checked', checked), $('<label>', { for: id }).text(text).css({
  2891. paddingLeft: '15px', marginRight: '4px'
  2892. })];
  2893. };
  2894. $('#panel-gis-layers-settings').empty().append(
  2895. $('<fieldset>', {
  2896. style: 'border:1px solid silver;padding:8px;border-radius:4px;-webkit-padding-before: 0;margin-top:-8px;'
  2897. }).append(
  2898. $('<legend>', {
  2899. style: 'margin-bottom:0px;border-bottom-style:none;width:auto;'
  2900. }).append($('<span>', {
  2901. style: 'font-size:14px;font-weight:600;text-transform: uppercase;'
  2902. }).text('Labels')),
  2903. $('<div>', { id: 'labelSettings' }).append(
  2904. $('<div>', { class: 'controls-container' }).css({ 'padding-top': '2px' }).append(
  2905. $('<label>', { style: 'font-weight:normal;' }).text('Addresses:'),
  2906. createRadioBtn('gisAddrDisplay', 'hn', 'HN', settings.addrLabelDisplay === 'hn'),
  2907. createRadioBtn('gisAddrDisplay', 'street', 'Street', settings.addrLabelDisplay === 'street'),
  2908. createRadioBtn('gisAddrDisplay', 'all', 'Both', settings.addrLabelDisplay === 'all'),
  2909. createRadioBtn('gisAddrDisplay', 'none', 'None', settings.addrLabelDisplay === 'none'),
  2910. $('<i>', {
  2911. class: 'waze-tooltip',
  2912. id: 'gisAddrDisplayInfo',
  2913. 'data-toggle': 'tooltip',
  2914. style: 'margin-left:8px; font-size:12px',
  2915. 'data-placement': 'bottom',
  2916. title: `This may not work properly for all layers. Please report issues to ${SCRIPT_AUTHOR}.`
  2917. }).tooltip(),
  2918. $('<br>'),
  2919. $('<label>', { style: 'font-weight:normal; margin-left:8px;' }).text('Label Popup:'),
  2920. createRadioBtn('popupVisibility', 'show', 'Show', isPopupVisible),
  2921. createRadioBtn('popupVisibility', 'hide', 'Hide', !isPopupVisible)
  2922. )
  2923. )
  2924. ),
  2925. $('<fieldset>', {
  2926. style: 'border:1px solid silver;padding:8px;border-radius:4px;-webkit-padding-before: 0;'
  2927. }).append(
  2928. $('<legend>', {
  2929. style: 'margin-bottom:0px;border-bottom-style:none;width:auto;'
  2930. }).append($('<span>', {
  2931. style: 'font-size:14px;font-weight:600;text-transform: uppercase;'
  2932. }).text('Layer Categories')),
  2933. $('<div>', { id: 'states_body' }).append(
  2934. $('<div>').css({ 'font-size': '11px' }).append(
  2935. $('<span>').append(
  2936. 'Select ',
  2937. $('<a>', { href: '#' }).text('All').click(true, onSelectAllClick),
  2938. ' / ',
  2939. $('<a>', { href: '#' }).text('None').click(true, onSelectNoneClick)
  2940. )
  2941. ),
  2942. $('<div>', { class: 'controls-container', style: 'padding-top:0px;' }).append(
  2943. states.map(st => {
  2944. const fullName = STATES.toFullName(st);
  2945. const id = `gis-layer-enable-state-${st}`;
  2946. return $('<div>', { class: 'controls-container' })
  2947. .css({ 'padding-top': '0px', display: 'block' })
  2948. .append(
  2949. $('<input>', { type: 'checkbox', id, class: 'gis-layers-state-checkbox' })
  2950. .change(st, onStateCheckChanged)
  2951. .prop('checked', settings.selectedStates.includes(st)),
  2952. $('<label>', { for: id }).css({ 'white-space': 'pre-line', color: '#777' }).text(fullName)
  2953. );
  2954. })
  2955. )
  2956. )
  2957. )
  2958. );
  2959. $('#panel-gis-layers-settings').append(
  2960. $('<fieldset>', { style: 'border:1px solid silver;padding:8px;border-radius:4px;-webkit-padding-before: 0;' })
  2961. .append(
  2962. $('<legend>', { style: 'margin-bottom:0px;border-bottom-style:none;width:auto;' })
  2963. .append(
  2964. $('<span>', { style: 'font-size:14px;font-weight:600;text-transform: uppercase;' })
  2965. .text('Appearance')
  2966. ),
  2967. $('<div>', { class: 'controls-container' }).css({ 'padding-top': '2px' }).append(
  2968. $('<input>', { type: 'checkbox', id: 'fill-parcels' })
  2969. .change(onFillParcelsCheckedChanged)
  2970. .prop('checked', settings.fillParcels),
  2971. $('<label>', { for: 'fill-parcels' }).css({ 'white-space': 'pre-line', color: '#777' }).text('Fill parcels')
  2972. )
  2973. )
  2974. );
  2975. $('input[name="gisAddrDisplay"]').change(onGisAddrDisplayChange);
  2976. $('input[name="popupVisibility"]').change(function() {
  2977. isPopupVisible = $(this).val() === 'show';
  2978. togglePopupVisibility();
  2979. });
  2980. }
  2981.  
  2982. async function initTab(firstCall = true) {
  2983. if (firstCall) {
  2984. const content = $('<div>').append(
  2985. $('<span>', { style: 'font-size:14px;font-weight:600' }).text('GIS Layers'),
  2986. $('<span>', { style: 'font-size:11px;margin-left:10px;color:#aaa;' }).text(GM_info.script.version),
  2987. // <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>
  2988. $('<a>', {
  2989. href: REQUEST_FORM_URL.replace('{username}', userInfo.userName),
  2990. target: '_blank',
  2991. style: 'color: #6290b7;font-size: 12px;margin-left: 8px;',
  2992. title: 'Report broken layers, bugs, request new layers, script features'
  2993. }).text('Submit a request'),
  2994. $('<span>', {
  2995. id: 'gis-layers-refresh',
  2996. class: 'fa fa-refresh',
  2997. style: 'float: right;',
  2998. 'data-toggle': 'tooltip',
  2999. title: 'Pull new layer info from master sheet and refresh all layers.'
  3000. }),
  3001. '<ul class="nav nav-tabs">'
  3002. + '<li class="active"><a data-toggle="tab" href="#panel-gis-state-layers" aria-expanded="true">'
  3003. + 'Layers'
  3004. + '</a></li>'
  3005. + '<li><a data-toggle="tab" href="#panel-gis-layers-settings" aria-expanded="true">'
  3006. + 'Settings'
  3007. + '</a></li> '
  3008. + '</ul>',
  3009. $('<div>', { class: 'tab-content', style: 'padding:8px;padding-top:2px' }).append(
  3010. $('<div>', { class: 'tab-pane active', id: 'panel-gis-state-layers', style: 'padding: 4px 0px 0px 0px; width: auto' }),
  3011. $('<div>', { class: 'tab-pane', id: 'panel-gis-layers-settings', style: 'padding: 4px 0px 0px 0px; width: auto' })
  3012. )
  3013. ).html();
  3014.  
  3015. const powerButtonColor = settings.enabled ? '#00bd00' : '#ccc';
  3016. const labelText = $('<div>').append(
  3017. $('<span>', {
  3018. class: 'fa fa-power-off',
  3019. id: 'gis-layers-power-btn',
  3020. style: `margin-right: 5px;cursor: pointer;color: ${powerButtonColor};font-size: 13px;`,
  3021. title: 'Toggle GIS Layers'
  3022. }),
  3023. $('<span>', { title: 'GIS Layers' }).text('GIS-L')
  3024. ).html();
  3025.  
  3026. const { tabLabel, tabPane } = await sdk.Sidebar.registerScriptTab();
  3027. tabLabel.innerHTML = labelText;
  3028. tabPane.innerHTML = content;
  3029. // Fix tab content div spacing.
  3030. $(tabPane).parent().css({ width: 'auto', padding: '6px' });
  3031. $('#gis-layers-power-btn').click(() => {
  3032. setEnabled(!settings.enabled);
  3033.  
  3034. // return false to prevent event from bubbling up the DOM tree and causing the GIS-L tab to activate
  3035. return false;
  3036. });
  3037. $('#gis-layers-refresh').click(onRefreshLayersClick);
  3038. }
  3039.  
  3040. initSettingsTab();
  3041. initLayersTab();
  3042. }
  3043.  
  3044. function initGui(firstCall = true) {
  3045. initLayer();
  3046.  
  3047. if (firstCall) {
  3048. initTab(true);
  3049.  
  3050. WazeWrap.Interface.AddLayerCheckbox('Display', 'GIS Layers', settings.enabled, onLayerCheckboxChanged);
  3051. // W.map.events.register('moveend', null, onMapMove);
  3052. WazeWrap.Events.register('moveend', null, onMapMove);
  3053. showScriptInfoAlert();
  3054. } else {
  3055. initTab(firstCall);
  3056. }
  3057. }
  3058.  
  3059. async function loadSpreadsheetAsync() {
  3060. let data;
  3061. try {
  3062. data = await $.getJSON(`${LAYER_DEF_SPREADSHEET_URL}?${DEC(API_KEY)}`);
  3063. } catch (err) {
  3064. throw new Error(`Spreadsheet call failed. (${err.status}: ${err.statusText})`);
  3065. }
  3066. const [[minVersion], fieldNames, ...layerDefRows] = data.values;
  3067. const REQUIRED_FIELD_NAMES = [
  3068. 'state', 'name', 'id', 'counties', 'url', 'where', 'labelFields',
  3069. 'processLabel', 'style', 'visibleAtZoom', 'labelsVisibleAtZoom', 'enabled',
  3070. 'restrictTo', 'oneTimeAlert'
  3071. ];
  3072. const result = { error: null };
  3073. const checkFieldNames = fldName => fieldNames.includes(fldName);
  3074.  
  3075. if (scriptVersion < minVersion) {
  3076. result.error = `Script must be updated to at least version ${
  3077. minVersion} before layer definitions can be loaded.`;
  3078. } else if (fieldNames.length < REQUIRED_FIELD_NAMES.length) {
  3079. result.error = `Expected ${
  3080. REQUIRED_FIELD_NAMES.length} columns in layer definition data. Spreadsheet returned ${
  3081. fieldNames.length}.`;
  3082. } else if (!REQUIRED_FIELD_NAMES.every(fldName => checkFieldNames(fldName))) {
  3083. result.error = 'Script expected to see the following column names in the layer '
  3084. + `definition spreadsheet:\n${REQUIRED_FIELD_NAMES.join(', ')}\n`
  3085. + `But the spreadsheet returned these:\n${fieldNames.join(', ')}`;
  3086. }
  3087. if (!result.error) {
  3088. layerDefRows.filter(row => row.length).forEach(layerDefRow => {
  3089. const layerDef = { enabled: '0' };
  3090. fieldNames.forEach((fldName, fldIdx) => {
  3091. let value = layerDefRow[fldIdx];
  3092. if (value !== undefined && value.trim().length > 0) {
  3093. value = value.trim();
  3094. if (fldName === 'counties' || fldName === 'labelFields') {
  3095. value = value.split(',').map(item => item.trim());
  3096. } else if (fldName === 'processLabel') {
  3097. try {
  3098. value = ESTreeProcessor.compile(`function __$proc(){${value}} __$proc();`);
  3099. } catch (ex) {
  3100. layerDef.labelProcessingError = true;
  3101. logError(`Error loading label processing function for layer "${layerDef.id}".`);
  3102. logDebug(ex);
  3103. }
  3104. } else if (fldName === 'style') {
  3105. layerDef.isRoadLayer = value === 'roads';
  3106. if (LAYER_STYLES.hasOwnProperty(value)) {
  3107. value = LAYER_STYLES[value];
  3108. } else if (!layerDef.isRoadLayer) {
  3109. // If style is not defined, try to read in as JSON (custom style)
  3110. try {
  3111. value = JSON.parse(value);
  3112. } catch (ex) {
  3113. // ignore error
  3114. }
  3115. }
  3116. } else if (fldName === 'state') {
  3117. value = value ? value.toUpperCase() : value;
  3118. } else if (fldName === 'restrictTo') {
  3119. try {
  3120. const values = value.split(',').map(v => v.trim().toLowerCase());
  3121. layerDef.notAllowed = !values.some(entry => {
  3122. const rankMatch = entry.match(/^r(\d)(\+am)?$/);
  3123. if (rankMatch) {
  3124. if (rankMatch[1] <= (userInfo.rank + 1) && (!rankMatch[2] || userInfo.isAreaManager)) {
  3125. return true;
  3126. }
  3127. } else if (entry === 'am' && userInfo.isAreaManager) {
  3128. return true;
  3129. } else if (entry === userInfo.userName.toLowerCase()) {
  3130. return true;
  3131. }
  3132. return false;
  3133. });
  3134. } catch (ex) {
  3135. logError(ex);
  3136. }
  3137. }
  3138. layerDef[fldName] = value;
  3139. } else if (fldName === 'labelFields') {
  3140. layerDef[fldName] = [''];
  3141. }
  3142. });
  3143. const enabled = layerDef.enabled && !['0', 'false', 'no', 'n'].includes(layerDef.enabled.toString().trim().toLowerCase());
  3144. if (!layerDef.notAllowed && enabled) {
  3145. _gisLayers.push(layerDef);
  3146. }
  3147. });
  3148. }
  3149.  
  3150. return result;
  3151. }
  3152.  
  3153. function createShortcut(shortcutId, description, callback) {
  3154. let shortcutKeys = settings.shortcuts?.[shortcutId] ?? null;
  3155. if (shortcutKeys && sdk.Shortcuts.areShortcutKeysInUse({ shortcutKeys })) {
  3156. shortcutKeys = null;
  3157. }
  3158. sdk.Shortcuts.createShortcut({
  3159. shortcutId,
  3160. shortcutKeys,
  3161. description,
  3162. callback
  3163. });
  3164. }
  3165.  
  3166. async function init(firstCall = true) {
  3167. _gisLayers = [];
  3168. if (firstCall) {
  3169. userInfo = sdk.State.getUserInfo();
  3170. labelProcessingGlobalVariables.W = W;
  3171. labelProcessingGlobalVariables.sdk = sdk;
  3172. initRoadStyle();
  3173. loadSettingsFromStorage();
  3174. createShortcut('toggleHnsOnly', 'Toggle HN-only address labels (GIS Layers)', onAddressDisplayShortcutKey);
  3175. createShortcut('toggleEnabled', 'Toggle display of GIS Layers', onToggleGisLayersShortcutKey);
  3176. installPathFollowingLabels();
  3177. window.addEventListener('beforeunload', saveSettingsToStorage, false);
  3178. _layerSettingsDialog = new LayerSettingsDialog();
  3179. }
  3180. const t0 = performance.now();
  3181. try {
  3182. const result = await loadSpreadsheetAsync();
  3183. if (result.error) {
  3184. logError(result.error);
  3185. return;
  3186. }
  3187. _layerRefinements.forEach(layerRefinement => {
  3188. const layerDef = _gisLayers.find(layerDef2 => layerDef2.id === layerRefinement.id);
  3189. if (layerDef) {
  3190. Object.keys(layerRefinement).forEach(fldName => {
  3191. const value = layerRefinement[fldName];
  3192. if (fldName !== 'id' && layerDef.hasOwnProperty(fldName)) {
  3193. logDebug(`The "${fldName}" property of layer "${
  3194. layerDef.id}" has a value hardcoded in the script, and also defined in the spreadsheet.`
  3195. + ' The spreadsheet value takes precedence.');
  3196. } else if (value) layerDef[fldName] = value;
  3197. });
  3198. } else {
  3199. logDebug(`Refined layer "${layerRefinement.id}" does not have a corresponding layer defined`
  3200. + ' in the spreadsheet. It can probably be removed from the script.');
  3201. }
  3202. });
  3203. logDebug(`Loaded ${_gisLayers.length} layer definitions in ${Math.round(performance.now() - t0)} ms.`);
  3204. initGui(firstCall);
  3205. fetchFeatures();
  3206. $('#gis-layers-refresh').removeClass('fa-spin').css({ cursor: 'pointer' });
  3207. logDebug('Initialized.');
  3208. } catch (err) {
  3209. logError(err);
  3210. }
  3211. }
  3212.  
  3213. init();
  3214.  
  3215. /*eslint-disable*/
  3216. function installPathFollowingLabels() {
  3217. // Copyright (c) 2015 by Jean-Marc.Viglino [at]ign.fr
  3218. // Dual-licensed under the CeCILL-B Licence (http://www.cecill.info/)
  3219. // and the Beerware license (http://en.wikipedia.org/wiki/Beerware),
  3220. // feel free to use and abuse it in your projects (the code, not the beer ;-).
  3221. //
  3222. //* Overwrite the SVG function to allow text along a path
  3223. //* setStyle function
  3224. //*
  3225. //* Add new options to the Openlayers.Style
  3226.  
  3227. // pathLabel: {String} Label to draw on the path
  3228. // pathLabelXOffset: {String} Offset along the line to start drawing text in pixel or %, default: "50%"
  3229. // pathLabelYOffset: {Number} Distance of the line to draw the text
  3230. // pathLabelCurve: {String} Smooth the line the label is drawn on (empty string for no)
  3231. // pathLabelReadable: {String} Make the label readable (empty string for no)
  3232.  
  3233. // * Extra standard values : all label and text values
  3234.  
  3235.  
  3236. // *
  3237. // * Method: removeChildById
  3238. // * Remove child in a node.
  3239. // *
  3240.  
  3241. function removeChildById(node, id) {
  3242. if (node.querySelector) {
  3243. var c = node.querySelector('#' + id);
  3244. if (c) node.removeChild(c);
  3245. return;
  3246. }
  3247. // For old browsers
  3248. var c = node.childNodes;
  3249. if (c) for (var i = 0; i < c.length; i++) {
  3250. if (c[i].id === id) {
  3251. node.removeChild(c[i]);
  3252. return;
  3253. }
  3254. }
  3255. }
  3256.  
  3257.  
  3258. // *
  3259. // * Method: setStyle
  3260. // * Use to set all the style attributes to a SVG node.
  3261. // *
  3262. // * Takes care to adjust stroke width and point radius to be
  3263. // * resolution-relative
  3264. // *
  3265. // * Parameters:
  3266. // * node - {SVGDomElement} An SVG element to decorate
  3267. // * style - {Object}
  3268. // * options - {Object} Currently supported options include
  3269. // * 'isFilled' {Boolean} and
  3270. // * 'isStroked' {Boolean}
  3271.  
  3272. var setStyle = OpenLayers.Renderer.SVG.prototype.setStyle;
  3273. OpenLayers.Renderer.SVG.LABEL_STARTOFFSET = { 'l': '0%', 'r': '100%', 'm': '50%' };
  3274.  
  3275. OpenLayers.Renderer.SVG.prototype.pathText = function (node, style, suffix) {
  3276. var label = this.nodeFactory(null, 'text');
  3277. label.setAttribute('id', node._featureId + '_' + suffix);
  3278. if (style.fontColor) label.setAttributeNS(null, 'fill', style.fontColor);
  3279. if (style.fontStrokeColor) label.setAttributeNS(null, 'stroke', style.fontStrokeColor);
  3280. if (style.fontStrokeWidth) label.setAttributeNS(null, 'stroke-width', style.fontStrokeWidth);
  3281. if (style.fontOpacity) label.setAttributeNS(null, 'opacity', style.fontOpacity);
  3282. if (style.fontFamily) label.setAttributeNS(null, 'font-family', style.fontFamily);
  3283. if (style.fontSize) label.setAttributeNS(null, 'font-size', style.fontSize);
  3284. if (style.fontWeight) label.setAttributeNS(null, 'font-weight', style.fontWeight);
  3285. if (style.fontStyle) label.setAttributeNS(null, 'font-style', style.fontStyle);
  3286. if (style.labelSelect === true) {
  3287. label.setAttributeNS(null, 'pointer-events', 'visible');
  3288. label._featureId = node._featureId;
  3289. } else {
  3290. label.setAttributeNS(null, 'pointer-events', 'none');
  3291. }
  3292.  
  3293. function getpath(pathStr, readeable) {
  3294. var npath = pathStr.split(',');
  3295. var pts = [];
  3296. if (!readeable || Number(npath[0]) - Number(npath[npath.length - 2]) < 0) {
  3297. while (npath.length) pts.push({ x: Number(npath.shift()), y: Number(npath.shift()) });
  3298. } else {
  3299. while (npath.length) pts.unshift({ x: Number(npath.shift()), y: Number(npath.shift()) });
  3300. }
  3301. return pts;
  3302. }
  3303.  
  3304. var path = this.nodeFactory(null, 'path');
  3305. var tpid = node._featureId + '_t' + suffix;
  3306. var tpath = node.getAttribute('points');
  3307. if (style.pathLabelCurve) {
  3308. var pts = getpath(tpath, style.pathLabelReadable);
  3309. var p = pts[0].x + ' ' + pts[0].y;
  3310. var dx, dy, s1, s2;
  3311. dx = (pts[0].x - pts[1].x) / 4;
  3312. dy = (pts[0].y - pts[1].y) / 4;
  3313. for (var i = 1; i < pts.length - 1; i++) {
  3314. p += ' C ' + (pts[i - 1].x - dx) + ' ' + (pts[i - 1].y - dy);
  3315. dx = (pts[i - 1].x - pts[i + 1].x) / 4;
  3316. dy = (pts[i - 1].y - pts[i + 1].y) / 4;
  3317. s1 = Math.sqrt(Math.pow(pts[i - 1].x - pts[i].x, 2) + Math.pow(pts[i - 1].y - pts[i].y, 2));
  3318. s2 = Math.sqrt(Math.pow(pts[i + 1].x - pts[i].x, 2) + Math.pow(pts[i + 1].y - pts[i].y, 2));
  3319. p += ' ' + (pts[i].x + s1 * dx / s2) + ' ' + (pts[i].y + s1 * dy / s2);
  3320. dx *= s2 / s1;
  3321. dy *= s2 / s1;
  3322. p += ' ' + pts[i].x + ' ' + pts[i].y;
  3323. }
  3324. p += ' C ' + (pts[i - 1].x - dx) + ' ' + (pts[i - 1].y - dy);
  3325. dx = (pts[i - 1].x - pts[i].x) / 4;
  3326. dy = (pts[i - 1].y - pts[i].y) / 4;
  3327. p += ' ' + (pts[i].x + dx) + ' ' + (pts[i].y + dy);
  3328. p += ' ' + pts[i].x + ' ' + pts[i].y;
  3329.  
  3330. path.setAttribute('d', 'M ' + p);
  3331. } else {
  3332. if (style.pathLabelReadable) {
  3333. var pts = getpath(tpath, style.pathLabelReadable);
  3334. var p = '';
  3335. for (var i = 0; i < pts.length; i++) p += ' ' + pts[i].x + ' ' + pts[i].y;
  3336. path.setAttribute('d', 'M ' + p);
  3337. } else path.setAttribute('d', 'M ' + tpath);
  3338. }
  3339. path.setAttribute('id', tpid);
  3340.  
  3341. var defs = this.createDefs();
  3342. removeChildById(defs, tpid);
  3343. defs.appendChild(path);
  3344.  
  3345. var textPath = this.nodeFactory(null, 'textPath');
  3346. textPath.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '#' + tpid);
  3347. var align = style.labelAlign || OpenLayers.Renderer.defaultSymbolizer.labelAlign;
  3348. label.setAttributeNS(null, 'text-anchor', OpenLayers.Renderer.SVG.LABEL_ALIGN[align[0]] || 'middle');
  3349. textPath.setAttribute('startOffset', style.pathLabelXOffset || OpenLayers.Renderer.SVG.LABEL_STARTOFFSET[align[0]] || '50%');
  3350. label.setAttributeNS(null, 'dominant-baseline', OpenLayers.Renderer.SVG.LABEL_ALIGN[align[1]] || 'central');
  3351. if (style.pathLabelYOffset) label.setAttribute('dy', style.pathLabelYOffset);
  3352. //textPath.setAttribute('method','stretch');
  3353. //textPath.setAttribute('spacing','auto');
  3354.  
  3355. textPath.textContent = style.pathLabel;
  3356. label.appendChild(textPath);
  3357.  
  3358. removeChildById(this.textRoot, node._featureId + '_' + suffix);
  3359. this.textRoot.appendChild(label);
  3360. };
  3361.  
  3362. OpenLayers.Renderer.SVG.prototype.setStyle = function (node, style, options) {
  3363. if (node._geometryClass === 'OpenLayers.Geometry.LineString' && style.pathLabel) {
  3364. if (node._geometryClass === 'OpenLayers.Geometry.LineString' && style.pathLabel) {
  3365. var drawOutline = (!!style.labelOutlineWidth);
  3366. // First draw text in halo color and size and overlay the
  3367. // normal text afterwards
  3368. if (drawOutline) {
  3369. var outlineStyle = OpenLayers.Util.extend({}, style);
  3370. outlineStyle.fontColor = outlineStyle.labelOutlineColor;
  3371. outlineStyle.fontStrokeColor = outlineStyle.labelOutlineColor;
  3372. outlineStyle.fontStrokeWidth = style.labelOutlineWidth;
  3373. if (style.labelOutlineOpacity) outlineStyle.fontOpacity = style.labelOutlineOpacity;
  3374. delete outlineStyle.labelOutlineWidth;
  3375. this.pathText(node, outlineStyle, 'txtpath0');
  3376. }
  3377. this.pathText(node, style, 'txtpath');
  3378. setStyle.apply(this, arguments);
  3379. }
  3380. } else setStyle.apply(this, arguments);
  3381. return node;
  3382. };
  3383.  
  3384. // *
  3385. // * Method: drawGeometry
  3386. // * Remove the textpath if no geometry is drawn.
  3387. // *
  3388. // * Parameters:
  3389. // * geometry - {<OpenLayers.Geometry>}
  3390. // * style - {Object}
  3391. // * featureId - {String}
  3392. // *
  3393. // * Returns:
  3394. // * {Boolean} true if the geometry has been drawn completely; null if
  3395. // * incomplete; false otherwise
  3396.  
  3397. var drawGeometry = OpenLayers.Renderer.SVG.prototype.drawGeometry;
  3398. OpenLayers.Renderer.SVG.prototype.drawGeometry = function (geometry, style, id) {
  3399. var rendered = drawGeometry.apply(this, arguments);
  3400. if (rendered === false) {
  3401. removeChildById(this.textRoot, id + '_txtpath');
  3402. removeChildById(this.textRoot, id + '_txtpath0');
  3403. }
  3404. return rendered;
  3405. };
  3406.  
  3407. // *
  3408. // * Method: eraseGeometry
  3409. // * Erase a geometry from the renderer. In the case of a multi-geometry,
  3410. // * we cycle through and recurse on ourselves. Otherwise, we look for a
  3411. // * node with the geometry.id, destroy its geometry, and remove it from
  3412. // * the DOM.
  3413. // *
  3414. // * Parameters:
  3415. // * geometry - {<OpenLayers.Geometry>}
  3416. // * featureId - {String}
  3417.  
  3418. var eraseGeometry = OpenLayers.Renderer.SVG.prototype.eraseGeometry;
  3419. OpenLayers.Renderer.SVG.prototype.eraseGeometry = function (geometry, featureId) {
  3420. eraseGeometry.apply(this, arguments);
  3421. removeChildById(this.textRoot, featureId + '_txtpath');
  3422. removeChildById(this.textRoot, featureId + '_txtpath0');
  3423. };
  3424.  
  3425. }
  3426. })();