text: /* ============================ app_leaflet =============================*/
  
  /* Autogenerated code from Flexx. Code Subject to the BSD-2-clause license. */
  
  
  
  flexx.define("app_leaflet", ["pyscript-std.js", "flexx.ui._widget"], function (_py, flexx_ui__widget) {
  
  "use strict";
  
  var _pyfunc_zip = _py._pyfunc_zip, _pyfunc_pow = _py._pyfunc_pow, _pyfunc_reversed = _py._pyfunc_reversed, _pyfunc_dict = _py._pyfunc_dict, _pyfunc_any = _py._pyfunc_any, _pyfunc_op_equals = _py._pyfunc_op_equals, _pyfunc_list = _py._pyfunc_list, _pyfunc_enumerate = _py._pyfunc_enumerate, _pyfunc_setattr = _py._pyfunc_setattr, _pyfunc_time = _py._pyfunc_time, _pyfunc_truthy = _py._pyfunc_truthy, _pyfunc_op_instantiate = _py._pyfunc_op_instantiate, _pyfunc_perf_counter = _py._pyfunc_perf_counter, _pyfunc_int = _py._pyfunc_int, _pyfunc_float = _py._pyfunc_float, _pyfunc_sum = _py._pyfunc_sum, _pyfunc_op_mult = _py._pyfunc_op_mult, _pyfunc_sorted = _py._pyfunc_sorted, _pyfunc_filter = _py._pyfunc_filter, _pyfunc_hasattr = _py._pyfunc_hasattr, _pyfunc_op_add = _py._pyfunc_op_add, _pyfunc_bool = _py._pyfunc_bool, _pyfunc_abs = _py._pyfunc_abs, _pyfunc_op_contains = _py._pyfunc_op_contains, _pyfunc_all = _py._pyfunc_all, _pyfunc_getattr = _py._pyfunc_getattr, _pyfunc_range = _py._pyfunc_range, _pyfunc_divmod = _py._pyfunc_divmod, _pyfunc_round = _py._pyfunc_round, _pyfunc_delattr = _py._pyfunc_delattr, _pyfunc_map = _py._pyfunc_map, _pyfunc_str = _py._pyfunc_str, _pyfunc_repr = _py._pyfunc_repr;
  var _pymeth_remove = _py._pymeth_remove, _pymeth_index = _py._pymeth_index, _pymeth_capitalize = _py._pymeth_capitalize, _pymeth_isnumeric = _py._pymeth_isnumeric, _pymeth_isalpha = _py._pymeth_isalpha, _pymeth_partition = _py._pymeth_partition, _pymeth_rstrip = _py._pymeth_rstrip, _pymeth_repeat = _py._pymeth_repeat, _pymeth_setdefault = _py._pymeth_setdefault, _pymeth_islower = _py._pymeth_islower, _pymeth_casefold = _py._pymeth_casefold, _pymeth_isupper = _py._pymeth_isupper, _pymeth_swapcase = _py._pymeth_swapcase, _pymeth_extend = _py._pymeth_extend, _pymeth_lstrip = _py._pymeth_lstrip, _pymeth_clear = _py._pymeth_clear, _pymeth_isidentifier = _py._pymeth_isidentifier, _pymeth_zfill = _py._pymeth_zfill, _pymeth_popitem = _py._pymeth_popitem, _pymeth_split = _py._pymeth_split, _pymeth_reverse = _py._pymeth_reverse, _pymeth_isspace = _py._pymeth_isspace, _pymeth_rjust = _py._pymeth_rjust, _pymeth_values = _py._pymeth_values, _pymeth_sort = _py._pymeth_sort, _pymeth_copy = _py._pymeth_copy, _pymeth_endswith = _py._pymeth_endswith, _pymeth_replace = _py._pymeth_replace, _pymeth_rindex = _py._pymeth_rindex, _pymeth_rpartition = _py._pymeth_rpartition, _pymeth_title = _py._pymeth_title, _pymeth_join = _py._pymeth_join, _pymeth_splitlines = _py._pymeth_splitlines, _pymeth_rsplit = _py._pymeth_rsplit, _pymeth_startswith = _py._pymeth_startswith, _pymeth_expandtabs = _py._pymeth_expandtabs, _pymeth_keys = _py._pymeth_keys, _pymeth_append = _py._pymeth_append, _pymeth_lower = _py._pymeth_lower, _pymeth_isalnum = _py._pymeth_isalnum, _pymeth_items = _py._pymeth_items, _pymeth_count = _py._pymeth_count, _pymeth_get = _py._pymeth_get, _pymeth_translate = _py._pymeth_translate, _pymeth_center = _py._pymeth_center, _pymeth_find = _py._pymeth_find, _pymeth_update = _py._pymeth_update, _pymeth_ljust = _py._pymeth_ljust, _pymeth_istitle = _py._pymeth_istitle, _pymeth_upper = _py._pymeth_upper, _pymeth_insert = _py._pymeth_insert, _pymeth_pop = _py._pymeth_pop, _pymeth_strip = _py._pymeth_strip, _pymeth_rfind = _py._pymeth_rfind;
  
  
  
  
  
  var LeafletWidget = flexx.classes.LeafletWidget = function () {
      _pyfunc_op_instantiate(this, arguments);
  }
  LeafletWidget.prototype = Object.create(flexx.classes.Widget.prototype);
  LeafletWidget.prototype._base_class = flexx.classes.Widget.prototype;
  LeafletWidget.prototype._class_name = "LeafletWidget";
  
  LeafletWidget.prototype.__emitters__ = ["key_down", "key_press", "key_up", "mouse_down", "mouse_event", "mouse_move", "mouse_up", "mouse_wheel"];
  LeafletWidget.prototype.__handlers__ = ["_Widget__children_changed", "_Widget__container_changed", "_Widget__css_class_changed", "_Widget__icon_changed", "_Widget__make_singleton_container_widgets_work", "_Widget__style_changed", "_Widget__title_changed", "_Widget__update_tabindex", "_handle_center", "_handle_max_zoom", "_handle_min_zoom", "_handle_show_layers", "_handle_show_scale", "_handle_zoom", "_layers_changed", "_size_changed", "check_size"];
  LeafletWidget.prototype.__local_properties__ = ["parent", "size"];
  LeafletWidget.prototype.__properties__ = ["base_size", "center", "children", "container", "css_class", "flex", "icon", "parent", "pos", "show_layers", "show_scale", "size", "style", "tabindex", "title", "zoom"];
  
  LeafletWidget.prototype._handle_center = function () {
      var events;
      events = Array.prototype.slice.call(arguments);
      this.map.panTo(events[events.length -1].new_value);
      return null;
  };
  LeafletWidget.prototype._handle_center.nobind = true;
  LeafletWidget.prototype._handle_center._connection_strings = ["center"];
  
  LeafletWidget.prototype._handle_max_zoom = function () {
      var events;
      events = Array.prototype.slice.call(arguments);
      this.map.setMaxZoom(events[events.length -1].new_value);
      return null;
  };
  LeafletWidget.prototype._handle_max_zoom.nobind = true;
  LeafletWidget.prototype._handle_max_zoom._connection_strings = ["max_zoom"];
  
  LeafletWidget.prototype._handle_min_zoom = function () {
      var events;
      events = Array.prototype.slice.call(arguments);
      this.map.setMinZoom(events[events.length -1].new_value);
      return null;
  };
  LeafletWidget.prototype._handle_min_zoom.nobind = true;
  LeafletWidget.prototype._handle_min_zoom._connection_strings = ["min_zoom"];
  
  LeafletWidget.prototype._handle_show_layers = function () {
      var events;
      events = Array.prototype.slice.call(arguments);
      if (_pyfunc_truthy(events[events.length -1].new_value)) {
          this.map.addControl(this.layer_control);
      } else {
          this.map.removeControl(this.layer_control);
      }
      return null;
  };
  LeafletWidget.prototype._handle_show_layers.nobind = true;
  LeafletWidget.prototype._handle_show_layers._connection_strings = ["show_layers"];
  
  LeafletWidget.prototype._handle_show_scale = function () {
      var events;
      events = Array.prototype.slice.call(arguments);
      if (_pyfunc_truthy(events[events.length -1].new_value)) {
          this.map.addControl(this.scale);
      } else {
          this.map.removeControl(this.scale);
      }
      return null;
  };
  LeafletWidget.prototype._handle_show_scale.nobind = true;
  LeafletWidget.prototype._handle_show_scale._connection_strings = ["show_scale"];
  
  LeafletWidget.prototype._handle_zoom = function () {
      var events;
      events = Array.prototype.slice.call(arguments);
      this.map.setZoom(events[events.length -1].new_value);
      return null;
  };
  LeafletWidget.prototype._handle_zoom.nobind = true;
  LeafletWidget.prototype._handle_zoom._connection_strings = ["zoom"];
  
  LeafletWidget.prototype._init_phosphor_and_node = function () {
      this.phosphor = this._create_phosphor_widget("div");
      this.node = this.phosphor.node;
      this.mapnode = window.document.createElement("div");
      this.node.appendChild(this.mapnode);
      this.mapnode.id = "maproot";
      this.mapnode.style.position = "absolute";
      this.mapnode.style.top = "0px";
      this.mapnode.style.left = "0px";
      this.map = L.map(this.mapnode);
      this.map.on("zoomend", this.map_handle_zoom);
      this.map.on("moveend", this.map_handle_move);
      this.map.on("click", this.map_handle_mouse);
      this.map.on("dblclick", this.map_handle_mouse);
      this.layer_container = [];
      this.layer_control = L.control.layers();
      this.scale = L.control.scale({"imperial": false, "maxWidth": 200});
      L.Icon.Default.prototype.options.imagePath = "_data/shared/";
      return null;
  };
  
  LeafletWidget.prototype._layers_changed = function () {
      var events, layer, layer_name, layer_url, new_layer, stub1_seq, stub2_itr, stub3_seq, stub4_itr, stub5_tgt;
      events = Array.prototype.slice.call(arguments);
      stub1_seq = this.layer_container;
      if ((typeof stub1_seq === "object") && (!Array.isArray(stub1_seq))) {
          stub1_seq = Object.keys(stub1_seq);
      }
      for (stub2_itr = 0; stub2_itr < stub1_seq.length; stub2_itr += 1) {
          layer = stub1_seq[stub2_itr];
          this.layer_control.removeLayer(layer);
          if (_pyfunc_truthy(this.map.hasLayer(layer))) {
              this.map.removeLayer(layer);
          }
      }
      stub3_seq = events[events.length -1].new_value;
      if ((typeof stub3_seq === "object") && (!Array.isArray(stub3_seq))) {
          stub3_seq = Object.keys(stub3_seq);
      }
      for (stub4_itr = 0; stub4_itr < stub3_seq.length; stub4_itr += 1) {
          stub5_tgt = stub3_seq[stub4_itr];
          layer_url = stub5_tgt[0]; layer_name = stub5_tgt[1];
          if ((!_pyfunc_truthy(_pymeth_endswith.call(layer_url, ".png")))) {
              if ((!_pyfunc_truthy(_pymeth_endswith.call(layer_url, "/")))) {
                  layer_url=_pyfunc_op_add(layer_url, "/")
              }
              layer_url=_pyfunc_op_add(layer_url, "{z}/{x}/{y}.png")
          }
          new_layer = L.tileLayer(layer_url);
          _pymeth_append.call(this.layer_container, new_layer);
          this.map.addLayer(new_layer);
          this.layer_control.addOverlay(new_layer, layer_name);
      }
      return null;
  };
  LeafletWidget.prototype._layers_changed.nobind = true;
  LeafletWidget.prototype._layers_changed._connection_strings = ["layers"];
  
  LeafletWidget.prototype._size_changed = function () {
      var events, size;
      events = Array.prototype.slice.call(arguments);
      size = this.size;
      if (_pyfunc_truthy(_pyfunc_truthy(size[0]) || size[1])) {
          this.mapnode.style.width = size[0] + "px";
          this.mapnode.style.height = size[1] + "px";
          this.map.invalidateSize();
      }
      return null;
  };
  LeafletWidget.prototype._size_changed.nobind = true;
  LeafletWidget.prototype._size_changed._connection_strings = ["size"];
  
  LeafletWidget.prototype.center = function (center) {
      center = (center === undefined) ? [52.0, 5.5]: center;
      return [_pyfunc_float(center[0]), _pyfunc_float(center[1])];
  };
  LeafletWidget.prototype.center.nobind = true;
  LeafletWidget.prototype.center.default = [52.0, 5.5];
  LeafletWidget.prototype.center.emitter_type = "Property";
  
  LeafletWidget.prototype.map_handle_mouse = function (e) {
      var latlng, xy;
      latlng = [e.latlng.lat, e.latlng.lng];
      xy = [e.layerPoint.x, e.layerPoint.y];
      this.mouse_event(e.type, latlng, xy);
      return null;
  };
  
  LeafletWidget.prototype.map_handle_move = function (e) {
      var center, center_coord;
      center_coord = this.map.getCenter();
      center = [center_coord.lat, center_coord.lng];
      if ((!_pyfunc_op_equals(center, this.center))) {
          this.center = center;
      }
      return null;
  };
  
  LeafletWidget.prototype.map_handle_zoom = function (e) {
      var zoom;
      zoom = this.map.getZoom();
      if (_pyfunc_truthy(window.isNaN(zoom))) {
          return null;
      }
      if ((!_pyfunc_op_equals(zoom, this.zoom))) {
          this.zoom = zoom;
      }
      return null;
  };
  
  LeafletWidget.prototype.mouse_event = function (event, latlng, xy) {
      return {"event": event, "latlng": latlng, "xy": xy};
  };
  LeafletWidget.prototype.mouse_event.nobind = true;
  LeafletWidget.prototype.mouse_event.emitter_type = "Emitter";
  
  LeafletWidget.prototype.show_layers = function (show_layers) {
      show_layers = (show_layers === undefined) ? false: show_layers;
      return _pyfunc_bool(show_layers);
  };
  LeafletWidget.prototype.show_layers.nobind = true;
  LeafletWidget.prototype.show_layers.default = false;
  LeafletWidget.prototype.show_layers.emitter_type = "Property";
  
  LeafletWidget.prototype.show_scale = function (show_scale) {
      show_scale = (show_scale === undefined) ? false: show_scale;
      return _pyfunc_bool(show_scale);
  };
  LeafletWidget.prototype.show_scale.nobind = true;
  LeafletWidget.prototype.show_scale.default = false;
  LeafletWidget.prototype.show_scale.emitter_type = "Property";
  
  LeafletWidget.prototype.zoom = function (zoom) {
      zoom = (zoom === undefined) ? 8: zoom;
      return _pyfunc_int(zoom);
  };
  LeafletWidget.prototype.zoom.nobind = true;
  LeafletWidget.prototype.zoom.default = 8;
  LeafletWidget.prototype.zoom.emitter_type = "Property";
  
  
  
  var LeafletExample = flexx.classes.LeafletExample = function () {
      _pyfunc_op_instantiate(this, arguments);
  }
  LeafletExample.prototype = Object.create(flexx.classes.Widget.prototype);
  LeafletExample.prototype._base_class = flexx.classes.Widget.prototype;
  LeafletExample.prototype._class_name = "LeafletExample";
  
  LeafletExample.prototype.__emitters__ = ["key_down", "key_press", "key_up", "mouse_down", "mouse_move", "mouse_up", "mouse_wheel"];
  LeafletExample.prototype.__handlers__ = ["_Widget__children_changed", "_Widget__container_changed", "_Widget__css_class_changed", "_Widget__icon_changed", "_Widget__make_singleton_container_widgets_work", "_Widget__style_changed", "_Widget__title_changed", "_Widget__update_tabindex", "check_size", "handle_leaflet_mouse"];
  LeafletExample.prototype.__local_properties__ = ["parent", "size"];
  LeafletExample.prototype.__properties__ = ["base_size", "children", "container", "css_class", "flex", "icon", "parent", "pos", "size", "style", "tabindex", "title"];
  
  LeafletExample.prototype.handle_leaflet_mouse = function () {
      var ev, events, latlng, m;
      events = Array.prototype.slice.call(arguments);
      ev = events[events.length -1];
      latlng = _pyfunc_list(ev["latlng"]);
      if (_pyfunc_op_equals(ev["event"], "click")) {
          m = L.marker(ev["latlng"]);
          m.bindTooltip("" + latlng[0] + ", " + latlng[1] + "");
          m.addTo(this.leaflet.map);
      }
      return null;
  };
  LeafletExample.prototype.handle_leaflet_mouse.nobind = true;
  LeafletExample.prototype.handle_leaflet_mouse._connection_strings = ["leaflet.mouse_event"];
  
  
  
  return {LeafletExample: LeafletExample, LeafletWidget: LeafletWidget};
  });
  