1 line
189 KiB
Plaintext
1 line
189 KiB
Plaintext
{"version":3,"sources":["togeojson.js","mustache.min.js","underscore-min.js","mapfun.js","layers.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AChSA;AACA;ACDA;AACA;AACA;AACA;AACA;AACA;ACLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACtuCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"map.js","sourcesContent":["toGeoJSON = (function() {\r\n 'use strict';\r\n\r\n var removeSpace = (/\\s*/g),\r\n trimSpace = (/^\\s*|\\s*$/g),\r\n splitSpace = (/\\s+/);\r\n // generate a short, numeric hash of a string\r\n function okhash(x) {\r\n if (!x || !x.length) return 0;\r\n for (var i = 0, h = 0; i < x.length; i++) {\r\n h = ((h << 5) - h) + x.charCodeAt(i) | 0;\r\n } return h;\r\n }\r\n // all Y children of X\r\n function get(x, y) { return x.getElementsByTagName(y); }\r\n function attr(x, y) { return x.getAttribute(y); }\r\n function attrf(x, y) { return parseFloat(attr(x, y)); }\r\n // one Y child of X, if any, otherwise null\r\n function get1(x, y) { var n = get(x, y); return n.length ? n[0] : null; }\r\n // https://developer.mozilla.org/en-US/docs/Web/API/Node.normalize\r\n function norm(el) { if (el.normalize) { el.normalize(); } return el; }\r\n // cast array x into numbers\r\n function numarray(x) {\r\n for (var j = 0, o = []; j < x.length; j++) o[j] = parseFloat(x[j]);\r\n return o;\r\n }\r\n function clean(x) {\r\n var o = {};\r\n for (var i in x) if (x[i]) o[i] = x[i];\r\n return o;\r\n }\r\n // get the content of a text node, if any\r\n function nodeVal(x) {\r\n if (x) { norm(x); }\r\n return (x && x.firstChild && x.firstChild.nodeValue) || '';\r\n }\r\n // get one coordinate from a coordinate array, if any\r\n function coord1(v) { return numarray(v.replace(removeSpace, '').split(',')); }\r\n // get all coordinates from a coordinate array as [[],[]]\r\n function coord(v) {\r\n var coords = v.replace(trimSpace, '').split(splitSpace),\r\n o = [];\r\n for (var i = 0; i < coords.length; i++) {\r\n o.push(coord1(coords[i]));\r\n }\r\n return o;\r\n }\r\n function coordPair(x) {\r\n var ll = [attrf(x, 'lon'), attrf(x, 'lat')],\r\n ele = get1(x, 'ele');\r\n if (ele) ll.push(parseFloat(nodeVal(ele)));\r\n return ll;\r\n }\r\n\r\n // create a new feature collection parent object\r\n function fc() {\r\n return {\r\n type: 'FeatureCollection',\r\n features: []\r\n };\r\n }\r\n\r\n var serializer;\r\n if (typeof XMLSerializer !== 'undefined') {\r\n serializer = new XMLSerializer();\r\n // only require xmldom in a node environment\r\n } else if (typeof exports === 'object' && typeof process === 'object' && !process.browser) {\r\n serializer = new (require('xmldom').XMLSerializer)();\r\n }\r\n function xml2str(str) { return serializer.serializeToString(str); }\r\n\r\n var t = {\r\n kml: function(doc, o) {\r\n o = o || {};\r\n\r\n var gj = fc(),\r\n // styleindex keeps track of hashed styles in order to match features\r\n styleIndex = {},\r\n // atomic geospatial types supported by KML - MultiGeometry is\r\n // handled separately\r\n geotypes = ['Polygon', 'LineString', 'Point', 'Track'],\r\n // all root placemarks in the file\r\n placemarks = get(doc, 'Placemark'),\r\n styles = get(doc, 'Style');\r\n\r\n for (var k = 0; k < styles.length; k++) {\r\n styleIndex['#' + attr(styles[k], 'id')] = okhash(xml2str(styles[k])).toString(16);\r\n }\r\n for (var j = 0; j < placemarks.length; j++) {\r\n gj.features = gj.features.concat(getPlacemark(placemarks[j]));\r\n }\r\n function kmlColor(v) {\r\n var color, opacity;\r\n v = v || \"\";\r\n if (v.substr(0, 1) === \"#\") v = v.substr(1);\r\n if (v.length === 6 || v.length === 3) color = v;\r\n if (v.length === 8) {\r\n opacity = parseInt(v.substr(0, 2), 16) / 255;\r\n color = v.substr(2);\r\n }\r\n return [color, isNaN(opacity) ? undefined : opacity];\r\n }\r\n function gxCoord(v) { return numarray(v.split(' ')); }\r\n function gxCoords(root) {\r\n var elems = get(root, 'coord', 'gx'), coords = [];\r\n for (var i = 0; i < elems.length; i++) coords.push(gxCoord(nodeVal(elems[i])));\r\n return coords;\r\n }\r\n function getGeometry(root) {\r\n var geomNode, geomNodes, i, j, k, geoms = [];\r\n if (get1(root, 'MultiGeometry')) return getGeometry(get1(root, 'MultiGeometry'));\r\n if (get1(root, 'MultiTrack')) return getGeometry(get1(root, 'MultiTrack'));\r\n for (i = 0; i < geotypes.length; i++) {\r\n geomNodes = get(root, geotypes[i]);\r\n if (geomNodes) {\r\n for (j = 0; j < geomNodes.length; j++) {\r\n geomNode = geomNodes[j];\r\n if (geotypes[i] == 'Point') {\r\n geoms.push({\r\n type: 'Point',\r\n coordinates: coord1(nodeVal(get1(geomNode, 'coordinates')))\r\n });\r\n } else if (geotypes[i] == 'LineString') {\r\n geoms.push({\r\n type: 'LineString',\r\n coordinates: coord(nodeVal(get1(geomNode, 'coordinates')))\r\n });\r\n } else if (geotypes[i] == 'Polygon') {\r\n var rings = get(geomNode, 'LinearRing'),\r\n coords = [];\r\n for (k = 0; k < rings.length; k++) {\r\n coords.push(coord(nodeVal(get1(rings[k], 'coordinates'))));\r\n }\r\n geoms.push({\r\n type: 'Polygon',\r\n coordinates: coords\r\n });\r\n } else if (geotypes[i] == 'Track') {\r\n geoms.push({\r\n type: 'LineString',\r\n coordinates: gxCoords(geomNode)\r\n });\r\n }\r\n }\r\n }\r\n }\r\n return geoms;\r\n }\r\n function getPlacemark(root) {\r\n var geoms = getGeometry(root), i, properties = {},\r\n name = nodeVal(get1(root, 'name')),\r\n styleUrl = nodeVal(get1(root, 'styleUrl')),\r\n description = nodeVal(get1(root, 'description')),\r\n timeSpan = get1(root, 'TimeSpan'),\r\n extendedData = get1(root, 'ExtendedData'),\r\n lineStyle = get1(root, 'LineStyle'),\r\n polyStyle = get1(root, 'PolyStyle');\r\n\r\n if (!geoms.length) return [];\r\n if (name) properties.name = name;\r\n if (styleUrl && styleIndex[styleUrl]) {\r\n properties.styleUrl = styleUrl;\r\n properties.styleHash = styleIndex[styleUrl];\r\n }\r\n if (description) properties.description = description;\r\n if (timeSpan) {\r\n var begin = nodeVal(get1(timeSpan, 'begin'));\r\n var end = nodeVal(get1(timeSpan, 'end'));\r\n properties.timespan = { begin: begin, end: end };\r\n }\r\n if (lineStyle) {\r\n var linestyles = kmlColor(nodeVal(get1(lineStyle, 'color'))),\r\n color = linestyles[0],\r\n opacity = linestyles[1],\r\n width = parseFloat(nodeVal(get1(lineStyle, 'width')));\r\n if (color) properties.stroke = color;\r\n if (!isNaN(opacity)) properties['stroke-opacity'] = opacity;\r\n if (!isNaN(width)) properties['stroke-width'] = width;\r\n }\r\n if (polyStyle) {\r\n var polystyles = kmlColor(nodeVal(get1(polyStyle, 'color'))),\r\n pcolor = polystyles[0],\r\n popacity = polystyles[1],\r\n fill = nodeVal(get1(polyStyle, 'fill')),\r\n outline = nodeVal(get1(polyStyle, 'outline'));\r\n if (pcolor) properties.fill = pcolor;\r\n if (!isNaN(popacity)) properties['fill-opacity'] = popacity;\r\n if (fill) properties['fill-opacity'] = fill === \"1\" ? 1 : 0;\r\n if (outline) properties['stroke-opacity'] = outline === \"1\" ? 1 : 0;\r\n }\r\n if (extendedData) {\r\n var datas = get(extendedData, 'Data'),\r\n simpleDatas = get(extendedData, 'SimpleData');\r\n\r\n for (i = 0; i < datas.length; i++) {\r\n properties[datas[i].getAttribute('name')] = nodeVal(get1(datas[i], 'value'));\r\n }\r\n for (i = 0; i < simpleDatas.length; i++) {\r\n properties[simpleDatas[i].getAttribute('name')] = nodeVal(simpleDatas[i]);\r\n }\r\n }\r\n return [{\r\n type: 'Feature',\r\n geometry: (geoms.length === 1) ? geoms[0] : {\r\n type: 'GeometryCollection',\r\n geometries: geoms\r\n },\r\n properties: properties\r\n }];\r\n }\r\n return gj;\r\n },\r\n gpx: function(doc, o) {\r\n var i,\r\n tracks = get(doc, 'trk'),\r\n routes = get(doc, 'rte'),\r\n waypoints = get(doc, 'wpt'),\r\n // a feature collection\r\n gj = fc();\r\n for (i = 0; i < tracks.length; i++) {\r\n gj.features.push(getTrack(tracks[i]));\r\n }\r\n for (i = 0; i < routes.length; i++) {\r\n gj.features.push(getRoute(routes[i]));\r\n }\r\n for (i = 0; i < waypoints.length; i++) {\r\n gj.features.push(getPoint(waypoints[i]));\r\n }\r\n function getPoints(node, pointname) {\r\n var pts = get(node, pointname), line = [];\r\n for (var i = 0; i < pts.length; i++) {\r\n line.push(coordPair(pts[i]));\r\n }\r\n return line;\r\n }\r\n function getTrack(node) {\r\n var segments = get(node, 'trkseg'), track = [];\r\n for (var i = 0; i < segments.length; i++) {\r\n track.push(getPoints(segments[i], 'trkpt'));\r\n }\r\n return {\r\n type: 'Feature',\r\n properties: getProperties(node),\r\n geometry: {\r\n type: track.length === 1 ? 'LineString' : 'MultiLineString',\r\n coordinates: track.length === 1 ? track[0] : track\r\n }\r\n };\r\n }\r\n function getRoute(node) {\r\n return {\r\n type: 'Feature',\r\n properties: getProperties(node),\r\n geometry: {\r\n type: 'LineString',\r\n coordinates: getPoints(node, 'rtept')\r\n }\r\n };\r\n }\r\n function getPoint(node) {\r\n var prop = getProperties(node);\r\n prop.sym = nodeVal(get1(node, 'sym'));\r\n return {\r\n type: 'Feature',\r\n properties: prop,\r\n geometry: {\r\n type: 'Point',\r\n coordinates: coordPair(node)\r\n }\r\n };\r\n }\r\n function getProperties(node) {\r\n var meta = ['name', 'desc', 'author', 'copyright', 'link',\r\n 'time', 'keywords'],\r\n prop = {},\r\n k;\r\n for (k = 0; k < meta.length; k++) {\r\n prop[meta[k]] = nodeVal(get1(node, meta[k]));\r\n }\r\n return clean(prop);\r\n }\r\n return gj;\r\n }\r\n };\r\n return t;\r\n})();\r\n\r\nif (typeof module !== 'undefined') module.exports = toGeoJSON;\r\n","(function defineMustache(global,factory){if(typeof exports===\"object\"&&exports&&typeof exports.nodeName!==\"string\"){factory(exports)}else if(typeof define===\"function\"&&define.amd){define([\"exports\"],factory)}else{global.Mustache={};factory(global.Mustache)}})(this,function mustacheFactory(mustache){var objectToString=Object.prototype.toString;var isArray=Array.isArray||function isArrayPolyfill(object){return objectToString.call(object)===\"[object Array]\"};function isFunction(object){return typeof object===\"function\"}function typeStr(obj){return isArray(obj)?\"array\":typeof obj}function escapeRegExp(string){return string.replace(/[\\-\\[\\]{}()*+?.,\\\\\\^$|#\\s]/g,\"\\\\$&\")}function hasProperty(obj,propName){return obj!=null&&typeof obj===\"object\"&&propName in obj}var regExpTest=RegExp.prototype.test;function testRegExp(re,string){return regExpTest.call(re,string)}var nonSpaceRe=/\\S/;function isWhitespace(string){return!testRegExp(nonSpaceRe,string)}var entityMap={\"&\":\"&\",\"<\":\"<\",\">\":\">\",'\"':\""\",\"'\":\"'\",\"/\":\"/\",\"`\":\"`\",\"=\":\"=\"};function escapeHtml(string){return String(string).replace(/[&<>\"'`=\\/]/g,function fromEntityMap(s){return entityMap[s]})}var whiteRe=/\\s*/;var spaceRe=/\\s+/;var equalsRe=/\\s*=/;var curlyRe=/\\s*\\}/;var tagRe=/#|\\^|\\/|>|\\{|&|=|!/;function parseTemplate(template,tags){if(!template)return[];var sections=[];var tokens=[];var spaces=[];var hasTag=false;var nonSpace=false;function stripSpace(){if(hasTag&&!nonSpace){while(spaces.length)delete tokens[spaces.pop()]}else{spaces=[]}hasTag=false;nonSpace=false}var openingTagRe,closingTagRe,closingCurlyRe;function compileTags(tagsToCompile){if(typeof tagsToCompile===\"string\")tagsToCompile=tagsToCompile.split(spaceRe,2);if(!isArray(tagsToCompile)||tagsToCompile.length!==2)throw new Error(\"Invalid tags: \"+tagsToCompile);openingTagRe=new RegExp(escapeRegExp(tagsToCompile[0])+\"\\\\s*\");closingTagRe=new RegExp(\"\\\\s*\"+escapeRegExp(tagsToCompile[1]));closingCurlyRe=new RegExp(\"\\\\s*\"+escapeRegExp(\"}\"+tagsToCompile[1]))}compileTags(tags||mustache.tags);var scanner=new Scanner(template);var start,type,value,chr,token,openSection;while(!scanner.eos()){start=scanner.pos;value=scanner.scanUntil(openingTagRe);if(value){for(var i=0,valueLength=value.length;i<valueLength;++i){chr=value.charAt(i);if(isWhitespace(chr)){spaces.push(tokens.length)}else{nonSpace=true}tokens.push([\"text\",chr,start,start+1]);start+=1;if(chr===\"\\n\")stripSpace()}}if(!scanner.scan(openingTagRe))break;hasTag=true;type=scanner.scan(tagRe)||\"name\";scanner.scan(whiteRe);if(type===\"=\"){value=scanner.scanUntil(equalsRe);scanner.scan(equalsRe);scanner.scanUntil(closingTagRe)}else if(type===\"{\"){value=scanner.scanUntil(closingCurlyRe);scanner.scan(curlyRe);scanner.scanUntil(closingTagRe);type=\"&\"}else{value=scanner.scanUntil(closingTagRe)}if(!scanner.scan(closingTagRe))throw new Error(\"Unclosed tag at \"+scanner.pos);token=[type,value,start,scanner.pos];tokens.push(token);if(type===\"#\"||type===\"^\"){sections.push(token)}else if(type===\"/\"){openSection=sections.pop();if(!openSection)throw new Error('Unopened section \"'+value+'\" at '+start);if(openSection[1]!==value)throw new Error('Unclosed section \"'+openSection[1]+'\" at '+start)}else if(type===\"name\"||type===\"{\"||type===\"&\"){nonSpace=true}else if(type===\"=\"){compileTags(value)}}openSection=sections.pop();if(openSection)throw new Error('Unclosed section \"'+openSection[1]+'\" at '+scanner.pos);return nestTokens(squashTokens(tokens))}function squashTokens(tokens){var squashedTokens=[];var token,lastToken;for(var i=0,numTokens=tokens.length;i<numTokens;++i){token=tokens[i];if(token){if(token[0]===\"text\"&&lastToken&&lastToken[0]===\"text\"){lastToken[1]+=token[1];lastToken[3]=token[3]}else{squashedTokens.push(token);lastToken=token}}}return squashedTokens}function nestTokens(tokens){var nestedTokens=[];var collector=nestedTokens;var sections=[];var token,section;for(var i=0,numTokens=tokens.length;i<numTokens;++i){token=tokens[i];switch(token[0]){case\"#\":case\"^\":collector.push(token);sections.push(token);collector=token[4]=[];break;case\"/\":section=sections.pop();section[5]=token[2];collector=sections.length>0?sections[sections.length-1][4]:nestedTokens;break;default:collector.push(token)}}return nestedTokens}function Scanner(string){this.string=string;this.tail=string;this.pos=0}Scanner.prototype.eos=function eos(){return this.tail===\"\"};Scanner.prototype.scan=function scan(re){var match=this.tail.match(re);if(!match||match.index!==0)return\"\";var string=match[0];this.tail=this.tail.substring(string.length);this.pos+=string.length;return string};Scanner.prototype.scanUntil=function scanUntil(re){var index=this.tail.search(re),match;switch(index){case-1:match=this.tail;this.tail=\"\";break;case 0:match=\"\";break;default:match=this.tail.substring(0,index);this.tail=this.tail.substring(index)}this.pos+=match.length;return match};function Context(view,parentContext){this.view=view;this.cache={\".\":this.view};this.parent=parentContext}Context.prototype.push=function push(view){return new Context(view,this)};Context.prototype.lookup=function lookup(name){var cache=this.cache;var value;if(cache.hasOwnProperty(name)){value=cache[name]}else{var context=this,names,index,lookupHit=false;while(context){if(name.indexOf(\".\")>0){value=context.view;names=name.split(\".\");index=0;while(value!=null&&index<names.length){if(index===names.length-1)lookupHit=hasProperty(value,names[index]);value=value[names[index++]]}}else{value=context.view[name];lookupHit=hasProperty(context.view,name)}if(lookupHit)break;context=context.parent}cache[name]=value}if(isFunction(value))value=value.call(this.view);return value};function Writer(){this.cache={}}Writer.prototype.clearCache=function clearCache(){this.cache={}};Writer.prototype.parse=function parse(template,tags){var cache=this.cache;var tokens=cache[template];if(tokens==null)tokens=cache[template]=parseTemplate(template,tags);return tokens};Writer.prototype.render=function render(template,view,partials){var tokens=this.parse(template);var context=view instanceof Context?view:new Context(view);return this.renderTokens(tokens,context,partials,template)};Writer.prototype.renderTokens=function renderTokens(tokens,context,partials,originalTemplate){var buffer=\"\";var token,symbol,value;for(var i=0,numTokens=tokens.length;i<numTokens;++i){value=undefined;token=tokens[i];symbol=token[0];if(symbol===\"#\")value=this.renderSection(token,context,partials,originalTemplate);else if(symbol===\"^\")value=this.renderInverted(token,context,partials,originalTemplate);else if(symbol===\">\")value=this.renderPartial(token,context,partials,originalTemplate);else if(symbol===\"&\")value=this.unescapedValue(token,context);else if(symbol===\"name\")value=this.escapedValue(token,context);else if(symbol===\"text\")value=this.rawValue(token);if(value!==undefined)buffer+=value}return buffer};Writer.prototype.renderSection=function renderSection(token,context,partials,originalTemplate){var self=this;var buffer=\"\";var value=context.lookup(token[1]);function subRender(template){return self.render(template,context,partials)}if(!value)return;if(isArray(value)){for(var j=0,valueLength=value.length;j<valueLength;++j){buffer+=this.renderTokens(token[4],context.push(value[j]),partials,originalTemplate)}}else if(typeof value===\"object\"||typeof value===\"string\"||typeof value===\"number\"){buffer+=this.renderTokens(token[4],context.push(value),partials,originalTemplate)}else if(isFunction(value)){if(typeof originalTemplate!==\"string\")throw new Error(\"Cannot use higher-order sections without the original template\");value=value.call(context.view,originalTemplate.slice(token[3],token[5]),subRender);if(value!=null)buffer+=value}else{buffer+=this.renderTokens(token[4],context,partials,originalTemplate)}return buffer};Writer.prototype.renderInverted=function renderInverted(token,context,partials,originalTemplate){var value=context.lookup(token[1]);if(!value||isArray(value)&&value.length===0)return this.renderTokens(token[4],context,partials,originalTemplate)};Writer.prototype.renderPartial=function renderPartial(token,context,partials){if(!partials)return;var value=isFunction(partials)?partials(token[1]):partials[token[1]];if(value!=null)return this.renderTokens(this.parse(value),context,partials,value)};Writer.prototype.unescapedValue=function unescapedValue(token,context){var value=context.lookup(token[1]);if(value!=null)return value};Writer.prototype.escapedValue=function escapedValue(token,context){var value=context.lookup(token[1]);if(value!=null)return mustache.escape(value)};Writer.prototype.rawValue=function rawValue(token){return token[1]};mustache.name=\"mustache.js\";mustache.version=\"2.2.1\";mustache.tags=[\"{{\",\"}}\"];var defaultWriter=new Writer;mustache.clearCache=function clearCache(){return defaultWriter.clearCache()};mustache.parse=function parse(template,tags){return defaultWriter.parse(template,tags)};mustache.render=function render(template,view,partials){if(typeof template!==\"string\"){throw new TypeError('Invalid template! Template should be a \"string\" '+'but \"'+typeStr(template)+'\" was given as the first '+\"argument for mustache#render(template, view, partials)\")}return defaultWriter.render(template,view,partials)};mustache.to_html=function to_html(template,view,partials,send){var result=mustache.render(template,view,partials);if(isFunction(send)){send(result)}else{return result}};mustache.escape=escapeHtml;mustache.Scanner=Scanner;mustache.Context=Context;mustache.Writer=Writer});\n","// Underscore.js 1.8.3\n// http://underscorejs.org\n// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n// Underscore may be freely distributed under the MIT license.\n(function(){function n(n){function t(t,r,e,u,i,o){for(;i>=0&&o>i;i+=n){var a=u?u[i]:i;e=r(e,t[a],a,t)}return e}return function(r,e,u,i){e=b(e,i,4);var o=!k(r)&&m.keys(r),a=(o||r).length,c=n>0?0:a-1;return arguments.length<3&&(u=r[o?o[c]:c],c+=n),t(r,e,u,o,c,a)}}function t(n){return function(t,r,e){r=x(r,e);for(var u=O(t),i=n>0?0:u-1;i>=0&&u>i;i+=n)if(r(t[i],i,t))return i;return-1}}function r(n,t,r){return function(e,u,i){var o=0,a=O(e);if(\"number\"==typeof i)n>0?o=i>=0?i:Math.max(i+a,o):a=i>=0?Math.min(i+1,a):i+a+1;else if(r&&i&&a)return i=r(e,u),e[i]===u?i:-1;if(u!==u)return i=t(l.call(e,o,a),m.isNaN),i>=0?i+o:-1;for(i=n>0?o:a-1;i>=0&&a>i;i+=n)if(e[i]===u)return i;return-1}}function e(n,t){var r=I.length,e=n.constructor,u=m.isFunction(e)&&e.prototype||a,i=\"constructor\";for(m.has(n,i)&&!m.contains(t,i)&&t.push(i);r--;)i=I[r],i in n&&n[i]!==u[i]&&!m.contains(t,i)&&t.push(i)}var u=this,i=u._,o=Array.prototype,a=Object.prototype,c=Function.prototype,f=o.push,l=o.slice,s=a.toString,p=a.hasOwnProperty,h=Array.isArray,v=Object.keys,g=c.bind,y=Object.create,d=function(){},m=function(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)};\"undefined\"!=typeof exports?(\"undefined\"!=typeof module&&module.exports&&(exports=module.exports=m),exports._=m):u._=m,m.VERSION=\"1.8.3\";var b=function(n,t,r){if(t===void 0)return n;switch(null==r?3:r){case 1:return function(r){return n.call(t,r)};case 2:return function(r,e){return n.call(t,r,e)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)}}return function(){return n.apply(t,arguments)}},x=function(n,t,r){return null==n?m.identity:m.isFunction(n)?b(n,t,r):m.isObject(n)?m.matcher(n):m.property(n)};m.iteratee=function(n,t){return x(n,t,1/0)};var _=function(n,t){return function(r){var e=arguments.length;if(2>e||null==r)return r;for(var u=1;e>u;u++)for(var i=arguments[u],o=n(i),a=o.length,c=0;a>c;c++){var f=o[c];t&&r[f]!==void 0||(r[f]=i[f])}return r}},j=function(n){if(!m.isObject(n))return{};if(y)return y(n);d.prototype=n;var t=new d;return d.prototype=null,t},w=function(n){return function(t){return null==t?void 0:t[n]}},A=Math.pow(2,53)-1,O=w(\"length\"),k=function(n){var t=O(n);return\"number\"==typeof t&&t>=0&&A>=t};m.each=m.forEach=function(n,t,r){t=b(t,r);var e,u;if(k(n))for(e=0,u=n.length;u>e;e++)t(n[e],e,n);else{var i=m.keys(n);for(e=0,u=i.length;u>e;e++)t(n[i[e]],i[e],n)}return n},m.map=m.collect=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=Array(u),o=0;u>o;o++){var a=e?e[o]:o;i[o]=t(n[a],a,n)}return i},m.reduce=m.foldl=m.inject=n(1),m.reduceRight=m.foldr=n(-1),m.find=m.detect=function(n,t,r){var e;return e=k(n)?m.findIndex(n,t,r):m.findKey(n,t,r),e!==void 0&&e!==-1?n[e]:void 0},m.filter=m.select=function(n,t,r){var e=[];return t=x(t,r),m.each(n,function(n,r,u){t(n,r,u)&&e.push(n)}),e},m.reject=function(n,t,r){return m.filter(n,m.negate(x(t)),r)},m.every=m.all=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(!t(n[o],o,n))return!1}return!0},m.some=m.any=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(t(n[o],o,n))return!0}return!1},m.contains=m.includes=m.include=function(n,t,r,e){return k(n)||(n=m.values(n)),(\"number\"!=typeof r||e)&&(r=0),m.indexOf(n,t,r)>=0},m.invoke=function(n,t){var r=l.call(arguments,2),e=m.isFunction(t);return m.map(n,function(n){var u=e?t:n[t];return null==u?u:u.apply(n,r)})},m.pluck=function(n,t){return m.map(n,m.property(t))},m.where=function(n,t){return m.filter(n,m.matcher(t))},m.findWhere=function(n,t){return m.find(n,m.matcher(t))},m.max=function(n,t,r){var e,u,i=-1/0,o=-1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],e>i&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(u>o||u===-1/0&&i===-1/0)&&(i=n,o=u)});return i},m.min=function(n,t,r){var e,u,i=1/0,o=1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],i>e&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(o>u||1/0===u&&1/0===i)&&(i=n,o=u)});return i},m.shuffle=function(n){for(var t,r=k(n)?n:m.values(n),e=r.length,u=Array(e),i=0;e>i;i++)t=m.random(0,i),t!==i&&(u[i]=u[t]),u[t]=r[i];return u},m.sample=function(n,t,r){return null==t||r?(k(n)||(n=m.values(n)),n[m.random(n.length-1)]):m.shuffle(n).slice(0,Math.max(0,t))},m.sortBy=function(n,t,r){return t=x(t,r),m.pluck(m.map(n,function(n,r,e){return{value:n,index:r,criteria:t(n,r,e)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),\"value\")};var F=function(n){return function(t,r,e){var u={};return r=x(r,e),m.each(t,function(e,i){var o=r(e,i,t);n(u,e,o)}),u}};m.groupBy=F(function(n,t,r){m.has(n,r)?n[r].push(t):n[r]=[t]}),m.indexBy=F(function(n,t,r){n[r]=t}),m.countBy=F(function(n,t,r){m.has(n,r)?n[r]++:n[r]=1}),m.toArray=function(n){return n?m.isArray(n)?l.call(n):k(n)?m.map(n,m.identity):m.values(n):[]},m.size=function(n){return null==n?0:k(n)?n.length:m.keys(n).length},m.partition=function(n,t,r){t=x(t,r);var e=[],u=[];return m.each(n,function(n,r,i){(t(n,r,i)?e:u).push(n)}),[e,u]},m.first=m.head=m.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:m.initial(n,n.length-t)},m.initial=function(n,t,r){return l.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))},m.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:m.rest(n,Math.max(0,n.length-t))},m.rest=m.tail=m.drop=function(n,t,r){return l.call(n,null==t||r?1:t)},m.compact=function(n){return m.filter(n,m.identity)};var S=function(n,t,r,e){for(var u=[],i=0,o=e||0,a=O(n);a>o;o++){var c=n[o];if(k(c)&&(m.isArray(c)||m.isArguments(c))){t||(c=S(c,t,r));var f=0,l=c.length;for(u.length+=l;l>f;)u[i++]=c[f++]}else r||(u[i++]=c)}return u};m.flatten=function(n,t){return S(n,t,!1)},m.without=function(n){return m.difference(n,l.call(arguments,1))},m.uniq=m.unique=function(n,t,r,e){m.isBoolean(t)||(e=r,r=t,t=!1),null!=r&&(r=x(r,e));for(var u=[],i=[],o=0,a=O(n);a>o;o++){var c=n[o],f=r?r(c,o,n):c;t?(o&&i===f||u.push(c),i=f):r?m.contains(i,f)||(i.push(f),u.push(c)):m.contains(u,c)||u.push(c)}return u},m.union=function(){return m.uniq(S(arguments,!0,!0))},m.intersection=function(n){for(var t=[],r=arguments.length,e=0,u=O(n);u>e;e++){var i=n[e];if(!m.contains(t,i)){for(var o=1;r>o&&m.contains(arguments[o],i);o++);o===r&&t.push(i)}}return t},m.difference=function(n){var t=S(arguments,!0,!0,1);return m.filter(n,function(n){return!m.contains(t,n)})},m.zip=function(){return m.unzip(arguments)},m.unzip=function(n){for(var t=n&&m.max(n,O).length||0,r=Array(t),e=0;t>e;e++)r[e]=m.pluck(n,e);return r},m.object=function(n,t){for(var r={},e=0,u=O(n);u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},m.findIndex=t(1),m.findLastIndex=t(-1),m.sortedIndex=function(n,t,r,e){r=x(r,e,1);for(var u=r(t),i=0,o=O(n);o>i;){var a=Math.floor((i+o)/2);r(n[a])<u?i=a+1:o=a}return i},m.indexOf=r(1,m.findIndex,m.sortedIndex),m.lastIndexOf=r(-1,m.findLastIndex),m.range=function(n,t,r){null==t&&(t=n||0,n=0),r=r||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=Array(e),i=0;e>i;i++,n+=r)u[i]=n;return u};var E=function(n,t,r,e,u){if(!(e instanceof t))return n.apply(r,u);var i=j(n.prototype),o=n.apply(i,u);return m.isObject(o)?o:i};m.bind=function(n,t){if(g&&n.bind===g)return g.apply(n,l.call(arguments,1));if(!m.isFunction(n))throw new TypeError(\"Bind must be called on a function\");var r=l.call(arguments,2),e=function(){return E(n,e,t,this,r.concat(l.call(arguments)))};return e},m.partial=function(n){var t=l.call(arguments,1),r=function(){for(var e=0,u=t.length,i=Array(u),o=0;u>o;o++)i[o]=t[o]===m?arguments[e++]:t[o];for(;e<arguments.length;)i.push(arguments[e++]);return E(n,r,this,this,i)};return r},m.bindAll=function(n){var t,r,e=arguments.length;if(1>=e)throw new Error(\"bindAll must be passed function names\");for(t=1;e>t;t++)r=arguments[t],n[r]=m.bind(n[r],n);return n},m.memoize=function(n,t){var r=function(e){var u=r.cache,i=\"\"+(t?t.apply(this,arguments):e);return m.has(u,i)||(u[i]=n.apply(this,arguments)),u[i]};return r.cache={},r},m.delay=function(n,t){var r=l.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},m.defer=m.partial(m.delay,m,1),m.throttle=function(n,t,r){var e,u,i,o=null,a=0;r||(r={});var c=function(){a=r.leading===!1?0:m.now(),o=null,i=n.apply(e,u),o||(e=u=null)};return function(){var f=m.now();a||r.leading!==!1||(a=f);var l=t-(f-a);return e=this,u=arguments,0>=l||l>t?(o&&(clearTimeout(o),o=null),a=f,i=n.apply(e,u),o||(e=u=null)):o||r.trailing===!1||(o=setTimeout(c,l)),i}},m.debounce=function(n,t,r){var e,u,i,o,a,c=function(){var f=m.now()-o;t>f&&f>=0?e=setTimeout(c,t-f):(e=null,r||(a=n.apply(i,u),e||(i=u=null)))};return function(){i=this,u=arguments,o=m.now();var f=r&&!e;return e||(e=setTimeout(c,t)),f&&(a=n.apply(i,u),i=u=null),a}},m.wrap=function(n,t){return m.partial(t,n)},m.negate=function(n){return function(){return!n.apply(this,arguments)}},m.compose=function(){var n=arguments,t=n.length-1;return function(){for(var r=t,e=n[t].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},m.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},m.before=function(n,t){var r;return function(){return--n>0&&(r=t.apply(this,arguments)),1>=n&&(t=null),r}},m.once=m.partial(m.before,2);var M=!{toString:null}.propertyIsEnumerable(\"toString\"),I=[\"valueOf\",\"isPrototypeOf\",\"toString\",\"propertyIsEnumerable\",\"hasOwnProperty\",\"toLocaleString\"];m.keys=function(n){if(!m.isObject(n))return[];if(v)return v(n);var t=[];for(var r in n)m.has(n,r)&&t.push(r);return M&&e(n,t),t},m.allKeys=function(n){if(!m.isObject(n))return[];var t=[];for(var r in n)t.push(r);return M&&e(n,t),t},m.values=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},m.mapObject=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=u.length,o={},a=0;i>a;a++)e=u[a],o[e]=t(n[e],e,n);return o},m.pairs=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},m.invert=function(n){for(var t={},r=m.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},m.functions=m.methods=function(n){var t=[];for(var r in n)m.isFunction(n[r])&&t.push(r);return t.sort()},m.extend=_(m.allKeys),m.extendOwn=m.assign=_(m.keys),m.findKey=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=0,o=u.length;o>i;i++)if(e=u[i],t(n[e],e,n))return e},m.pick=function(n,t,r){var e,u,i={},o=n;if(null==o)return i;m.isFunction(t)?(u=m.allKeys(o),e=b(t,r)):(u=S(arguments,!1,!1,1),e=function(n,t,r){return t in r},o=Object(o));for(var a=0,c=u.length;c>a;a++){var f=u[a],l=o[f];e(l,f,o)&&(i[f]=l)}return i},m.omit=function(n,t,r){if(m.isFunction(t))t=m.negate(t);else{var e=m.map(S(arguments,!1,!1,1),String);t=function(n,t){return!m.contains(e,t)}}return m.pick(n,t,r)},m.defaults=_(m.allKeys,!0),m.create=function(n,t){var r=j(n);return t&&m.extendOwn(r,t),r},m.clone=function(n){return m.isObject(n)?m.isArray(n)?n.slice():m.extend({},n):n},m.tap=function(n,t){return t(n),n},m.isMatch=function(n,t){var r=m.keys(t),e=r.length;if(null==n)return!e;for(var u=Object(n),i=0;e>i;i++){var o=r[i];if(t[o]!==u[o]||!(o in u))return!1}return!0};var N=function(n,t,r,e){if(n===t)return 0!==n||1/n===1/t;if(null==n||null==t)return n===t;n instanceof m&&(n=n._wrapped),t instanceof m&&(t=t._wrapped);var u=s.call(n);if(u!==s.call(t))return!1;switch(u){case\"[object RegExp]\":case\"[object String]\":return\"\"+n==\"\"+t;case\"[object Number]\":return+n!==+n?+t!==+t:0===+n?1/+n===1/t:+n===+t;case\"[object Date]\":case\"[object Boolean]\":return+n===+t}var i=\"[object Array]\"===u;if(!i){if(\"object\"!=typeof n||\"object\"!=typeof t)return!1;var o=n.constructor,a=t.constructor;if(o!==a&&!(m.isFunction(o)&&o instanceof o&&m.isFunction(a)&&a instanceof a)&&\"constructor\"in n&&\"constructor\"in t)return!1}r=r||[],e=e||[];for(var c=r.length;c--;)if(r[c]===n)return e[c]===t;if(r.push(n),e.push(t),i){if(c=n.length,c!==t.length)return!1;for(;c--;)if(!N(n[c],t[c],r,e))return!1}else{var f,l=m.keys(n);if(c=l.length,m.keys(t).length!==c)return!1;for(;c--;)if(f=l[c],!m.has(t,f)||!N(n[f],t[f],r,e))return!1}return r.pop(),e.pop(),!0};m.isEqual=function(n,t){return N(n,t)},m.isEmpty=function(n){return null==n?!0:k(n)&&(m.isArray(n)||m.isString(n)||m.isArguments(n))?0===n.length:0===m.keys(n).length},m.isElement=function(n){return!(!n||1!==n.nodeType)},m.isArray=h||function(n){return\"[object Array]\"===s.call(n)},m.isObject=function(n){var t=typeof n;return\"function\"===t||\"object\"===t&&!!n},m.each([\"Arguments\",\"Function\",\"String\",\"Number\",\"Date\",\"RegExp\",\"Error\"],function(n){m[\"is\"+n]=function(t){return s.call(t)===\"[object \"+n+\"]\"}}),m.isArguments(arguments)||(m.isArguments=function(n){return m.has(n,\"callee\")}),\"function\"!=typeof/./&&\"object\"!=typeof Int8Array&&(m.isFunction=function(n){return\"function\"==typeof n||!1}),m.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},m.isNaN=function(n){return m.isNumber(n)&&n!==+n},m.isBoolean=function(n){return n===!0||n===!1||\"[object Boolean]\"===s.call(n)},m.isNull=function(n){return null===n},m.isUndefined=function(n){return n===void 0},m.has=function(n,t){return null!=n&&p.call(n,t)},m.noConflict=function(){return u._=i,this},m.identity=function(n){return n},m.constant=function(n){return function(){return n}},m.noop=function(){},m.property=w,m.propertyOf=function(n){return null==n?function(){}:function(t){return n[t]}},m.matcher=m.matches=function(n){return n=m.extendOwn({},n),function(t){return m.isMatch(t,n)}},m.times=function(n,t,r){var e=Array(Math.max(0,n));t=b(t,r,1);for(var u=0;n>u;u++)e[u]=t(u);return e},m.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},m.now=Date.now||function(){return(new Date).getTime()};var B={\"&\":\"&\",\"<\":\"<\",\">\":\">\",'\"':\""\",\"'\":\"'\",\"`\":\"`\"},T=m.invert(B),R=function(n){var t=function(t){return n[t]},r=\"(?:\"+m.keys(n).join(\"|\")+\")\",e=RegExp(r),u=RegExp(r,\"g\");return function(n){return n=null==n?\"\":\"\"+n,e.test(n)?n.replace(u,t):n}};m.escape=R(B),m.unescape=R(T),m.result=function(n,t,r){var e=null==n?void 0:n[t];return e===void 0&&(e=r),m.isFunction(e)?e.call(n):e};var q=0;m.uniqueId=function(n){var t=++q+\"\";return n?n+t:t},m.templateSettings={evaluate:/<%([\\s\\S]+?)%>/g,interpolate:/<%=([\\s\\S]+?)%>/g,escape:/<%-([\\s\\S]+?)%>/g};var K=/(.)^/,z={\"'\":\"'\",\"\\\\\":\"\\\\\",\"\\r\":\"r\",\"\\n\":\"n\",\"\\u2028\":\"u2028\",\"\\u2029\":\"u2029\"},D=/\\\\|'|\\r|\\n|\\u2028|\\u2029/g,L=function(n){return\"\\\\\"+z[n]};m.template=function(n,t,r){!t&&r&&(t=r),t=m.defaults({},t,m.templateSettings);var e=RegExp([(t.escape||K).source,(t.interpolate||K).source,(t.evaluate||K).source].join(\"|\")+\"|$\",\"g\"),u=0,i=\"__p+='\";n.replace(e,function(t,r,e,o,a){return i+=n.slice(u,a).replace(D,L),u=a+t.length,r?i+=\"'+\\n((__t=(\"+r+\"))==null?'':_.escape(__t))+\\n'\":e?i+=\"'+\\n((__t=(\"+e+\"))==null?'':__t)+\\n'\":o&&(i+=\"';\\n\"+o+\"\\n__p+='\"),t}),i+=\"';\\n\",t.variable||(i=\"with(obj||{}){\\n\"+i+\"}\\n\"),i=\"var __t,__p='',__j=Array.prototype.join,\"+\"print=function(){__p+=__j.call(arguments,'');};\\n\"+i+\"return __p;\\n\";try{var o=new Function(t.variable||\"obj\",\"_\",i)}catch(a){throw a.source=i,a}var c=function(n){return o.call(this,n,m)},f=t.variable||\"obj\";return c.source=\"function(\"+f+\"){\\n\"+i+\"}\",c},m.chain=function(n){var t=m(n);return t._chain=!0,t};var P=function(n,t){return n._chain?m(t).chain():t};m.mixin=function(n){m.each(m.functions(n),function(t){var r=m[t]=n[t];m.prototype[t]=function(){var n=[this._wrapped];return f.apply(n,arguments),P(this,r.apply(m,n))}})},m.mixin(m),m.each([\"pop\",\"push\",\"reverse\",\"shift\",\"sort\",\"splice\",\"unshift\"],function(n){var t=o[n];m.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),\"shift\"!==n&&\"splice\"!==n||0!==r.length||delete r[0],P(this,r)}}),m.each([\"concat\",\"join\",\"slice\"],function(n){var t=o[n];m.prototype[n]=function(){return P(this,t.apply(this._wrapped,arguments))}}),m.prototype.value=function(){return this._wrapped},m.prototype.valueOf=m.prototype.toJSON=m.prototype.value,m.prototype.toString=function(){return\"\"+this._wrapped},\"function\"==typeof define&&define.amd&&define(\"underscore\",[],function(){return m})}).call(this);\n//# sourceMappingURL=underscore-min.map","var legend = new Array();\nvar activeLayers = new Array();\nvar show_active_layers_flag = true;\nfunction toWKT(layer) {\n var lng, lat, coords = [];\n if (layer instanceof L.Polygon || layer instanceof L.Polyline) {\n var latlngs = layer.getLatLngs();\n for (var i = 0; i < latlngs.length; i++) {\n latlngs[i]\n coords.push(latlngs[i].lng + \" \" + latlngs[i].lat);\n if (i === 0) {\n lng = latlngs[i].lng;\n lat = latlngs[i].lat;\n }\n }\n ;\n if (layer instanceof L.Polygon) {\n return \"POLYGON((\" + coords.join(\",\") + \",\" + lng + \" \" + lat + \"))\";\n } else if (layer instanceof L.Polyline) {\n return \"LINESTRING(\" + coords.join(\",\") + \")\";\n }\n } else if (layer instanceof L.Marker) {\n return \"POINT(\" + layer.getLatLng().lng + \" \" + layer.getLatLng().lat + \")\";\n }\n}\n\njQuery(document).ready(function () {\n L.TileLayer.BetterWMS = L.TileLayer.WMS.extend({\n\n onAdd: function (map) {\n // Triggered when the layer is added to a map.\n // Register a click listener, then do all the upstream WMS things\n L.TileLayer.WMS.prototype.onAdd.call(this, map);\n map.on('click', this.getFeatureInfo, this);\n },\n\n onRemove: function (map) {\n // Triggered when the layer is removed from a map.\n // Unregister a click listener, then do all the upstream WMS things\n L.TileLayer.WMS.prototype.onRemove.call(this, map);\n map.off('click', this.getFeatureInfo, this);\n },\n\n getFeatureInfo: function (evt) {\n\n // Make an AJAX request to the server and hope for the best\n var url = this.getFeatureInfoUrl(evt.latlng),\n showResults = L.Util.bind(this.showGetFeatureInfo, this);\n $.ajax({\n url: url,\n success: function (data, status, xhr) {\n var err = typeof data === 'string' ? null : data;\n showResults(err, evt.latlng, data);\n },\n error: function (xhr, status, error) {\n showResults(error);\n }\n });\n },\n\n getFeatureInfoUrl: function (latlng) {\n //console.log(this.wmsParams.srs1);\n // Construct a GetFeatureInfo request URL given a point\n var point = this._map.latLngToContainerPoint(latlng, this._map.getZoom()),\n size = this._map.getSize();\n var ltype = this.wmsParams.layer_type;\n\n var format = \"application/json\";\n if (ltype == 4) {\n format = \"text/html\";\n }\n var params = {\n request: 'GetFeatureInfo',\n service: 'WMS',\n //srs: this.wmsParams.srs1,\n srs: 'EPSG:4326',\n styles: this.wmsParams.styles,\n transparent: this.wmsParams.transparent,\n version: this.wmsParams.version,\n format: this.wmsParams.format,\n // bbox: this._map.getBounds().toBBoxString(),\n height: size.y,\n width: size.x,\n layers: this.wmsParams.layers,\n query_layers: this.wmsParams.layers,\n info_format: format\n };\n\n params[params.version === '1.3.0' ? 'i' : 'x'] = point.x;\n params[params.version === '1.3.0' ? 'j' : 'y'] = point.y;\n\n return this._url + L.Util.getParamString(params, this._url, true);\n },\n\n showGetFeatureInfo: function (err, latlng, content) {\n // console.log(err);\n // console.log(this.wmsParams.keyname);\n // don't open again....\n// if (err) {\n// console.log(err);\n// return;\n// } // do nothing if there's an error\n // console.log(content);\n\n console.log(content);\n\n var index = getIndex(selectedLayers, 'unique_id', this.wmsParams.unique_id);\n var popupContent = \"\";\n\n if (selectedLayers[index].type == 1) {\n if (!content.features || content.features.length == 0) {\n return;\n }\n\n popupContent = getPopupContent(content, selectedLayers[index].pc);\n\n } else {\n\n if (jQuery(content).find(\"tr\").length < 2) {\n return;\n }\n popupContent = content;\n }\n // Otherwise show the content in a popup, or something.\n L.popup({maxWidth: 'auto'})\n .setLatLng(latlng)\n .setContent(popupContent)\n .openOn(this._map);\n\n// if (selectedLayers[index].type == 4) { \n// $('.leaflet-popup-content-wrapper').find('table').addClass(\"table\"); \n// }\n }\n });\n\n L.tileLayer.betterWms = function (url, options) {\n return new L.TileLayer.BetterWMS(url, options);\n };\n\n L.Icon.Default.imagePath = baseURL + \"/assets/plugins/leaflet/images\";\n L.AwesomeMarkers.Icon.prototype.options.prefix = 'fa';\n})\nfunction renderLayer(t, data) {\n\n if (typeof featureGroup[t.unique_id] == \"undefined\") {\n featureGroup[t.unique_id] = new Array();\n }\n\n if (t.type == 2 && (typeof t.cluster != \"undefined\" && t.cluster == 1)) {\n featureGroup[t.unique_id][t.name] = new L.MarkerClusterGroup();\n } else {\n featureGroup[t.unique_id][t.name] = new L.FeatureGroup();\n }\n console.log(t.settings);\n if (typeof t.settings != \"undefined\") {\n if (t.settings.active == 1) {\n add_current_layer_text(t);\n featureGroup[t.unique_id][t.name].addTo(mymap);\n } else {\n t.settings.active = 0;\n }\n } else {\n featureGroup[t.unique_id][t.name].addTo(mymap);\n t.settings = new Object;\n t.settings.active = 1;\n }\n\n if (t.settings.active == 1) {\n activeLayers.push({id: t._id, order: 0});\n order_current_active_layers();\n }\n\n if (typeof page != \"undefined\" && page == \"phantom\") {\n console.log(\"added\" + t._id);\n if ($.inArray(t._id, active_ids) !== -1) {\n // console.log(t.settings.active);\n // if(t.settings.active == 0){\n console.log(\"added\");\n featureGroup[t.unique_id][t.name].addTo(mymap);\n\n //} \n } else if (t.settings.active == 1) {\n console.log(\"not added\");\n mymap.removeLayer(featureGroup[t.unique_id][t.name]);\n }\n\n }\n\n if (typeof page != \"undefined\" && page == \"user_farm\") {\n\n if (t.settings.active == 1 && show_active_layers_flag == true) {\n jQuery('#chk_' + t.unique_id).prop(\"checked\", \"checked\");\n }\n }\n\n if (typeof page != \"undefined\" && page == \"manage\" && show_active_layers_flag == true) {\n\n //jQuery('#active-layers-container').append(Mustache.render(tmpl.activeLayer, t));\n jQuery('#active-layers-container .media-list').append(Mustache.render(tmpl.activeLayer, {t: t, type: layerType[t.type]}));\n if (t.settings.active == 0) {\n jQuery('#at-' + t.unique_id + \" a.dropdown-toggle span\").addClass(\"label-danger\").removeClass(\"label-primary\");\n }\n\n jQuery('.help-active-popup-hover').popover({\n title: 'Active & In-Active',\n content: '<div class=\"row\"><div class=\"col-md-12\"><p>This feature allows you to initially hide a layer. This can be used to achieve a desired layer presentation as well as to provide faster map loading for larger layers.</p></div></div>',\n html: true,\n trigger: 'hover',\n container: 'body'\n });\n\n jQuery('.at_active_chk').bootstrapSwitch({\n size: 'mini',\n onSwitchChange: function (event, state) {\n event.preventDefault();\n var self = jQuery(this).parents(\".active-layer-action:first\");\n var key = self.attr(\"data-id\");\n var index = getIndex(selectedLayers, 'unique_id', key);\n\n if (!selectedLayers[index].settings && typeof selectedLayers[index].settings == \"undefined\") {\n selectedLayers[index].settings = new Object;\n }\n\n update_dirty(index);\n\n if (state === true) {\n selectedLayers[index].settings.active = 1;\n jQuery('#at-' + t.unique_id + \" a.dropdown-toggle span\").removeClass(\"label-danger\").addClass(\"label-primary\");\n mymap.addLayer(featureGroup[key][selectedLayers[index].name]);\n } else {\n selectedLayers[index].settings.active = 0;\n jQuery('#at-' + t.unique_id + \" a.dropdown-toggle span\").addClass(\"label-danger\").removeClass(\"label-primary\");\n mymap.removeLayer(featureGroup[key][selectedLayers[index].name]);\n }\n calculateBounds();\n }\n });\n }\n\n if (t.type == 1 || t.type == 4) {\n\n // L.imageOverlay('http://services.sentinel-hub.com/v1/wms/1977e8da-981e-447b-9f45-876336853164?SERVICE=WMS&REQUEST=GetMap&MAXCC=100&SRS=CRS:84&LAYERS=VEGETATION_INDEX&WIDTH=1141&HEIGHT=600&COLCOR=,BOOST&FORMAT=image/jpeg&BGCOLOR=00000000&TRANSPARENT=1&TIME=2015-01-01/2016-12-04&BBOX=31.86337271,-25.58553214,31.92626005,-25.55247732&GEOMETRY=POLYGON%28%2831.86501197235643%20-25.552477323857563,31.86337270813486%20-25.564976812169963,31.866014590158265%20-25.565714510820147,31.86637945987775%20-25.566359976486257,31.86634960957168%20-25.566972492232132,31.866314735384275%20-25.567069146264945,31.86628018302301%20-25.567197997023754,31.8660717242862%20-25.56784185437009,31.86603721621925%20-25.567970549041522,31.86579847109656%20-25.569127641679255,31.865728265045835%20-25.5692560707222,31.86521915498914%20-25.569470655598835,31.864963139386557%20-25.570045740273795,31.86492153624839%20-25.570699113585093,31.864864465054946%20-25.572219530020224,31.86513680151194%20-25.573523146724966,31.86593214730313%20-25.574992044206205,31.86768405924886%20-25.575919426212707,31.86979657229066%20-25.575715805214962,31.87133132314888%20-25.57577734584977,31.87282582024432%20-25.57555223276595,31.873941937061705%20-25.57524284976536,31.87508945824082%20-25.574888979398064,31.8767961971982%20-25.575014487828785,31.87887319114594%20-25.568987092446744,31.90660330293984%20-25.575217674743918,31.900480916710546%20-25.581002937467453,31.9200238144976%20-25.585532135993283,31.92626004605639%20-25.5706509773005,31.86501197235643%20-25.552477323857563%29%29', [[31.86337271,-25.58553214],[31.92626005,-25.55247732]])\n // .addTo(featureGroup[t.unique_id][t.name]);\n // console.log(t.SRS);\n var options = {\n format: 'image/png',\n layers: t.Name,\n transparent: true,\n crs: L.CRS.EPSG4326,\n unique_id: t.unique_id,\n srs1: t.SRS,\n layer_type: t.type\n };\n\n if (typeof t.geometry_area != \"undefined\") {\n options.geometry = t.geometry_area;\n }\n\n if (typeof t.time != \"undefined\") {\n options.time = t.time;\n }\n\n L.tileLayer.betterWms(t.url, options).addTo(featureGroup[t.unique_id][t.name]);\n\n } else if (t.type == 2) {\n //check data is coming \n if (data == \"\") {\n if (page == \"phantom\") {\n filterGlobalData();\n\n } else {\n if (!t.cache_timer && typeof t.cache_timer == \"undefined\") {\n t.cache_timer = 15;\n }\n data = {\n datasource: t.connection_id,\n sql_layer_name: t.name,\n \"query_box\": t.query,\n \"_token\": jQuery('[name=\"_token\"]').val(),\n \"cache_key\": t.cache_key,\n \"cache_timer\": t.cache_timer,\n \"type\": 2,\n \"map_id\": map.id\n };\n\n ajaxRequest('map/layer/json', 'post', 'json', data, function (data) {\n if (data.status == \"200\") {\n processSQLJSON(data, t);\n } else {\n showMsg(data.status, data.msg);\n }\n });\n }\n } else {\n processSQLJSON(data, t);\n }\n } else if (t.type == 3) {\n\n }\n\n overlayers_controls(t);\n overlays[t.name] = featureGroup[t.unique_id][t.name];\n layerSelector.addOverlay(featureGroup[t.unique_id][t.name], t.name);\n if (t.type == 3) {\n jQuery('#at-' + t.unique_id).find('.style-at-layer').remove();\n }\n calculateBounds();\n}\n\n\nfunction getPopupContent(content, defined_content) {\n // var featuresHTML = defined_content;\n\n $.each(content.features, function (key, feature) {\n\n //featuresHTML += '<div class=\"row\"><div class=\"col-md-12\"><h4>' + feature.id + '</h4><ul class=\"map-popup-feature-lists\">';\n $.each(feature.properties, function (key, value) {\n defined_content = defined_content.replace(\"<\" + key + \">\", value);\n //featuresHTML = '<li>' + key + ' : ' + value + '</li>';\n });\n //featuresHTML += \"</ul></div></div>\";\n })\n return defined_content;\n}\n\n\nfunction processSQLJSON(data, t) {\n t = defaultLayerStyle(t);\n if (data.more_data.sql_type == 3) {\n processheatmapJSON(data, t);\n } else {\n clearLayersAndControls(data, t);\n\n jQuery.each(data.result, function (name, json) {\n L.geoJson(json, {\n onEachFeature: function (feature, layer) {\n if (layer instanceof L.Marker) {\n var found = false;\n if (t.style.type == \"nr\") {\n\n\n $.each(t.style.custom, function (key, val) {\n\n if (between(feature.properties[t.style.field], val.val)) {\n found = true;\n layer.setIcon(L.AwesomeMarkers.icon(val.style));\n return false;\n }\n })\n\n\n\n } else if (t.style.type == \"g\") {\n\n\n $.each(t.style.custom, function (key, val) {\n\n if (feature.properties[t.style.field] == val.val) {\n found = true;\n layer.setIcon(L.AwesomeMarkers.icon(val.style));\n return false;\n }\n });\n }\n\n if (found == false) {\n layer.setIcon(L.AwesomeMarkers.icon(t.style.marker));\n }\n }\n// if (layer instanceof L.Marker) {\n// layer.setIcon(L.AwesomeMarkers.icon(t.style.marker));\n// }\n layer.on('click', function (e) {\n\n var c = getSQLPopupContent(feature.properties, t.pc);\n layer.bindPopup(c);\n\n// if (layer instanceof L.Marker) { \n// var popup = L.popup();\n// popup.setLatLng(layer.getLatLng());\n// popup.setContent(c);\n// mymap.openPopup(popup);\n// } else {\n// var bounds = layer.getBounds();\n// var popup = L.popup();\n// popup.setLatLng(bounds.getCenter());\n// popup.setContent(c);\n// mymap.openPopup(popup);\n// } \n\n })\n },\n style: function (feature, layer) {\n return t.style.polygon;\n }\n }).addTo(featureGroup[t.unique_id][t.name]);\n\n mymap.fitBounds(featureGroup[t.unique_id][t.name].getBounds());\n });\n }\n}\n\nfunction initLayer() {\n\n\n selectedLayers.sort(sort_value_layer);\n\n if (selectedBaseLayers.length > 0) {\n jQuery('#visiable-layers').find('.baselayers-control').removeClass(\"hide\");\n }\n jQuery.each(selectedBaseLayers, function (key, value) {\n\n layerSelector.addBaseLayer(baseLayers['mymap'][value.name], value.name);\n baselayers_controls(value.name);\n\n if (typeof page != \"undefined\" && page == \"manage\") {\n //alert(page);\n var ls = jQuery('#base_layer_selection').find('input:checkbox[data-name=\"' + value.name + '\"]');\n\n if (ls.length > 0) {\n ls.prop(\"checked\", \"checked\");\n baseLayerMap(ls, false);\n }\n }\n })\n\n jQuery.each(selectedLayers, function (key, value) {\n renderLayer(value, '');\n })\n\n //look for custom layers\n var data = {\n \"type\": 3,\n \"id\": map.id,\n \"_token\": jQuery('[name=\"_token\"]').val(),\n }\n ajaxRequest('map/layer/json', 'post', 'json', data, function (data) {\n\n if (data.status == \"200\") {\n processFreeHand(data);\n } else {\n showMsg(data.status, data.msg);\n }\n });\n\n\n}\n\nfunction processFreeHand(cl) {\n\n jQuery.each(cl.result, function (name, json) {\n\n index = getIndex(selectedLayers, 'unique_id', name);\n t = selectedLayers[index];\n\n if (typeof featureGroup[t.unique_id] == \"undefined\") {\n featureGroup[t.unique_id] = new Array();\n }\n featureGroup[t.unique_id][t.name] = new L.FeatureGroup();\n\n if (typeof t.settings != \"undefined\") {\n if (t.settings.active == 1) {\n featureGroup[t.unique_id][t.name].addTo(mymap);\n } else {\n t.settings.active = 0;\n }\n } else {\n featureGroup[t.unique_id][t.name].addTo(mymap);\n t.settings = new Object;\n t.settings.active = 1;\n }\n\n //featureGroup[t.unique_id][t.name].addTo(mymap);\n L.geoJson(json, {\n onEachFeature: function (feature, layer) {\n\n selectedLayers[index].layer = layer;\n\n if (t.settings.active == 1) {\n drawingGroup.addLayer(layer);\n }\n featureGroup[t.unique_id][t.name].addLayer(layer);\n\n if (layer instanceof L.Marker) {\n layer.setIcon(L.AwesomeMarkers.icon(selectedLayers[index].style.marker));\n }\n layer.bindPopup(selectedLayers[index].pc);\n\n// layer.on(\"click\", function () {\n// var index = getLayerIndex1(layer);\n// if (layer instanceof L.Marker) {\n// var popup = L.popup();\n// popup.setLatLng(layer.getLatLng());\n// popup.setContent(selectedLayers[index].pc);\n// mymap.openPopup(popup);\n// } else {\n// var bounds = layer.getBounds();\n// var popup = L.popup();\n// popup.setLatLng(bounds.getCenter());\n// popup.setContent(selectedLayers[index].pc);\n// mymap.openPopup(popup);\n// }\n// });\n\n },\n style: function (feature, layer) {\n return t.style.polygon;\n },\n pointToLayer: function (feature, latlng) {\n //console.log(feature);\n if (typeof t.radius != \"undefined\") {\n return L.circle(latlng, parseInt(t.radius, 10));\n } else {\n return L.marker(latlng);\n }\n },\n })\n\n });\n calculateBounds();\n}\n\nfunction calculateBounds() {\n\n bounds = true;\n\n jQuery.each(selectedLayers, function (key, g) {\n\n if (typeof g.settings.active == \"undefined\" || g.settings.active == 1) {\n\n if (g.type == 1 || (g.type == 4 && typeof g.geometry_area == \"undefined\")) {\n\n// if (bounds != true) {\n// // console.log(\"inside\");\n// bounds.extend([parseFloat(g['LatLonBoundingBox']['@attributes']['miny']), parseFloat(g['LatLonBoundingBox']['@attributes']['minx'])], [parseFloat(g['LatLonBoundingBox']['@attributes']['maxy']), parseFloat(g['LatLonBoundingBox']['@attributes']['maxx'])]);\n// \n// bounds = L.latLngBounds([parseFloat(g['LatLonBoundingBox']['@attributes']['miny']), parseFloat(g['LatLonBoundingBox']['@attributes']['minx'])], [parseFloat(g['LatLonBoundingBox']['@attributes']['maxy']), parseFloat(g['LatLonBoundingBox']['@attributes']['maxx'])]);\n// \n// } else {\n// if(typeof g['LatLonBoundingBox'] != \"undefined\"){\n// bounds = L.latLngBounds([parseFloat(g['LatLonBoundingBox']['@attributes']['miny']), parseFloat(g['LatLonBoundingBox']['@attributes']['minx'])], [parseFloat(g['LatLonBoundingBox']['@attributes']['maxy']), parseFloat(g['LatLonBoundingBox']['@attributes']['maxx'])]);\n// } else if(typeof g['BoundingBox'] != \"undefined\"){\n// bounds = L.latLngBounds([parseFloat(g['BoundingBox']['@attributes']['miny']), parseFloat(g['BoundingBox']['@attributes']['minx'])], [parseFloat(g['BoundingBox']['@attributes']['maxy']), parseFloat(g['BoundingBox']['@attributes']['maxx'])]);\n// } \n// }\n }\n if (g.type == 3) {\n\n\n if (typeof featureGroup[g.unique_id] != \"undefined\" && typeof featureGroup[g.unique_id][g.name] != \"undefined\") {\n\n var layer1 = featureGroup[g.unique_id][g.name];\n if (bounds != true) {\n var b1 = layer1.getBounds();\n\n if (typeof b1._southWest != \"undefined\") {\n bounds.extend(layer1.getBounds());\n }\n } else {\n var b1 = layer1.getBounds();\n\n if (typeof b1._southWest != \"undefined\") {\n console.log(\"checked\");\n bounds = b1;\n }\n }\n }\n\n }\n }\n\n })\n\n// $.each(featureGroup, function (l, layer) {\n// if (bounds != true) {\n// // console.log(\"inside\");\n// bounds.extend(layer.getBounds());\n// } else {\n// bounds = layer.getBounds();\n// }\n// })\n//\n\n if (bounds !== true) {\n mymap.fitBounds(bounds);\n }\n\n}\n\n\nfunction getLayersIndex(id) {\n var len = selectedLayers.length;\n for (i = 0; i < len; i++) {\n if (selectedLayers[i].unique_id == id) {\n return i;\n }\n }\n}\n\nfunction getIndex(obj, key, value) {\n var len = obj.length;\n for (i = 0; i < len; i++) {\n if (obj[i][key] == value) {\n return i;\n }\n }\n}\n\nfunction getSQLPopupContent(properties, defined_content) {\n // var featuresHTML = defined_content;\n\n $.each(properties, function (key, value) {\n \n if (value.match(/\\.(jpeg|jpg|gif|png)$/) != null) {\n console.log(value);\n var image = '<img src=\"' + value + '\" style=\"height:50px;width:50px;\"/>';\n defined_content = defined_content.replace(\"<\" + key + \">\", image);\n } else {\n defined_content = defined_content.replace(\"<\" + key + \">\", value);\n }\n \n });\n //featuresHTML += \"</ul></div></div>\";\n\n return defined_content;\n}\n\nfunction defaultSettings() {\n\n map.settings = map.settings != \"\" ? JSON.parse(map.settings) : new Object;\n\n if (typeof map.settings.width == \"undefined\") {\n map.settings.width = 500;\n }\n if (typeof map.settings.height == \"undefined\") {\n map.settings.height = 500;\n }\n if (typeof map.settings.zoom == \"undefined\") {\n map.settings.zoom = 6;\n }\n\n if (typeof map.settings.fullscreen == \"undefined\") {\n map.settings.fullscreen = 1;\n }\n\n if (typeof map.settings.https == \"undefined\") {\n map.settings.https = 1;\n }\n}\n\nfunction assingSettings() {\n // mymap.setZoom(map.settings.zoom);\n}\n\nfunction saveMapData(type, callback) {\n\n var len = selectedLayers.length;\n\n var jt = new Array();\n for (i = 0; i < len; i++) {\n\n if (typeof selectedLayers[i].is_dirty != \"undefined\") {\n\n if (typeof selectedLayers[i].boundary_id != \"undefined\" && typeof selectedLayers[i].geometry_area != \"undefined\") {\n selectedLayers[i].geometry_area = \"\";\n }\n\n var s = jQuery.extend(true, {}, selectedLayers[i]);\n\n if (s.type == 3) {\n if (s.layer instanceof L.Circle) {\n s.radius = s.layer.getRadius();\n }\n s.layer = s.layer.toGeoJSON();\n }\n jt.push(s);\n }\n }\n var t = {\n \"selectedLayers\": jt,\n \"selectedBaseLayers\": selectedBaseLayers\n }\n jQuery('#action_type').val(type);\n var json = JSON.stringify(t);\n\n jQuery('#layer_json').val(json);\n var formdata = jQuery('#layer-form, #map-settings-form').serialize();\n\n ajaxRequest('/developer/map/save', 'post', 'json', formdata, function (data) {\n\n if (data.status == 200) {\n jQuery('#map_id').val(data.map_id);\n // window.location = baseURL + \"/developer/map/edit/\" + data.map_id;\n //showMsg(data.action, data.msg);\n\n $.each(selectedLayers, function (key, value) {\n selectedLayers[key].is_dirty = undefined;\n if (typeof selectedLayers[key]._id == \"undefined\") {\n selectedLayers[key]._id = data.mapping_array[value.unique_id];\n }\n })\n callback(data);\n } else {\n showMsg(\"error\", data.msg);\n }\n })\n}\n\nfunction sortLayers() {\n var all_id = new Array();\n var i = 0;\n $(\"#visiable-layers div.dropdown-menu .custom-control-layers\").find('li').each(function (i) {\n var id = $(this).attr(\"data-key\");\n all_id[i] = id;\n i++;\n\n });\n\n $.each(all_id, function (index1, value) {\n var index = getIndex(selectedLayers, 'unique_id', value);\n selectedLayers[index].order = index1 + 1;\n });\n\n// $.ajax({\n// type: \"POST\",\n// url: \"{{URL::action('Superadmin\\LayersController@postSetOrder')}}\",\n// data: {'data_id': all_id}\n// }).done(function(data) {\n// alert(\"Order set successfully.\");\n// });\n}\n\nfunction overlayers_controls(t) {\n\n var temp = document.getElementById('map-overlayer-controls-tmpl').innerHTML;\n Mustache.parse(temp);\n // var html = \"\";\n if (t.type == 2 && (t.style.type == \"nr\" || t.style.type == \"g\")) {\n\n var temp2 = document.getElementById('map-overlayer-submenu-controls-tmpl').innerHTML;\n Mustache.parse(temp2);\n $(\"<li/>\").attr(\"data-key\", t.unique_id).attr(\"data-name\", t.name).addClass(\"nav-item treeview overlay_control_\" + t.unique_id).html(Mustache.render(temp2, t)).appendTo(\"#visiable-layers div.dropdown-menu .custom-control-layers\");\n\n addSubOverLayer(t);\n\n } else {\n $(\"<li/>\").attr(\"data-key\", t.unique_id).attr(\"data-name\", t.name).addClass(\"overlay_control_\" + t.unique_id).html(Mustache.render(temp, t)).appendTo(\"#visiable-layers div.dropdown-menu .custom-control-layers\").find('input[type=\"checkbox\"]').bootstrapSwitch({size: 'mini', onSwitchChange: function (event, state) {\n event.preventDefault();\n var self = jQuery(this).parents(\"li:first\");\n var key = self.attr(\"data-key\");\n var name = self.attr(\"data-name\");\n var index = getIndex(selectedLayers, 'unique_id', key);\n var t = selectedLayers[index];\n// if (t.type == 3) {\n// \n// if (state === true) {\n// \n// var layers = featureGroup[key][name];\n// console.log(layers);\n// // $.each(layers, function (key, val) {\n// \n// drawingGroup.addLayer(layers); \n// // });\n// \n// }else{\n// var layers = featureGroup[key][name];\n// //$.each(layers, function (key, val) {\n// drawingGroup.removeLayer(layers); \n// //});\n// }\n// } else {\n if (state === true) {\n mymap.addLayer(featureGroup[key][name]);\n } else {\n mymap.removeLayer(featureGroup[key][name]);\n }\n // }\n\n\n }\n });\n }\n\n\n\n\n if (typeof page != \"undefined\" && page == \"manage\") {\n// $(\"#visiable-layers div.dropdown-menu .custom-control-layers\").sortable({\n// // helper: fixHelperModified,\n// stop: sortLayers,\n// // helper: 'clone'\n// // cursorAt: {left:0, top:0}\n// //connectWith: \"table\"\n// }).disableSelection();\n }\n}\n\nfunction addSubOverLayer(t) {\n\n var $vl = jQuery('li[data-key=\"' + t.unique_id + '\"]');\n var temp1 = document.getElementById('map-overlayer-sub-controls-tmpl').innerHTML;\n // html = '<ul class=\"nav custom-control-layers ui-sortable sub-overlayers-control\"></ul>';\n //$vl.append(html);\n\n $.each(t.style.custom, function (index, val) {\n\n $(\"<li/>\").attr(\"data-key\", t.unique_id).attr(\"data-name\", t.name).attr(\"data-val\", val.val).html(Mustache.render(temp1, {val: val.val, t: t})).appendTo($vl.find(\"ul\")).find('input[type=\"checkbox\"]').bootstrapSwitch({size: 'mini', onSwitchChange: function (event, state) {\n event.preventDefault();\n var self = jQuery(this).parents(\"li:first\");\n var key = self.attr(\"data-key\");\n var name = self.attr(\"data-name\");\n var val = self.attr(\"data-val\");\n\n var index = getIndex(selectedLayers, 'unique_id', key);\n var t = selectedLayers[index];\n var layers = featureGroup[key][name].getLayers();\n\n $.each(layers, function (key1, val1) {\n\n val1.eachLayer(function (layer) {\n\n if (t.style.type == \"nr\") {\n\n if (between(layer.feature.properties[t.style.field], val)) {\n if (state === true) {\n mymap.addLayer(layer);\n } else {\n mymap.removeLayer(layer);\n }\n }\n\n } else if (t.style.type == \"g\") {\n if (layer.feature.properties[t.style.field] == val) {\n if (state === true) {\n mymap.addLayer(layer);\n } else {\n mymap.removeLayer(layer);\n }\n\n }\n }\n\n });\n\n });\n\n }\n });\n\n })\n jQuery('.subcontrol-layer-action').slimScroll({\n alwaysVisible: true,\n height: 100\n });\n\n jQuery('.submenu-overlay-controls').click(function (e) {\n e.preventDefault();\n var $self = jQuery(this);\n $self.toggleClass(\"in\");\n var d = $($self.attr(\"href\"));\n\n if (d.hasClass(\"in\")) {\n d.collapse(\"hide\");\n } else {\n d.collapse(\"show\");\n }\n\n return false;\n\n })\n}\n\nfunction baselayers_controls(name) {\n\n var temp = document.getElementById('map-baselayer-controls-tmpl').innerHTML;\n Mustache.parse(temp);\n\n $(\"<li/>\").attr(\"data-name\", name).addClass(\"baselayer_control_\" + name).html(Mustache.render(temp, {name: name})).prependTo(\"#visiable-layers div.dropdown-menu .baselayers-control-layers\").find('input[type=\"radio\"]').bootstrapSwitch({size: 'mini', onSwitchChange: function (event, state) {\n event.preventDefault();\n\n var self = jQuery(this).parents(\"li:first\");\n var name = self.attr(\"data-name\");\n\n $.each(baseLayers[\"mymap\"], function (name, value) {\n console.log(name);\n mymap.removeLayer(baseLayers[\"mymap\"][name]);\n })\n if (state === true) {\n\n mymap.addLayer(baseLayers[\"mymap\"][name]);\n }\n }});\n\n\n}\n\nfunction removeOverlayerControl(gskey) {\n jQuery('#visiable-layers').find('.overlay_control_' + gskey).remove();\n}\nfunction applyLiveStyle(type) {\n\n var my_unique_id = jQuery('#map-sidebar-container [name=\"my_unique_id\"]').val();\n var index = getIndex(selectedLayers, 'unique_id', my_unique_id);\n update_dirty(index, 2);\n\n var style = {};\n jQuery('#layer-polygon-styling input').each(function () {\n var $self = jQuery(this);\n style[$self.attr(\"name\")] = $self.val();\n })\n\n var marker = {};\n jQuery('#layer-marker-styling .default-marker-style select').each(function () {\n var $self = jQuery(this);\n marker[$self.attr(\"data-name\")] = $self.val();\n })\n\n if (selectedLayers[index].type == 2) {\n var layers = featureGroup[selectedLayers[index].unique_id][selectedLayers[index].name].getLayers();\n $.each(layers, function (key, val) {\n val.eachLayer(function (layer) {\n\n if (layer instanceof L.Marker) {\n layer.setIcon(L.AwesomeMarkers.icon(marker));\n } else if (layer instanceof L.Polyline ||\n layer instanceof L.Polygon ||\n layer instanceof L.Rectangle ||\n layer instanceof L.Circle) {\n layer.setStyle(style);\n }\n\n });\n });\n } else if (selectedLayers[index].type == 3) {\n var layer = selectedLayers[index].layer;\n if (layer instanceof L.Marker) {\n layer.setIcon(L.AwesomeMarkers.icon(marker));\n } else if (layer instanceof L.Polyline ||\n layer instanceof L.Polygon ||\n layer instanceof L.Rectangle ||\n layer instanceof L.Circle) {\n layer.setStyle(style);\n }\n\n }\n\n // .setStyle(style);\n selectedLayers[index]['style'].polygon = style;\n selectedLayers[index]['style'].marker = marker;\n\n}\n\nfunction defaultLayerStyle(t) {\n\n var polygon = new Object;\n var marker = new Object;\n\n if (typeof t.style == \"undefined\") {\n t.style = new Object;\n\n }\n if (typeof t.style.polygon != \"undefined\") {\n polygon = t.style.polygon;\n } else {\n t.style.polygon = new Object;\n }\n\n if (typeof t.style.marker != \"undefined\") {\n marker = t.style.marker;\n } else {\n t.style.marker = new Object;\n }\n\n\n if (typeof polygon.color == \"undefined\") {\n polygon.color = \"#ccc\";\n }\n\n if (typeof polygon.opacity == \"undefined\") {\n polygon.opacity = 1;\n }\n\n if (typeof polygon.fillOpacity == \"undefined\") {\n polygon.fillOpacity = 1;\n }\n\n if (typeof polygon.fillColor == \"undefined\") {\n polygon.fillColor = \"#ccc\";\n }\n\n if (typeof polygon.weight == \"undefined\") {\n polygon.weight = 1;\n }\n\n if (typeof marker.icon == \"undefined\") {\n marker.icon = \"\";\n }\n\n if (typeof marker.color == \"undefined\") {\n marker.color = \"blue\";\n }\n\n t.style.polygon = polygon;\n t.style.marker = marker;\n\n var index = getIndex(selectedLayers, 'unique_id', t.unique_id);\n selectedLayers[index]['style'] = t.style;\n return t;\n}\n\nfunction getLayerIndex1(layer) {\n var len = selectedLayers.length;\n for (i = 0; i < len; i++) {\n if (selectedLayers[i].type == 3 && selectedLayers[i].layer == layer) {\n return i;\n }\n }\n}\n\nfunction between(x, range) {\n x = parseFloat(x);\n var n = range.split('-');\n return x >= n[0] && x <= n[1];\n}\n\nfunction getMarkerStyle(marker) {\n\n if (marker.markerColor == \"\") {\n var marker_color = jQuery('#default_style_marker_color').val();\n console.log(marker_color);\n if (marker_color != \"\") {\n marker.markerColor = marker_color;\n } else {\n marker.markerColor = \"blue\";\n }\n\n }\n\n if (marker.icon == \"\") {\n\n var marker_icon = jQuery('#default_style_marker_icon').val();\n if (marker_icon != \"\") {\n marker.icon = marker_icon;\n } else {\n marker.icon = \"\";\n }\n\n }\n return marker;\n}\n\nfunction update_dirty(index, action) {\n selectedLayers[index].is_dirty = 1;\n if (typeof selectedLayers[index]._id == \"undefined\") {\n if (action == 1 || action == 2) {\n selectedLayers[index].is_dirty = 1;\n } else if (action == 3) {\n selectedLayers.splice(index, 1);\n }\n } else {\n selectedLayers[index].is_dirty = action;\n }\n\n}\nfunction order_current_active_layers() {\n\n activeLayers.sort(sort_value_layer);\n\n var len = activeLayers.length;\n for (i = 0; i < len; i++) {\n activeLayers[i].order = activeLayers[i].order + 1;\n }\n}\n\nfunction add_current_layer_text(t) {\n if (typeof page != \"undefined\" && page == \"user_farm\") {\n var cs_html = document.getElementById('user-farm-active-layers-tmpl').innerHTML;\n Mustache.parse(cs_html);\n\n jQuery('#current-active-layer ul').prepend(Mustache.render(cs_html, t));\n }\n\n}\n\n\nfunction add_sql_legend(t, show) {\n console.log(t);\n if (show == true) {\n if (t.type == 2 && (t.style.type == \"nr\" || t.style.type == \"g\")) {\n\n legend[t.unique_id] = L.control({position: 'bottomright'});\n legend[t.unique_id].onAdd = function (map) {\n\n var div = L.DomUtil.create('div', 'info mapfig-legend');\n div.innerHTML += '<h6 class=\"map-legend-title\">' + t.name + \"</h6>\";\n\n $.each(t.style.custom, function (key, val) {\n\n var icon = val.style.icon;\n\n if (icon.indexOf(\".png\") !== -1) {\n var href = baseURL + \"assets/img/markers/\" + val.style.markerColor + '-' + val.style.icon;\n div.innerHTML += '<div class=\"map-legend\"><img src=\"' + href + '\" height=\"20\"/><div class=\"legend-text\">' + val.val + '</div></div>';\n } else {\n div.innerHTML += '<div class=\"map-legend\"><i class=\"fa fa-map-marker\" style=\"color:' + val.style.markerColor + ' !important\"></i><div class=\"legend-text\">' + val.val + '</div></div>';\n }\n });\n return div;\n };\n\n mymap.addControl(legend[t.unique_id]);\n }\n } else {\n //legend[t.unique_id]).removeFrom(mymap);\n }\n}\n\nfunction runFilterElementJS() {\n\n if (jQuery('.datepicker').length > 0) {\n jQuery('.datepicker').datepicker({\n format: 'yyyy-mm-dd',\n autoclose: true\n });\n }\n\n if (jQuery('.input-daterange').length > 0) {\n $(\".input-daterange input.form-control\").each(function () {\n $self1 = $(this);\n $self1.daterangepicker({\n format: 'YYYY-MM-DD',\n autoclose: true,\n ranges: {\n 'Today': [moment(), moment()],\n 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],\n 'Last 7 Days': [moment().subtract(6, 'days'), moment()],\n 'Last 30 Days': [moment().subtract(29, 'days'), moment()],\n 'This Month': [moment().startOf('month'), moment().endOf('month')],\n 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]\n }\n }).on('apply.daterangepicker', function (ev, picker) {\n var startname = $self1.attr(\"data-startname\");\n var endname = $self1.attr(\"data-endname\");\n console.log(startname);\n $self1.parents('.input-daterange:first').find('[name=\"' + startname + '\"]').val(picker.startDate.format('YYYY-MM-DD'));\n $self1.parents('.input-daterange:first').find('[name=\"' + endname + '\"]').val(picker.endDate.format('YYYY-MM-DD'));\n });\n\n });\n\n }\n\n\n if (jQuery('.dbisunique').length > 0) {\n var $dbisunique = jQuery('select.dbisunique');\n $dbisunique.each(function () {\n\n jQuery(this).select2({\n placeholder: \"Select Filter\",\n width: \"100%\"\n });\n });\n }\n}\n\n\nfunction filterGlobalData() {\n\n $.each(selectedLayers, function (key, l) {\n\n if (l.type == 2) {\n\n var data = jQuery('#global_filter').serializeArray();\n data.push({name: \"type\", value: 2});\n data.push({name: \"datasource\", value: l.connection_id});\n data.push({name: \"layer_id\", value: l._id});\n data.push({name: \"map_id\", value: map.id});\n data.push({name: \"_token\", value: jQuery('[name=\"_token\"]').val()});\n data.push({name: \"sql_layer_name\", value: l.name});\n data.push({name: \"query_box\", value: l.query});\n data.push({name: \"cache_key\", value: l.cache_key});\n data.push({name: \"cache_timer\", value: 0});\n\n ajaxRequest('map/layer/json', 'post', 'json', data, function (data) {\n\n if (data.status == \"200\") {\n processSQLJSON(data, l);\n } else {\n showMsg(data.status, data.msg);\n }\n });\n }\n\n })\n\n}\n\n\nfunction clearLayersAndControls(data, t) {\n\n layer = featureGroup[t.unique_id][t.name];\n\n if (layer) {\n layer.clearLayers();\n// if (typeof legend[t.unique_id] != \"undefined\") {\n// legend[t.unique_id].removeFrom(mymap);\n// }\n }\n}\n\nfunction getSQLFeatureData(t) {\n\n var layers = featureGroup[t.unique_id][t.name].getLayers();\n var featuredata = new Array();\n var counter = 0;\n\n $.each(layers, function (key, val) {\n if (typeof t.cluster != \"undefined\" && t.cluster == 1) {\n featuredata[counter++] = val.feature.properties;\n } else {\n val.eachLayer(function (layer) {\n featuredata[counter++] = layer.feature.properties;\n });\n }\n\n });\n\n return featuredata;\n\n}\nvar heatmap = new Array();\nfunction processheatmapJSON(data, t) {\n\n\n// addressPoints = addressPoints.map(function (p) {\n// return [p[0], p[1], parseInt(p[2], 10)];\n// });\n// console.log(addressPoints);\n\n //console.log(featureGroup[t.unique_id][t.name]);\n if (typeof heatmap[t.unique_id] == \"undefined\") {\n heatmap[t.unique_id] = L.heatLayer(data.result, {radius: 30}).addTo(featureGroup[t.unique_id][t.name]);\n } else {\n heatmap[t.unique_id].setLatLngs(data.result).setOptions({radius: 30}).redraw();\n }\n\n}\n\nfunction render_layer_again(t) {\n console.log(t);\n featureGroup[t.unique_id][t.name].clearLayers();\n show_active_layers_flag = false;\n renderLayer(t, '');\n show_active_layers_flag = true;\n}","var pgsql_tmpl;\r\nvar featureGroup = new Array();\r\nvar bounds;\r\nvar layerSelector = new Array();\r\nvar overlays = new Array();\r\nvar mymap;\r\nvar currentBaseMap = new Array();\r\nvar marker_content_tmpl;\r\nvar popupContentId = new Array();\r\nvar tmpl = {};\r\nvar db = {};\r\nvar table_tmpl = document.getElementById('table-tmpl').innerHTML;\r\nMustache.parse(table_tmpl);\r\n\r\nvar column_tmpl = document.getElementById('column-tmpl').innerHTML;\r\nMustache.parse(column_tmpl);\r\nvar currentIndex = -1;\r\nvar drawingGroup;\r\nvar editMode = false;\r\nvar baselayer_arr = new Array();\r\njQuery(document).ready(function () {\r\n\r\n\r\n calculateWindow();\r\n manage_map_settings();\r\n\r\n $.fn.button.Constructor.DEFAULTS = {\r\n loadingText: '<i class=\"fa fa-spin fa-spinner\"></i> Processing...…'\r\n }\r\n $('.gs-collapse').on('click', function () {\r\n var $self = jQuery(this);\r\n // var $self = jQuery('#' + $self.attr(''));\r\n getGeoLayer($self, 'gs');\r\n })\r\n\r\n $('.wms-collapse').on('click', function () {\r\n var $self = jQuery(this);\r\n getGeoLayer($self, 'wms');\r\n })\r\n\r\n drawingGroup = new L.FeatureGroup();\r\n\r\n marker_content_tmpl = document.getElementById(\"marker-content-tmpl\").innerHTML;\r\n Mustache.parse(marker_content_tmpl);\r\n\r\n tmpl.activeLayer = document.getElementById(\"active-layers-tmpl\").innerHTML;\r\n Mustache.parse(tmpl.activeLayer);\r\n\r\n\r\n defaultSettings();\r\n var drawControl = new L.Control.Draw({\r\n edit: {\r\n featureGroup: drawingGroup\r\n }\r\n });\r\n\r\n\r\n mymap = L.map('mapid', {\r\n // crs: L.CRS.EPSG4326,\r\n zoomControl: false,\r\n }).setView([51.505, -0.09], 13);\r\n\r\n L.control.zoom({\r\n position: 'topright'\r\n }).addTo(mymap);\r\n\r\n L.control.fullscreen({\r\n position: 'topright', // change the position of the button can be topleft, topright, bottomright or bottomleft, defaut topleft\r\n // title: 'Show me the fullscreen !', // change the title of the button, default Full Screen\r\n // titleCancel: 'Exit fullscreen mode', // change the title of the button when fullscreen is on, default Exit Full Screen\r\n //content: null, // change the content of the button, can be HTML, default null\r\n // forceSeparateButton: true, // force seperate button to detach from zoom buttons, default false\r\n // forcePseudoFullscreen: true, // force use of pseudo full screen even if full screen API is available, default false\r\n // fullscreenElement: false // Dom element to render in full screen, false by default, fallback to map._container\r\n }).addTo(mymap);\r\n\r\n //mymap.addControl(drawControl);\r\n drawControl.addTo(mymap);\r\n drawingGroup.addTo(mymap);\r\n\r\n drawing_event();\r\n\r\n// if(typeof map.settings.base_layer != \"undefined\"){\r\n// layername = map.settings.base_layer;\r\n// }else \r\n \r\n if (selectedBaseLayers.length > 0) {\r\n layername = selectedBaseLayers[0]['name'];\r\n \r\n $.each(selectedBaseLayers, function (layer, value) {\r\n console.log(layer);\r\n console.log(value);\r\n baselayer_arr[value.name] = baseLayers[\"mymap\"][value.name];\r\n });\r\n } else {\r\n baselayer_arr = baseLayers['mymap'];\r\n $.each(baseLayers[\"mymap\"], function (layer, value) {\r\n layername = layer;\r\n })\r\n }\r\n\r\n $('#share-modal').on('shown.bs.modal', function () {\r\n var URL = baseURL\r\n if (!map.settings.https && map.settings.https != 1) {\r\n URL = baseURL.replace(\"s://\", \"://\");\r\n }\r\n var ifrmecode = '<iframe src=\"' + URL + \"map/embed/\" + map.random_token + '\" height=\"' + map.settings.height + '\" width=\"' + map.settings.width + '\"></iframe>';\r\n jQuery('#ds_iframe_code').val(ifrmecode);\r\n jQuery('#ds_share_url').val(URL + \"map/share/\" + map.random_token);\r\n jQuery('#ds_json_url').val(URL + \"map/json/\" + map.random_token);\r\n\r\n })\r\n\r\n\r\n if (isGoogle()) {\r\n\r\n currentBaseMap = L.tileLayer('https://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}', {\r\n maxZoom: 20,\r\n subdomains: ['mt0', 'mt1', 'mt2', 'mt3']\r\n }).addTo(mymap);\r\n\r\n\r\n } else {\r\n\r\n currentBaseMap = L.tileLayer(baseLayers['mymap'][layername]._url, {\r\n maxZoom: 18,\r\n attribution: baseLayers['mymap'][layername].options.attribution,\r\n id: baseLayers['mymap'][layername].options.id\r\n }).addTo(mymap);\r\n }\r\n\r\n\r\n layerSelector = L.control.layers(baselayer_arr, {});\r\n mymap.on(\"baselayerchange\", function (layer, e) {\r\n\r\n })\r\n\r\n mymap.addControl(layerSelector);\r\n\r\n jQuery('#active-layers-container').on(\"click\", '.delete-at-layer', function () {\r\n var $self = jQuery(this);\r\n swal({\r\n title: \"Are you sure?\",\r\n text: \"This will remove layer from current map.\",\r\n type: \"warning\",\r\n showCancelButton: true,\r\n confirmButtonColor: \"#DD6B55\",\r\n confirmButtonText: \"Yes, delete it!\",\r\n cancelButtonText: \"No, cancel plx!\",\r\n closeOnConfirm: true,\r\n closeOnCancel: true\r\n },\r\n function (isConfirm) {\r\n if (isConfirm) {\r\n var unique_id = $self.parents(\".active-layer-action:first\").attr(\"data-id\");\r\n deleteLayer(unique_id);\r\n }\r\n });\r\n })\r\n\r\n sentinel_stuff();\r\n\r\n\r\n jQuery('#active-layers-container').on(\"click\", '.geometry-area-limit', function () {\r\n\r\n var $self = jQuery(this);\r\n var unique_id = $self.parents(\".active-layer-action:first\").attr(\"data-id\");\r\n // alert(unique_id);\r\n var tmpl = document.getElementById(\"geometry-area-limit-tmpl\").innerHTML;\r\n Mustache.parse(tmpl);\r\n var t = getIndex(selectedLayers, 'unique_id', unique_id);\r\n var freehand_map = _.filter(selectedLayers, function (x) {\r\n return x.type == 2 || x.type == 3;\r\n });\r\n\r\n jQuery('#geometry-area-limit-form-body').html(Mustache.render(tmpl, {unique_id: unique_id, t: t, f: freehand_map}));\r\n jQuery('#geometry-area-limit-modal').modal(\"show\");\r\n validateForm(jQuery('#geometry-area-limit-form'));\r\n\r\n jQuery('#geometry_area_dd').change(function () {\r\n\r\n var value = jQuery(this).val();\r\n\r\n if (jQuery('#' + value).length > 0) {\r\n var tmpl = document.getElementById(value).innerHTML;\r\n Mustache.parse(tmpl);\r\n jQuery('#geometry-type-render-container').html(Mustache.render(tmpl));\r\n if (value == \"query-geometry-type-tmpl\") {\r\n console.log(\"tmc\");\r\n setupGeomtryQuery();\r\n }\r\n }\r\n\r\n });\r\n jQuery('#geometry_area_dd').trigger(\"change\");\r\n jQuery('#geometry-area-limit-submit').unbind(\"click\");\r\n jQuery('#geometry-area-limit-submit').click(function () {\r\n var $form = jQuery('#geometry-area-limit-form');\r\n if ($form.validate().form()) {\r\n var unique_id = $form.find('[name=\"unique_id\"]').val();\r\n var index = getIndex(selectedLayers, 'unique_id', unique_id);\r\n var l1 = $form.find('[name=\"geometry_area\"]').val();\r\n var type = $form.find('[name=\"geometry_area\"] option:selected').attr(\"data-type\");\r\n\r\n if (l1 == \"custom-geometry-type-tmpl\") {\r\n var index1 = getIndex(selectedLayers, 'unique_id', unique_id);\r\n selectedLayers[index1].geometry_area = jQuery('#custom_geometry_area').val();\r\n\r\n ajaxRequest(\"developer/map/get/wkt\", 'post', 'json', {data: selectedLayers[index1].geometry_area, unique_id: unique_id, boundary_type: 'custom', _token: jQuery('[name=\"_token\"]').val(), geometry_name: jQuery('#geometry_name').val()}, function (html) {\r\n\r\n if (html.status == 200) {\r\n var index1 = getIndex(selectedLayers, 'unique_id', html.unique_id);\r\n\r\n update_dirty(index1, 2);\r\n selectedLayers[index1].boundary_id = html.boundary_id;\r\n selectedLayers[index1].geometry_area = html.wkt;\r\n\r\n render_layer_again(selectedLayers[index1]);\r\n\r\n jQuery('#geometry-area-limit-modal').modal(\"hide\");\r\n } else {\r\n showMsg(\"error\", html.msg);\r\n }\r\n\r\n });\r\n } else if (l1 == \"shape-file-geometry-type-tmpl\") {\r\n upload_geometry_shape_file();\r\n } else if (type == \"boundary\") {\r\n\r\n $form.find('[name=\"boundary_type\"]').val('boundary');\r\n ajaxRequest(\"developer/map/get/wkt\", 'post', 'json', jQuery('#geometry-area-limit-form').serialize(), function (html) {\r\n if (html.status == 200) {\r\n var index1 = getIndex(selectedLayers, 'unique_id', html.unique_id);\r\n selectedLayers[index1].geometry_area = html.wkt;\r\n selectedLayers[index1].boundary_id = html.boundary_id;\r\n update_dirty(index1, 2);\r\n render_layer_again(selectedLayers[index1]);\r\n jQuery('#geometry-area-limit-modal').modal(\"hide\");\r\n } else {\r\n showMsg(\"error\", html.msg);\r\n }\r\n });\r\n\r\n } else {\r\n var geometry_id = $form.find('[name=\"geometry_area\"]').val();\r\n var custom_index = getIndex(selectedLayers, 'unique_id', geometry_id);\r\n var index1 = getIndex(selectedLayers, 'unique_id', unique_id);\r\n //console.log(toWKT(featureGroup[selectedLayers[index1].unique_id][selectedLayers[index1].name]));\r\n\r\n jQuery('#geometry-area-limit-modal').modal(\"hide\");\r\n if (selectedLayers[custom_index].type == 2) {\r\n $form.find('[name=\"boundary_type\"]').val('sql');\r\n ajaxRequest(\"developer/map/get/wkt\", 'post', 'json', {data: selectedLayers[custom_index], _token: jQuery('[name=\"_token\"]').val(), boundary_type: 'sql', geometry_name: jQuery('#geometry_name').val(), unique_id: unique_id}, function (html) {\r\n\r\n if (html.status == 200) {\r\n var index1 = getIndex(selectedLayers, 'unique_id', html.unique_id);\r\n\r\n update_dirty(index1, 2);\r\n selectedLayers[index1].boundary_id = html.boundary_id;\r\n selectedLayers[index1].geometry_area = html.wkt;\r\n render_layer_again(selectedLayers[index1]);\r\n jQuery('#geometry-area-limit-modal').modal(\"hide\");\r\n } else {\r\n showMsg(\"error\", html.msg);\r\n }\r\n\r\n });\r\n } else {\r\n $form.find('[name=\"boundary_type\"]').val('custom');\r\n selectedLayers[index1].geometry_area = toWKT(selectedLayers[custom_index].layer);\r\n\r\n ajaxRequest(\"developer/map/get/wkt\", 'post', 'json', {data: selectedLayers[index1].geometry_area, _token: jQuery('[name=\"_token\"]').val(), boundary_type: 'custom', unique_id: unique_id, geometry_name: 'default'}, function (html) {\r\n\r\n if (html.status == 200) {\r\n var index1 = getIndex(selectedLayers, 'unique_id', html.unique_id);\r\n\r\n update_dirty(index1, 2);\r\n selectedLayers[index1].boundary_id = html.boundary_id;\r\n selectedLayers[index1].geometry_area = html.wkt;\r\n render_layer_again(selectedLayers[index1]);\r\n jQuery('#geometry-area-limit-modal').modal(\"hide\");\r\n } else {\r\n showMsg(\"error\", html.msg);\r\n }\r\n\r\n });\r\n\r\n\r\n }\r\n }\r\n\r\n\r\n }\r\n })\r\n })\r\n\r\n jQuery('[href=\"#layer-panel\"], [href=\"#settings-panel\"]').click(function(){\r\n \r\n sidebar_toggle(jQuery(this).attr(\"href\"));\r\n })\r\n\r\n jQuery('#active-layers-container').on(\"click\", '.edit-at-layer', function () {\r\n\r\n var $self = jQuery(this);\r\n var unique_id = $self.parents(\".active-layer-action:first\").attr(\"data-id\");\r\n console.log(unique_id);\r\n editATLayer(unique_id);\r\n })\r\n\r\n jQuery('#active-layers-container').on(\"click\", '.edit-query-at-layer', function () {\r\n\r\n var $self = jQuery(this);\r\n var unique_id = $self.parents(\".active-layer-action:first\").attr(\"data-id\");\r\n editSQLATLayer(unique_id);\r\n })\r\n\r\n\r\n jQuery('#active-layers-container').on(\"click\", '.cache-at-layer', function () {\r\n var $self = jQuery(this);\r\n var unique_id = $self.parents(\".active-layer-action:first\").attr(\"data-id\");\r\n editCacheLayer(unique_id);\r\n })\r\n\r\n jQuery('#active-layers-container').on(\"click\", '.style-at-layer', function (e) {\r\n var $self = jQuery(this);\r\n var unique_id = $self.parents(\".active-layer-action:first\").attr(\"data-id\");\r\n editStyleLayer(unique_id);\r\n })\r\n\r\n\r\n jQuery('#cache-settings-modal').on(\"click\", '#cache-settings-save-btn', function (e) {\r\n e.preventDefault();\r\n var $form = jQuery('#cache_settings_form');\r\n\r\n if ($form.validate().form()) {\r\n var unique_id = $form.find('[name=\"unique_id\"]').val();\r\n var index = getIndex(selectedLayers, 'unique_id', unique_id);\r\n update_dirty(index, 2);\r\n var time = $form.find('[name=\"cache_timer\"]').val();\r\n selectedLayers[index].cache_timer = time;\r\n jQuery('#cahe-settings-modal').modal(\"hide\");\r\n saveMapData('settings', function () {\r\n showMsg(\"success\", \"Cache settings save successfully.\");\r\n });\r\n }\r\n })\r\n\r\n jQuery('#layer-tmpl').change(function () {\r\n var tmpl = jQuery(this).val();\r\n var tmpl = document.getElementById(tmpl).innerHTML;\r\n Mustache.parse(tmpl);\r\n jQuery('#layer-render-tmpl').html(Mustache.render(tmpl));\r\n })\r\n\r\n jQuery('.layer_chk').change(function () {\r\n var $self = jQuery(this);\r\n WMSLayers($self, true);\r\n })\r\n\r\n jQuery('#layer-submit').click(function () {\r\n\r\n var data = jQuery('#layer-form').serialize();\r\n ajaxRequest('/developer/connection/save', 'post', 'json', data, function (data) {\r\n if (data.status == 200 && data.table_name == \"\") {\r\n var tmpl = document.getElementById(\"table-tmpl\").innerHTML;\r\n Mustache.parse(tmpl);\r\n jQuery('#tables_div').html(Mustache.render(tmpl, {tables: data.result}));\r\n } else if (data.status == 200 && data.table_name != \"\") {\r\n\r\n jQuery.each(data.result, function (name, json) {\r\n featureGroup = new L.FeatureGroup();\r\n featureGroup.addTo(mymap);\r\n L.geoJson(json, {\r\n onEachFeature: function (feature, layer) {\r\n }\r\n }).addTo(featureGroup);\r\n mymap.fitBounds(featureGroup.getBounds());\r\n });\r\n jQuery('#layer-modal').modal(\"hide\");\r\n }\r\n\r\n });\r\n })\r\n\r\n jQuery('#save-your-map').click(function (e) {\r\n e.preventDefault();\r\n var $self = jQuery(this);\r\n $self.button(\"loading\");\r\n saveMapData('map', function (data) {\r\n $self.button(\"reset\");\r\n window.location = baseURL + \"/developer/map/edit/\" + data.map_id;\r\n });\r\n })\r\n\r\n// jQuery('body').click(function(){\r\n// if(jQuery('.control-sidebar').has(\"control-sidebar-open\")){ \r\n// jQuery('.control-sidebar').removeClass('control-sidebar-open');\r\n// jQuery('.sidebar_hide').removeClass(\"hide\");\r\n// } \r\n// })\r\n\r\n jQuery('.close-right-sidebar').click(function () {\r\n\r\n if (jQuery('.sidebar_hide').hasClass(\"hide\")) {\r\n jQuery('.sidebar_hide').toggleClass(\"hide\");\r\n jQuery('.control-sidebar').toggleClass('control-sidebar-open');\r\n }\r\n\r\n })\r\n\r\n jQuery('#settings-menu-open').click(function (e) {\r\n e.stopPropagation();\r\n\r\n\r\n\r\n e.preventDefault();\r\n var rs_tmpl = document.getElementById('map-settings-sidebar-tmpl').innerHTML;\r\n Mustache.parse(rs_tmpl);\r\n jQuery('#map-sidebar-container').html(Mustache.render(rs_tmpl, {}));\r\n\r\n// var htmlMarkerContent = \"\";\r\n// jQuery('#marker_content_html').html('');\r\n//\r\n// $.each(selectedLayers, function (key, value) {\r\n// htmlMarkerContent += Mustache.render(marker_content_tmpl, {layers: value, unique_id: value.unique_id});\r\n// })\r\n// jQuery('#marker_content_html').html(htmlMarkerContent);\r\n\r\n var setting_tab_2 = document.getElementById(\"map-settings-tmpl\").innerHTML;\r\n Mustache.parse(setting_tab_2);\r\n jQuery('#setting_tab_2').html(Mustache.render(setting_tab_2, {settings: map.settings, bg_layers: bglayersrow}));\r\n\r\n if (typeof map.settings.base_layer != \"undefined\") {\r\n jQuery('#map_base_layers').val(map.settings.base_layer);\r\n }\r\n\r\n if (!jQuery('.sidebar_hide').hasClass(\"hide\")) {\r\n jQuery('.sidebar_hide').toggleClass(\"hide\");\r\n jQuery('.control-sidebar').toggleClass('control-sidebar-open');\r\n }\r\n\r\n\r\n tinyMCEInit_Popup('.popup-content-textarea');\r\n var $mform = jQuery('#map-settings-form');\r\n\r\n validateForm($mform);\r\n\r\n if (map.settings.fullscreen && map.settings.fullscreen == 1) {\r\n $mform.find('[name=\"fullscreen\"]').prop(\"checked\", true);\r\n }\r\n\r\n if (map.settings.https && map.settings.https == 1) {\r\n $mform.find('[name=\"https\"]').prop(\"checked\", true);\r\n }\r\n\r\n jQuery('.map_settings_chk').bootstrapSwitch({\r\n size: 'small'\r\n })\r\n\r\n// jQuery('#marker_content_html').slimScroll({\r\n// height: jQuery(window).height(),\r\n// railVisible: true,\r\n// alwaysVisible: true\r\n// });\r\n\r\n })\r\n\r\n jQuery('.control-sidebar').on('click', '#save-settings-btn', function (e) {\r\n\r\n if (jQuery('#map-settings-form').validate().form()) {\r\n e.preventDefault();\r\n var $self = jQuery(this);\r\n $self.button(\"loading\");\r\n saveMapData('settings', function (data) {\r\n $self.button(\"reset\");\r\n map.settings = data.settings;\r\n showMsg(\"success\", \"Settings saved successfully.\");\r\n });\r\n }\r\n })\r\n\r\n\r\n jQuery('.control-sidebar').on('click', '.save-settings', function (e) {\r\n e.preventDefault();\r\n var $self = jQuery(this);\r\n if (jQuery('#style_settings_form').validate().form()) {\r\n $self.button(\"loading\");\r\n saveMapData('style', function (data) {\r\n $self.button(\"reset\");\r\n showMsg(\"success\", \"Style saved successfully.\");\r\n });\r\n }\r\n })\r\n\r\n\r\n jQuery('.control-sidebar').on('click', '#save_popup_content', function () {\r\n\r\n var formdata = jQuery('#layer-form').serialize();\r\n\r\n ajaxRequest('/developer/map/save', 'post', 'json', formdata, function (data) {\r\n\r\n if (data.status == 200) {\r\n jQuery('#map_id').val(data.map_id);\r\n window.location = baseURL + \"/developer/map/edit/\" + data.map_id;\r\n //showMsg(data.action, data.msg);\r\n } else {\r\n showMsg(\"error\", data.msg);\r\n }\r\n })\r\n })\r\n\r\n// jQuery('.control-sidebar').on('change', '.popup-content-textarea', function () {\r\n// var $self = jQuery(this);\r\n// var keyname = $self.attr(\"data-keyname\");\r\n// var content = $self.val();\r\n// var index = getGSIndex(keyname);\r\n// selectedLayers[index].gs.layers.pc = content;\r\n// })\r\n\r\n sqlFormEvent();\r\n assingSettings();\r\n global_filter_event();\r\n //load settings tab \r\n})\r\njQuery(document).ready(function () {\r\n jQuery('#main-loader').removeClass(\"hide\");\r\n initLayer();\r\n\r\n\r\n $('input[type=\"checkbox\"].bg_layer_chk').each(function () {\r\n jQuery(this).bootstrapSwitch({\r\n size: 'mini',\r\n onSwitchChange: function (event, state) {\r\n event.preventDefault();\r\n var $self = jQuery(event.target);\r\n baseLayerMap($self, true);\r\n\r\n }\r\n });\r\n });\r\n\r\n\r\n jQuery('.make-switch').bootstrapSwitch({size: 'mini'});\r\n\r\n// $('.make-switch').on('switchChange.bootstrapSwitch', function (event, state) {\r\n// event.preventDefault();\r\n// var $self = jQuery(event.target);\r\n// baseLayerMap($self, true);\r\n// });\r\n\r\n// iCheck({\r\n// labelHover: false,\r\n// cursor: true,\r\n// checkboxClass: 'icheckbox_flat-blue'\r\n// }).on('ifChanged', function (event) {\r\n// //console.log(event.target);\r\n// var $self = jQuery(event.target);\r\n// baseLayerMap($self, true);\r\n// });\r\n var sqlLayers = getDetailsByAttr(selectedLayers, 'type', 2);\r\n if (sqlLayers.length == 0) {\r\n ajaxLoadSucess();\r\n }\r\n\r\n}).ajaxStop(function () {\r\n //ajaxLoadSucess();a\r\n ajaxLoadSucess();\r\n\r\n});\r\n\r\nfunction ajaxLoadSucess() {\r\n jQuery('#main-loader').addClass(\"hide\");\r\n}\r\nfunction WMSLayers($self, useStore, type) {\r\n\r\n var gsid = $self.attr(\"data-gsid\");\r\n var layername = $self.attr(\"data-layername\");\r\n var index = getIndex(DBLayerType, \"id\", type);\r\n console.log(type);\r\n //console.log(dbType.tmpl + \"_\" + gsid);\r\n var gg = gslayers[DBLayerType[index].tmpl + \"_\" + gsid][0];\r\n\r\n var g = getDetailsByAttr(gg.layers, \"Name\", layername);\r\n g = g[0];\r\n\r\n var wkname = g['Name'].split(\":\");\r\n\r\n var url;\r\n if (type == 1) {\r\n url = gg.url + wkname[0] + \"/wms\";\r\n } else {\r\n url = gg.url; //+ wkname[0] + \"/wms\";\r\n }\r\n\r\n //console.log(url); \r\n var gskey = g.l_id;\r\n\r\n console.log(\"test\");\r\n var $li = $self.parents(\"li:first\");\r\n // console.log($self.is(\":checked\"));\r\n if ($self.is(\":checked\")) {\r\n\r\n add_sentinel_date_picker(gsid, $li);\r\n\r\n if (useStore == true) {\r\n\r\n t = g;\r\n t.id = gg.id;\r\n t.unique_id = gskey;\r\n t.type = type;\r\n t.name = g['Title'];\r\n t.url = url;\r\n t.pc = \"\";\r\n t.is_dirty = 1;\r\n selectedLayers.push(t);\r\n }\r\n\r\n renderLayer(t, '');\r\n\r\n } else {\r\n $li.find('.date_sentinel_hub').remove();\r\n jQuery('#at-' + gskey).remove();\r\n var index = getLayersIndex(gskey);\r\n\r\n update_dirty(index, 3);\r\n\r\n featureGroup[gskey][g.Title].clearLayers();\r\n layerSelector.removeLayer(featureGroup[gskey][g.Title]);\r\n removeOverlayerControl(gskey);\r\n }\r\n\r\n calculateBounds();\r\n\r\n}\r\n\r\nfunction add_sentinel_date_picker(gsid, $li) {\r\n var g = getDetailsByAttr(wms_layers, \"id\", gsid);\r\n console.log($li);\r\n if (g.length > 0 && typeof g[0].wms_service_id != \"undefined\" && g[0].wms_service_id == 1) {\r\n\r\n $li.append('<a href=\"javascript:void(0)\" class=\"date_sentinel_hub\"><i class=\"fa fa-calendar\"></i></a>');\r\n jQuery('.date_sentinel_hub').datepicker({\r\n endDate: '+0d',\r\n format: \"yyyy-mm-DD\"\r\n }).on('changeDate', function (vale, date) {\r\n var $checkbox = jQuery(this).parents(\"li:first\").find('input[type=\"checkbox\"]');\r\n var id = $checkbox.attr(\"data-gsid\");\r\n var layername = $checkbox.attr(\"data-layername\");\r\n\r\n var gg = gslayers[ \"wms_\" + id][0];\r\n\r\n var g = getDetailsByAttr(gg.layers, \"Name\", layername);\r\n g = g[0];\r\n\r\n var index = getIndex(selectedLayers, 'unique_id', g.l_id);\r\n selectedLayers[index].time = vale.format('yyyy-mm-dd');\r\n render_layer_again(selectedLayers[index]);\r\n\r\n });\r\n }\r\n}\r\n\r\n\r\nfunction clearMap() {\r\n\r\n jQuery.each(selectedLayers, function (key, value) {\r\n\r\n $self = jQuery('#layer_selection_' + value.gs.id).find('input:checkbox[data-layername=\"' + value.gs.layers.Name + '\"]');\r\n var gsid = $self.attr(\"data-gsid\");\r\n var layername = $self.attr(\"data-layername\");\r\n var gg = getDetailsByAttr(layers, \"id\", gsid);\r\n gg = gg[0];\r\n var g = getDetailsByAttr(gg.layers, \"Name\", layername);\r\n g = g[0];\r\n\r\n var gskey = \"gs_\" + g['Name'] + \"_\" + gg.id;\r\n\r\n layerSelector.removeLayer(featureGroup[gskey][g.Title]);\r\n featureGroup[gskey][g.Title].clearLayers();\r\n })\r\n}\r\n\r\n\r\nfunction tinyMCEInit_Popup(textarea) {\r\n// if (textarea) {\r\n// tinyMCE.remove('#' + textarea);\r\n// }\r\n// tinyMCE.remove('#imageOverlayPopupContentInput');\r\n// tinyMCE.remove('#modalPropertyValue');\r\n// tinyMCE.remove('#edit_overlay_content');\r\n// tinyMCE.remove('#edit_legend_content');\r\n\r\n tinyMCE.init({\r\n selector: textarea,\r\n theme: \"modern\",\r\n plugins: [\r\n // \"advlist autolink lists link image charmap print preview hr anchor pagebreak\",\r\n // \"searchreplace wordcount visualblocks visualchars code fullscreen\",\r\n // \"insertdatetime media nonbreaking save table contextmenu directionality\",\r\n// \"emoticons template paste textcolor colorpicker textpattern jbimages mapshapes\"\r\n ],\r\n toolbar1: \"insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image jbimages\",\r\n toolbar2: \"print preview media | forecolor backcolor emoticons | mapshapes\",\r\n image_advtab: true,\r\n relative_urls: false,\r\n remove_script_host: false,\r\n convert_urls: true,\r\n autosave_ask_before_unload: false,\r\n extended_valid_elements: \"a[onclick|style|href|title|id|class|target]\",\r\n setup: function (ed) {\r\n ed.on('change', function (e) {\r\n\r\n var $target = jQuery(ed.targetElm);\r\n console.log($target.attr(\"data-uniqueid\"));\r\n var index = getIndex(selectedLayers, 'unique_id', $target.attr(\"data-uniqueid\"));\r\n selectedLayers[index].pc = ed.getContent();\r\n });\r\n }\r\n });\r\n}\r\n\r\nfunction baseLayerMap($self, store) {\r\n\r\n var layername = $self.attr(\"data-name\");\r\n var id = $self.val();\r\n console.log(\"bagg\");\r\n if ($self.is(\":checked\")) {\r\n \r\n console.log(\"bagg1\");\r\n \r\n if (store === true) {\r\n layerSelector.addBaseLayer(baseLayers['mymap'][layername], layername);\r\n\r\n var t = new Object;\r\n t.id = id;\r\n t.name = layername;\r\n selectedBaseLayers.push(t);\r\n baselayers_controls(layername);\r\n }\r\n\r\n } else {\r\n layerSelector.removeLayer(baseLayers['mymap'][layername]);\r\n\r\n var index = getIndex(selectedBaseLayers, \"id\", id);\r\n selectedBaseLayers.splice(index, 1);\r\n jQuery('#custom_layers [data-name=\"' + layername + '\"]').remove();\r\n }\r\n\r\n if (selectedBaseLayers.length > 0) {\r\n jQuery('#visiable-layers').find('.baselayers-control').removeClass(\"hide\");\r\n }\r\n\r\n}\r\n\r\n\r\nfunction makeFasterTree(id) {\r\n\r\n var t = new Array();\r\n\r\n $.each(db.columns, function (key, value) {\r\n\r\n var t1 = new Object;\r\n t1.text = key;\r\n t1.href = key;\r\n t1.tags = value.length;\r\n t1.nodes = new Array();\r\n\r\n $.each(value, function (key1, value1) {\r\n var t2 = new Object;\r\n t2.text = value1.column_name;\r\n t2.href = value1.column_name;\r\n //t2.tags = value1.length;\r\n\r\n t1.nodes.push(t2);\r\n })\r\n t.push(t1);\r\n })\r\n\r\n var options = {\r\n bootstrap2: false,\r\n showTags: false,\r\n levels: 1,\r\n data: t,\r\n onNodeSelected: function (event, node) {\r\n if (typeof node.parentId == \"undefined\") {\r\n $(this).treeview('toggleNodeExpanded', [node.nodeId, {silent: true}]);\r\n } else {\r\n jQuery('#query_box').val(jQuery('#query_box').val() + \" \" + node.href);\r\n }\r\n }\r\n };\r\n\r\n $('#' + id).treeview(options);\r\n\r\n jQuery('#table_tree_container').slimScroll({\r\n height: 400\r\n });\r\n\r\n jQuery('#query-help-text-btn').slimScroll({\r\n height: 400\r\n });\r\n\r\n}\r\n\r\n\r\nfunction getGeoLayer(obj, type) {\r\n\r\n var id = obj.attr(\"data-id\");\r\n console.log(obj);\r\n obj.find('.loading').removeClass(\"hide\");\r\n\r\n if (obj.find(\"ul\").length == 0) {\r\n\r\n ajaxRequest('developer/geoserver/layers/json', 'get', 'json', {id: id, type: type}, function (data) {\r\n\r\n obj.find('.loading').addClass(\"hide\");\r\n\r\n if (data.status == 200) {\r\n\r\n gslayers[ type + '_' + id] = data.result;\r\n\r\n var d = document.getElementById(\"geoserver-layers-tmpl\").innerHTML;\r\n Mustache.parse(d);\r\n jQuery(obj.attr('href')).html(Mustache.render(d, {geolayers: data.result}));\r\n\r\n\r\n var index = getIndex(DBLayerType, \"tmpl\", type);\r\n //find selected Layers based on Type Field\r\n var gg = getDetailsByType(selectedLayers, \"id\", id, \"type\", DBLayerType[index].id);\r\n var $gs = jQuery('#' + type + '-layer-collapse-' + id);\r\n\r\n jQuery.each(gg, function (key, value) {\r\n $gs.find('[data-layername=\"' + value.Name + '\"]').prop(\"checked\", true);\r\n\r\n })\r\n\r\n jQuery('.scroller').slimScroll({\r\n railVisible: true,\r\n alwaysVisible: true\r\n });\r\n // alert(\"called\");\r\n $('.gs-container input[type=\"checkbox\"].layer_chk').change(function () {\r\n // alert(\"called\");\r\n var $self = jQuery(this);\r\n WMSLayers($self, true, 1);\r\n\r\n\r\n });\r\n\r\n $('.wms-container input[type=\"checkbox\"].layer_chk').change(function () {\r\n // alert(\"called\");\r\n var $self = jQuery(this);\r\n WMSLayers($self, true, 4);\r\n\r\n\r\n });\r\n\r\n\r\n jQuery.each(gg, function (key, value) {\r\n var $li = $gs.find('[data-layername=\"' + value.Name + '\"]').parents(\"li:first\");\r\n console.log(value.name);\r\n add_sentinel_date_picker(value.id, $li);\r\n });\r\n\r\n } else {\r\n showMsg(data.error, data.msg);\r\n }\r\n\r\n });\r\n }\r\n}\r\n\r\nfunction deleteLayer(id) {\r\n var index = getLayersIndex(id);\r\n if (selectedLayers[index].type == 3) {\r\n drawingGroup.removeLayer(selectedLayers[index].layer);\r\n }\r\n jQuery('#at-' + id).remove();\r\n featureGroup[selectedLayers[index]['unique_id']][selectedLayers[index]['name']].clearLayers();\r\n layerSelector.removeLayer(featureGroup[selectedLayers[index]['unique_id']][selectedLayers[index]['name']]);\r\n\r\n update_dirty(index, 3);\r\n\r\n}\r\n\r\nfunction editATLayer(id) {\r\n\r\n var index = getLayersIndex(id);\r\n //var id = jQuery(this).val();\r\n update_dirty(index, 1);\r\n currentIndex = index;\r\n\r\n if (selectedLayers[index]['type'] == 1 || selectedLayers[index]['type'] == 4) {\r\n\r\n// var geoserver_tmpl = document.getElementById(\"geoserver-modal-tmpl\").innerHTML;\r\n// Mustache.parse(geoserver_tmpl);\r\n// jQuery('#geoserver_layer_form').html(Mustache.render(geoserver_tmpl));\r\n// jQuery('#geoserver-layer-modal').modal(\"show\");\r\n//\r\n// jQuery('#geoserver_layer_name').val(selectedLayers[index]['name']);\r\n// jQuery('#geoserver_unique_id').val(selectedLayers[index]['unique_id']);\r\n//\r\n// validateForm(jQuery('#geoserver_layer_form'));\r\n//\r\n// sqlFormChange = false;\r\n\r\n layerDialog(selectedLayers[index]);\r\n\r\n } else if (selectedLayers[index]['type'] == 2) {\r\n\r\n// var sql_tmpl = document.getElementById(\"sql-layer-modal-tmpl\").innerHTML;\r\n// Mustache.parse(sql_tmpl);\r\n// jQuery('#sql_layer_form').html(Mustache.render(sql_tmpl, {ds: ds}));\r\n// jQuery('#sql-layer-modal').modal(\"show\");\r\n//\r\n//\r\n// jQuery('#query_box').val(selectedLayers[index]['query']);\r\n//\r\n// jQuery('#query_box').val(selectedLayers[index]['query']);\r\n// jQuery('#sql_layer_name').val(selectedLayers[index]['name']);\r\n// jQuery('#sql_datasource').val(selectedLayers[index]['connection_id']);\r\n// jQuery('#sql_unique_id').val(selectedLayers[index]['unique_id']);\r\n//\r\n// jQuery('#sql_datasource').trigger(\"change\");\r\n// validateForm(jQuery('#sql_layer_form'));\r\n//\r\n// // jQuery('#sql-mode-switch').bootstrapSwitch('state', selectedLayers[index]['sql_mode'], false);\r\n//\r\n// sqlFormChange = false;\r\n// SQLModeModal(selectedLayers[index]['sqlMode']);\r\n layerDialog(selectedLayers[index]);\r\n } else if (selectedLayers[index]['type'] == 3) {\r\n layerDialog(selectedLayers[index]);\r\n }\r\n\r\n}\r\n\r\n\r\nfunction editSQLATLayer(id) {\r\n\r\n var index = getLayersIndex(id);\r\n //var id = jQuery(this).val();\r\n currentIndex = index;\r\n\r\n if (selectedLayers[index]['type'] == 1) {\r\n\r\n// var geoserver_tmpl = document.getElementById(\"geoserver-modal-tmpl\").innerHTML;\r\n// Mustache.parse(geoserver_tmpl);\r\n// jQuery('#geoserver_layer_form').html(Mustache.render(geoserver_tmpl));\r\n// jQuery('#geoserver-layer-modal').modal(\"show\");\r\n//\r\n// jQuery('#geoserver_layer_name').val(selectedLayers[index]['name']);\r\n// jQuery('#geoserver_unique_id').val(selectedLayers[index]['unique_id']);\r\n//\r\n// validateForm(jQuery('#geoserver_layer_form'));\r\n//\r\n// sqlFormChange = false;\r\n\r\n layerDialog(selectedLayers[index]);\r\n\r\n } else if (selectedLayers[index]['type'] == 2) {\r\n\r\n var sql_tmpl = document.getElementById(\"sql-layer-modal-tmpl\").innerHTML;\r\n Mustache.parse(sql_tmpl);\r\n jQuery('#sql_layer_form').html(Mustache.render(sql_tmpl, {ds: ds}));\r\n jQuery('#sql-layer-modal').modal(\"show\");\r\n\r\n\r\n jQuery('#query_box').val(selectedLayers[index]['query']);\r\n\r\n jQuery('#query_box').val(selectedLayers[index]['query']);\r\n jQuery('#sql_layer_name').val(selectedLayers[index]['name']);\r\n jQuery('#sql_datasource').val(selectedLayers[index]['connection_id']);\r\n jQuery('#sql_unique_id').val(selectedLayers[index]['unique_id']);\r\n\r\n jQuery('#sql_datasource').trigger(\"change\");\r\n validateForm(jQuery('#sql_layer_form'));\r\n\r\n // jQuery('#sql-mode-switch').bootstrapSwitch('state', selectedLayers[index]['sql_mode'], false);\r\n\r\n sqlFormChange = false;\r\n SQLModeModal(selectedLayers[index]['sqlMode']);\r\n\r\n } else if (selectedLayers[index]['type'] == 3) {\r\n layerDialog(selectedLayers[index]);\r\n }\r\n\r\n}\r\n\r\nfunction editCacheLayer(id) {\r\n\r\n var index = getLayersIndex(id);\r\n\r\n currentIndex = index;\r\n var $form = jQuery('#cache_settings_form');\r\n if (selectedLayers[index]['type'] == 1 || selectedLayers[index]['type'] == 3) {\r\n var msg = \"Cache settings not avaliable for Geoserver layers.\";\r\n if (selectedLayers[index]['type'] == 3) {\r\n msg = \"Cache settings not avaliable for FreeHand layers.\";\r\n }\r\n var geoserver_tmpl = document.getElementById(\"no-settings-msg-modal-tmpl\").innerHTML;\r\n Mustache.parse(geoserver_tmpl);\r\n $form.html(Mustache.render(geoserver_tmpl, {msg: msg}));\r\n jQuery('#cache-settings-modal').modal(\"show\");\r\n jQuery('#cache-settings-modal .btn.btn-success').addClass(\"hide\");\r\n\r\n } else if (selectedLayers[index]['type'] == 2) {\r\n\r\n var sql_tmpl = document.getElementById(\"sql-layer-cache-modal-tmpl\").innerHTML;\r\n Mustache.parse(sql_tmpl);\r\n $form.html(Mustache.render(sql_tmpl, {ds: ds}));\r\n jQuery('#cache-settings-modal').modal(\"show\");\r\n\r\n\r\n $form.find('[name=\"cache_timer\"]').val(selectedLayers[index]['cache_timer']);\r\n $form.find('[name=\"unique_id\"]').val(selectedLayers[index]['unique_id']);\r\n\r\n validateForm(jQuery('#cache_settings_form'));\r\n jQuery('#cache-settings-modal .btn.btn-success').removeClass(\"hide\");\r\n }\r\n}\r\n\r\n\r\nfunction editStyleLayer(id) {\r\n\r\n\r\n var index = getLayersIndex(id);\r\n currentIndex = index;\r\n var $form = jQuery('#style_settings_form');\r\n\r\n if (selectedLayers[index]['type'] == 1) {\r\n var geoserver_tmpl = document.getElementById(\"geoserver-style-modal-tmpl\").innerHTML;\r\n Mustache.parse(geoserver_tmpl);\r\n $form.html(Mustache.render(geoserver_tmpl));\r\n jQuery('#style-settings-modal').modal(\"show\");\r\n jQuery('#style-settings-modal .btn.btn-success').addClass(\"hide\");\r\n\r\n } else if (selectedLayers[index]['type'] == 2) {\r\n\r\n var rs_tmpl = document.getElementById('sql-layer-style-modal-tmpl').innerHTML;\r\n Mustache.parse(rs_tmpl);\r\n jQuery('#map-sidebar-container').html(Mustache.render(rs_tmpl, {t: selectedLayers[index]}));\r\n jQuery('.control-sidebar').toggleClass('control-sidebar-open');\r\n\r\n\r\n jQuery('#layer_polygon_fill_color,#layer_polygon_color').colorpicker({\r\n theme: 'bootstrap',\r\n }).on('changeColor', function (ev) {\r\n applyLiveStyle();\r\n });\r\n\r\n jQuery('#layer-polygon-styling input').change(function () {\r\n applyLiveStyle();\r\n });\r\n\r\n\r\n jQuery('#layer-marker-styling select').change(function () {\r\n applyLiveStyle();\r\n });\r\n\r\n jQuery('.sidebar_hide').toggleClass(\"hide\");\r\n return;\r\n\r\n var sql_tmpl = document.getElementById(\"sql-layer-style-modal-tmpl\").innerHTML;\r\n Mustache.parse(sql_tmpl);\r\n $form.html(Mustache.render(sql_tmpl, {ds: ds}));\r\n jQuery('#style-settings-modal').modal(\"show\");\r\n\r\n $form.find('[name=\"unique_id\"]').val(selectedLayers[index]['unique_id']);\r\n\r\n validateForm(jQuery('#style_settings_form'));\r\n jQuery('#style-settings-modal .btn.btn-success').removeClass(\"hide\");\r\n } else if (selectedLayers[index]['type'] == 3) {\r\n\r\n jQuery('#layer_polygon_fill_color,#layer_polygon_color').colorpicker({\r\n theme: 'bootstrap',\r\n }).on('changeColor', function (ev) {\r\n applyLiveStyle();\r\n });\r\n\r\n jQuery('#layer-polygon-styling input').change(function () {\r\n applyLiveStyle();\r\n });\r\n\r\n }\r\n}\r\nvar sqlFormChange = false;\r\nfunction sqlFormEvent() {\r\n\r\n jQuery('.sql-layers-btn').click(function () {\r\n currentIndex = -1;\r\n var id = jQuery(this).val();\r\n var sql_tmpl = document.getElementById(\"sql-layer-modal-tmpl\").innerHTML;\r\n Mustache.parse(sql_tmpl);\r\n jQuery('#sql_layer_form').html(Mustache.render(sql_tmpl, {ds: ds}));\r\n jQuery('#sql-layer-modal').modal(\"show\");\r\n\r\n validateForm(jQuery('#sql_layer_form'));\r\n SQLModeModal();\r\n })\r\n\r\n jQuery('#sql-layer-modal,#geometry-area-limit-modal').on('change', \"#sql_datasource\", function () {\r\n var id = jQuery(this).val();\r\n\r\n if (currentIndex != -1) {\r\n if (selectedLayers[currentIndex]['connection_id'] != id) {\r\n setupEditor();\r\n }\r\n }\r\n\r\n ajaxRequest('db/table/' + id, 'get', 'json', {}, function (data) {\r\n if (data['status'] == 200) {\r\n db.tables = data['tables'];\r\n db.columns = data['columns'];\r\n makeFasterTree('tree_5');\r\n\r\n jQuery('#drag_table').html('');\r\n jQuery('#drag_table').append(Mustache.render(table_tmpl, data));\r\n\r\n if (currentIndex != -1) {\r\n jQuery('#drag_table').val(selectedLayers[currentIndex]['table_name']);\r\n jQuery('#drag_table').trigger(\"change\");\r\n }\r\n\r\n jQuery('#drag_table').select2({\r\n width: '100%'\r\n })\r\n\r\n } else {\r\n showMsg(\"error\", data.error);\r\n }\r\n });\r\n })\r\n\r\n\r\n jQuery('#sql-layer-modal,#geometry-area-limit-modal').on('change', \"#drag_table\", function () {\r\n\r\n var table_name = jQuery(this).val();\r\n jQuery('#drag_geometry_column').html(Mustache.render(column_tmpl, {columns: db.columns[table_name]}));\r\n jQuery('#drag_other_column').html(Mustache.render(column_tmpl, {columns: db.columns[table_name]}));\r\n\r\n if (currentIndex != -1) {\r\n jQuery('#drag_geometry_column').val(selectedLayers[currentIndex]['geometry_col']);\r\n\r\n if (typeof selectedLayers[currentIndex]['other_col'] != \"undefined\" && selectedLayers[currentIndex]['other_col'].length > 0) {\r\n for (var i in selectedLayers[currentIndex]['other_col']) {\r\n var optionVal = selectedLayers[currentIndex]['other_col'][i];\r\n $(\"#drag_other_column\").find(\"option[value=\" + optionVal + \"]\").prop(\"selected\", \"selected\");\r\n }\r\n }\r\n\r\n }\r\n\r\n\r\n jQuery('#drag_other_column, #drag_geometry_column').select2({\r\n width: '100%'\r\n })\r\n })\r\n\r\n\r\n\r\n jQuery('#sql-layer-modal,#geometry-area-limit-modal').on('change', \"#geohelm_tags\", function () {\r\n var tag = jQuery(this).val();\r\n jQuery('#query_box').val(jQuery('#query_box').val() + tag);\r\n })\r\n\r\n\r\n jQuery('#sql-layer-save-btn').click(function (e) {\r\n\r\n e.preventDefault();\r\n var $self = jQuery(this);\r\n\r\n if (jQuery('#sql_layer_form').validate().form()) {\r\n //alert(sqlFormChange);\r\n if (sqlFormChange === true) {\r\n\r\n $self.button(\"loading\");\r\n var data = jQuery('#sql_layer_form').serialize();\r\n\r\n ajaxRequest('developer/map/sql/layer/save', 'post', 'json', data, function (data) {\r\n\r\n $self.button(\"reset\");\r\n\r\n if (data.status == 200) {\r\n\r\n sqlMode = jQuery('#sql-mode-switch').bootstrapSwitch('state');\r\n\r\n\r\n var unique_id = jQuery('#sql_unique_id').val(), index = -1;\r\n if (unique_id != \"\") {\r\n index = getLayersIndex(unique_id);\r\n t = selectedLayers[index];\r\n\r\n } else {\r\n t = new Object;\r\n t.unique_id = uniqId('pg');\r\n t.pc = \"\";\r\n t.type = 2;\r\n t.cache_timer = 15;\r\n\r\n }\r\n t.connection_id = jQuery('#sql_datasource').val();\r\n if (sqlMode == true) {\r\n t.query = jQuery('#query_box').val();\r\n t.sqlMode = true;\r\n } else {\r\n t.query = data.query;\r\n }\r\n\r\n t.table_name = jQuery('#drag_table').val();\r\n t.geometry_col = jQuery('#drag_geometry_column').val();\r\n t.other_col = jQuery('#drag_other_column').val();\r\n\r\n\r\n t.name = jQuery('#sql_layer_name').val();\r\n t.properties = data.columns;\r\n\r\n if (index != -1) {\r\n t.is_dirty = 2;\r\n selectedLayers[index] = t;\r\n mymap.removeLayer(featureGroup[t.unique_id][t.name]);\r\n mymap.addLayer(featureGroup[t.unique_id][t.name]);\r\n processSQLJSON(data, t);\r\n } else {\r\n t.is_dirty = 1;\r\n selectedLayers.push(t);\r\n renderLayer(t, data);\r\n\r\n }\r\n\r\n jQuery('#sql-layer-modal').modal(\"hide\");\r\n\r\n } else {\r\n showMsg(data.status, data.msg);\r\n }\r\n });\r\n } else {\r\n jQuery('#sql-layer-modal').modal(\"hide\");\r\n\r\n }\r\n\r\n }\r\n })\r\n\r\n jQuery('#geoserver-layer-save-btn').click(function (e) {\r\n\r\n e.preventDefault();\r\n var $self = jQuery(this);\r\n\r\n if (jQuery('#geoserver_layer_form').validate().form()) {\r\n\r\n //$self.button(\"loading\");\r\n\r\n var unique_id = jQuery('#geoserver_unique_id').val(), index = -1;\r\n if (unique_id != \"\") {\r\n index = getLayersIndex(unique_id);\r\n t = selectedLayers[index];\r\n } else {\r\n t = new Object;\r\n t.unique_id = uniqId('pg');\r\n t.pc = \"\";\r\n t.type = 2;\r\n }\r\n t.name = jQuery('#geoserver_layer_name').val();\r\n\r\n if (index != -1) {\r\n selectedLayers[index] = t;\r\n jQuery('#at-' + t.unique_id + \" span\").html(t.name);\r\n } else {\r\n selectedLayers.push(t);\r\n renderLayer(t, data);\r\n }\r\n\r\n jQuery('#geoserver-layer-modal').modal(\"hide\");\r\n }\r\n\r\n })\r\n\r\n jQuery('#sql-layer-modal,#geometry-area-limit-modal').on('change', '#sql_datasource, #drag_sql_datasource', function () {\r\n sqlFormChange = true;\r\n })\r\n\r\n jQuery('#sql-layer-modal, #geometry-area-limit-modal').on('change', '#query_box, #drag_geometry_column,#drag_other_column,#drag_table', function () {\r\n sqlFormChange = true;\r\n })\r\n}\r\n\r\nfunction SQLModeModal(sqlMode) {\r\n\r\n jQuery('#drag_sql_datasource,#sql_datasource').select2({\r\n width: '100%'\r\n });\r\n\r\n $('#sql-mode-switch').on('switchChange.bootstrapSwitch', function (event, state) {\r\n sqlFormChange = true;\r\n event.preventDefault();\r\n\r\n //Q.sqlMode = state;\r\n jQuery('#sql_mode').val(true);\r\n\r\n if (state === true) {\r\n jQuery('#sql-mode-container').show();\r\n jQuery('#drag-drop-container').hide();\r\n } else {\r\n jQuery('#sql-mode-container').hide();\r\n jQuery('#drag-drop-container').show();\r\n }\r\n });\r\n\r\n\r\n jQuery('#sql-mode-switch').bootstrapSwitch('state', sqlMode, false);\r\n\r\n}\r\n\r\nfunction setupEditor() {\r\n jQuery('#query_box').val('');\r\n jQuery('#drag_table').val('');\r\n jQuery('#drag_geometry_column').val('');\r\n jQuery('#drag_other_column').val('');\r\n}\r\n\r\nfunction setupGeomtryQuery() {\r\n jQuery('#query_box').val('');\r\n jQuery('#drag_table').val('');\r\n jQuery('#drag_geometry_column').val('');\r\n jQuery('#drag_other_column').val('');\r\n SQLModeModal(false);\r\n}\r\nfunction drawing_event() {\r\n\r\n var handleDrawEvent = function () {\r\n\r\n mymap.on('draw:drawstart', function (e) {\r\n draw_editStart(e);\r\n });\r\n mymap.on('draw:deletestart', function (e) {\r\n draw_editStart(e);\r\n });\r\n\r\n mymap.on('draw:editstop', function (e) {\r\n draw_editStop(e)\r\n });\r\n mymap.on('draw:drawstop', function (e) {\r\n draw_editStop(e)\r\n });\r\n mymap.on('draw:deletestop', function (e) {\r\n draw_editStop(e)\r\n });\r\n\r\n\r\n mymap.on('moveend', function (e) {\r\n updateMapCenter();\r\n });\r\n\r\n mymap.on('draw:created', function (e) {\r\n\r\n var layerPro = new Object;\r\n layerPro.lt = e.layerType;\r\n\r\n var layer = e.layer;\r\n\r\n drawingGroup.addLayer(layer);\r\n layer.on(\"click\", function () {\r\n var index = getLayerIndex1(layer);\r\n if (editMode) {\r\n\r\n layerDialog(selectedLayers[index]);\r\n\r\n setTimeout(function () {\r\n mymap.closePopup();\r\n }, 50);\r\n\r\n } else {\r\n\r\n layer.bindPopup(selectedLayers[index].pc);\r\n\r\n// if (layer instanceof L.Marker) { \r\n// var popup = L.popup();\r\n// popup.setLatLng(layer.getLatLng());\r\n// popup.setContent();\r\n// mymap.openPopup(popup);\r\n// } else {\r\n// var bounds = layer.getBounds();\r\n// var popup = L.popup();\r\n// popup.setLatLng(bounds.getCenter());\r\n// popup.setContent(selectedLayers[index].pc);\r\n// mymap.openPopup(popup);\r\n// }\r\n\r\n\r\n //openPopup(layer);\r\n // Otherwise show the content in a popup, or something.\r\n\r\n }\r\n\r\n });\r\n\r\n /* Shape Style */\r\n style = {};\r\n var layerType = \"\";\r\n if (layer instanceof L.Marker) {\r\n style.marker = new Object;\r\n style.marker.icon = '';\r\n style.marker.color = '';\r\n layerPro.marker = true;\r\n layerPro.polygon = false;\r\n\r\n } else if (layer instanceof L.MultiPolygon ||\r\n layer instanceof L.Polyline ||\r\n layer instanceof L.Rectangle ||\r\n layer instanceof L.Circle) {\r\n\r\n style.polygon = new Object;\r\n style.polygon.color = '#ff0000';\r\n style.polygon.opacity = 0.5;\r\n style.polygon.weight = 5;\r\n style.polygon.fillColor = '#ff0000';\r\n style.polygon.fillOpacity = 0.5;\r\n\r\n layer.setStyle(style.polygon);\r\n layerPro.marker = false;\r\n layerPro.polygon = true;\r\n }\r\n\r\n layerPro.layer = layer;\r\n layerPro.style = style;\r\n layerPro.type = 3;\r\n layerPro.name = \"Layer Name\";\r\n layerPro.location = \"\";\r\n layerPro.pc = \"\";\r\n layerPro.is_dirty = 1;\r\n layerPro.unique_id = uniqId('cl'); //custom layers\r\n selectedLayers.push(layerPro);\r\n layerDialog(layerPro);\r\n\r\n renderLayer(layerPro);\r\n });\r\n\r\n mymap.on('draw:editstart', function (e) {\r\n// setTimeout(function () {\r\n// var layers = drawingGroup.getLayers();\r\n// $.each(layers, function (index, layer) {\r\n// index = getLayerIndex(layer);\r\n// if (layer instanceof L.Marker) {\r\n// if (mapLayers[index].style.markerColor) {\r\n// layer.setIcon(L.AwesomeMarkers.icon(mapLayers[index].style));\r\n// }\r\n// } else if (layer instanceof L.Polyline ||\r\n// layer instanceof L.Polygon ||\r\n// layer instanceof L.Rectangle ||\r\n// layer instanceof L.Circle) {\r\n// layer.setStyle(mapLayers[index].style);\r\n// }\r\n// });\r\n// }, 50);\r\n\r\n draw_editStart();\r\n editMode = true;\r\n });\r\n\r\n mymap.on('draw:editstop', function (e) {\r\n// setTimeout(function () {\r\n// var layers = drawingGroup.getLayers();\r\n// $.each(layers, function (index, layer) {\r\n// index = getLayerIndex(layer);\r\n// if (layer instanceof L.Marker) {\r\n// if (selectedLayers[index].style.marker) {\r\n// layer.setIcon(L.AwesomeMarkers.icon(selectedLayers[index].style.marker));\r\n// }\r\n// } else if (layer instanceof L.Polyline ||\r\n// layer instanceof L.Polygon ||\r\n// layer instanceof L.Rectangle ||\r\n// layer instanceof L.Circle) {\r\n// layer.setStyle(selectedLayers[index].style.polygon);\r\n// }\r\n// });\r\n// }, 50);\r\n\r\n editMode = false;\r\n draw_editStop(e);\r\n });\r\n\r\n mymap.on('draw:deleted', function (e) {\r\n var layers = e.layers;\r\n layers.eachLayer(function (layer) {\r\n if (layer instanceof L.MultiPolygon ||\r\n layer instanceof L.Polyline ||\r\n layer instanceof L.Rectangle ||\r\n layer instanceof L.Circle ||\r\n layer instanceof L.Marker) {\r\n deleteLayer(layer.feature.properties.unique_id);\r\n }\r\n });\r\n });\r\n }\r\n handleDrawEvent();\r\n\r\n $('.leaflet-draw.leaflet-control').hide();\r\n\r\n $('#mapid > #data').show();\r\n\r\n $('#draw-polyline,#draw-polygon,#draw-rectangle,#draw-marker, #edit-edit,#edit-remove, #draw-circle').click(function (e) {\r\n if ($(this).attr('href') == \"#\") {\r\n e.preventDefault();\r\n\r\n var id = $(this).attr('id');\r\n $('.leaflet-draw-' + id)[0].click();\r\n }\r\n });\r\n}\r\n\r\nfunction draw_editStart(e) {\r\n var idx = 0;\r\n\r\n setTimeout(function () {\r\n info = $('.leaflet-draw-tooltip').text().replace('Click cancel to undo changes.', '');\r\n $('#control-tip-info').html(info);\r\n\r\n $('#control-tip-buttons').text('');\r\n $('.leaflet-draw-actions li').each(function (index) {\r\n var obj = $(this);\r\n if (obj.parent().css('display') == 'block') {\r\n var value = obj.text();\r\n var icon = '';\r\n\r\n if (/cancel/i.test(value)) {\r\n icon = 'remove';\r\n } else if (/save/i.test(value)) {\r\n icon = 'save';\r\n } else {\r\n icon = 'trash';\r\n }\r\n\r\n Actions = '<a href=\"#\" onClick=\"return tipButtonsclick(' + (idx++) + ');\" class=\"button-top drawing-icon pin-right unround button quiet icon close pad1 inline\"><i class=\"fa fa-' + icon + '\"></i> ' + obj.text() + '</a>';\r\n $('#control-tip-buttons').prepend(Actions);\r\n }\r\n });\r\n }, 100);\r\n}\r\nfunction draw_editStop(e) {\r\n $('#control-tip-info').html('Select the Shape to draw on Map or <a href=\"#\" class=\"btn btn-primary btn-xs\" onClick=\"$(\\'#data-importer\\').click(); return false;\" style=\"color:white;\">click here to import</a> gpx, json or kml.');\r\n $('#control-tip-buttons').text('');\r\n}\r\nfunction updateMapCenter() {\r\n canter = mymap.getCenter();\r\n $('input[name=latitude]').val(canter.lat);\r\n $('input[name=longitude]').val(canter.lng);\r\n\r\n $('#mapcenter').val('[' + canter.lat + ',' + canter.lng + ']');\r\n}\r\nvar autocomplete;\r\n\r\nfunction layerDialog(t) {\r\n\r\n var cs_html = document.getElementById('cl-style-modal-tmpl').innerHTML;\r\n Mustache.parse(cs_html);\r\n jQuery('#map-sidebar-container').html(Mustache.render(cs_html, {t: t, type: layerType[t.type]}));\r\n sidebar_toggle('#side-panel');\r\n tinyMCEInit_Popup('#cs-layer-popup [name=\"pc\"]');\r\n if (t.type == 2 || t.type == 3) {\r\n\r\n if (t.style.type == \"nr\" || t.style.type == \"g\") {\r\n\r\n var layers = featureGroup[t.unique_id][t.name].getLayers();\r\n var featuredata = new Array();\r\n var counter = 0;\r\n $.each(layers, function (key, val) {\r\n val.eachLayer(function (layer) {\r\n featuredata[counter++] = layer.feature.properties;\r\n });\r\n });\r\n console.log(featuredata);\r\n if (t.style.type == \"nr\") {\r\n\r\n var featuremax = _.max(featuredata, function (o) {\r\n return o[t.style.field];\r\n });\r\n var numericRange = document.getElementById(t.style.type + \"-style-selection\").innerHTML;\r\n Mustache.parse(numericRange);\r\n jQuery('#style_column_name').val(t.style.field);\r\n jQuery('#style_data_type').val(t.style.type);\r\n jQuery('#attribute-input-field').html(Mustache.render(numericRange, {max: featuremax[t.style.field]}));\r\n var tr = 0;\r\n $.each(t.style.custom, function (tr, val) {\r\n var numericRange = document.getElementById(t.style.type + \"-column-style-selection\").innerHTML;\r\n Mustache.parse(numericRange);\r\n var html = Mustache.render(numericRange, {});\r\n jQuery('#attribute-input-field table tbody').append(html);\r\n var $last = jQuery('#attribute-input-field table tbody tr:last');\r\n $last.find(\"input\").val(val.val);\r\n $last.find('select[data-name=\"markerColor\"]').val(val.style.markerColor);\r\n $last.find('select[data-name=\"icon\"]').val(val.style.icon);\r\n })\r\n\r\n } else if (t.style.type == \"g\") {\r\n\r\n var featuremax = _.groupBy(featuredata, function (o) {\r\n return parseFloat(o[t.style.field]);\r\n });\r\n var numericRange = document.getElementById(t.style.type + \"-style-selection\").innerHTML;\r\n Mustache.parse(numericRange);\r\n jQuery('#style_column_name').val(t.style.field);\r\n jQuery('#style_data_type').val(t.style.type);\r\n jQuery('#attribute-input-field').html(Mustache.render(numericRange, {max: featuremax[t.style.field]}));\r\n var tr = 0;\r\n $.each(t.style.custom, function (tr, val) {\r\n var numericRange = document.getElementById(t.style.type + \"-column-style-selection\").innerHTML;\r\n Mustache.parse(numericRange);\r\n var html = Mustache.render(numericRange, {});\r\n jQuery('#attribute-input-field table tbody').append(html);\r\n var $last = jQuery('#attribute-input-field table tbody tr:last');\r\n $last.find(\"input\").val(val.val);\r\n $last.find('select[data-name=\"markerColor\"]').val(val.style.markerColor);\r\n $last.find('select[data-name=\"icon\"]').val(val.style.icon);\r\n })\r\n\r\n }\r\n }\r\n\r\n jQuery('#layer_polygon_fill_color,#layer_polygon_color').colorpicker({\r\n theme: 'bootstrap',\r\n }).on('changeColor', function (ev) {\r\n applyLiveStyle();\r\n });\r\n jQuery('#layer-polygon-styling input').change(function () {\r\n applyLiveStyle();\r\n });\r\n jQuery('#layer-marker-styling .default-marker-style select').change(function () {\r\n applyLiveStyle();\r\n });\r\n jQuery('#layer-marker-styling').on(\"click\", \".numeric-range\", function () {\r\n var $currentTr = jQuery(this).parents(\"tr:first\");\r\n var cloneTr = $currentTr.clone();\r\n cloneTr.find('input').val('');\r\n $currentTr.after(cloneTr);\r\n })\r\n\r\n jQuery('#layer-marker-styling .custom-marker-style #style_data_type, #layer-marker-styling .custom-marker-style #style_column_name').change(function () {\r\n\r\n var columnName = jQuery('#style_column_name').val();\r\n var data_type = jQuery('#style_data_type').val();\r\n if (columnName != \"\" && data_type != \"\") {\r\n\r\n jQuery('#attribute-input-field').html('');\r\n var my_unique_id = jQuery('#map-sidebar-container [name=\"my_unique_id\"]').val();\r\n var index = getIndex(selectedLayers, 'unique_id', my_unique_id);\r\n var layers = featureGroup[selectedLayers[index].unique_id][selectedLayers[index].name].getLayers();\r\n var featuredata = new Array();\r\n var counter = 0;\r\n $.each(layers, function (key, val) {\r\n val.eachLayer(function (layer) {\r\n featuredata[counter++] = layer.feature.properties;\r\n });\r\n });\r\n if (data_type == \"nr\") {\r\n\r\n var featuremax = _.max(featuredata, function (o) {\r\n return parseFloat(o[columnName]);\r\n });\r\n var numericRange = document.getElementById(data_type + \"-style-selection\").innerHTML;\r\n Mustache.parse(numericRange);\r\n jQuery('#attribute-input-field').html(Mustache.render(numericRange, {max: featuremax[columnName]}));\r\n if (jQuery('#attribute-input-field table tboday tr').length == 0) {\r\n var numericRange = document.getElementById(\"nr-column-style-selection\").innerHTML;\r\n Mustache.parse(numericRange);\r\n var html = Mustache.render(numericRange, {});\r\n jQuery('#attribute-input-field table tbody').append(html);\r\n }\r\n\r\n } else {\r\n\r\n var featuremax = _.groupBy(featuredata, function (o) {\r\n return o[columnName];\r\n });\r\n var numericRange = document.getElementById(data_type + \"-style-selection\").innerHTML;\r\n Mustache.parse(numericRange);\r\n jQuery('#attribute-input-field').html(Mustache.render(numericRange, {max: featuremax[columnName]}));\r\n $.each(featuremax, function (tr, val) {\r\n\r\n var numericRange = document.getElementById(\"g-column-style-selection\").innerHTML;\r\n Mustache.parse(numericRange);\r\n var html = Mustache.render(numericRange, {attr: tr});\r\n jQuery('#attribute-input-field table tbody').append(html);\r\n// var $last = jQuery('#attribute-input-field table tbody tr:last');\r\n// $last.find(\"input\").val(val.range);\r\n// $last.find('select[data-name=\"markerColor\"]').val(val.style.markerColor);\r\n// $last.find('select[data-name=\"icon\"]').val(val.style.icon);\r\n })\r\n\r\n }\r\n\r\n\r\n }\r\n });\r\n var customStyle = new Array();\r\n var s = 0;\r\n jQuery('#attribute-input-field').on('change', 'table input, table select', function () {\r\n\r\n var my_unique_id = jQuery('#map-sidebar-container [name=\"my_unique_id\"]').val();\r\n var index = getIndex(selectedLayers, 'unique_id', my_unique_id);\r\n var layers = featureGroup[selectedLayers[index].unique_id][selectedLayers[index].name].getLayers();\r\n var columnName = jQuery('#style_column_name').val();\r\n var data_type = jQuery('#style_data_type').val();\r\n customStyle = new Array();\r\n s = 0;\r\n jQuery('#attribute-numeric-table tbody tr').each(function () {\r\n\r\n var $self = jQuery(this);\r\n var range = $self.find('input:text').val();\r\n var marker = {};\r\n $self.find(\"select\").each(function () {\r\n marker[jQuery(this).attr(\"data-name\")] = jQuery(this).val();\r\n });\r\n customStyle[s] = new Object;\r\n customStyle[s].val = range;\r\n customStyle[s].style = marker;\r\n s++;\r\n marker = getMarkerStyle(marker);\r\n $.each(layers, function (key, val) {\r\n val.eachLayer(function (layer) {\r\n\r\n if (data_type == \"nr\") {\r\n\r\n if (between(layer.feature.properties[columnName], range)) {\r\n layer.setIcon(L.AwesomeMarkers.icon(marker));\r\n }\r\n } else if (data_type == \"g\") {\r\n if (layer.feature.properties[columnName] == range) {\r\n layer.setIcon(L.AwesomeMarkers.icon(marker));\r\n }\r\n }\r\n\r\n });\r\n });\r\n })\r\n\r\n if (typeof selectedLayers[index].style.custom == \"undefined\") {\r\n selectedLayers[index].style.custom = new Object;\r\n }\r\n\r\n selectedLayers[index].style.custom = customStyle;\r\n selectedLayers[index].style.type = data_type;\r\n selectedLayers[index].style.field = columnName;\r\n })\r\n\r\n\r\n\r\n if (t.style.marker && typeof t.style.marker != \"undefined\") {\r\n jQuery('#layer-marker-styling select[name=\"marker_color\"]').val(t.style.marker.markerColor);\r\n jQuery('#layer-marker-styling select[name=\"marker_icon\"]').val(t.style.marker.icon);\r\n }\r\n }\r\n\r\n jQuery('#cs-layer-info input, #cs-layer-info select').change(function () {\r\n var $self = jQuery(this);\r\n var my_unique_id = jQuery('#map-sidebar-container [name=\"my_unique_id\"]').val();\r\n var index = getIndex(selectedLayers, 'unique_id', my_unique_id);\r\n selectedLayers[index][$self.attr(\"name\")] = $self.val();\r\n jQuery('#at-' + selectedLayers[index]['unique_id'] + \" span.at-text\").html(selectedLayers[index].name);\r\n });\r\n if (t.type == 3) {\r\n\r\n autocomplete = new google.maps.places.Autocomplete(document.getElementById(\"autoFillAddress\"), {types: [\"geocode\"]});\r\n google.maps.event.addListener(autocomplete, \"place_changed\", function (e) {\r\n lat = autocomplete.getPlace().geometry.location.lat();\r\n lng = autocomplete.getPlace().geometry.location.lng();\r\n var v = jQuery('#style_settings_form').find('[name=\"my_unique_id\"]').val();\r\n var index = getIndex(selectedLayers, 'unique_id', v);\r\n console.log(index);\r\n selectedLayers[index].layer.setLatLng([lat, lng]);\r\n selectedLayers[index].location = jQuery('#autoFillAddress').val();\r\n mymap.setView([lat, lng], mymap.getZoom());\r\n });\r\n }\r\n\r\n\r\n}\r\nfunction tipButtonsclick(index) {\r\n\r\n var action = undefined;\r\n $('.leaflet-draw-actions').each(function (index) {\r\n if ($(this).css('display') == 'block') {\r\n action = $(this);\r\n }\r\n });\r\n\r\n if (action) {\r\n action.find('a')[index].click();\r\n }\r\n\r\n return false;\r\n}\r\n\r\nfunction getDetailsByType(obj, key, val, key1, value1) {\r\n var objects = [];\r\n var len = obj.length;\r\n for (i = 0; i < len; i++) {\r\n if (obj[i][key] == val && obj[i][key1] == value1) {\r\n objects.push(obj[i]);\r\n }\r\n }\r\n return objects;\r\n}\r\n\r\nvar globalLastFileFormat = '';\r\nfunction initiateUpload() {\r\n\r\n if ($('#data-importer').val() == \"\") {\r\n globalLastFileFormat = '';\r\n return;\r\n }\r\n\r\n var temp = $('form#layer-form input[type=file]').val().split('.');\r\n globalLastFileFormat = temp[temp.length - 1];\r\n\r\n //progressBar = createProgressBar();\r\n var formData = new FormData($('form#layer-form')[0]);\r\n\r\n $.ajax({\r\n url: baseURL + 'developer/map/file/upload', //Server script to process data\r\n type: 'POST',\r\n xhr: function () {\r\n // Custom XMLHttpRequest\r\n var myXhr = $.ajaxSettings.xhr();\r\n if (myXhr.upload) { // Check if upload property exists\r\n myXhr.upload.addEventListener('progress', function (e) {\r\n if (e.lengthComputable) {\r\n // updateProgressBar(progressBar, Math.floor((e.loaded / e.total) * 100));\r\n }\r\n }, false); // For handling the progress of the upload\r\n }\r\n return myXhr;\r\n },\r\n success: function (data) {\r\n try {\r\n jsonData = JSON.parse(data);\r\n if (jsonData['status'] = 200) {\r\n\r\n if (jsonData['format'] == \"json\") {\r\n // processSQLJSON(jsonData);\r\n\r\n jQuery.each(jsonData.result, function (name, json) {\r\n L.geoJson(json, {\r\n onEachFeature: function (feature, layer) {\r\n\r\n console.log(feature);\r\n\r\n layer.on('click', function (e) {\r\n\r\n var c = getSQLPopupContent(feature.properties, t.pc);\r\n var bounds = layer.getBounds();\r\n var popup = L.popup();\r\n popup.setLatLng(bounds.getCenter());\r\n popup.setContent(c);\r\n mymap.openPopup(popup);\r\n\r\n return;\r\n })\r\n\r\n }\r\n }).addTo(mymap);\r\n\r\n // mymap.fitBounds(featureGroup[t.unique_id][t.name].getBounds());\r\n });\r\n\r\n } else if (jsonData['format'] == \"kml\" || jsonData['format'] == \"gpx\") {\r\n var data = new Object;\r\n var st = new Object;\r\n var t = JSON.parse(JSON.stringify(toGeoJSON[globalLastFileFormat.toLowerCase()]((new DOMParser()).parseFromString(jsonData.kmlData, 'text/xml')), null, 4));\r\n console.log(t);\r\n st.mapfig = t.features;\r\n data.geoJSON = st;\r\n // createLayers(data); \r\n\r\n L.geoJson(st, {\r\n onEachFeature: function (feature, layer) {\r\n\r\n console.log(feature);\r\n\r\n layer.on('click', function (e) {\r\n\r\n var c = getSQLPopupContent(feature.properties, t.pc);\r\n var bounds = layer.getBounds();\r\n var popup = L.popup();\r\n popup.setLatLng(bounds.getCenter());\r\n popup.setContent(c);\r\n mymap.openPopup(popup);\r\n\r\n return;\r\n })\r\n\r\n }\r\n }).addTo(mymap);\r\n }\r\n $('form#layer-form input[type=file]').val('');\r\n } else {\r\n alert(\"Invalid File\");\r\n return;\r\n }\r\n } catch (err) {\r\n console.log(err);\r\n alert(\"Invalid File\", 'error');\r\n return;\r\n }\r\n },\r\n error: function (e) {\r\n alert(\"Error While Uploading the file\", \"error\");\r\n // progressBar.close();\r\n },\r\n // Form data\r\n data: formData,\r\n //Options to tell jQuery not to process data or worry about content-type.\r\n cache: false,\r\n contentType: false,\r\n processData: false\r\n });\r\n\r\n $('form#data-importer-form input[type=file]').val('');\r\n}\r\n\r\nfunction upload_geometry_shape_file() {\r\n\r\n var formData = new FormData($('form#geometry-area-limit-form')[0]);\r\n jQuery('#geometry-area-limit-submit').button(\"loading\");\r\n $.ajax({\r\n url: baseURL + 'developer/map/shapefile/upload', //Server script to process data\r\n type: 'POST',\r\n success: function (html) {\r\n try {\r\n jQuery('#geometry-area-limit-submit').button(\"reset\");\r\n if (html.status = 200) {\r\n var index1 = getIndex(selectedLayers, 'unique_id', html.unique_id);\r\n selectedLayers[index1].boundary_id = html.boundary_id;\r\n update_dirty(index1, 2);\r\n render_layer_again(selectedLayers[index1]);\r\n jQuery('#geometry-area-limit-modal').modal(\"hide\");\r\n } else {\r\n alert(html.msg);\r\n return;\r\n }\r\n\r\n } catch (err) {\r\n console.log(err);\r\n alert(\"Invalid File\", 'error');\r\n return;\r\n }\r\n },\r\n error: function (e) {\r\n alert(\"Error While Uploading the file\", \"error\");\r\n progressBar.close();\r\n },\r\n // Form data\r\n data: formData,\r\n //Options to tell jQuery not to process data or worry about content-type.\r\n cache: false,\r\n contentType: false,\r\n processData: false\r\n });\r\n\r\n $('form#data-importer-form input[type=file]').val('');\r\n}\r\n\r\n\r\nfunction global_filter_event() {\r\n\r\n $('#add-control-popover-btn').popover({\r\n container: 'body',\r\n trigger: 'focus',\r\n html: true,\r\n placement: \"left\",\r\n title: \"Add Control\",\r\n content: jQuery('#dashboard-control-popupover').html()\r\n })\r\n\r\n jQuery('body').on(\"click\", \".global-filter-control-btn\", function () {\r\n var $self = jQuery(this);\r\n\r\n var value = $self.attr(\"data-id\");\r\n var tmpl = $self.attr(\"data-tmpl\");\r\n\r\n var m = document.getElementById(tmpl + \"-filter-tmpl\").innerHTML;\r\n\r\n Mustache.parse(m);\r\n jQuery('#filtering-form-container').html(Mustache.render(m, {}));\r\n validateForm(jQuery(\"#filtering_form\"));\r\n jQuery('#filter_id').val(value);\r\n jQuery('#global_filter_id').val(\"\");\r\n jQuery('#filtering-type-modal').modal({\r\n backdrop: 'static',\r\n keyboard: false,\r\n show: true\r\n });\r\n\r\n\r\n })\r\n\r\n jQuery('#filtering-type-modal').on('change', \"#filter_datasource\", function () {\r\n var id = jQuery(this).val();\r\n ajaxRequest('db/table/' + id, 'get', 'json', {}, function (data) {\r\n if (data['status'] == 200) {\r\n db.tables = data['tables'];\r\n db.columns = data['columns'];\r\n makeFasterTree('tree_6');\r\n } else {\r\n showMsg(\"error\", data.error);\r\n }\r\n });\r\n })\r\n\r\n jQuery('#save_filter_query').click(function () {\r\n\r\n if (jQuery('#filtering_form').validate().form()) {\r\n\r\n saveFiltering();\r\n }\r\n })\r\n\r\n global_filter_listing();\r\n\r\n\r\n\r\n jQuery('#global-filtering-modal').on('click', '.edit_report_global_filter', function () {\r\n var id = jQuery(this).attr(\"data-id\");\r\n var url = 'developer/report/global/filter/edit';\r\n var data = {\r\n \"id\": id,\r\n \"_token\": jQuery('[name=\"_token\"]').val()\r\n };\r\n ajaxRequest(url, 'post', 'json', data, function (html) {\r\n\r\n if (html['status'] == 200) {\r\n\r\n var m = document.getElementById(html.data.tmpl + \"-filter-tmpl\").innerHTML;\r\n\r\n Mustache.parse(m);\r\n jQuery('#filtering-form-container').html(Mustache.render(m, html.data));\r\n jQuery('#filter_id').val(html.data.tmpl_id);\r\n jQuery('#global_filter_id').val(html.data.id);\r\n jQuery('#filtering-type-modal').modal({\r\n backdrop: 'static',\r\n keyboard: false,\r\n show: true\r\n });\r\n if (html.data.tmpl_id == 1) {\r\n jQuery('#filter_datasource').val(html.data.connection_id);\r\n jQuery('#filter_datasource').trigger(\"change\");\r\n }\r\n jQuery('#global-filtering-modal').modal(\"hide\");\r\n\r\n } else {\r\n showMsg('error', 'Global Filter', data.msg);\r\n }\r\n })\r\n })\r\n}\r\n\r\n\r\n\r\n\r\nvar global_filtering_tbl = \"\";\r\nfunction global_filter_listing() {\r\n\r\n if (global_filtering_tbl != \"\") {\r\n global_filtering_tbl.fnDestroy();\r\n }\r\n\r\n global_filtering_tbl = jQuery('#global-filter-lists').dataTable({\r\n paging: true,\r\n \"aoColumns\": [\r\n {data: 'name', name: 'name', orderable: false, searchable: false},\r\n {data: 'variable_name', name: 'variable_name'},\r\n {data: 'gname', name: 'gname'},\r\n {data: 'action', name: 'action', orderable: false, searchable: false}\r\n ],\r\n autoWidth: false,\r\n \"bProcessing\": true,\r\n \"bServerSide\": true,\r\n \"sAjaxSource\": baseURL + \"developer/report/global/filter/lists/\" + mapid\r\n });\r\n}\r\n\r\nfunction delete_global_filter(id) {\r\n\r\n swal({\r\n title: \"Are you sure?\",\r\n text: \"This will remove layer from current map.\",\r\n type: \"warning\",\r\n showCancelButton: true,\r\n confirmButtonColor: \"#DD6B55\",\r\n confirmButtonText: \"Yes, delete it!\",\r\n cancelButtonText: \"No, cancel plx!\",\r\n closeOnConfirm: true,\r\n closeOnCancel: true\r\n },\r\n function (isConfirm) {\r\n if (isConfirm) {\r\n data = {\r\n id: id,\r\n \"_token\": jQuery('[name=\"_token\"]').val()\r\n }\r\n ajaxRequest('developer/report/global/filter/delete', 'post', 'json', data, function (data) {\r\n if (data['status'] == 200) {\r\n global_filter_listing();\r\n showMsg('success', 'Global Filter', data.msg);\r\n } else {\r\n showMsg('error', 'Global Filter', data.msg);\r\n }\r\n\r\n })\r\n }\r\n\r\n });\r\n\r\n\r\n\r\n}\r\nfunction saveFiltering() {\r\n\r\n var data = jQuery('#filtering_form, #report_type_form').serialize();\r\n ajaxRequest(\"developer/report/global/filter/save\", 'post', 'json', data, function (html) {\r\n //Metronic.unblockUI();\r\n if (html.status == 200) {\r\n window.location.reload();\r\n } else {\r\n jQuery('#notify_filter_type_html').html(html.error_msg);\r\n }\r\n });\r\n}\r\n\r\nfunction sentinel_stuff() {\r\n jQuery('#active-layers-container').on(\"click\", '.sentinel-hub-history-limit', function () {\r\n var unique_id = jQuery(this).parents(\".active-layer-action:first\").attr(\"data-id\");\r\n var index1 = getIndex(selectedLayers, 'unique_id', unique_id);\r\n\r\n var $senti = jQuery('#download-history-range-form');\r\n $senti.find('[name=\"layer_id\"]').val(selectedLayers[index1]._id);\r\n\r\n jQuery('#download-history-sentinel-limit-modal').modal(\"show\");\r\n $('#history-sentinel-datetimepicker').daterangepicker({\r\n locale: {\r\n format: 'YYYY-MM-DD'\r\n },\r\n ranges: {\r\n 'Today': [moment(), moment()],\r\n 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],\r\n 'Last 7 Days': [moment().subtract(6, 'days'), moment()],\r\n 'Last 30 Days': [moment().subtract(29, 'days'), moment()],\r\n 'This Month': [moment().startOf('month'), moment().endOf('month')],\r\n 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]\r\n },\r\n maxDate: moment().add(1, 'days')\r\n },\r\n function (start, end, label) {\r\n console.log(start.format(\"YYYY-MM-DD\"));\r\n jQuery('#download-history-range-form').find('[name=\"start_date_range\"]').val(start.format(\"YYYY-MM-DD\"));\r\n jQuery('#download-history-range-form').find('[name=\"end_date_range\"]').val(end.format(\"YYYY-MM-DD\"));\r\n\r\n }\r\n );\r\n });\r\n\r\n jQuery('#download-history-save-btn').click(function (e) {\r\n var data = jQuery('#download-history-range-form').serialize();\r\n\r\n jQuery('#download-history-save-btn').button(\"loading\");\r\n ajaxRequest('/developer/sentinel/history/range/save', 'post', 'json', data, function (data) {\r\n jQuery('#download-history-save-btn').button(\"reset\");\r\n if (data['status'] == 200) {\r\n jQuery('#download-history-sentinel-limit-modal').modal(\"hide\");\r\n showMsg('success', 'Sentinel History', data.msg);\r\n } else {\r\n showMsg('error', 'Sentinel History', data.msg);\r\n }\r\n });\r\n })\r\n}\r\n\r\n\r\nfunction calculateWindow() {\r\n\r\n // if (map.settings.fullscreen == 1) {\r\n var $window = jQuery(window);\r\n jQuery('.map-container').height($window.height());\r\n jQuery('.map-container').width($window.width());\r\n jQuery('#mapid').height($window.height());\r\n jQuery('#mapid').width($window.width());\r\n jQuery('#mapid,.map-container').css(\"width\", \"100%\");\r\n// } else {\r\n// jQuery('#mapid, .map-container').height(map.settings.height);\r\n// jQuery('#mapid, .map-container').css(\"width\", \"100%\");\r\n// }\r\n\r\n}\r\nfunction sidebar_toggle(eleid) {\r\n jQuery('.control-sidebar').removeClass('open');\r\n jQuery( eleid).addClass('open');\r\n}\r\n\r\nfunction manage_map_settings() {\r\n var $cancel_btn = $(\"#btn_setting_close\");\r\n var $save_btn = $(\"#btn_setting_save\");\r\n\r\n\r\n $save_btn.on(\"click\", function (e) {\r\n e.preventDefault();\r\n $save_btn.button(\"loading\");\r\n var data = $(\"#map_settings_form\").serialize();\r\n ajaxRequest(\"developer/map/settings/save\", 'post', 'json', data, function (html) {\r\n $save_btn.button(\"reset\");\r\n if (html.status == 200) {\r\n $cancel_btn.trigger(\"click\");\r\n showMsg(\"success\", html.msg);\r\n\r\n $(\"#map_setting_name\").val(html.data.name);\r\n $(\"#map_setting_width\").val(html.data.width);\r\n $(\"#map_setting_height\").val(html.data.height);\r\n } else {\r\n showMsg(\"error\", html.msg);\r\n }\r\n });\r\n });\r\n\r\n $cancel_btn.on(\"click\", function (e) {\r\n e.preventDefault();\r\n $save_btn.button(\"reset\");\r\n $(\"#settings-panel\").toggleClass(\"open\");\r\n });\r\n}\r\n"]} |