[PLUGINS] ~gis v4.41.1 --> v4.43.1
authorLudovic CHEVALIER <ludovic.chevalier@heureux-cyclage.org>
Wed, 8 Mar 2017 10:13:23 +0000 (11:13 +0100)
committerLudovic CHEVALIER <ludovic.chevalier@heureux-cyclage.org>
Wed, 8 Mar 2017 10:13:23 +0000 (11:13 +0100)
47 files changed:
www/plugins/gis/action/gis_geocoder_rechercher.php
www/plugins/gis/gis_download.html
www/plugins/gis/gis_fonctions.php
www/plugins/gis/gis_options.php
www/plugins/gis/gis_pipelines.php
www/plugins/gis/javascript/gis.js.html
www/plugins/gis/javascript/gis_geocoder.js
www/plugins/gis/lang/gis.xml
www/plugins/gis/lang/gis_de.php
www/plugins/gis/lang/gis_en.php
www/plugins/gis/lang/gis_es.php
www/plugins/gis/lang/gis_fr.php
www/plugins/gis/lang/gis_nl.php
www/plugins/gis/lang/gis_pt_br.php [new file with mode: 0644]
www/plugins/gis/lang/gis_ru.php
www/plugins/gis/lang/gis_sk.php
www/plugins/gis/lang/paquet-gis.xml
www/plugins/gis/lang/paquet-gis_en.php
www/plugins/gis/lang/paquet-gis_es.php
www/plugins/gis/lang/paquet-gis_nl.php
www/plugins/gis/lang/paquet-gis_pt_br.php [new file with mode: 0644]
www/plugins/gis/lang/paquet-gis_ru.php
www/plugins/gis/lang/paquet-gis_sk.php
www/plugins/gis/lib/leaflet/LICENSE
www/plugins/gis/lib/leaflet/README.md
www/plugins/gis/lib/leaflet/dist/images/layers-2x.png
www/plugins/gis/lib/leaflet/dist/images/layers.png
www/plugins/gis/lib/leaflet/dist/images/marker-icon-2x.png
www/plugins/gis/lib/leaflet/dist/images/marker-icon.png
www/plugins/gis/lib/leaflet/dist/images/marker-shadow.png
www/plugins/gis/lib/leaflet/dist/leaflet-src.js
www/plugins/gis/lib/leaflet/dist/leaflet.css
www/plugins/gis/lib/leaflet/dist/leaflet.js
www/plugins/gis/lib/leaflet/plugins/Control.MiniMap.js
www/plugins/gis/lib/leaflet/plugins/Google.js [deleted file]
www/plugins/gis/lib/leaflet/plugins/Leaflet.GoogleMutant.js [new file with mode: 0644]
www/plugins/gis/lib/leaflet/plugins/Marker.Rotate.js
www/plugins/gis/lib/leaflet/plugins/leaflet-plugins.css
www/plugins/gis/lib/leaflet/plugins/leaflet-providers.js
www/plugins/gis/lib/leaflet/plugins/leaflet.markercluster-src.js
www/plugins/gis/lib/leaflet/plugins/leaflet.markercluster.css
www/plugins/gis/modeles/carte_gis.html
www/plugins/gis/modeles/carte_gis_preview.html
www/plugins/gis/paquet.xml
www/plugins/gis/prive/squelettes/contenu/gis_tous.html
www/plugins/gis/svn.revision
www/plugins/gis/tests/gis_connect_sql.php

index 0fc48fb..3e7f757 100644 (file)
@@ -1,16 +1,18 @@
 <?php
+
 if (!defined('_ECRIRE_INC_VERSION')) {
        return;
 }
+
 include_spip('inc/distant');
 
 /**
- * Proxy vers le service Nomatim d'OpenStreetMap.
+ * Proxy vers le service du geocoder
  *
  * Cette fonction permet de transmettre une requete auprès du service
- * de recherche d'adresse d'OpenStreetMap (Nomatim).
+ * de recherche d'adresse d'OpenStreetMap (Nomatim ou Photon).
  *
- * Seuls les arguments spécifiques à Nomatim sont transmis.
+ * Seuls les arguments spécifiques au service sont transmis.
  */
 function action_gis_geocoder_rechercher_dist() {
        include_spip('inc/modifier');
@@ -23,7 +25,7 @@ function action_gis_geocoder_rechercher_dist() {
        /* On filtre les arguments à renvoyer à Nomatim (liste blanche) */
        $arguments = collecter_requests(array('json_callback', 'format', 'q', 'limit', 'addressdetails', 'accept-language', 'lat', 'lon'), array());
 
-       $geocoder = defined('_GIS_GEOCODER') ? _GIS_GEOCODER : 'nominatim';
+       $geocoder = defined('_GIS_GEOCODER') ? _GIS_GEOCODER : 'photon';
 
        if (!empty($arguments) && in_array($geocoder, array('photon','nominatim'))) {
                header('Content-Type: application/json; charset=UTF-8');
index 914a7bd..bcd698a 100644 (file)
@@ -1 +1 @@
-<BOUCLE_gis(GIS){id_gis}>[(#ENV**{format}|=={kml}|?{#HTTP_HEADER{Content-Type: application/vnd.google-earth.kml+xml;charset=#CHARSET},#HTTP_HEADER{Content-Type: application/gpx+xml;charset=#CHARSET}})][(#HTTP_HEADER{Content-Disposition: attachment; filename=#TITRE|concat{.#ENV**{format}}})][(#INCLURE{fond=inclure/download_#ENV{format},id_gis})]</BOUCLE_gis>
\ No newline at end of file
+<BOUCLE_gis(GIS){id_gis}{si #VAL{inclure/download_#ENV{format}}|trouver_fond}>[(#ENV**{format}|=={kml}|?{#HTTP_HEADER{Content-Type: application/vnd.google-earth.kml+xml;charset=#CHARSET},#HTTP_HEADER{Content-Type: application/gpx+xml;charset=#CHARSET}})][(#HTTP_HEADER{Content-Disposition: attachment; filename=#TITRE|concat{.#ENV**{format}}})][(#INCLURE{fond=inclure/download_#ENV{format},id_gis})]</BOUCLE_gis>
\ No newline at end of file
index 5df9b7d..dbb3004 100755 (executable)
@@ -92,7 +92,7 @@ function distance($from, $to, $miles = false) {
  * @return string
  *             Retourne une chaine composée d'un nombre arrondi et d'une unité de mesure de distance
  **/
-function distance_en_metres($distance, $precision=2, $format_entree='km') {
+function distance_en_metres($distance, $precision = 2, $format_entree = 'km') {
        if ($distance) {
                // On passe toujours tout en kilomètres pour uniformiser
                if ($format_entree == 'm') {
@@ -102,8 +102,7 @@ function distance_en_metres($distance, $precision=2, $format_entree='km') {
                // Si c'est supérieur à 1, on reste en kilomètres
                if ($distance > 1) {
                        $unite = 'km';
-               }
-               elseif (($distance = $distance*1000) > 1) {
+               } elseif (($distance = $distance*1000) > 1) {
                        $unite = 'm';
                }
 
@@ -415,12 +414,12 @@ function gis_modele_url_json_env($env) {
 /**
  * Transforme un paramètre d'entrée en tableau
  * s'il n'en est pas déjà un.
- * 
+ *
  * Permet d'utiliser dans l'appel au modèle de carte gis
  * depuis un texte d'article des paramètres tabulaires,
  * tel que des identifiants de documents de tracés kml,
  * tel que `<carte_gis|kml=10,11,12>`
- * 
+ *
  * @example `#ENV{kml}|gis_param_to_array`
  *
  * @param string|int|array $param
index 6cf5881..19d2353 100755 (executable)
@@ -34,44 +34,20 @@ $gis_layers = array (
        ),
        'google_roadmap' => array(
                'nom' => 'Google Roadmap',
-               'layer' => 'L.Google("ROADMAP")'
+               'layer' => 'L.gridLayer.googleMutant({type:"roadmap"})'
        ),
        'google_satellite' => array(
                'nom' => 'Google Satellite',
-               'layer' => 'L.Google("SATELLITE")'
+               'layer' => 'L.gridLayer.googleMutant({type:"satellite"})'
        ),
        'google_terrain' => array(
                'nom' => 'Google Terrain',
-               'layer' => 'L.Google("TERRAIN")'
+               'layer' => 'L.gridLayer.googleMutant({type:"terrain"})'
        ),
        'bing_aerial' => array(
                'nom' => 'Bing Aerial',
                'layer' => 'L.BingLayer("'.$config['api_key_bing'].'")'
        ),
-       'thunderforest_opencyclemap' => array(
-               'nom' => 'Thunderforest OpenCycleMap',
-               'layer' => 'L.tileLayer.provider("Thunderforest.OpenCycleMap")'
-       ),
-       'thunderforest_transport' => array(
-               'nom' => 'Thunderforest Transport',
-               'layer' => 'L.tileLayer.provider("Thunderforest.Transport")'
-       ),
-       'thunderforest_landscape' => array(
-               'nom' => 'Thunderforest Landscape',
-               'layer' => 'L.tileLayer.provider("Thunderforest.Landscape")'
-       ),
-       'thunderforest_outdoors' => array(
-               'nom' => 'Thunderforest Outdoors',
-               'layer' => 'L.tileLayer.provider("Thunderforest.Outdoors")'
-       ),
-       'thunderforest_spinalmap' => array(
-               'nom' => 'Thunderforest SpinalMap',
-               'layer' => 'L.tileLayer.provider("Thunderforest.SpinalMap")'
-       ),
-       'thunderforest_pioneer' => array(
-               'nom' => 'Thunderforest Pioneer',
-               'layer' => 'L.tileLayer.provider("Thunderforest.Pioneer")'
-       ),
        'opentopomap' => array(
                'nom' => 'OpenTopoMap',
                'layer' => 'L.tileLayer.provider("OpenTopoMap")'
index 6f4056e..66d19b9 100755 (executable)
@@ -39,7 +39,7 @@ function gis_insert_head($flux) {
 
        // insertion des scripts pour google si nécessaire
        if (count(array_intersect(array('google_roadmap', 'google_satellite', 'google_terrain'), $config['layers'])) > 0) {
-               $flux .="\n".'<script type="text/javascript" src="//maps.google.com/maps/api/js?language='.$GLOBALS['spip_lang'].'&amp;key='.$config['api_key_google'].'"></script>';
+               $flux .="\n".'<script type="text/javascript" src="//maps.google.com/maps/api/js?language='.$GLOBALS['spip_lang'].'&amp;key='.(isset($config['api_key_google']) ? $config['api_key_google'] : '').'"></script>';
        }
 
        return $flux;
index cacd208..c7e36a1 100644 (file)
@@ -1,8 +1,9 @@
 #HTTP_HEADER{Content-type:text/javascript}
 
-[(#INCLURE{lib/leaflet/dist/[(#CONFIG{auto_compress_js}|=={oui}|?{'leaflet','leaflet-src'})].js})]
+[(#INCLURE{lib/leaflet/dist/leaflet-src.js})]
 
-[L.Icon.Default.imagePath = '(#CHEMIN{lib/leaflet/dist/images}|url_absolue)';]
+[(#REM) Déprécié avec Leaflet 1.0, mais nécessaire si le site utilise compresseur_embarquer_images_css ]
+[L.Icon.Default.imagePath = '(#CHEMIN{lib/leaflet/dist/images/}|url_absolue)';]
 
 (function() {
 
@@ -43,7 +44,7 @@ L.geocoderConfig = {
 ]
 
 [(#LISTE{google_roadmap,google_satellite,google_terrain}|array_intersect{#GET{layers}}|count|>{0}|oui)
-[(#INCLURE{lib/leaflet/plugins/Google.js})]
+[(#INCLURE{lib/leaflet/plugins/Leaflet.GoogleMutant.js})]
 ]
 
 [(#VAL{bing_aerial}|in_array{#GET{layers}}|oui)
index 3eec60d..c97d596 100644 (file)
@@ -181,6 +181,7 @@ L.Geocoder = L.Class.extend({
                                return_location.point = new L.LatLng(place.lat, place.lon);
                        }
                }
+               this.fire('complete', {result: return_location});
                this._user_callback(return_location);
        }
 });
index f1a2f99..961fbe2 100644 (file)
@@ -1,30 +1,33 @@
-<traduction module="gis" gestionnaire="salvatore" url="http://trad.spip.net" source="svn://zone.spip.org/spip-zone/_plugins_/gis/trunk/lang/" reference="fr">
-       <langue code="de" url="http://trad.spip.net/tradlang_module/gis?lang_cible=de" total="151" traduits="123" relire="0" modifs="2" nouveaux="26" pourcent="81.46">
-               <traducteur nom="Torsten Willmann" lien="http://trad.spip.net/auteur/torsten-willmann" />
-       </langue>
-       <langue code="en" url="http://trad.spip.net/tradlang_module/gis?lang_cible=en" total="151" traduits="151" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
-               <traducteur nom="b_b" lien="http://trad.spip.net/auteur/b_b" />
-               <traducteur nom="Benitron" lien="http://trad.spip.net/auteur/benitron" />
-               <traducteur nom="Hanjo" lien="http://trad.spip.net/auteur/hanjo" />
-               <traducteur nom="kent1" lien="http://trad.spip.net/auteur/kent1" />
-       </langue>
-       <langue code="es" url="http://trad.spip.net/tradlang_module/gis?lang_cible=es" total="151" traduits="123" relire="0" modifs="2" nouveaux="26" pourcent="81.46">
-               <traducteur nom="alf" lien="http://trad.spip.net/auteur/alf" />
-               <traducteur nom="b_b" lien="http://trad.spip.net/auteur/b_b" />
-               <traducteur nom="Raquel S. Bujaldón" lien="http://trad.spip.net/auteur/raquel-s-bujaldon" />
-               <traducteur nom="severo" lien="http://trad.spip.net/auteur/severo" />
-       </langue>
-       <langue code="fr" url="http://trad.spip.net/tradlang_module/gis?lang_cible=fr" total="151" traduits="151" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
-       </langue>
-       <langue code="nl" url="http://trad.spip.net/tradlang_module/gis?lang_cible=nl" total="151" traduits="151" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
-               <traducteur nom="b_b" lien="http://trad.spip.net/auteur/b_b" />
-               <traducteur nom="Hanjo" lien="http://trad.spip.net/auteur/hanjo" />
-       </langue>
-       <langue code="ru" url="http://trad.spip.net/tradlang_module/gis?lang_cible=ru" total="151" traduits="106" relire="0" modifs="3" nouveaux="42" pourcent="70.20">
-               <traducteur nom="Serge Markitanenko" lien="http://trad.spip.net/auteur/serge-markitanenko" />
-       </langue>
-       <langue code="sk" url="http://trad.spip.net/tradlang_module/gis?lang_cible=sk" total="151" traduits="122" relire="0" modifs="3" nouveaux="26" pourcent="80.79">
-               <traducteur nom="b_b" lien="http://trad.spip.net/auteur/b_b" />
-               <traducteur nom="jaro" lien="http://trad.spip.net/auteur/jaro" />
+<traduction module="gis" gestionnaire="salvatore" url="https://trad.spip.net" source="svn://zone.spip.org/spip-zone/_plugins_/gis/trunk/lang/" reference="fr">
+       <langue code="de" url="https://trad.spip.net/tradlang_module/gis?lang_cible=de" total="155" traduits="155" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
+               <traducteur nom="Torsten Willmann" lien="https://trad.spip.net/auteur/torsten-willmann" />
+       </langue>
+       <langue code="en" url="https://trad.spip.net/tradlang_module/gis?lang_cible=en" total="155" traduits="151" relire="0" modifs="0" nouveaux="4" pourcent="97.42">
+               <traducteur nom="b_b" lien="https://trad.spip.net/auteur/b_b" />
+               <traducteur nom="Benitron" lien="https://trad.spip.net/auteur/benitron" />
+               <traducteur nom="Hanjo" lien="https://trad.spip.net/auteur/hanjo" />
+               <traducteur nom="kent1" lien="https://trad.spip.net/auteur/kent1" />
+       </langue>
+       <langue code="es" url="https://trad.spip.net/tradlang_module/gis?lang_cible=es" total="155" traduits="123" relire="0" modifs="2" nouveaux="30" pourcent="79.35">
+               <traducteur nom="alf" lien="https://trad.spip.net/auteur/alf" />
+               <traducteur nom="b_b" lien="https://trad.spip.net/auteur/b_b" />
+               <traducteur nom="Raquel S. Bujaldón" lien="https://trad.spip.net/auteur/raquel-s-bujaldon" />
+               <traducteur nom="severo" lien="https://trad.spip.net/auteur/severo" />
+       </langue>
+       <langue code="fr" url="https://trad.spip.net/tradlang_module/gis?lang_cible=fr" total="155" traduits="155" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
+       </langue>
+       <langue code="nl" url="https://trad.spip.net/tradlang_module/gis?lang_cible=nl" total="155" traduits="151" relire="0" modifs="0" nouveaux="4" pourcent="97.42">
+               <traducteur nom="b_b" lien="https://trad.spip.net/auteur/b_b" />
+               <traducteur nom="Hanjo" lien="https://trad.spip.net/auteur/hanjo" />
+       </langue>
+       <langue code="pt_br" url="https://trad.spip.net/tradlang_module/gis?lang_cible=pt_br" total="155" traduits="155" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
+               <traducteur nom="Ricardo Porto" lien="https://trad.spip.net/auteur/ricardo-porto" />
+       </langue>
+       <langue code="ru" url="https://trad.spip.net/tradlang_module/gis?lang_cible=ru" total="155" traduits="106" relire="0" modifs="3" nouveaux="46" pourcent="68.39">
+               <traducteur nom="Serge Markitanenko" lien="https://trad.spip.net/auteur/serge-markitanenko" />
+       </langue>
+       <langue code="sk" url="https://trad.spip.net/tradlang_module/gis?lang_cible=sk" total="155" traduits="122" relire="0" modifs="3" nouveaux="30" pourcent="78.71">
+               <traducteur nom="b_b" lien="https://trad.spip.net/auteur/b_b" />
+               <traducteur nom="jaro" lien="https://trad.spip.net/auteur/jaro" />
        </langue>
 </traduction>
index 7cd9bd3..5f7691d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // This is a SPIP language file  --  Ceci est un fichier langue de SPIP
-// extrait automatiquement de http://trad.spip.net/tradlang_module/gis?lang_cible=de
+// extrait automatiquement de https://trad.spip.net/tradlang_module/gis?lang_cible=de
 // ** ne pas modifier le fichier **
 
 if (!defined('_ECRIRE_INC_VERSION')) {
@@ -14,17 +14,20 @@ $GLOBALS[$GLOBALS['idx_lang']] = array(
        'aucun_objet' => 'Kein Objekt',
 
        // B
+       'bouton_annuler_title' => 'Bearbeitung abbrechen, Änderungen werden nicht übernommen.',
+       'bouton_enregistrer_title' => 'Änderungen speichern.',
        'bouton_lier' => 'Diesen Punkt verknüpfen',
        'bouton_supprimer_gis' => 'Diesen Punkt endgültig löschen',
        'bouton_supprimer_lien' => 'Diese Verknüpfung löschen',
 
        // C
        'cfg_descr_gis' => 'Geoinformationssystem<br /><a href="http://contrib.spip.net/4189" class="spip_out">zur Dokumentation</a>.',
-       'cfg_inf_adresse' => 'Adressfelder anzeigen (Land, Satdt, Region, Adresse ...)',
+       'cfg_inf_adresse' => 'Adressfelder anzeigen (Land, Stadt, Region, Adresse ...)',
        'cfg_inf_bing' => 'Der Layer Bing Aerial benötigt einen Schlüssel zu erzeugen auf der  <a href=\'@url@\' class="spip_out">Bing Website</a>.',
        'cfg_inf_geocoder' => 'Geocoding aktivieren (Suche nach einer Adresse, Anzeige von Adressen zu den Koordinaten).',
        'cfg_inf_geolocaliser_user_html5' => 'Wenn es der Browser des Nutzers erlaubt, wird sein ungefährer Standort als Voreinstellung für die Position von Punkten genommen.',
-       'cfg_inf_google' => 'Diese API benötigt einen Schlüssel. Zu erzeugen auf der <a href=\'@url@\' class="spip_out">le GoogleMaps Seite </a>.', # MODIF
+       'cfg_inf_google' => 'Diese API benötigt einen Schlüssel. Zu erzeugen auf der <a href=\'@url@\' class="spip_out">der GoogleMaps Seite </a>.',
+       'cfg_inf_styles' => 'Zusätzliche Felder für den Stil anzeigen (Farbe, Transparenz, Dicke...)',
        'cfg_lbl_activer_objets' => 'Geotargeting für folgende Inhalte aktivieren:',
        'cfg_lbl_adresse' => 'Adressfelder anzeigen',
        'cfg_lbl_api' => 'Karten-API ',
@@ -36,19 +39,25 @@ $GLOBALS[$GLOBALS['idx_lang']] = array(
        'cfg_lbl_layer_defaut' => 'Standardlayer',
        'cfg_lbl_layers' => 'Vorgeschlagene Layer',
        'cfg_lbl_maptype' => 'Kartentyp',
+       'cfg_lbl_styles' => 'Felder für Stil anzeigen',
        'cfg_titre_gis' => 'GIS Einstellungen',
 
        // E
        'editer_gis_editer' => 'Punkt bearbeiten',
        'editer_gis_nouveau' => 'Neuen Punkt anlegen',
        'editer_gis_titre' => 'GIS Punkte',
-       'erreur_geocoder' => 'Ihre Suche ergab kein Ergebnis:', # MODIF
+       'erreur_geocoder' => 'Ihre Suche ergab kein Ergebnis:',
        'erreur_recherche_pas_resultats' => 'Kein Punkt passt zu Ihrer Suche.',
        'erreur_xmlrpc_lat_lon' => 'Länge und Breite müssen als Argumente übergeben werden.',
        'explication_api_forcee' => 'Die API wird durch ein Plugin oder Skelett erzwungen.',
+       'explication_color' => 'Linienfarbe im CSS-Format (Standardwert: #0033FF)',
+       'explication_fillcolor' => 'Füllfarbe im CSS-Format (Standardwert: vererbt von der Linienfarbe)',
+       'explication_fillopacity' => 'Transparenz der Füllung von 0 bis 1 (Standardwert: 0.2)',
        'explication_import' => 'Eine Datei im GPX oder KML - Format importieren.',
        'explication_layer_forcee' => 'Der Layer wird durch ein anderes Plugin oder Skelett erzwungen.',
        'explication_maptype_force' => 'Der Kartentyp wird durch ein anderes Plugin oder Skelett erzwungen.',
+       'explication_opacity' => 'Transparenz der Linien von 0 bis 1 (Standardwert: 0.5)',
+       'explication_weight' => 'Linienstärke (Standardwert: 5)',
 
        // F
        'formulaire_creer_gis' => 'GIS-Punkt anlegen:',
@@ -80,7 +89,10 @@ $GLOBALS[$GLOBALS['idx_lang']] = array(
        'label_adress' => 'Adresse',
        'label_code_pays' => 'Länderkürzel',
        'label_code_postal' => 'Postleitzahl',
+       'label_color' => 'Farbe',
        'label_departement' => 'Bundesland',
+       'label_fillcolor' => 'Füllfarbe',
+       'label_fillopacity' => 'Transparenz der Füllung',
        'label_import' => 'Importieren',
        'label_inserer_modele_articles' => 'verknüpft mit Artikeln',
        'label_inserer_modele_articles_sites' => 'verknüpft mit Artikeln und Websites',
@@ -113,16 +125,28 @@ $GLOBALS[$GLOBALS['idx_lang']] = array(
        'label_inserer_modele_rubriques' => 'verknüpft mit Rubriken',
        'label_inserer_modele_sites' => 'verknüpft mit Websites',
        'label_inserer_modele_titre_carte' => 'Titel der Karte',
+       'label_opacity' => 'Transparenz',
        'label_pays' => 'Land',
        'label_rechercher_address' => 'Adresse suchen',
        'label_rechercher_point' => 'Punkt suchen',
        'label_region' => 'Region',
        'label_ville' => 'Stadt',
+       'label_weight' => 'Stärke',
        'lat' => 'Breite',
        'libelle_logo_gis' => 'LOGO DES PUNKTS',
        'lien_ajouter_gis' => 'Deisen Punkt hinzufügen',
        'lon' => 'Länge',
 
+       // M
+       'message_limite_atteinte' => 'Es gibt mehr GIS-Punkte als das aktuelle Anzeigelimit.<br /> Wenn Sie alle anzeigen wollen <a href="@url@">hier klicken</a>.',
+
+       // O
+       'onglet_carte' => 'Karte',
+       'onglet_liste' => 'Liste',
+
+       // P
+       'placeholder_geocoder' => 'Eine Adresse, eine Stadt, ein Land, eine Sehenswürdigkeit...',
+
        // T
        'telecharger_gis' => 'Im Format @format@ herunterladen',
        'texte_ajouter_gis' => 'GIS Punkt hinzufügen',
@@ -133,14 +157,24 @@ $GLOBALS[$GLOBALS['idx_lang']] = array(
        'titre_bloc_creer_point' => 'Neuen Punkt verknüpfen',
        'titre_bloc_points_lies' => 'Verknüpfte Punkte',
        'titre_bloc_rechercher_point' => 'Punkt suchen',
+       'titre_limite_atteinte' => 'Anzeigelimit erreicht (@limite@)',
        'titre_nombre_utilisation' => 'Eine Verwendung',
        'titre_nombre_utilisations' => '@nb@ Verwendungen',
        'titre_nouveau_point' => 'Neuer Punkt',
        'titre_objet' => 'Ttiel',
        'toolbar_actions_title' => 'Zeichnen abbrechen',
+       'toolbar_buttons_circle' => 'Einen Kreis zeichnen',
        'toolbar_buttons_marker' => 'Einen Punkt zeichnen',
        'toolbar_buttons_polygon' => 'Ein Polygon zeichnen',
        'toolbar_buttons_polyline' => 'Eine Linie zeichnen',
+       'toolbar_buttons_rectangle' => 'Ein Rechteck zeichnen',
+       'toolbar_edit_buttons_edit' => 'Objekt bearbeiten',
+       'toolbar_edit_buttons_editdisabled' => 'Kein bearbeitbares Objekt',
+       'toolbar_edit_buttons_remove' => 'Objekt löschen',
+       'toolbar_edit_buttons_removedisabled' => 'Kein löschbares Objekt',
+       'toolbar_edit_handlers_edit_tooltip_subtext' => 'Abbrechen klicken um die Änderungen zu verwerfen.',
+       'toolbar_edit_handlers_edit_tooltip_text' => 'Die Marker verschieben, um das Objekt zu ändern.',
+       'toolbar_edit_handlers_remove_tooltip_text' => 'Zum Löschen auf das Objekt klicken',
        'toolbar_handlers_marker_tooltip_start' => 'Klicken um Marker zu setzen',
        'toolbar_handlers_polygon_tooltip_cont' => 'Klicken um das Polygonzeichnen   fortzusetzen',
        'toolbar_handlers_polygon_tooltip_end' => 'Auf den ersten Punkt klicken um das Polygon abzuschliessen',
@@ -148,6 +182,8 @@ $GLOBALS[$GLOBALS['idx_lang']] = array(
        'toolbar_handlers_polyline_tooltip_cont' => 'Klicken um die Linie fortzusetzen',
        'toolbar_handlers_polyline_tooltip_end' => 'Letzten Punkt klicken um Linie abzuschließen',
        'toolbar_handlers_polyline_tooltip_start' => 'Klicken um Linie zu beginnen',
+       'toolbar_handlers_rectangle_tooltip_start' => 'Klicken und ziehen um ein Rechteck zu zeichnen',
+       'toolbar_handlers_simpleshape_tooltip_end' => 'Maustaste loslassen um das Design abzuschliessen',
        'toolbar_undo_text' => 'Letzten Punkt löschen',
        'toolbar_undo_title' => 'Letzten Punkt löschen',
 
index 7bed0d9..ad23a9e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // This is a SPIP language file  --  Ceci est un fichier langue de SPIP
-// extrait automatiquement de http://trad.spip.net/tradlang_module/gis?lang_cible=en
+// extrait automatiquement de https://trad.spip.net/tradlang_module/gis?lang_cible=en
 // ** ne pas modifier le fichier **
 
 if (!defined('_ECRIRE_INC_VERSION')) {
index a6b3741..52f7c40 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // This is a SPIP language file  --  Ceci est un fichier langue de SPIP
-// extrait automatiquement de http://trad.spip.net/tradlang_module/gis?lang_cible=es
+// extrait automatiquement de https://trad.spip.net/tradlang_module/gis?lang_cible=es
 // ** ne pas modifier le fichier **
 
 if (!defined('_ECRIRE_INC_VERSION')) {
index 0199974..1576521 100644 (file)
@@ -135,6 +135,13 @@ $GLOBALS[$GLOBALS['idx_lang']] = array(
        'lien_ajouter_gis' => 'Ajouter ce point',
        'lon' => 'Longitude',
 
+       // M
+       'message_limite_atteinte' => 'Vous disposez de plus de points géolocalisés que la limite d’affichage actuelle.<br /> Si vous souhaitez tous les afficher, suivez <a href="@url@">ce lien</a>.',
+
+       // O
+       'onglet_carte' => 'Carte',
+       'onglet_liste' => 'Liste',
+
        // P
        'placeholder_geocoder' => 'Une adresse, une ville, un pays, un lieu touristique...',
 
@@ -148,6 +155,7 @@ $GLOBALS[$GLOBALS['idx_lang']] = array(
        'titre_bloc_creer_point' => 'Lier un nouveau point',
        'titre_bloc_points_lies' => 'Points liés',
        'titre_bloc_rechercher_point' => 'Rechercher un point',
+       'titre_limite_atteinte' => 'Limite du nombre de points affichés atteinte (@limite@)',
        'titre_nombre_utilisation' => 'Une utilisation',
        'titre_nombre_utilisations' => '@nb@ utilisations',
        'titre_nouveau_point' => 'Nouveau point',
index 47a8a47..e8a8cb8 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // This is a SPIP language file  --  Ceci est un fichier langue de SPIP
-// extrait automatiquement de http://trad.spip.net/tradlang_module/gis?lang_cible=nl
+// extrait automatiquement de https://trad.spip.net/tradlang_module/gis?lang_cible=nl
 // ** ne pas modifier le fichier **
 
 if (!defined('_ECRIRE_INC_VERSION')) {
diff --git a/www/plugins/gis/lang/gis_pt_br.php b/www/plugins/gis/lang/gis_pt_br.php
new file mode 100644 (file)
index 0000000..55949f4
--- /dev/null
@@ -0,0 +1,192 @@
+<?php
+// This is a SPIP language file  --  Ceci est un fichier langue de SPIP
+// extrait automatiquement de https://trad.spip.net/tradlang_module/gis?lang_cible=pt_br
+// ** ne pas modifier le fichier **
+
+if (!defined('_ECRIRE_INC_VERSION')) {
+       return;
+}
+
+$GLOBALS[$GLOBALS['idx_lang']] = array(
+
+       // A
+       'aucun_gis' => 'Nenhum ponto',
+       'aucun_objet' => 'Nenhum objeto',
+
+       // B
+       'bouton_annuler_title' => 'Anular a edição, descartará todas as modificações.',
+       'bouton_enregistrer_title' => 'Grave suas alterações.',
+       'bouton_lier' => 'Vincular este ponto',
+       'bouton_supprimer_gis' => 'Excluir definitivamente este ponto',
+       'bouton_supprimer_lien' => 'Excluir este vínculo',
+
+       // C
+       'cfg_descr_gis' => 'Sistema de Informações Geográficas.<br /><a href="http://contrib.spip.net/4189" class="spip_out">Acessar a documentação</a>.',
+       'cfg_inf_adresse' => 'Exibir os campos suplementares de localização (país, cidade, região, endereço...)',
+       'cfg_inf_bing' => 'A camada Bing Aerial precisa de uma chave a ser criada no <a href=\'@url@\' class="spip_out">site do Bing</a>.',
+       'cfg_inf_geocoder' => 'Ativar as funcões do geocoder (busca a partir de um endereço, recperação do endereço a partir das coordenadas).',
+       'cfg_inf_geolocaliser_user_html5' => 'Se o nevagador do usuario permitir, a sua localização geográfica aproximadaé recuperada para dar a posição ao se criar um ponto.',
+       'cfg_inf_google' => 'As camadas Google precisam de uma chave a ser criada no <a href=\'@url@\' class="spip_out">site do GoogleMaps</a>.',
+       'cfg_inf_styles' => 'Exibe os campos supplementares de estilo (cor, opacidade, espessura...)',
+       'cfg_lbl_activer_objets' => 'Ativar a geolocalização nos conteúdos:',
+       'cfg_lbl_adresse' => 'Exibir os campos de endereço',
+       'cfg_lbl_api' => 'API de cartografia',
+       'cfg_lbl_api_key_bing' => 'Chave Bing',
+       'cfg_lbl_api_key_google' => 'Chave GoogleMaps',
+       'cfg_lbl_api_microsoft' => 'Microsoft Bing',
+       'cfg_lbl_geocoder' => 'Geocoder',
+       'cfg_lbl_geolocaliser_user_html5' => 'Centrar o mapa na localização do usuário, na criação',
+       'cfg_lbl_layer_defaut' => 'Camada padrão',
+       'cfg_lbl_layers' => 'Camadas propostas',
+       'cfg_lbl_maptype' => 'Fundo cartográfico',
+       'cfg_lbl_styles' => 'Exibir os campos de estilos',
+       'cfg_titre_gis' => 'Configuração de GIS',
+
+       // E
+       'editer_gis_editer' => 'Alterar este ponto',
+       'editer_gis_nouveau' => 'Criar um novo ponto',
+       'editer_gis_titre' => 'Os pontos geolocalizados',
+       'erreur_geocoder' => 'Nenhum resultado para a sua busca',
+       'erreur_recherche_pas_resultats' => 'Nenhum ponto corresponde à busca.',
+       'erreur_xmlrpc_lat_lon' => 'A latitude e a longitude devem ser passadas em argumento',
+       'explication_api_forcee' => 'A API é imposta por um outro plugin ou gabarito.',
+       'explication_color' => 'Cor do traço no formato CSS (valor padrão: #0033FF)',
+       'explication_fillcolor' => 'Cor de fundo no formato CSS (valor padrão: herdado da cor do traço)',
+       'explication_fillopacity' => 'Opacidade do fundo de 0 à 1 (valor padrão: 0.2)',
+       'explication_import' => 'Importar um arquivo no formato GPX ou KML.',
+       'explication_layer_forcee' => 'A camada é imposta por um outro plugin ou gabarito.',
+       'explication_maptype_force' => 'O fundo cartográfico é imposto por um outro plugin ou gabarito.',
+       'explication_opacity' => 'Opacidade do traço de 0 à 1 (valor padrão: 0.5)',
+       'explication_weight' => 'Espessura do traço (valor padrão: 5)',
+
+       // F
+       'formulaire_creer_gis' => 'Criar um ponto geolocalizado:',
+       'formulaire_modifier_gis' => 'Alterar o ponto geolocalizado:',
+
+       // G
+       'gis_pluriel' => 'Pontos geolocalizados',
+       'gis_singulier' => 'Ponto geolocalizado',
+
+       // I
+       'icone_gis_tous' => 'Pontos geolocalizados',
+       'info_1_gis' => 'Um ponto geolocalizado',
+       'info_1_objet_gis' => 'Um objeto vinculado a este ponto',
+       'info_aucun_gis' => 'Nenhum ponto geolocalizado',
+       'info_aucun_objet_gis' => 'Nenhum objeto vinculado a este ponto',
+       'info_geolocalisation' => 'Géolocalização',
+       'info_id_objet' => 'N°',
+       'info_liste_gis' => 'Pontos geolocalizados',
+       'info_nb_gis' => '@nb@ pontos geolocalizados',
+       'info_nb_objets_gis' => '@nb@ objetos vinculados a este ponto',
+       'info_numero_gis' => 'Ponto número',
+       'info_objet' => 'Objeto',
+       'info_recherche_gis_zero' => 'Nenhum resultado para «@cherche_gis@».',
+       'info_supprimer_lien' => 'Desvincular',
+       'info_supprimer_liens' => 'Desvincular todos os pontos',
+       'info_voir_fiche_objet' => 'Ver a ficha',
+
+       // L
+       'label_adress' => 'Endereço',
+       'label_code_pays' => 'Código do país',
+       'label_code_postal' => 'CEP',
+       'label_color' => 'Cor',
+       'label_departement' => 'Estado',
+       'label_fillcolor' => 'Cor de fundo',
+       'label_fillopacity' => 'Opacidade de fundo',
+       'label_import' => 'Importar',
+       'label_inserer_modele_articles' => 'vinculados às matérias',
+       'label_inserer_modele_articles_sites' => 'vinculados às matérias + sites',
+       'label_inserer_modele_auteurs' => 'vinculados aos autores',
+       'label_inserer_modele_centrer_auto' => 'Sem centralização automática',
+       'label_inserer_modele_centrer_fichier' => 'Não centralizar o mapa nos arquivos KLM/GPX',
+       'label_inserer_modele_controle' => 'Ocultar os controles',
+       'label_inserer_modele_controle_type' => 'Ocultar os tipos',
+       'label_inserer_modele_description' => 'Descrição',
+       'label_inserer_modele_documents' => 'vinculados aos documentos',
+       'label_inserer_modele_echelle' => 'Escala',
+       'label_inserer_modele_fullscreen' => 'Botão tela cheia',
+       'label_inserer_modele_gpx' => 'Arquivo GPX a sobrepor',
+       'label_inserer_modele_hauteur_carte' => 'Altura do mapa',
+       'label_inserer_modele_identifiant' => 'Identificador',
+       'label_inserer_modele_identifiant_opt' => 'Identificador (opcional)',
+       'label_inserer_modele_identifiant_placeholder' => 'id_gis',
+       'label_inserer_modele_kml' => 'Arquivo KML a sobrepor',
+       'label_inserer_modele_kml_gpx' => 'id_document ou url',
+       'label_inserer_modele_largeur_carte' => 'Largura do mapa',
+       'label_inserer_modele_limite' => 'Número máximo de pontos',
+       'label_inserer_modele_localiser_visiteur' => 'Centralizar no visitante',
+       'label_inserer_modele_mini_carte' => 'Mini mapa de situação',
+       'label_inserer_modele_molette' => 'Desativar a roda do mouse',
+       'label_inserer_modele_mots' => 'vinculados às palavras',
+       'label_inserer_modele_objets' => 'Tipo de ponto(s)',
+       'label_inserer_modele_point_gis' => 'ponto único gravado',
+       'label_inserer_modele_point_libre' => 'ponto único livre',
+       'label_inserer_modele_points' => 'Cachear os pontos',
+       'label_inserer_modele_rubriques' => 'vinculados às seções',
+       'label_inserer_modele_sites' => 'vinculados aos sites',
+       'label_inserer_modele_titre_carte' => 'Título do mapa',
+       'label_opacity' => 'Opacidade',
+       'label_pays' => 'País',
+       'label_rechercher_address' => 'Buscar um endereço',
+       'label_rechercher_point' => 'Buscar um ponto',
+       'label_region' => 'Região',
+       'label_ville' => 'Cidade',
+       'label_weight' => 'Espessura',
+       'lat' => 'Latitude',
+       'libelle_logo_gis' => 'LOGO DO PONTO',
+       'lien_ajouter_gis' => 'Incluir este ponto',
+       'lon' => 'Longitude',
+
+       // M
+       'message_limite_atteinte' => 'Você dispõe de mais pontos geolocalizados do que o limite de exibição atual.<br /> Se você deseja exibir todos, clique <a href="@url@">neste link</a>.',
+
+       // O
+       'onglet_carte' => 'Mapa',
+       'onglet_liste' => 'Lista',
+
+       // P
+       'placeholder_geocoder' => 'Um endereço, uma cidade, um país, um local turístico...',
+
+       // T
+       'telecharger_gis' => 'Transferir no formato @format@',
+       'texte_ajouter_gis' => 'Incluir um ponto geolocalizado',
+       'texte_creer_associer_gis' => 'Criar e vincular um ponto geolocalizado',
+       'texte_creer_gis' => 'Criar um ponto geolocalizado',
+       'texte_modifier_gis' => 'Alterar o ponto geolocalizado',
+       'texte_voir_gis' => 'Ver o ponto geolocalizado',
+       'titre_bloc_creer_point' => 'Vincular um novo ponto',
+       'titre_bloc_points_lies' => 'Pontos vinculados',
+       'titre_bloc_rechercher_point' => 'Buscar um ponto',
+       'titre_limite_atteinte' => 'Limite do número de pontos atingido (@limite@)',
+       'titre_nombre_utilisation' => 'Uma utilização',
+       'titre_nombre_utilisations' => '@nb@ utilizações',
+       'titre_nouveau_point' => 'Novo ponto',
+       'titre_objet' => 'Título',
+       'toolbar_actions_title' => 'Anular o traçado',
+       'toolbar_buttons_circle' => 'Traçar um círculo',
+       'toolbar_buttons_marker' => 'Traçar um ponto',
+       'toolbar_buttons_polygon' => 'Traçar um polígono',
+       'toolbar_buttons_polyline' => 'Traçar uma linha',
+       'toolbar_buttons_rectangle' => 'Traçar um retângulo',
+       'toolbar_edit_buttons_edit' => 'Alterar o objeto',
+       'toolbar_edit_buttons_editdisabled' => 'Nenhum objeto alterável',
+       'toolbar_edit_buttons_remove' => 'Excuir um objeto',
+       'toolbar_edit_buttons_removedisabled' => 'Nenhum objeto a excluir',
+       'toolbar_edit_handlers_edit_tooltip_subtext' => 'Clique em Cancelar para suprimir as modificações',
+       'toolbar_edit_handlers_edit_tooltip_text' => 'Desloque as pegas ou o marcador para alterar o objeto.',
+       'toolbar_edit_handlers_remove_tooltip_text' => 'Clique num objeto para o excluir',
+       'toolbar_handlers_marker_tooltip_start' => 'Clique para posicionar o marcador',
+       'toolbar_handlers_polygon_tooltip_cont' => 'Clique para continuar a traçar o polígono',
+       'toolbar_handlers_polygon_tooltip_end' => 'Clique sobre o primeiro ponto para fechar o polígnono',
+       'toolbar_handlers_polygon_tooltip_start' => 'Clique para começar a traçar o polígono',
+       'toolbar_handlers_polyline_tooltip_cont' => 'Clique para continua a traçar a linha',
+       'toolbar_handlers_polyline_tooltip_end' => 'Clique sobre o último ponto para finalizar a linha',
+       'toolbar_handlers_polyline_tooltip_start' => 'Clique para começar a traçar a linha',
+       'toolbar_handlers_rectangle_tooltip_start' => 'Clique e arraste para traçar um retângulo',
+       'toolbar_handlers_simpleshape_tooltip_end' => 'Solte o mouse para concluir o desenho',
+       'toolbar_undo_text' => 'Excluir o último ponto',
+       'toolbar_undo_title' => 'Excluir o último ponto traçado',
+
+       // Z
+       'zoom' => 'Zoom'
+);
index 79b9a19..27e14f2 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // This is a SPIP language file  --  Ceci est un fichier langue de SPIP
-// extrait automatiquement de http://trad.spip.net/tradlang_module/gis?lang_cible=ru
+// extrait automatiquement de https://trad.spip.net/tradlang_module/gis?lang_cible=ru
 // ** ne pas modifier le fichier **
 
 if (!defined('_ECRIRE_INC_VERSION')) {
index a43eb8b..df6ce0d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // This is a SPIP language file  --  Ceci est un fichier langue de SPIP
-// extrait automatiquement de http://trad.spip.net/tradlang_module/gis?lang_cible=sk
+// extrait automatiquement de https://trad.spip.net/tradlang_module/gis?lang_cible=sk
 // ** ne pas modifier le fichier **
 
 if (!defined('_ECRIRE_INC_VERSION')) {
index 12799ff..07a03a2 100644 (file)
@@ -1,19 +1,22 @@
-<traduction module="paquet-gis" gestionnaire="salvatore" url="http://trad.spip.net" source="svn://zone.spip.org/spip-zone/_plugins_/gis/trunk/lang/" reference="fr">
-       <langue code="en" url="http://trad.spip.net/tradlang_module/paquet-gis?lang_cible=en" total="2" traduits="2" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
-               <traducteur nom="kent1" lien="http://trad.spip.net/auteur/kent1" />
+<traduction module="paquet-gis" gestionnaire="salvatore" url="https://trad.spip.net" source="svn://zone.spip.org/spip-zone/_plugins_/gis/trunk/lang/" reference="fr">
+       <langue code="en" url="https://trad.spip.net/tradlang_module/paquet-gis?lang_cible=en" total="2" traduits="2" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
+               <traducteur nom="kent1" lien="https://trad.spip.net/auteur/kent1" />
        </langue>
-       <langue code="es" url="http://trad.spip.net/tradlang_module/paquet-gis?lang_cible=es" total="2" traduits="2" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
-               <traducteur nom="Raquel S. Bujaldón" lien="http://trad.spip.net/auteur/raquel-s-bujaldon" />
+       <langue code="es" url="https://trad.spip.net/tradlang_module/paquet-gis?lang_cible=es" total="2" traduits="2" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
+               <traducteur nom="Raquel S. Bujaldón" lien="https://trad.spip.net/auteur/raquel-s-bujaldon" />
        </langue>
-       <langue code="fr" url="http://trad.spip.net/tradlang_module/paquet-gis?lang_cible=fr" total="2" traduits="2" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
+       <langue code="fr" url="https://trad.spip.net/tradlang_module/paquet-gis?lang_cible=fr" total="2" traduits="2" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
        </langue>
-       <langue code="nl" url="http://trad.spip.net/tradlang_module/paquet-gis?lang_cible=nl" total="2" traduits="2" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
-               <traducteur nom="Hanjo" lien="http://trad.spip.net/auteur/hanjo" />
+       <langue code="nl" url="https://trad.spip.net/tradlang_module/paquet-gis?lang_cible=nl" total="2" traduits="2" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
+               <traducteur nom="Hanjo" lien="https://trad.spip.net/auteur/hanjo" />
        </langue>
-       <langue code="ru" url="http://trad.spip.net/tradlang_module/paquet-gis?lang_cible=ru" total="2" traduits="2" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
-               <traducteur nom="Serge Markitanenko" lien="http://trad.spip.net/auteur/serge-markitanenko" />
+       <langue code="pt_br" url="https://trad.spip.net/tradlang_module/paquet-gis?lang_cible=pt_br" total="2" traduits="2" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
+               <traducteur nom="Ricardo Porto" lien="https://trad.spip.net/auteur/ricardo-porto" />
        </langue>
-       <langue code="sk" url="http://trad.spip.net/tradlang_module/paquet-gis?lang_cible=sk" total="2" traduits="2" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
-               <traducteur nom="jaro" lien="http://trad.spip.net/auteur/jaro" />
+       <langue code="ru" url="https://trad.spip.net/tradlang_module/paquet-gis?lang_cible=ru" total="2" traduits="2" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
+               <traducteur nom="Serge Markitanenko" lien="https://trad.spip.net/auteur/serge-markitanenko" />
+       </langue>
+       <langue code="sk" url="https://trad.spip.net/tradlang_module/paquet-gis?lang_cible=sk" total="2" traduits="2" relire="0" modifs="0" nouveaux="0" pourcent="100.00">
+               <traducteur nom="jaro" lien="https://trad.spip.net/auteur/jaro" />
        </langue>
 </traduction>
index a88581b..5479599 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // This is a SPIP language file  --  Ceci est un fichier langue de SPIP
-// extrait automatiquement de http://trad.spip.net/tradlang_module/paquet-gis?lang_cible=en
+// extrait automatiquement de https://trad.spip.net/tradlang_module/paquet-gis?lang_cible=en
 // ** ne pas modifier le fichier **
 
 if (!defined('_ECRIRE_INC_VERSION')) {
index 2bf3e49..16df07d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // This is a SPIP language file  --  Ceci est un fichier langue de SPIP
-// extrait automatiquement de http://trad.spip.net/tradlang_module/paquet-gis?lang_cible=es
+// extrait automatiquement de https://trad.spip.net/tradlang_module/paquet-gis?lang_cible=es
 // ** ne pas modifier le fichier **
 
 if (!defined('_ECRIRE_INC_VERSION')) {
index e9bf901..8ae3e7f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // This is a SPIP language file  --  Ceci est un fichier langue de SPIP
-// extrait automatiquement de http://trad.spip.net/tradlang_module/paquet-gis?lang_cible=nl
+// extrait automatiquement de https://trad.spip.net/tradlang_module/paquet-gis?lang_cible=nl
 // ** ne pas modifier le fichier **
 
 if (!defined('_ECRIRE_INC_VERSION')) {
diff --git a/www/plugins/gis/lang/paquet-gis_pt_br.php b/www/plugins/gis/lang/paquet-gis_pt_br.php
new file mode 100644 (file)
index 0000000..88e8192
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+// This is a SPIP language file  --  Ceci est un fichier langue de SPIP
+// extrait automatiquement de https://trad.spip.net/tradlang_module/paquet-gis?lang_cible=pt_br
+// ** ne pas modifier le fichier **
+
+if (!defined('_ECRIRE_INC_VERSION')) {
+       return;
+}
+
+$GLOBALS[$GLOBALS['idx_lang']] = array(
+
+       // G
+       'gis_description' => 'Este plugin permite criar pontos geolocalizados que podem ser vinculados aos objetos do SPIP para exibí-los em mapas no seu site. Os mapas podem usar os mosaicos de diferentes fornecedores, graças à biblioteca Leaflet.',
+       'gis_slogan' => 'Sistema de informaç¬oes geográficas.'
+);
index 0e5298c..af1a7fc 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // This is a SPIP language file  --  Ceci est un fichier langue de SPIP
-// extrait automatiquement de http://trad.spip.net/tradlang_module/paquet-gis?lang_cible=ru
+// extrait automatiquement de https://trad.spip.net/tradlang_module/paquet-gis?lang_cible=ru
 // ** ne pas modifier le fichier **
 
 if (!defined('_ECRIRE_INC_VERSION')) {
index b31feb1..76e1191 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // This is a SPIP language file  --  Ceci est un fichier langue de SPIP
-// extrait automatiquement de http://trad.spip.net/tradlang_module/paquet-gis?lang_cible=sk
+// extrait automatiquement de https://trad.spip.net/tradlang_module/paquet-gis?lang_cible=sk
 // ** ne pas modifier le fichier **
 
 if (!defined('_ECRIRE_INC_VERSION')) {
index 46cd121..9a246c9 100644 (file)
@@ -1,4 +1,4 @@
-Copyright (c) 2010-2013, Vladimir Agafonkin\r
+Copyright (c) 2010-2016, Vladimir Agafonkin\r
 Copyright (c) 2010-2011, CloudMade\r
 All rights reserved.\r
 \r
index 9d512e1..24ee9d5 100644 (file)
@@ -9,16 +9,16 @@
 * [Bing.js](https://github.com/shramov/leaflet-plugins/blob/master/layer/tile/Bing.js)\r
 * [Control.FullScreen.js](https://github.com/brunob/leaflet.fullscreen/blob/master/Control.FullScreen.js)\r
 * [Control.MiniMap.js](https://github.com/Norkart/Leaflet-MiniMap/blob/master/src/Control.MiniMap.js)\r
-* [Google.js](https://github.com/shramov/leaflet-plugins/blob/master/layer/tile/Google.js)\r
+* [Leaflet.GoogleMutant.js](https://gitlab.com/IvanSanchez/Leaflet.GridLayer.GoogleMutant/blob/master/Leaflet.GoogleMutant.js)\r
 * [GPX.js](https://github.com/shramov/leaflet-plugins/blob/master/layer/vector/GPX.js)\r
 * [GPX.Speed.js](https://github.com/shramov/leaflet-plugins/blob/master/layer/vector/GPX.Speed.js)\r
 * images\r
        * mixed from all sources\r
 * [KML.js](https://github.com/shramov/leaflet-plugins/blob/master/layer/vector/KML.js)\r
 * leaflet.markercluster.css\r
-       * [MarkerCluster.css](https://github.com/Leaflet/Leaflet.markercluster/blob/leaflet-0.7/dist/MarkerCluster.css)\r
-       * [MarkerCluster.Default.css](https://github.com/Leaflet/Leaflet.markercluster/blob/leaflet-0.7/dist/MarkerCluster.Default.css)\r
-* [leaflet.markercluster-src.js](https://github.com/Leaflet/Leaflet.markercluster/blob/leaflet-0.7/dist/leaflet.markercluster-src.js)\r
+       * [MarkerCluster.css](https://github.com/Leaflet/Leaflet.markercluster/blob/v1.0.0/dist/MarkerCluster.css)\r
+       * [MarkerCluster.Default.css](https://github.com/Leaflet/Leaflet.markercluster/blob/v1.0.0/dist/MarkerCluster.Default.css)\r
+* [leaflet.markercluster-src.js](https://github.com/Leaflet/Leaflet.markercluster/blob/v1.0.0/dist/leaflet.markercluster-src.js)\r
 * leaflet-plugins.css\r
        * [Control.FullScreen.css](https://github.com/brunob/leaflet.fullscreen/blob/master/Control.FullScreen.css)\r
        * [Control.MiniMap.css](https://github.com/Norkart/Leaflet-MiniMap/blob/master/src/Control.MiniMap.css)\r
index a2cf7f9..200c333 100644 (file)
Binary files a/www/plugins/gis/lib/leaflet/dist/images/layers-2x.png and b/www/plugins/gis/lib/leaflet/dist/images/layers-2x.png differ
index bca0a0e..1a72e57 100644 (file)
Binary files a/www/plugins/gis/lib/leaflet/dist/images/layers.png and b/www/plugins/gis/lib/leaflet/dist/images/layers.png differ
index 0015b64..e4abba3 100644 (file)
Binary files a/www/plugins/gis/lib/leaflet/dist/images/marker-icon-2x.png and b/www/plugins/gis/lib/leaflet/dist/images/marker-icon-2x.png differ
index e2e9f75..950edf2 100644 (file)
Binary files a/www/plugins/gis/lib/leaflet/dist/images/marker-icon.png and b/www/plugins/gis/lib/leaflet/dist/images/marker-icon.png differ
index d1e773c..9fd2979 100644 (file)
Binary files a/www/plugins/gis/lib/leaflet/dist/images/marker-shadow.png and b/www/plugins/gis/lib/leaflet/dist/images/marker-shadow.png differ
index 721ddfb..c31aa03 100644 (file)
@@ -1,13 +1,22 @@
 /*
- Leaflet, a JavaScript library for mobile-friendly interactive maps. http://leafletjs.com
- (c) 2010-2013, Vladimir Agafonkin
- (c) 2010-2011, CloudMade
+ Leaflet 1.0.3+ed36a04, a JS library for interactive maps. http://leafletjs.com
+ (c) 2010-2016 Vladimir Agafonkin, (c) 2010-2011 CloudMade
 */
 (function (window, document, undefined) {\r
-var oldL = window.L,\r
-    L = {};\r
+var L = {\r
+       version: "1.0.3+ed36a04"\r
+};\r
+\r
+function expose() {\r
+       var oldL = window.L;\r
+\r
+       L.noConflict = function () {\r
+               window.L = oldL;\r
+               return this;\r
+       };\r
 \r
-L.version = '0.7.7';\r
+       window.L = L;\r
+}\r
 \r
 // define Leaflet for Node module pattern loaders, including Browserify\r
 if (typeof module === 'object' && typeof module.exports === 'object') {\r
@@ -19,114 +28,160 @@ if (typeof module === 'object' && typeof module.exports === 'object') {
 }\r
 \r
 // define Leaflet as a global L variable, saving the original L to restore later if needed\r
-\r
-L.noConflict = function () {\r
-       window.L = oldL;\r
-       return this;\r
-};\r
-\r
-window.L = L;\r
+if (typeof window !== 'undefined') {\r
+       expose();\r
+}\r
+
 
 
 /*\r
- * L.Util contains various utility functions used throughout Leaflet code.\r
+ * @namespace Util\r
+ *\r
+ * Various utility functions, used by Leaflet internally.\r
  */\r
 \r
 L.Util = {\r
-       extend: function (dest) { // (Object[, Object, ...]) ->\r
-               var sources = Array.prototype.slice.call(arguments, 1),\r
-                   i, j, len, src;\r
 \r
-               for (j = 0, len = sources.length; j < len; j++) {\r
-                       src = sources[j] || {};\r
+       // @function extend(dest: Object, src?: Object): Object\r
+       // Merges the properties of the `src` object (or multiple objects) into `dest` object and returns the latter. Has an `L.extend` shortcut.\r
+       extend: function (dest) {\r
+               var i, j, len, src;\r
+\r
+               for (j = 1, len = arguments.length; j < len; j++) {\r
+                       src = arguments[j];\r
                        for (i in src) {\r
-                               if (src.hasOwnProperty(i)) {\r
-                                       dest[i] = src[i];\r
-                               }\r
+                               dest[i] = src[i];\r
                        }\r
                }\r
                return dest;\r
        },\r
 \r
-       bind: function (fn, obj) { // (Function, Object) -> Function\r
-               var args = arguments.length > 2 ? Array.prototype.slice.call(arguments, 2) : null;\r
-               return function () {\r
-                       return fn.apply(obj, args || arguments);\r
-               };\r
-       },\r
-\r
-       stamp: (function () {\r
-               var lastId = 0,\r
-                   key = '_leaflet_id';\r
-               return function (obj) {\r
-                       obj[key] = obj[key] || ++lastId;\r
-                       return obj[key];\r
+       // @function create(proto: Object, properties?: Object): Object\r
+       // Compatibility polyfill for [Object.create](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/create)\r
+       create: Object.create || (function () {\r
+               function F() {}\r
+               return function (proto) {\r
+                       F.prototype = proto;\r
+                       return new F();\r
                };\r
-       }()),\r
+       })(),\r
 \r
-       invokeEach: function (obj, method, context) {\r
-               var i, args;\r
+       // @function bind(fn: Function, …): Function\r
+       // Returns a new function bound to the arguments passed, like [Function.prototype.bind](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).\r
+       // Has a `L.bind()` shortcut.\r
+       bind: function (fn, obj) {\r
+               var slice = Array.prototype.slice;\r
 \r
-               if (typeof obj === 'object') {\r
-                       args = Array.prototype.slice.call(arguments, 3);\r
-\r
-                       for (i in obj) {\r
-                               method.apply(context, [i, obj[i]].concat(args));\r
-                       }\r
-                       return true;\r
+               if (fn.bind) {\r
+                       return fn.bind.apply(fn, slice.call(arguments, 1));\r
                }\r
 \r
-               return false;\r
-       },\r
+               var args = slice.call(arguments, 2);\r
 \r
-       limitExecByInterval: function (fn, time, context) {\r
-               var lock, execOnUnlock;\r
-\r
-               return function wrapperFn() {\r
-                       var args = arguments;\r
+               return function () {\r
+                       return fn.apply(obj, args.length ? args.concat(slice.call(arguments)) : arguments);\r
+               };\r
+       },\r
 \r
-                       if (lock) {\r
-                               execOnUnlock = true;\r
-                               return;\r
+       // @function stamp(obj: Object): Number\r
+       // Returns the unique ID of an object, assiging it one if it doesn't have it.\r
+       stamp: function (obj) {\r
+               /*eslint-disable */\r
+               obj._leaflet_id = obj._leaflet_id || ++L.Util.lastId;\r
+               return obj._leaflet_id;\r
+               /*eslint-enable */\r
+       },\r
+\r
+       // @property lastId: Number\r
+       // Last unique ID used by [`stamp()`](#util-stamp)\r
+       lastId: 0,\r
+\r
+       // @function throttle(fn: Function, time: Number, context: Object): Function\r
+       // Returns a function which executes function `fn` with the given scope `context`\r
+       // (so that the `this` keyword refers to `context` inside `fn`'s code). The function\r
+       // `fn` will be called no more than one time per given amount of `time`. The arguments\r
+       // received by the bound function will be any arguments passed when binding the\r
+       // function, followed by any arguments passed when invoking the bound function.\r
+       // Has an `L.bind` shortcut.\r
+       throttle: function (fn, time, context) {\r
+               var lock, args, wrapperFn, later;\r
+\r
+               later = function () {\r
+                       // reset lock and call if queued\r
+                       lock = false;\r
+                       if (args) {\r
+                               wrapperFn.apply(context, args);\r
+                               args = false;\r
                        }\r
+               };\r
 \r
-                       lock = true;\r
-\r
-                       setTimeout(function () {\r
-                               lock = false;\r
-\r
-                               if (execOnUnlock) {\r
-                                       wrapperFn.apply(context, args);\r
-                                       execOnUnlock = false;\r
-                               }\r
-                       }, time);\r
+               wrapperFn = function () {\r
+                       if (lock) {\r
+                               // called too soon, queue to call later\r
+                               args = arguments;\r
 \r
-                       fn.apply(context, args);\r
+                       } else {\r
+                               // call and lock until later\r
+                               fn.apply(context, arguments);\r
+                               setTimeout(later, time);\r
+                               lock = true;\r
+                       }\r
                };\r
+\r
+               return wrapperFn;\r
        },\r
 \r
-       falseFn: function () {\r
-               return false;\r
+       // @function wrapNum(num: Number, range: Number[], includeMax?: Boolean): Number\r
+       // Returns the number `num` modulo `range` in such a way so it lies within\r
+       // `range[0]` and `range[1]`. The returned value will be always smaller than\r
+       // `range[1]` unless `includeMax` is set to `true`.\r
+       wrapNum: function (x, range, includeMax) {\r
+               var max = range[1],\r
+                   min = range[0],\r
+                   d = max - min;\r
+               return x === max && includeMax ? x : ((x - min) % d + d) % d + min;\r
        },\r
 \r
+       // @function falseFn(): Function\r
+       // Returns a function which always returns `false`.\r
+       falseFn: function () { return false; },\r
+\r
+       // @function formatNum(num: Number, digits?: Number): Number\r
+       // Returns the number `num` rounded to `digits` decimals, or to 5 decimals by default.\r
        formatNum: function (num, digits) {\r
                var pow = Math.pow(10, digits || 5);\r
                return Math.round(num * pow) / pow;\r
        },\r
 \r
+       // @function trim(str: String): String\r
+       // Compatibility polyfill for [String.prototype.trim](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim)\r
        trim: function (str) {\r
                return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');\r
        },\r
 \r
+       // @function splitWords(str: String): String[]\r
+       // Trims and splits the string on whitespace and returns the array of parts.\r
        splitWords: function (str) {\r
                return L.Util.trim(str).split(/\s+/);\r
        },\r
 \r
+       // @function setOptions(obj: Object, options: Object): Object\r
+       // Merges the given properties to the `options` of the `obj` object, returning the resulting options. See `Class options`. Has an `L.setOptions` shortcut.\r
        setOptions: function (obj, options) {\r
-               obj.options = L.extend({}, obj.options, options);\r
+               if (!obj.hasOwnProperty('options')) {\r
+                       obj.options = obj.options ? L.Util.create(obj.options) : {};\r
+               }\r
+               for (var i in options) {\r
+                       obj.options[i] = options[i];\r
+               }\r
                return obj.options;\r
        },\r
 \r
+       // @function getParamString(obj: Object, existingUrl?: String, uppercase?: Boolean): String\r
+       // Converts an object into a parameter URL string, e.g. `{a: "foo", b: "bar"}`\r
+       // translates to `'?a=foo&b=bar'`. If `existingUrl` is set, the parameters will\r
+       // be appended at the end. If `uppercase` is `true`, the parameter names will\r
+       // be uppercased (e.g. `'?A=foo&B=bar'`)\r
        getParamString: function (obj, existingUrl, uppercase) {\r
                var params = [];\r
                for (var i in obj) {\r
@@ -134,11 +189,19 @@ L.Util = {
                }\r
                return ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&');\r
        },\r
+\r
+       // @function template(str: String, data: Object): String\r
+       // Simple templating facility, accepts a template string of the form `'Hello {a}, {b}'`\r
+       // and a data object like `{a: 'foo', b: 'bar'}`, returns evaluated string\r
+       // `('Hello foo, bar')`. You can also specify functions instead of strings for\r
+       // data values — they will be evaluated passing `data` as an argument.\r
        template: function (str, data) {\r
-               return str.replace(/\{ *([\w_]+) *\}/g, function (str, key) {\r
+               return str.replace(L.Util.templateRe, function (str, key) {\r
                        var value = data[key];\r
+\r
                        if (value === undefined) {\r
                                throw new Error('No value provided for variable ' + str);\r
+\r
                        } else if (typeof value === 'function') {\r
                                value = value(data);\r
                        }\r
@@ -146,30 +209,40 @@ L.Util = {
                });\r
        },\r
 \r
+       templateRe: /\{ *([\w_\-]+) *\}/g,\r
+\r
+       // @function isArray(obj): Boolean\r
+       // Compatibility polyfill for [Array.isArray](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray)\r
        isArray: Array.isArray || function (obj) {\r
                return (Object.prototype.toString.call(obj) === '[object Array]');\r
        },\r
 \r
+       // @function indexOf(array: Array, el: Object): Number\r
+       // Compatibility polyfill for [Array.prototype.indexOf](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)\r
+       indexOf: function (array, el) {\r
+               for (var i = 0; i < array.length; i++) {\r
+                       if (array[i] === el) { return i; }\r
+               }\r
+               return -1;\r
+       },\r
+\r
+       // @property emptyImageUrl: String\r
+       // Data URI string containing a base64-encoded empty GIF image.\r
+       // Used as a hack to free memory from unused images on WebKit-powered\r
+       // mobile devices (by setting image `src` to this string).\r
        emptyImageUrl: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='\r
 };\r
 \r
 (function () {\r
-\r
        // inspired by http://paulirish.com/2011/requestanimationframe-for-smart-animating/\r
 \r
        function getPrefixed(name) {\r
-               var i, fn,\r
-                   prefixes = ['webkit', 'moz', 'o', 'ms'];\r
-\r
-               for (i = 0; i < prefixes.length && !fn; i++) {\r
-                       fn = window[prefixes[i] + name];\r
-               }\r
-\r
-               return fn;\r
+               return window['webkit' + name] || window['moz' + name] || window['ms' + name];\r
        }\r
 \r
        var lastTime = 0;\r
 \r
+       // fallback for IE 7-8\r
        function timeoutDefer(fn) {\r
                var time = +new Date(),\r
                    timeToCall = Math.max(0, 16 - (time - lastTime));\r
@@ -178,32 +251,33 @@ L.Util = {
                return window.setTimeout(fn, timeToCall);\r
        }\r
 \r
-       var requestFn = window.requestAnimationFrame ||\r
-               getPrefixed('RequestAnimationFrame') || timeoutDefer;\r
+       var requestFn = window.requestAnimationFrame || getPrefixed('RequestAnimationFrame') || timeoutDefer,\r
+           cancelFn = window.cancelAnimationFrame || getPrefixed('CancelAnimationFrame') ||\r
+                      getPrefixed('CancelRequestAnimationFrame') || function (id) { window.clearTimeout(id); };\r
 \r
-       var cancelFn = window.cancelAnimationFrame ||\r
-               getPrefixed('CancelAnimationFrame') ||\r
-               getPrefixed('CancelRequestAnimationFrame') ||\r
-               function (id) { window.clearTimeout(id); };\r
-\r
-\r
-       L.Util.requestAnimFrame = function (fn, context, immediate, element) {\r
-               fn = L.bind(fn, context);\r
 \r
+       // @function requestAnimFrame(fn: Function, context?: Object, immediate?: Boolean): Number\r
+       // Schedules `fn` to be executed when the browser repaints. `fn` is bound to\r
+       // `context` if given. When `immediate` is set, `fn` is called immediately if\r
+       // the browser doesn't have native support for\r
+       // [`window.requestAnimationFrame`](https://developer.mozilla.org/docs/Web/API/window/requestAnimationFrame),\r
+       // otherwise it's delayed. Returns a request ID that can be used to cancel the request.\r
+       L.Util.requestAnimFrame = function (fn, context, immediate) {\r
                if (immediate && requestFn === timeoutDefer) {\r
-                       fn();\r
+                       fn.call(context);\r
                } else {\r
-                       return requestFn.call(window, fn, element);\r
+                       return requestFn.call(window, L.bind(fn, context));\r
                }\r
        };\r
 \r
+       // @function cancelAnimFrame(id: Number): undefined\r
+       // Cancels a previous `requestAnimFrame`. See also [window.cancelAnimationFrame](https://developer.mozilla.org/docs/Web/API/window/cancelAnimationFrame).\r
        L.Util.cancelAnimFrame = function (id) {\r
                if (id) {\r
                        cancelFn.call(window, id);\r
                }\r
        };\r
-\r
-}());\r
+})();\r
 \r
 // shortcuts for most used utility functions\r
 L.extend = L.Util.extend;\r
@@ -212,16 +286,23 @@ L.stamp = L.Util.stamp;
 L.setOptions = L.Util.setOptions;\r
 
 
-/*\r
- * L.Class powers the OOP facilities of the library.\r
- * Thanks to John Resig and Dean Edwards for inspiration!\r
- */\r
+
+\r
+// @class Class\r
+// @aka L.Class\r
+\r
+// @section\r
+// @uninheritable\r
+\r
+// Thanks to John Resig and Dean Edwards for inspiration!\r
 \r
 L.Class = function () {};\r
 \r
 L.Class.extend = function (props) {\r
 \r
-       // extended class with the new prototype\r
+       // @function extend(props: Object): Function\r
+       // [Extends the current class](#class-inheritance) given the properties to be included.\r
+       // Returns a Javascript function that is a class constructor (to be called with `new`).\r
        var NewClass = function () {\r
 \r
                // call the constructor\r
@@ -230,21 +311,17 @@ L.Class.extend = function (props) {
                }\r
 \r
                // call all constructor hooks\r
-               if (this._initHooks) {\r
-                       this.callInitHooks();\r
-               }\r
+               this.callInitHooks();\r
        };\r
 \r
-       // instantiate class without calling constructor\r
-       var F = function () {};\r
-       F.prototype = this.prototype;\r
+       var parentProto = NewClass.__super__ = this.prototype;\r
 \r
-       var proto = new F();\r
+       var proto = L.Util.create(parentProto);\r
        proto.constructor = NewClass;\r
 \r
        NewClass.prototype = proto;\r
 \r
-       //inherit parent's statics\r
+       // inherit parent's statics\r
        for (var i in this) {\r
                if (this.hasOwnProperty(i) && i !== 'prototype') {\r
                        NewClass[i] = this[i];\r
@@ -264,8 +341,8 @@ L.Class.extend = function (props) {
        }\r
 \r
        // merge options\r
-       if (props.options && proto.options) {\r
-               props.options = L.extend({}, proto.options, props.options);\r
+       if (proto.options) {\r
+               props.options = L.Util.extend(L.Util.create(proto.options), props.options);\r
        }\r
 \r
        // mix given properties into the prototype\r
@@ -273,17 +350,13 @@ L.Class.extend = function (props) {
 \r
        proto._initHooks = [];\r
 \r
-       var parent = this;\r
-       // jshint camelcase: false\r
-       NewClass.__super__ = parent.prototype;\r
-\r
        // add method for calling all hooks\r
        proto.callInitHooks = function () {\r
 \r
                if (this._initHooksCalled) { return; }\r
 \r
-               if (parent.prototype.callInitHooks) {\r
-                       parent.prototype.callInitHooks.call(this);\r
+               if (parentProto.callInitHooks) {\r
+                       parentProto.callInitHooks.call(this);\r
                }\r
 \r
                this._initHooksCalled = true;\r
@@ -297,17 +370,22 @@ L.Class.extend = function (props) {
 };\r
 \r
 \r
-// method for adding properties to prototype\r
+// @function include(properties: Object): this\r
+// [Includes a mixin](#class-includes) into the current class.\r
 L.Class.include = function (props) {\r
        L.extend(this.prototype, props);\r
+       return this;\r
 };\r
 \r
-// merge new default options to the Class\r
+// @function mergeOptions(options: Object): this\r
+// [Merges `options`](#class-options) into the defaults of the class.\r
 L.Class.mergeOptions = function (options) {\r
        L.extend(this.prototype.options, options);\r
+       return this;\r
 };\r
 \r
-// add a constructor hook\r
+// @function addInitHook(fn: Function): this\r
+// Adds a [constructor hook](#class-constructor-hooks) to the class.\r
 L.Class.addInitHook = function (fn) { // (Function) || (String, args...)\r
        var args = Array.prototype.slice.call(arguments, 1);\r
 \r
@@ -317,284 +395,508 @@ L.Class.addInitHook = function (fn) { // (Function) || (String, args...)
 \r
        this.prototype._initHooks = this.prototype._initHooks || [];\r
        this.prototype._initHooks.push(init);\r
+       return this;\r
 };\r
 
 
+
 /*\r
- * L.Mixin.Events is used to add custom events functionality to Leaflet classes.\r
+ * @class Evented\r
+ * @aka L.Evented\r
+ * @inherits Class\r
+ *\r
+ * A set of methods shared between event-powered classes (like `Map` and `Marker`). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map to fire `'click'` event).\r
+ *\r
+ * @example\r
+ *\r
+ * ```js\r
+ * map.on('click', function(e) {\r
+ *     alert(e.latlng);\r
+ * } );\r
+ * ```\r
+ *\r
+ * Leaflet deals with event listeners by reference, so if you want to add a listener and then remove it, define it as a function:\r
+ *\r
+ * ```js\r
+ * function onClick(e) { ... }\r
+ *\r
+ * map.on('click', onClick);\r
+ * map.off('click', onClick);\r
+ * ```\r
  */\r
 \r
-var eventsKey = '_leaflet_events';\r
-\r
-L.Mixin = {};\r
 \r
-L.Mixin.Events = {\r
+L.Evented = L.Class.extend({\r
 \r
-       addEventListener: function (types, fn, context) { // (String, Function[, Object]) or (Object[, Object])\r
+       /* @method on(type: String, fn: Function, context?: Object): this\r
+        * Adds a listener function (`fn`) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. `'click dblclick'`).\r
+        *\r
+        * @alternative\r
+        * @method on(eventMap: Object): this\r
+        * Adds a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}`\r
+        */\r
+       on: function (types, fn, context) {\r
 \r
                // types can be a map of types/handlers\r
-               if (L.Util.invokeEach(types, this.addEventListener, this, fn, context)) { return this; }\r
-\r
-               var events = this[eventsKey] = this[eventsKey] || {},\r
-                   contextId = context && context !== this && L.stamp(context),\r
-                   i, len, event, type, indexKey, indexLenKey, typeIndex;\r
-\r
-               // types can be a string of space-separated words\r
-               types = L.Util.splitWords(types);\r
-\r
-               for (i = 0, len = types.length; i < len; i++) {\r
-                       event = {\r
-                               action: fn,\r
-                               context: context || this\r
-                       };\r
-                       type = types[i];\r
+               if (typeof types === 'object') {\r
+                       for (var type in types) {\r
+                               // we don't process space-separated events here for performance;\r
+                               // it's a hot path since Layer uses the on(obj) syntax\r
+                               this._on(type, types[type], fn);\r
+                       }\r
 \r
-                       if (contextId) {\r
-                               // store listeners of a particular context in a separate hash (if it has an id)\r
-                               // gives a major performance boost when removing thousands of map layers\r
+               } else {\r
+                       // types can be a string of space-separated words\r
+                       types = L.Util.splitWords(types);\r
 \r
-                               indexKey = type + '_idx';\r
-                               indexLenKey = indexKey + '_len';\r
+                       for (var i = 0, len = types.length; i < len; i++) {\r
+                               this._on(types[i], fn, context);\r
+                       }\r
+               }\r
 \r
-                               typeIndex = events[indexKey] = events[indexKey] || {};\r
+               return this;\r
+       },\r
 \r
-                               if (!typeIndex[contextId]) {\r
-                                       typeIndex[contextId] = [];\r
+       /* @method off(type: String, fn?: Function, context?: Object): this\r
+        * Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to `on`, you must pass the same context to `off` in order to remove the listener.\r
+        *\r
+        * @alternative\r
+        * @method off(eventMap: Object): this\r
+        * Removes a set of type/listener pairs.\r
+        *\r
+        * @alternative\r
+        * @method off: this\r
+        * Removes all listeners to all events on the object.\r
+        */\r
+       off: function (types, fn, context) {\r
 \r
-                                       // keep track of the number of keys in the index to quickly check if it's empty\r
-                                       events[indexLenKey] = (events[indexLenKey] || 0) + 1;\r
-                               }\r
+               if (!types) {\r
+                       // clear all listeners if called without arguments\r
+                       delete this._events;\r
 \r
-                               typeIndex[contextId].push(event);\r
+               } else if (typeof types === 'object') {\r
+                       for (var type in types) {\r
+                               this._off(type, types[type], fn);\r
+                       }\r
 \r
+               } else {\r
+                       types = L.Util.splitWords(types);\r
 \r
-                       } else {\r
-                               events[type] = events[type] || [];\r
-                               events[type].push(event);\r
+                       for (var i = 0, len = types.length; i < len; i++) {\r
+                               this._off(types[i], fn, context);\r
                        }\r
                }\r
 \r
                return this;\r
        },\r
 \r
-       hasEventListeners: function (type) { // (String) -> Boolean\r
-               var events = this[eventsKey];\r
-               return !!events && ((type in events && events[type].length > 0) ||\r
-                                   (type + '_idx' in events && events[type + '_idx_len'] > 0));\r
-       },\r
-\r
-       removeEventListener: function (types, fn, context) { // ([String, Function, Object]) or (Object[, Object])\r
+       // attach listener (without syntactic sugar now)\r
+       _on: function (type, fn, context) {\r
+               this._events = this._events || {};\r
 \r
-               if (!this[eventsKey]) {\r
-                       return this;\r
+               /* get/init listeners for type */\r
+               var typeListeners = this._events[type];\r
+               if (!typeListeners) {\r
+                       typeListeners = [];\r
+                       this._events[type] = typeListeners;\r
                }\r
 \r
-               if (!types) {\r
-                       return this.clearAllEventListeners();\r
+               if (context === this) {\r
+                       // Less memory footprint.\r
+                       context = undefined;\r
                }\r
+               var newListener = {fn: fn, ctx: context},\r
+                   listeners = typeListeners;\r
 \r
-               if (L.Util.invokeEach(types, this.removeEventListener, this, fn, context)) { return this; }\r
-\r
-               var events = this[eventsKey],\r
-                   contextId = context && context !== this && L.stamp(context),\r
-                   i, len, type, listeners, j, indexKey, indexLenKey, typeIndex, removed;\r
+               // check if fn already there\r
+               for (var i = 0, len = listeners.length; i < len; i++) {\r
+                       if (listeners[i].fn === fn && listeners[i].ctx === context) {\r
+                               return;\r
+                       }\r
+               }\r
 \r
-               types = L.Util.splitWords(types);\r
+               listeners.push(newListener);\r
+       },\r
 \r
-               for (i = 0, len = types.length; i < len; i++) {\r
-                       type = types[i];\r
-                       indexKey = type + '_idx';\r
-                       indexLenKey = indexKey + '_len';\r
+       _off: function (type, fn, context) {\r
+               var listeners,\r
+                   i,\r
+                   len;\r
 \r
-                       typeIndex = events[indexKey];\r
+               if (!this._events) { return; }\r
 \r
-                       if (!fn) {\r
-                               // clear all listeners for a type if function isn't specified\r
-                               delete events[type];\r
-                               delete events[indexKey];\r
-                               delete events[indexLenKey];\r
+               listeners = this._events[type];\r
 \r
-                       } else {\r
-                               listeners = contextId && typeIndex ? typeIndex[contextId] : events[type];\r
-\r
-                               if (listeners) {\r
-                                       for (j = listeners.length - 1; j >= 0; j--) {\r
-                                               if ((listeners[j].action === fn) && (!context || (listeners[j].context === context))) {\r
-                                                       removed = listeners.splice(j, 1);\r
-                                                       // set the old action to a no-op, because it is possible\r
-                                                       // that the listener is being iterated over as part of a dispatch\r
-                                                       removed[0].action = L.Util.falseFn;\r
-                                               }\r
-                                       }\r
+               if (!listeners) {\r
+                       return;\r
+               }\r
 \r
-                                       if (context && typeIndex && (listeners.length === 0)) {\r
-                                               delete typeIndex[contextId];\r
-                                               events[indexLenKey]--;\r
-                                       }\r
-                               }\r
+               if (!fn) {\r
+                       // Set all removed listeners to noop so they are not called if remove happens in fire\r
+                       for (i = 0, len = listeners.length; i < len; i++) {\r
+                               listeners[i].fn = L.Util.falseFn;\r
                        }\r
+                       // clear all listeners for a type if function isn't specified\r
+                       delete this._events[type];\r
+                       return;\r
                }\r
 \r
-               return this;\r
-       },\r
-\r
-       clearAllEventListeners: function () {\r
-               delete this[eventsKey];\r
-               return this;\r
-       },\r
-\r
-       fireEvent: function (type, data) { // (String[, Object])\r
-               if (!this.hasEventListeners(type)) {\r
-                       return this;\r
+               if (context === this) {\r
+                       context = undefined;\r
                }\r
 \r
-               var event = L.Util.extend({}, data, { type: type, target: this });\r
+               if (listeners) {\r
 \r
-               var events = this[eventsKey],\r
-                   listeners, i, len, typeIndex, contextId;\r
+                       // find fn and remove it\r
+                       for (i = 0, len = listeners.length; i < len; i++) {\r
+                               var l = listeners[i];\r
+                               if (l.ctx !== context) { continue; }\r
+                               if (l.fn === fn) {\r
 \r
-               if (events[type]) {\r
-                       // make sure adding/removing listeners inside other listeners won't cause infinite loop\r
-                       listeners = events[type].slice();\r
+                                       // set the removed listener to noop so that's not called if remove happens in fire\r
+                                       l.fn = L.Util.falseFn;\r
 \r
-                       for (i = 0, len = listeners.length; i < len; i++) {\r
-                               listeners[i].action.call(listeners[i].context, event);\r
+                                       if (this._firingCount) {\r
+                                               /* copy array in case events are being fired */\r
+                                               this._events[type] = listeners = listeners.slice();\r
+                                       }\r
+                                       listeners.splice(i, 1);\r
+\r
+                                       return;\r
+                               }\r
                        }\r
                }\r
+       },\r
+\r
+       // @method fire(type: String, data?: Object, propagate?: Boolean): this\r
+       // Fires an event of the specified type. You can optionally provide an data\r
+       // object — the first argument of the listener function will contain its\r
+       // properties. The event can optionally be propagated to event parents.\r
+       fire: function (type, data, propagate) {\r
+               if (!this.listens(type, propagate)) { return this; }\r
 \r
-               // fire event for the context-indexed listeners as well\r
-               typeIndex = events[type + '_idx'];\r
+               var event = L.Util.extend({}, data, {type: type, target: this});\r
 \r
-               for (contextId in typeIndex) {\r
-                       listeners = typeIndex[contextId].slice();\r
+               if (this._events) {\r
+                       var listeners = this._events[type];\r
 \r
                        if (listeners) {\r
-                               for (i = 0, len = listeners.length; i < len; i++) {\r
-                                       listeners[i].action.call(listeners[i].context, event);\r
+                               this._firingCount = (this._firingCount + 1) || 1;\r
+                               for (var i = 0, len = listeners.length; i < len; i++) {\r
+                                       var l = listeners[i];\r
+                                       l.fn.call(l.ctx || this, event);\r
                                }\r
+\r
+                               this._firingCount--;\r
                        }\r
                }\r
 \r
+               if (propagate) {\r
+                       // propagate the event to parents (set with addEventParent)\r
+                       this._propagateEvent(event);\r
+               }\r
+\r
                return this;\r
        },\r
 \r
-       addOneTimeEventListener: function (types, fn, context) {\r
+       // @method listens(type: String): Boolean\r
+       // Returns `true` if a particular event type has any listeners attached to it.\r
+       listens: function (type, propagate) {\r
+               var listeners = this._events && this._events[type];\r
+               if (listeners && listeners.length) { return true; }\r
+\r
+               if (propagate) {\r
+                       // also check parents for listeners if event propagates\r
+                       for (var id in this._eventParents) {\r
+                               if (this._eventParents[id].listens(type, propagate)) { return true; }\r
+                       }\r
+               }\r
+               return false;\r
+       },\r
+\r
+       // @method once(…): this\r
+       // Behaves as [`on(…)`](#evented-on), except the listener will only get fired once and then removed.\r
+       once: function (types, fn, context) {\r
 \r
-               if (L.Util.invokeEach(types, this.addOneTimeEventListener, this, fn, context)) { return this; }\r
+               if (typeof types === 'object') {\r
+                       for (var type in types) {\r
+                               this.once(type, types[type], fn);\r
+                       }\r
+                       return this;\r
+               }\r
 \r
                var handler = L.bind(function () {\r
                        this\r
-                           .removeEventListener(types, fn, context)\r
-                           .removeEventListener(types, handler, context);\r
+                           .off(types, fn, context)\r
+                           .off(types, handler, context);\r
                }, this);\r
 \r
+               // add a listener that's executed once and removed after that\r
                return this\r
-                   .addEventListener(types, fn, context)\r
-                   .addEventListener(types, handler, context);\r
+                   .on(types, fn, context)\r
+                   .on(types, handler, context);\r
+       },\r
+\r
+       // @method addEventParent(obj: Evented): this\r
+       // Adds an event parent - an `Evented` that will receive propagated events\r
+       addEventParent: function (obj) {\r
+               this._eventParents = this._eventParents || {};\r
+               this._eventParents[L.stamp(obj)] = obj;\r
+               return this;\r
+       },\r
+\r
+       // @method removeEventParent(obj: Evented): this\r
+       // Removes an event parent, so it will stop receiving propagated events\r
+       removeEventParent: function (obj) {\r
+               if (this._eventParents) {\r
+                       delete this._eventParents[L.stamp(obj)];\r
+               }\r
+               return this;\r
+       },\r
+\r
+       _propagateEvent: function (e) {\r
+               for (var id in this._eventParents) {\r
+                       this._eventParents[id].fire(e.type, L.extend({layer: e.target}, e), true);\r
+               }\r
        }\r
-};\r
+});\r
+\r
+var proto = L.Evented.prototype;\r
 \r
-L.Mixin.Events.on = L.Mixin.Events.addEventListener;\r
-L.Mixin.Events.off = L.Mixin.Events.removeEventListener;\r
-L.Mixin.Events.once = L.Mixin.Events.addOneTimeEventListener;\r
-L.Mixin.Events.fire = L.Mixin.Events.fireEvent;\r
+// aliases; we should ditch those eventually\r
+\r
+// @method addEventListener(…): this\r
+// Alias to [`on(…)`](#evented-on)\r
+proto.addEventListener = proto.on;\r
+\r
+// @method removeEventListener(…): this\r
+// Alias to [`off(…)`](#evented-off)\r
+\r
+// @method clearAllEventListeners(…): this\r
+// Alias to [`off()`](#evented-off)\r
+proto.removeEventListener = proto.clearAllEventListeners = proto.off;\r
+\r
+// @method addOneTimeEventListener(…): this\r
+// Alias to [`once(…)`](#evented-once)\r
+proto.addOneTimeEventListener = proto.once;\r
+\r
+// @method fireEvent(…): this\r
+// Alias to [`fire(…)`](#evented-fire)\r
+proto.fireEvent = proto.fire;\r
+\r
+// @method hasEventListeners(…): Boolean\r
+// Alias to [`listens(…)`](#evented-listens)\r
+proto.hasEventListeners = proto.listens;\r
+\r
+L.Mixin = {Events: proto};\r
+
 
 
 /*\r
- * L.Browser handles different browser and feature detections for internal Leaflet use.\r
+ * @namespace Browser\r
+ * @aka L.Browser\r
+ *\r
+ * A namespace with static properties for browser/feature detection used by Leaflet internally.\r
+ *\r
+ * @example\r
+ *\r
+ * ```js\r
+ * if (L.Browser.ielt9) {\r
+ *   alert('Upgrade your browser, dude!');\r
+ * }\r
+ * ```\r
  */\r
 \r
 (function () {\r
 \r
-       var ie = 'ActiveXObject' in window,\r
-               ielt9 = ie && !document.addEventListener,\r
+       var ua = navigator.userAgent.toLowerCase(),\r
+           doc = document.documentElement,\r
+\r
+           ie = 'ActiveXObject' in window,\r
 \r
-           // terrible browser detection to work around Safari / iOS / Android browser bugs\r
-           ua = navigator.userAgent.toLowerCase(),\r
-           webkit = ua.indexOf('webkit') !== -1,\r
-           chrome = ua.indexOf('chrome') !== -1,\r
+           webkit    = ua.indexOf('webkit') !== -1,\r
            phantomjs = ua.indexOf('phantom') !== -1,\r
-           android = ua.indexOf('android') !== -1,\r
            android23 = ua.search('android [23]') !== -1,\r
-               gecko = ua.indexOf('gecko') !== -1,\r
+           chrome    = ua.indexOf('chrome') !== -1,\r
+           gecko     = ua.indexOf('gecko') !== -1  && !webkit && !window.opera && !ie,\r
 \r
-           mobile = typeof orientation !== undefined + '',\r
+           win = navigator.platform.indexOf('Win') === 0,\r
+\r
+           mobile = typeof orientation !== 'undefined' || ua.indexOf('mobile') !== -1,\r
            msPointer = !window.PointerEvent && window.MSPointerEvent,\r
-               pointer = (window.PointerEvent && window.navigator.pointerEnabled) ||\r
-                                 msPointer,\r
-           retina = ('devicePixelRatio' in window && window.devicePixelRatio > 1) ||\r
-                    ('matchMedia' in window && window.matchMedia('(min-resolution:144dpi)') &&\r
-                     window.matchMedia('(min-resolution:144dpi)').matches),\r
+           pointer = window.PointerEvent || msPointer,\r
 \r
-           doc = document.documentElement,\r
            ie3d = ie && ('transition' in doc.style),\r
            webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()) && !android23,\r
            gecko3d = 'MozPerspective' in doc.style,\r
-           opera3d = 'OTransition' in doc.style,\r
-           any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d || opera3d) && !phantomjs;\r
+           opera12 = 'OTransition' in doc.style;\r
 \r
-       var touch = !window.L_NO_TOUCH && !phantomjs && (pointer || 'ontouchstart' in window ||\r
-               (window.DocumentTouch && document instanceof window.DocumentTouch));\r
+\r
+       var touch = !window.L_NO_TOUCH && (pointer || 'ontouchstart' in window ||\r
+                       (window.DocumentTouch && document instanceof window.DocumentTouch));\r
 \r
        L.Browser = {\r
+\r
+               // @property ie: Boolean\r
+               // `true` for all Internet Explorer versions (not Edge).\r
                ie: ie,\r
-               ielt9: ielt9,\r
+\r
+               // @property ielt9: Boolean\r
+               // `true` for Internet Explorer versions less than 9.\r
+               ielt9: ie && !document.addEventListener,\r
+\r
+               // @property edge: Boolean\r
+               // `true` for the Edge web browser.\r
+               edge: 'msLaunchUri' in navigator && !('documentMode' in document),\r
+\r
+               // @property webkit: Boolean\r
+               // `true` for webkit-based browsers like Chrome and Safari (including mobile versions).\r
                webkit: webkit,\r
-               gecko: gecko && !webkit && !window.opera && !ie,\r
 \r
-               android: android,\r
+               // @property gecko: Boolean\r
+               // `true` for gecko-based browsers like Firefox.\r
+               gecko: gecko,\r
+\r
+               // @property android: Boolean\r
+               // `true` for any browser running on an Android platform.\r
+               android: ua.indexOf('android') !== -1,\r
+\r
+               // @property android23: Boolean\r
+               // `true` for browsers running on Android 2 or Android 3.\r
                android23: android23,\r
 \r
+               // @property chrome: Boolean\r
+               // `true` for the Chrome browser.\r
                chrome: chrome,\r
 \r
+               // @property safari: Boolean\r
+               // `true` for the Safari browser.\r
+               safari: !chrome && ua.indexOf('safari') !== -1,\r
+\r
+\r
+               // @property win: Boolean\r
+               // `true` when the browser is running in a Windows platform\r
+               win: win,\r
+\r
+\r
+               // @property ie3d: Boolean\r
+               // `true` for all Internet Explorer versions supporting CSS transforms.\r
                ie3d: ie3d,\r
+\r
+               // @property webkit3d: Boolean\r
+               // `true` for webkit-based browsers supporting CSS transforms.\r
                webkit3d: webkit3d,\r
+\r
+               // @property gecko3d: Boolean\r
+               // `true` for gecko-based browsers supporting CSS transforms.\r
                gecko3d: gecko3d,\r
-               opera3d: opera3d,\r
-               any3d: any3d,\r
 \r
+               // @property opera12: Boolean\r
+               // `true` for the Opera browser supporting CSS transforms (version 12 or later).\r
+               opera12: opera12,\r
+\r
+               // @property any3d: Boolean\r
+               // `true` for all browsers supporting CSS transforms.\r
+               any3d: !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d) && !opera12 && !phantomjs,\r
+\r
+\r
+               // @property mobile: Boolean\r
+               // `true` for all browsers running in a mobile device.\r
                mobile: mobile,\r
+\r
+               // @property mobileWebkit: Boolean\r
+               // `true` for all webkit-based browsers in a mobile device.\r
                mobileWebkit: mobile && webkit,\r
+\r
+               // @property mobileWebkit3d: Boolean\r
+               // `true` for all webkit-based browsers in a mobile device supporting CSS transforms.\r
                mobileWebkit3d: mobile && webkit3d,\r
+\r
+               // @property mobileOpera: Boolean\r
+               // `true` for the Opera browser in a mobile device.\r
                mobileOpera: mobile && window.opera,\r
 \r
-               touch: touch,\r
-               msPointer: msPointer,\r
-               pointer: pointer,\r
+               // @property mobileGecko: Boolean\r
+               // `true` for gecko-based browsers running in a mobile device.\r
+               mobileGecko: mobile && gecko,\r
+\r
 \r
-               retina: retina\r
+               // @property touch: Boolean\r
+               // `true` for all browsers supporting [touch events](https://developer.mozilla.org/docs/Web/API/Touch_events).\r
+               // This does not necessarily mean that the browser is running in a computer with\r
+               // a touchscreen, it only means that the browser is capable of understanding\r
+               // touch events.\r
+               touch: !!touch,\r
+\r
+               // @property msPointer: Boolean\r
+               // `true` for browsers implementing the Microsoft touch events model (notably IE10).\r
+               msPointer: !!msPointer,\r
+\r
+               // @property pointer: Boolean\r
+               // `true` for all browsers supporting [pointer events](https://msdn.microsoft.com/en-us/library/dn433244%28v=vs.85%29.aspx).\r
+               pointer: !!pointer,\r
+\r
+\r
+               // @property retina: Boolean\r
+               // `true` for browsers on a high-resolution "retina" screen.\r
+               retina: (window.devicePixelRatio || (window.screen.deviceXDPI / window.screen.logicalXDPI)) > 1\r
        };\r
 \r
 }());\r
 
 
+
 /*\r
- * L.Point represents a point with x and y coordinates.\r
+ * @class Point\r
+ * @aka L.Point\r
+ *\r
+ * Represents a point with `x` and `y` coordinates in pixels.\r
+ *\r
+ * @example\r
+ *\r
+ * ```js\r
+ * var point = L.point(200, 300);\r
+ * ```\r
+ *\r
+ * All Leaflet methods and options that accept `Point` objects also accept them in a simple Array form (unless noted otherwise), so these lines are equivalent:\r
+ *\r
+ * ```js\r
+ * map.panBy([200, 300]);\r
+ * map.panBy(L.point(200, 300));\r
+ * ```\r
  */\r
 \r
-L.Point = function (/*Number*/ x, /*Number*/ y, /*Boolean*/ round) {\r
+L.Point = function (x, y, round) {\r
+       // @property x: Number; The `x` coordinate of the point\r
        this.x = (round ? Math.round(x) : x);\r
+       // @property y: Number; The `y` coordinate of the point\r
        this.y = (round ? Math.round(y) : y);\r
 };\r
 \r
 L.Point.prototype = {\r
 \r
+       // @method clone(): Point\r
+       // Returns a copy of the current point.\r
        clone: function () {\r
                return new L.Point(this.x, this.y);\r
        },\r
 \r
-       // non-destructive, returns a new point\r
+       // @method add(otherPoint: Point): Point\r
+       // Returns the result of addition of the current and the given points.\r
        add: function (point) {\r
+               // non-destructive, returns a new point\r
                return this.clone()._add(L.point(point));\r
        },\r
 \r
-       // destructive, used directly for performance in situations where it's safe to modify existing point\r
        _add: function (point) {\r
+               // destructive, used directly for performance in situations where it's safe to modify existing point\r
                this.x += point.x;\r
                this.y += point.y;\r
                return this;\r
        },\r
 \r
+       // @method subtract(otherPoint: Point): Point\r
+       // Returns the result of subtraction of the given point from the current.\r
        subtract: function (point) {\r
                return this.clone()._subtract(L.point(point));\r
        },\r
@@ -605,6 +907,8 @@ L.Point.prototype = {
                return this;\r
        },\r
 \r
+       // @method divideBy(num: Number): Point\r
+       // Returns the result of division of the current point by the given number.\r
        divideBy: function (num) {\r
                return this.clone()._divideBy(num);\r
        },\r
@@ -615,6 +919,8 @@ L.Point.prototype = {
                return this;\r
        },\r
 \r
+       // @method multiplyBy(num: Number): Point\r
+       // Returns the result of multiplication of the current point by the given number.\r
        multiplyBy: function (num) {\r
                return this.clone()._multiplyBy(num);\r
        },\r
@@ -625,6 +931,24 @@ L.Point.prototype = {
                return this;\r
        },\r
 \r
+       // @method scaleBy(scale: Point): Point\r
+       // Multiply each coordinate of the current point by each coordinate of\r
+       // `scale`. In linear algebra terms, multiply the point by the\r
+       // [scaling matrix](https://en.wikipedia.org/wiki/Scaling_%28geometry%29#Matrix_representation)\r
+       // defined by `scale`.\r
+       scaleBy: function (point) {\r
+               return new L.Point(this.x * point.x, this.y * point.y);\r
+       },\r
+\r
+       // @method unscaleBy(scale: Point): Point\r
+       // Inverse of `scaleBy`. Divide each coordinate of the current point by\r
+       // each coordinate of `scale`.\r
+       unscaleBy: function (point) {\r
+               return new L.Point(this.x / point.x, this.y / point.y);\r
+       },\r
+\r
+       // @method round(): Point\r
+       // Returns a copy of the current point with rounded coordinates.\r
        round: function () {\r
                return this.clone()._round();\r
        },\r
@@ -635,6 +959,8 @@ L.Point.prototype = {
                return this;\r
        },\r
 \r
+       // @method floor(): Point\r
+       // Returns a copy of the current point with floored coordinates (rounded down).\r
        floor: function () {\r
                return this.clone()._floor();\r
        },\r
@@ -645,6 +971,20 @@ L.Point.prototype = {
                return this;\r
        },\r
 \r
+       // @method ceil(): Point\r
+       // Returns a copy of the current point with ceiled coordinates (rounded up).\r
+       ceil: function () {\r
+               return this.clone()._ceil();\r
+       },\r
+\r
+       _ceil: function () {\r
+               this.x = Math.ceil(this.x);\r
+               this.y = Math.ceil(this.y);\r
+               return this;\r
+       },\r
+\r
+       // @method distanceTo(otherPoint: Point): Number\r
+       // Returns the cartesian distance between the current and the given points.\r
        distanceTo: function (point) {\r
                point = L.point(point);\r
 \r
@@ -654,6 +994,8 @@ L.Point.prototype = {
                return Math.sqrt(x * x + y * y);\r
        },\r
 \r
+       // @method equals(otherPoint: Point): Boolean\r
+       // Returns `true` if the given point has the same coordinates.\r
        equals: function (point) {\r
                point = L.point(point);\r
 \r
@@ -661,6 +1003,8 @@ L.Point.prototype = {
                       point.y === this.y;\r
        },\r
 \r
+       // @method contains(otherPoint: Point): Boolean\r
+       // Returns `true` if both coordinates of the given point are less than the corresponding current point coordinates (in absolute values).\r
        contains: function (point) {\r
                point = L.point(point);\r
 \r
@@ -668,6 +1012,8 @@ L.Point.prototype = {
                       Math.abs(point.y) <= Math.abs(this.y);\r
        },\r
 \r
+       // @method toString(): String\r
+       // Returns a string representation of the point for debugging purposes.\r
        toString: function () {\r
                return 'Point(' +\r
                        L.Util.formatNum(this.x) + ', ' +\r
@@ -675,6 +1021,16 @@ L.Point.prototype = {
        }\r
 };\r
 \r
+// @factory L.point(x: Number, y: Number, round?: Boolean)\r
+// Creates a Point object with the given `x` and `y` coordinates. If optional `round` is set to true, rounds the `x` and `y` values.\r
+\r
+// @alternative\r
+// @factory L.point(coords: Number[])\r
+// Expects an array of the form `[x, y]` instead.\r
+\r
+// @alternative\r
+// @factory L.point(coords: Object)\r
+// Expects a plain object of the form `{x: Number, y: Number}` instead.\r
 L.point = function (x, y, round) {\r
        if (x instanceof L.Point) {\r
                return x;\r
@@ -685,15 +1041,36 @@ L.point = function (x, y, round) {
        if (x === undefined || x === null) {\r
                return x;\r
        }\r
+       if (typeof x === 'object' && 'x' in x && 'y' in x) {\r
+               return new L.Point(x.x, x.y);\r
+       }\r
        return new L.Point(x, y, round);\r
 };\r
 
 
+
 /*\r
- * L.Bounds represents a rectangular area on the screen in pixel coordinates.\r
+ * @class Bounds\r
+ * @aka L.Bounds\r
+ *\r
+ * Represents a rectangular area in pixel coordinates.\r
+ *\r
+ * @example\r
+ *\r
+ * ```js\r
+ * var p1 = L.point(10, 10),\r
+ * p2 = L.point(40, 60),\r
+ * bounds = L.bounds(p1, p2);\r
+ * ```\r
+ *\r
+ * All Leaflet methods that accept `Bounds` objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:\r
+ *\r
+ * ```js\r
+ * otherBounds.intersects([[10, 10], [40, 60]]);\r
+ * ```\r
  */\r
 \r
-L.Bounds = function (a, b) { //(Point, Point) or Point[]\r
+L.Bounds = function (a, b) {\r
        if (!a) { return; }\r
 \r
        var points = b ? [a, b] : a;\r
@@ -704,10 +1081,15 @@ L.Bounds = function (a, b) { //(Point, Point) or Point[]
 };\r
 \r
 L.Bounds.prototype = {\r
-       // extend the bounds to contain the given point\r
+       // @method extend(point: Point): this\r
+       // Extends the bounds to contain the given point.\r
        extend: function (point) { // (Point)\r
                point = L.point(point);\r
 \r
+               // @property min: Point\r
+               // The top left corner of the rectangle.\r
+               // @property max: Point\r
+               // The bottom right corner of the rectangle.\r
                if (!this.min && !this.max) {\r
                        this.min = point.clone();\r
                        this.max = point.clone();\r
@@ -720,25 +1102,38 @@ L.Bounds.prototype = {
                return this;\r
        },\r
 \r
-       getCenter: function (round) { // (Boolean) -> Point\r
+       // @method getCenter(round?: Boolean): Point\r
+       // Returns the center point of the bounds.\r
+       getCenter: function (round) {\r
                return new L.Point(\r
                        (this.min.x + this.max.x) / 2,\r
                        (this.min.y + this.max.y) / 2, round);\r
        },\r
 \r
-       getBottomLeft: function () { // -> Point\r
+       // @method getBottomLeft(): Point\r
+       // Returns the bottom-left point of the bounds.\r
+       getBottomLeft: function () {\r
                return new L.Point(this.min.x, this.max.y);\r
        },\r
 \r
+       // @method getTopRight(): Point\r
+       // Returns the top-right point of the bounds.\r
        getTopRight: function () { // -> Point\r
                return new L.Point(this.max.x, this.min.y);\r
        },\r
 \r
+       // @method getSize(): Point\r
+       // Returns the size of the given bounds\r
        getSize: function () {\r
                return this.max.subtract(this.min);\r
        },\r
 \r
-       contains: function (obj) { // (Bounds) or (Point) -> Boolean\r
+       // @method contains(otherBounds: Bounds): Boolean\r
+       // Returns `true` if the rectangle contains the given one.\r
+       // @alternative\r
+       // @method contains(point: Point): Boolean\r
+       // Returns `true` if the rectangle contains the given point.\r
+       contains: function (obj) {\r
                var min, max;\r
 \r
                if (typeof obj[0] === 'number' || obj instanceof L.Point) {\r
@@ -760,6 +1155,9 @@ L.Bounds.prototype = {
                       (max.y <= this.max.y);\r
        },\r
 \r
+       // @method intersects(otherBounds: Bounds): Boolean\r
+       // Returns `true` if the rectangle intersects the given bounds. Two bounds\r
+       // intersect if they have at least one point in common.\r
        intersects: function (bounds) { // (Bounds) -> Boolean\r
                bounds = L.bounds(bounds);\r
 \r
@@ -773,12 +1171,34 @@ L.Bounds.prototype = {
                return xIntersects && yIntersects;\r
        },\r
 \r
+       // @method overlaps(otherBounds: Bounds): Boolean\r
+       // Returns `true` if the rectangle overlaps the given bounds. Two bounds\r
+       // overlap if their intersection is an area.\r
+       overlaps: function (bounds) { // (Bounds) -> Boolean\r
+               bounds = L.bounds(bounds);\r
+\r
+               var min = this.min,\r
+                   max = this.max,\r
+                   min2 = bounds.min,\r
+                   max2 = bounds.max,\r
+                   xOverlaps = (max2.x > min.x) && (min2.x < max.x),\r
+                   yOverlaps = (max2.y > min.y) && (min2.y < max.y);\r
+\r
+               return xOverlaps && yOverlaps;\r
+       },\r
+\r
        isValid: function () {\r
                return !!(this.min && this.max);\r
        }\r
 };\r
 \r
-L.bounds = function (a, b) { // (Bounds) or (Point, Point) or (Point[])\r
+\r
+// @factory L.bounds(topLeft: Point, bottomRight: Point)\r
+// Creates a Bounds object from two coordinates (usually top-left and bottom-right corners).\r
+// @alternative\r
+// @factory L.bounds(points: Point[])\r
+// Creates a Bounds object from the points it contains\r
+L.bounds = function (a, b) {\r
        if (!a || a instanceof L.Bounds) {\r
                return a;\r
        }\r
@@ -786,10 +1206,28 @@ L.bounds = function (a, b) { // (Bounds) or (Point, Point) or (Point[])
 };\r
 
 
+
 /*\r
- * L.Transformation is an utility class to perform simple point transformations through a 2d-matrix.\r
+ * @class Transformation\r
+ * @aka L.Transformation\r
+ *\r
+ * Represents an affine transformation: a set of coefficients `a`, `b`, `c`, `d`\r
+ * for transforming a point of a form `(x, y)` into `(a*x + b, c*y + d)` and doing\r
+ * the reverse. Used by Leaflet in its projections code.\r
+ *\r
+ * @example\r
+ *\r
+ * ```js\r
+ * var transformation = new L.Transformation(2, 5, -1, 10),\r
+ *     p = L.point(1, 2),\r
+ *     p2 = transformation.transform(p), //  L.point(7, 8)\r
+ *     p3 = transformation.untransform(p2); //  L.point(1, 2)\r
+ * ```\r
  */\r
 \r
+\r
+// factory new L.Transformation(a: Number, b: Number, c: Number, d: Number)\r
+// Creates a `Transformation` object with the given coefficients.\r
 L.Transformation = function (a, b, c, d) {\r
        this._a = a;\r
        this._b = b;\r
@@ -798,6 +1236,9 @@ L.Transformation = function (a, b, c, d) {
 };\r
 \r
 L.Transformation.prototype = {\r
+       // @method transform(point: Point, scale?: Number): Point\r
+       // Returns a transformed point, optionally multiplied by the given scale.\r
+       // Only accepts actual `L.Point` instances, not arrays.\r
        transform: function (point, scale) { // (Point, Number) -> Point\r
                return this._transform(point.clone(), scale);\r
        },\r
@@ -810,6 +1251,9 @@ L.Transformation.prototype = {
                return point;\r
        },\r
 \r
+       // @method untransform(point: Point, scale?: Number): Point\r
+       // Returns the reverse transformation of the given point, optionally divided\r
+       // by the given scale. Only accepts actual `L.Point` instances, not arrays.\r
        untransform: function (point, scale) {\r
                scale = scale || 1;\r
                return new L.Point(\r
@@ -819,22 +1263,33 @@ L.Transformation.prototype = {
 };\r
 
 
+
 /*\r
- * L.DomUtil contains various utility functions for working with DOM.\r
+ * @namespace DomUtil\r
+ *\r
+ * Utility functions to work with the [DOM](https://developer.mozilla.org/docs/Web/API/Document_Object_Model)\r
+ * tree, used by Leaflet internally.\r
+ *\r
+ * Most functions expecting or returning a `HTMLElement` also work for\r
+ * SVG elements. The only difference is that classes refer to CSS classes\r
+ * in HTML and SVG classes in SVG.\r
  */\r
 \r
 L.DomUtil = {\r
+\r
+       // @function get(id: String|HTMLElement): HTMLElement\r
+       // Returns an element given its DOM id, or returns the element itself\r
+       // if it was passed directly.\r
        get: function (id) {\r
-               return (typeof id === 'string' ? document.getElementById(id) : id);\r
+               return typeof id === 'string' ? document.getElementById(id) : id;\r
        },\r
 \r
+       // @function getStyle(el: HTMLElement, styleAttrib: String): String\r
+       // Returns the value for a certain style attribute on an element,\r
+       // including computed values or values set through CSS.\r
        getStyle: function (el, style) {\r
 \r
-               var value = el.style[style];\r
-\r
-               if (!value && el.currentStyle) {\r
-                       value = el.currentStyle[style];\r
-               }\r
+               var value = el.style[style] || (el.currentStyle && el.currentStyle[style]);\r
 \r
                if ((!value || value === 'auto') && document.defaultView) {\r
                        var css = document.defaultView.getComputedStyle(el, null);\r
@@ -844,94 +1299,62 @@ L.DomUtil = {
                return value === 'auto' ? null : value;\r
        },\r
 \r
-       getViewportOffset: function (element) {\r
-\r
-               var top = 0,\r
-                   left = 0,\r
-                   el = element,\r
-                   docBody = document.body,\r
-                   docEl = document.documentElement,\r
-                   pos;\r
-\r
-               do {\r
-                       top  += el.offsetTop  || 0;\r
-                       left += el.offsetLeft || 0;\r
-\r
-                       //add borders\r
-                       top += parseInt(L.DomUtil.getStyle(el, 'borderTopWidth'), 10) || 0;\r
-                       left += parseInt(L.DomUtil.getStyle(el, 'borderLeftWidth'), 10) || 0;\r
-\r
-                       pos = L.DomUtil.getStyle(el, 'position');\r
-\r
-                       if (el.offsetParent === docBody && pos === 'absolute') { break; }\r
-\r
-                       if (pos === 'fixed') {\r
-                               top  += docBody.scrollTop  || docEl.scrollTop  || 0;\r
-                               left += docBody.scrollLeft || docEl.scrollLeft || 0;\r
-                               break;\r
-                       }\r
-\r
-                       if (pos === 'relative' && !el.offsetLeft) {\r
-                               var width = L.DomUtil.getStyle(el, 'width'),\r
-                                   maxWidth = L.DomUtil.getStyle(el, 'max-width'),\r
-                                   r = el.getBoundingClientRect();\r
-\r
-                               if (width !== 'none' || maxWidth !== 'none') {\r
-                                       left += r.left + el.clientLeft;\r
-                               }\r
-\r
-                               //calculate full y offset since we're breaking out of the loop\r
-                               top += r.top + (docBody.scrollTop  || docEl.scrollTop  || 0);\r
-\r
-                               break;\r
-                       }\r
-\r
-                       el = el.offsetParent;\r
-\r
-               } while (el);\r
-\r
-               el = element;\r
-\r
-               do {\r
-                       if (el === docBody) { break; }\r
+       // @function create(tagName: String, className?: String, container?: HTMLElement): HTMLElement\r
+       // Creates an HTML element with `tagName`, sets its class to `className`, and optionally appends it to `container` element.\r
+       create: function (tagName, className, container) {\r
 \r
-                       top  -= el.scrollTop  || 0;\r
-                       left -= el.scrollLeft || 0;\r
+               var el = document.createElement(tagName);\r
+               el.className = className || '';\r
 \r
-                       el = el.parentNode;\r
-               } while (el);\r
+               if (container) {\r
+                       container.appendChild(el);\r
+               }\r
 \r
-               return new L.Point(left, top);\r
+               return el;\r
        },\r
 \r
-       documentIsLtr: function () {\r
-               if (!L.DomUtil._docIsLtrCached) {\r
-                       L.DomUtil._docIsLtrCached = true;\r
-                       L.DomUtil._docIsLtr = L.DomUtil.getStyle(document.body, 'direction') === 'ltr';\r
+       // @function remove(el: HTMLElement)\r
+       // Removes `el` from its parent element\r
+       remove: function (el) {\r
+               var parent = el.parentNode;\r
+               if (parent) {\r
+                       parent.removeChild(el);\r
                }\r
-               return L.DomUtil._docIsLtr;\r
        },\r
 \r
-       create: function (tagName, className, container) {\r
-\r
-               var el = document.createElement(tagName);\r
-               el.className = className;\r
-\r
-               if (container) {\r
-                       container.appendChild(el);\r
+       // @function empty(el: HTMLElement)\r
+       // Removes all of `el`'s children elements from `el`\r
+       empty: function (el) {\r
+               while (el.firstChild) {\r
+                       el.removeChild(el.firstChild);\r
                }\r
+       },\r
 \r
-               return el;\r
+       // @function toFront(el: HTMLElement)\r
+       // Makes `el` the last children of its parent, so it renders in front of the other children.\r
+       toFront: function (el) {\r
+               el.parentNode.appendChild(el);\r
+       },\r
+\r
+       // @function toBack(el: HTMLElement)\r
+       // Makes `el` the first children of its parent, so it renders back from the other children.\r
+       toBack: function (el) {\r
+               var parent = el.parentNode;\r
+               parent.insertBefore(el, parent.firstChild);\r
        },\r
 \r
+       // @function hasClass(el: HTMLElement, name: String): Boolean\r
+       // Returns `true` if the element's class attribute contains `name`.\r
        hasClass: function (el, name) {\r
                if (el.classList !== undefined) {\r
                        return el.classList.contains(name);\r
                }\r
-               var className = L.DomUtil._getClass(el);\r
+               var className = L.DomUtil.getClass(el);\r
                return className.length > 0 && new RegExp('(^|\\s)' + name + '(\\s|$)').test(className);\r
        },\r
 \r
+       // @function addClass(el: HTMLElement, name: String)\r
+       // Adds `name` to the element's class attribute.\r
        addClass: function (el, name) {\r
                if (el.classList !== undefined) {\r
                        var classes = L.Util.splitWords(name);\r
@@ -939,20 +1362,24 @@ L.DomUtil = {
                                el.classList.add(classes[i]);\r
                        }\r
                } else if (!L.DomUtil.hasClass(el, name)) {\r
-                       var className = L.DomUtil._getClass(el);\r
-                       L.DomUtil._setClass(el, (className ? className + ' ' : '') + name);\r
+                       var className = L.DomUtil.getClass(el);\r
+                       L.DomUtil.setClass(el, (className ? className + ' ' : '') + name);\r
                }\r
        },\r
 \r
+       // @function removeClass(el: HTMLElement, name: String)\r
+       // Removes `name` from the element's class attribute.\r
        removeClass: function (el, name) {\r
                if (el.classList !== undefined) {\r
                        el.classList.remove(name);\r
                } else {\r
-                       L.DomUtil._setClass(el, L.Util.trim((' ' + L.DomUtil._getClass(el) + ' ').replace(' ' + name + ' ', ' ')));\r
+                       L.DomUtil.setClass(el, L.Util.trim((' ' + L.DomUtil.getClass(el) + ' ').replace(' ' + name + ' ', ' ')));\r
                }\r
        },\r
 \r
-       _setClass: function (el, name) {\r
+       // @function setClass(el: HTMLElement, name: String)\r
+       // Sets the element's class.\r
+       setClass: function (el, name) {\r
                if (el.className.baseVal === undefined) {\r
                        el.className = name;\r
                } else {\r
@@ -961,40 +1388,52 @@ L.DomUtil = {
                }\r
        },\r
 \r
-       _getClass: function (el) {\r
+       // @function getClass(el: HTMLElement): String\r
+       // Returns the element's class.\r
+       getClass: function (el) {\r
                return el.className.baseVal === undefined ? el.className : el.className.baseVal;\r
        },\r
 \r
+       // @function setOpacity(el: HTMLElement, opacity: Number)\r
+       // Set the opacity of an element (including old IE support).\r
+       // `opacity` must be a number from `0` to `1`.\r
        setOpacity: function (el, value) {\r
 \r
                if ('opacity' in el.style) {\r
                        el.style.opacity = value;\r
 \r
                } else if ('filter' in el.style) {\r
+                       L.DomUtil._setOpacityIE(el, value);\r
+               }\r
+       },\r
 \r
-                       var filter = false,\r
-                           filterName = 'DXImageTransform.Microsoft.Alpha';\r
+       _setOpacityIE: function (el, value) {\r
+               var filter = false,\r
+                   filterName = 'DXImageTransform.Microsoft.Alpha';\r
 \r
-                       // filters collection throws an error if we try to retrieve a filter that doesn't exist\r
-                       try {\r
-                               filter = el.filters.item(filterName);\r
-                       } catch (e) {\r
-                               // don't set opacity to 1 if we haven't already set an opacity,\r
-                               // it isn't needed and breaks transparent pngs.\r
-                               if (value === 1) { return; }\r
-                       }\r
+               // filters collection throws an error if we try to retrieve a filter that doesn't exist\r
+               try {\r
+                       filter = el.filters.item(filterName);\r
+               } catch (e) {\r
+                       // don't set opacity to 1 if we haven't already set an opacity,\r
+                       // it isn't needed and breaks transparent pngs.\r
+                       if (value === 1) { return; }\r
+               }\r
 \r
-                       value = Math.round(value * 100);\r
+               value = Math.round(value * 100);\r
 \r
-                       if (filter) {\r
-                               filter.Enabled = (value !== 100);\r
-                               filter.Opacity = value;\r
-                       } else {\r
-                               el.style.filter += ' progid:' + filterName + '(opacity=' + value + ')';\r
-                       }\r
+               if (filter) {\r
+                       filter.Enabled = (value !== 100);\r
+                       filter.Opacity = value;\r
+               } else {\r
+                       el.style.filter += ' progid:' + filterName + '(opacity=' + value + ')';\r
                }\r
        },\r
 \r
+       // @function testProp(props: String[]): String|false\r
+       // Goes through the array of style names and returns the first name\r
+       // that is a valid style name for an element. If no such name is found,\r
+       // it returns false. Useful for vendor-prefixed styles like `transform`.\r
        testProp: function (props) {\r
 \r
                var style = document.documentElement.style;\r
@@ -1007,137 +1446,192 @@ L.DomUtil = {
                return false;\r
        },\r
 \r
-       getTranslateString: function (point) {\r
-               // on WebKit browsers (Chrome/Safari/iOS Safari/Android) using translate3d instead of translate\r
-               // makes animation smoother as it ensures HW accel is used. Firefox 13 doesn't care\r
-               // (same speed either way), Opera 12 doesn't support translate3d\r
+       // @function setTransform(el: HTMLElement, offset: Point, scale?: Number)\r
+       // Resets the 3D CSS transform of `el` so it is translated by `offset` pixels\r
+       // and optionally scaled by `scale`. Does not have an effect if the\r
+       // browser doesn't support 3D CSS transforms.\r
+       setTransform: function (el, offset, scale) {\r
+               var pos = offset || new L.Point(0, 0);\r
 \r
-               var is3d = L.Browser.webkit3d,\r
-                   open = 'translate' + (is3d ? '3d' : '') + '(',\r
-                   close = (is3d ? ',0' : '') + ')';\r
-\r
-               return open + point.x + 'px,' + point.y + 'px' + close;\r
+               el.style[L.DomUtil.TRANSFORM] =\r
+                       (L.Browser.ie3d ?\r
+                               'translate(' + pos.x + 'px,' + pos.y + 'px)' :\r
+                               'translate3d(' + pos.x + 'px,' + pos.y + 'px,0)') +\r
+                       (scale ? ' scale(' + scale + ')' : '');\r
        },\r
 \r
-       getScaleString: function (scale, origin) {\r
+       // @function setPosition(el: HTMLElement, position: Point)\r
+       // Sets the position of `el` to coordinates specified by `position`,\r
+       // using CSS translate or top/left positioning depending on the browser\r
+       // (used by Leaflet internally to position its layers).\r
+       setPosition: function (el, point) { // (HTMLElement, Point[, Boolean])\r
 \r
-               var preTranslateStr = L.DomUtil.getTranslateString(origin.add(origin.multiplyBy(-1 * scale))),\r
-                   scaleStr = ' scale(' + scale + ') ';\r
+               /*eslint-disable */\r
+               el._leaflet_pos = point;\r
+               /*eslint-enable */\r
 \r
-               return preTranslateStr + scaleStr;\r
-       },\r
-\r
-       setPosition: function (el, point, disable3D) { // (HTMLElement, Point[, Boolean])\r
-\r
-               // jshint camelcase: false\r
-               el._leaflet_pos = point;\r
-\r
-               if (!disable3D && L.Browser.any3d) {\r
-                       el.style[L.DomUtil.TRANSFORM] =  L.DomUtil.getTranslateString(point);\r
+               if (L.Browser.any3d) {\r
+                       L.DomUtil.setTransform(el, point);\r
                } else {\r
                        el.style.left = point.x + 'px';\r
                        el.style.top = point.y + 'px';\r
                }\r
        },\r
 \r
+       // @function getPosition(el: HTMLElement): Point\r
+       // Returns the coordinates of an element previously positioned with setPosition.\r
        getPosition: function (el) {\r
                // this method is only used for elements previously positioned using setPosition,\r
                // so it's safe to cache the position for performance\r
 \r
-               // jshint camelcase: false\r
-               return el._leaflet_pos;\r
+               return el._leaflet_pos || new L.Point(0, 0);\r
        }\r
 };\r
 \r
 \r
-// prefix style property names\r
+(function () {\r
+       // prefix style property names\r
 \r
-L.DomUtil.TRANSFORM = L.DomUtil.testProp(\r
-        ['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform']);\r
+       // @property TRANSFORM: String\r
+       // Vendor-prefixed fransform style name (e.g. `'webkitTransform'` for WebKit).\r
+       L.DomUtil.TRANSFORM = L.DomUtil.testProp(\r
+                       ['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform']);\r
 \r
-// webkitTransition comes first because some browser versions that drop vendor prefix don't do\r
-// the same for the transitionend event, in particular the Android 4.1 stock browser\r
 \r
-L.DomUtil.TRANSITION = L.DomUtil.testProp(\r
-        ['webkitTransition', 'transition', 'OTransition', 'MozTransition', 'msTransition']);\r
+       // webkitTransition comes first because some browser versions that drop vendor prefix don't do\r
+       // the same for the transitionend event, in particular the Android 4.1 stock browser\r
 \r
-L.DomUtil.TRANSITION_END =\r
-        L.DomUtil.TRANSITION === 'webkitTransition' || L.DomUtil.TRANSITION === 'OTransition' ?\r
-        L.DomUtil.TRANSITION + 'End' : 'transitionend';\r
+       // @property TRANSITION: String\r
+       // Vendor-prefixed transform style name.\r
+       var transition = L.DomUtil.TRANSITION = L.DomUtil.testProp(\r
+                       ['webkitTransition', 'transition', 'OTransition', 'MozTransition', 'msTransition']);\r
 \r
-(function () {\r
-    if ('onselectstart' in document) {\r
-        L.extend(L.DomUtil, {\r
-            disableTextSelection: function () {\r
-                L.DomEvent.on(window, 'selectstart', L.DomEvent.preventDefault);\r
-            },\r
-\r
-            enableTextSelection: function () {\r
-                L.DomEvent.off(window, 'selectstart', L.DomEvent.preventDefault);\r
-            }\r
-        });\r
-    } else {\r
-        var userSelectProperty = L.DomUtil.testProp(\r
-            ['userSelect', 'WebkitUserSelect', 'OUserSelect', 'MozUserSelect', 'msUserSelect']);\r
-\r
-        L.extend(L.DomUtil, {\r
-            disableTextSelection: function () {\r
-                if (userSelectProperty) {\r
-                    var style = document.documentElement.style;\r
-                    this._userSelect = style[userSelectProperty];\r
-                    style[userSelectProperty] = 'none';\r
-                }\r
-            },\r
-\r
-            enableTextSelection: function () {\r
-                if (userSelectProperty) {\r
-                    document.documentElement.style[userSelectProperty] = this._userSelect;\r
-                    delete this._userSelect;\r
-                }\r
-            }\r
-        });\r
-    }\r
-\r
-       L.extend(L.DomUtil, {\r
-               disableImageDrag: function () {\r
-                       L.DomEvent.on(window, 'dragstart', L.DomEvent.preventDefault);\r
-               },\r
+       L.DomUtil.TRANSITION_END =\r
+                       transition === 'webkitTransition' || transition === 'OTransition' ? transition + 'End' : 'transitionend';\r
 \r
-               enableImageDrag: function () {\r
-                       L.DomEvent.off(window, 'dragstart', L.DomEvent.preventDefault);\r
-               }\r
-       });\r
+       // @function disableTextSelection()\r
+       // Prevents the user from generating `selectstart` DOM events, usually generated\r
+       // when the user drags the mouse through a page with text. Used internally\r
+       // by Leaflet to override the behaviour of any click-and-drag interaction on\r
+       // the map. Affects drag interactions on the whole document.\r
+\r
+       // @function enableTextSelection()\r
+       // Cancels the effects of a previous [`L.DomUtil.disableTextSelection`](#domutil-disabletextselection).\r
+       if ('onselectstart' in document) {\r
+               L.DomUtil.disableTextSelection = function () {\r
+                       L.DomEvent.on(window, 'selectstart', L.DomEvent.preventDefault);\r
+               };\r
+               L.DomUtil.enableTextSelection = function () {\r
+                       L.DomEvent.off(window, 'selectstart', L.DomEvent.preventDefault);\r
+               };\r
+\r
+       } else {\r
+               var userSelectProperty = L.DomUtil.testProp(\r
+                       ['userSelect', 'WebkitUserSelect', 'OUserSelect', 'MozUserSelect', 'msUserSelect']);\r
+\r
+               L.DomUtil.disableTextSelection = function () {\r
+                       if (userSelectProperty) {\r
+                               var style = document.documentElement.style;\r
+                               this._userSelect = style[userSelectProperty];\r
+                               style[userSelectProperty] = 'none';\r
+                       }\r
+               };\r
+               L.DomUtil.enableTextSelection = function () {\r
+                       if (userSelectProperty) {\r
+                               document.documentElement.style[userSelectProperty] = this._userSelect;\r
+                               delete this._userSelect;\r
+                       }\r
+               };\r
+       }\r
+\r
+       // @function disableImageDrag()\r
+       // As [`L.DomUtil.disableTextSelection`](#domutil-disabletextselection), but\r
+       // for `dragstart` DOM events, usually generated when the user drags an image.\r
+       L.DomUtil.disableImageDrag = function () {\r
+               L.DomEvent.on(window, 'dragstart', L.DomEvent.preventDefault);\r
+       };\r
+\r
+       // @function enableImageDrag()\r
+       // Cancels the effects of a previous [`L.DomUtil.disableImageDrag`](#domutil-disabletextselection).\r
+       L.DomUtil.enableImageDrag = function () {\r
+               L.DomEvent.off(window, 'dragstart', L.DomEvent.preventDefault);\r
+       };\r
+\r
+       // @function preventOutline(el: HTMLElement)\r
+       // Makes the [outline](https://developer.mozilla.org/docs/Web/CSS/outline)\r
+       // of the element `el` invisible. Used internally by Leaflet to prevent\r
+       // focusable elements from displaying an outline when the user performs a\r
+       // drag interaction on them.\r
+       L.DomUtil.preventOutline = function (element) {\r
+               while (element.tabIndex === -1) {\r
+                       element = element.parentNode;\r
+               }\r
+               if (!element || !element.style) { return; }\r
+               L.DomUtil.restoreOutline();\r
+               this._outlineElement = element;\r
+               this._outlineStyle = element.style.outline;\r
+               element.style.outline = 'none';\r
+               L.DomEvent.on(window, 'keydown', L.DomUtil.restoreOutline, this);\r
+       };\r
+\r
+       // @function restoreOutline()\r
+       // Cancels the effects of a previous [`L.DomUtil.preventOutline`]().\r
+       L.DomUtil.restoreOutline = function () {\r
+               if (!this._outlineElement) { return; }\r
+               this._outlineElement.style.outline = this._outlineStyle;\r
+               delete this._outlineElement;\r
+               delete this._outlineStyle;\r
+               L.DomEvent.off(window, 'keydown', L.DomUtil.restoreOutline, this);\r
+       };\r
 })();\r
 
 
-/*\r
- * L.LatLng represents a geographical point with latitude and longitude coordinates.\r
+
+/* @class LatLng\r
+ * @aka L.LatLng\r
+ *\r
+ * Represents a geographical point with a certain latitude and longitude.\r
+ *\r
+ * @example\r
+ *\r
+ * ```\r
+ * var latlng = L.latLng(50.5, 30.5);\r
+ * ```\r
+ *\r
+ * All Leaflet methods that accept LatLng objects also accept them in a simple Array form and simple object form (unless noted otherwise), so these lines are equivalent:\r
+ *\r
+ * ```\r
+ * map.panTo([50, 30]);\r
+ * map.panTo({lon: 30, lat: 50});\r
+ * map.panTo({lat: 50, lng: 30});\r
+ * map.panTo(L.latLng(50, 30));\r
+ * ```\r
  */\r
 \r
-L.LatLng = function (lat, lng, alt) { // (Number, Number, Number)\r
-       lat = parseFloat(lat);\r
-       lng = parseFloat(lng);\r
-\r
+L.LatLng = function (lat, lng, alt) {\r
        if (isNaN(lat) || isNaN(lng)) {\r
                throw new Error('Invalid LatLng object: (' + lat + ', ' + lng + ')');\r
        }\r
 \r
-       this.lat = lat;\r
-       this.lng = lng;\r
+       // @property lat: Number\r
+       // Latitude in degrees\r
+       this.lat = +lat;\r
+\r
+       // @property lng: Number\r
+       // Longitude in degrees\r
+       this.lng = +lng;\r
 \r
+       // @property alt: Number\r
+       // Altitude in meters (optional)\r
        if (alt !== undefined) {\r
-               this.alt = parseFloat(alt);\r
+               this.alt = +alt;\r
        }\r
 };\r
 \r
-L.extend(L.LatLng, {\r
-       DEG_TO_RAD: Math.PI / 180,\r
-       RAD_TO_DEG: 180 / Math.PI,\r
-       MAX_MARGIN: 1.0E-9 // max margin of error for the "equals" check\r
-});\r
-\r
 L.LatLng.prototype = {\r
-       equals: function (obj) { // (LatLng) -> Boolean\r
+       // @method equals(otherLatLng: LatLng, maxMargin?: Number): Boolean\r
+       // Returns `true` if the given `LatLng` point is at the same position (within a small margin of error). The margin of error can be overriden by setting `maxMargin` to a small number.\r
+       equals: function (obj, maxMargin) {\r
                if (!obj) { return false; }\r
 \r
                obj = L.latLng(obj);\r
@@ -1146,79 +1640,115 @@ L.LatLng.prototype = {
                        Math.abs(this.lat - obj.lat),\r
                        Math.abs(this.lng - obj.lng));\r
 \r
-               return margin <= L.LatLng.MAX_MARGIN;\r
+               return margin <= (maxMargin === undefined ? 1.0E-9 : maxMargin);\r
        },\r
 \r
-       toString: function (precision) { // (Number) -> String\r
+       // @method toString(): String\r
+       // Returns a string representation of the point (for debugging purposes).\r
+       toString: function (precision) {\r
                return 'LatLng(' +\r
                        L.Util.formatNum(this.lat, precision) + ', ' +\r
                        L.Util.formatNum(this.lng, precision) + ')';\r
        },\r
 \r
-       // Haversine distance formula, see http://en.wikipedia.org/wiki/Haversine_formula\r
-       // TODO move to projection code, LatLng shouldn't know about Earth\r
-       distanceTo: function (other) { // (LatLng) -> Number\r
-               other = L.latLng(other);\r
+       // @method distanceTo(otherLatLng: LatLng): Number\r
+       // Returns the distance (in meters) to the given `LatLng` calculated using the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula).\r
+       distanceTo: function (other) {\r
+               return L.CRS.Earth.distance(this, L.latLng(other));\r
+       },\r
 \r
-               var R = 6378137, // earth radius in meters\r
-                   d2r = L.LatLng.DEG_TO_RAD,\r
-                   dLat = (other.lat - this.lat) * d2r,\r
-                   dLon = (other.lng - this.lng) * d2r,\r
-                   lat1 = this.lat * d2r,\r
-                   lat2 = other.lat * d2r,\r
-                   sin1 = Math.sin(dLat / 2),\r
-                   sin2 = Math.sin(dLon / 2);\r
+       // @method wrap(): LatLng\r
+       // Returns a new `LatLng` object with the longitude wrapped so it's always between -180 and +180 degrees.\r
+       wrap: function () {\r
+               return L.CRS.Earth.wrapLatLng(this);\r
+       },\r
 \r
-               var a = sin1 * sin1 + sin2 * sin2 * Math.cos(lat1) * Math.cos(lat2);\r
+       // @method toBounds(sizeInMeters: Number): LatLngBounds\r
+       // Returns a new `LatLngBounds` object in which each boundary is `sizeInMeters/2` meters apart from the `LatLng`.\r
+       toBounds: function (sizeInMeters) {\r
+               var latAccuracy = 180 * sizeInMeters / 40075017,\r
+                   lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);\r
 \r
-               return R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\r
+               return L.latLngBounds(\r
+                       [this.lat - latAccuracy, this.lng - lngAccuracy],\r
+                       [this.lat + latAccuracy, this.lng + lngAccuracy]);\r
        },\r
 \r
-       wrap: function (a, b) { // (Number, Number) -> LatLng\r
-               var lng = this.lng;\r
+       clone: function () {\r
+               return new L.LatLng(this.lat, this.lng, this.alt);\r
+       }\r
+};\r
 \r
-               a = a || -180;\r
-               b = b ||  180;\r
 \r
-               lng = (lng + b) % (b - a) + (lng < a || lng === b ? b : a);\r
 \r
-               return new L.LatLng(this.lat, lng);\r
-       }\r
-};\r
+// @factory L.latLng(latitude: Number, longitude: Number, altitude?: Number): LatLng\r
+// Creates an object representing a geographical point with the given latitude and longitude (and optionally altitude).\r
+\r
+// @alternative\r
+// @factory L.latLng(coords: Array): LatLng\r
+// Expects an array of the form `[Number, Number]` or `[Number, Number, Number]` instead.\r
 \r
-L.latLng = function (a, b) { // (LatLng) or ([Number, Number]) or (Number, Number)\r
+// @alternative\r
+// @factory L.latLng(coords: Object): LatLng\r
+// Expects an plain object of the form `{lat: Number, lng: Number}` or `{lat: Number, lng: Number, alt: Number}` instead.\r
+\r
+L.latLng = function (a, b, c) {\r
        if (a instanceof L.LatLng) {\r
                return a;\r
        }\r
-       if (L.Util.isArray(a)) {\r
-               if (typeof a[0] === 'number' || typeof a[0] === 'string') {\r
+       if (L.Util.isArray(a) && typeof a[0] !== 'object') {\r
+               if (a.length === 3) {\r
                        return new L.LatLng(a[0], a[1], a[2]);\r
-               } else {\r
-                       return null;\r
                }\r
+               if (a.length === 2) {\r
+                       return new L.LatLng(a[0], a[1]);\r
+               }\r
+               return null;\r
        }\r
        if (a === undefined || a === null) {\r
                return a;\r
        }\r
        if (typeof a === 'object' && 'lat' in a) {\r
-               return new L.LatLng(a.lat, 'lng' in a ? a.lng : a.lon);\r
+               return new L.LatLng(a.lat, 'lng' in a ? a.lng : a.lon, a.alt);\r
        }\r
        if (b === undefined) {\r
                return null;\r
        }\r
-       return new L.LatLng(a, b);\r
+       return new L.LatLng(a, b, c);\r
 };\r
-\r
+
 
 
 /*\r
- * L.LatLngBounds represents a rectangular area on the map in geographical coordinates.\r
+ * @class LatLngBounds\r
+ * @aka L.LatLngBounds\r
+ *\r
+ * Represents a rectangular geographical area on a map.\r
+ *\r
+ * @example\r
+ *\r
+ * ```js\r
+ * var corner1 = L.latLng(40.712, -74.227),\r
+ * corner2 = L.latLng(40.774, -74.125),\r
+ * bounds = L.latLngBounds(corner1, corner2);\r
+ * ```\r
+ *\r
+ * All Leaflet methods that accept LatLngBounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:\r
+ *\r
+ * ```js\r
+ * map.fitBounds([\r
+ *     [40.712, -74.227],\r
+ *     [40.774, -74.125]\r
+ * ]);\r
+ * ```\r
+ *\r
+ * Caution: if the area crosses the antimeridian (often confused with the International Date Line), you must specify corners _outside_ the [-180, 180] degrees longitude range.\r
  */\r
 \r
-L.LatLngBounds = function (southWest, northEast) { // (LatLng, LatLng) or (LatLng[])\r
-       if (!southWest) { return; }\r
+L.LatLngBounds = function (corner1, corner2) { // (LatLng, LatLng) or (LatLng[])\r
+       if (!corner1) { return; }\r
 \r
-       var latlngs = northEast ? [southWest, northEast] : southWest;\r
+       var latlngs = corner2 ? [corner1, corner2] : corner1;\r
 \r
        for (var i = 0, len = latlngs.length; i < len; i++) {\r
                this.extend(latlngs[i]);\r
@@ -1226,37 +1756,48 @@ L.LatLngBounds = function (southWest, northEast) { // (LatLng, LatLng) or (LatLn
 };\r
 \r
 L.LatLngBounds.prototype = {\r
-       // extend the bounds to contain the given point or bounds\r
-       extend: function (obj) { // (LatLng) or (LatLngBounds)\r
-               if (!obj) { return this; }\r
 \r
-               var latLng = L.latLng(obj);\r
-               if (latLng !== null) {\r
-                       obj = latLng;\r
-               } else {\r
-                       obj = L.latLngBounds(obj);\r
-               }\r
+       // @method extend(latlng: LatLng): this\r
+       // Extend the bounds to contain the given point\r
+\r
+       // @alternative\r
+       // @method extend(otherBounds: LatLngBounds): this\r
+       // Extend the bounds to contain the given bounds\r
+       extend: function (obj) {\r
+               var sw = this._southWest,\r
+                   ne = this._northEast,\r
+                   sw2, ne2;\r
 \r
                if (obj instanceof L.LatLng) {\r
-                       if (!this._southWest && !this._northEast) {\r
-                               this._southWest = new L.LatLng(obj.lat, obj.lng);\r
-                               this._northEast = new L.LatLng(obj.lat, obj.lng);\r
-                       } else {\r
-                               this._southWest.lat = Math.min(obj.lat, this._southWest.lat);\r
-                               this._southWest.lng = Math.min(obj.lng, this._southWest.lng);\r
+                       sw2 = obj;\r
+                       ne2 = obj;\r
 \r
-                               this._northEast.lat = Math.max(obj.lat, this._northEast.lat);\r
-                               this._northEast.lng = Math.max(obj.lng, this._northEast.lng);\r
-                       }\r
                } else if (obj instanceof L.LatLngBounds) {\r
-                       this.extend(obj._southWest);\r
-                       this.extend(obj._northEast);\r
+                       sw2 = obj._southWest;\r
+                       ne2 = obj._northEast;\r
+\r
+                       if (!sw2 || !ne2) { return this; }\r
+\r
+               } else {\r
+                       return obj ? this.extend(L.latLng(obj) || L.latLngBounds(obj)) : this;\r
+               }\r
+\r
+               if (!sw && !ne) {\r
+                       this._southWest = new L.LatLng(sw2.lat, sw2.lng);\r
+                       this._northEast = new L.LatLng(ne2.lat, ne2.lng);\r
+               } else {\r
+                       sw.lat = Math.min(sw2.lat, sw.lat);\r
+                       sw.lng = Math.min(sw2.lng, sw.lng);\r
+                       ne.lat = Math.max(ne2.lat, ne.lat);\r
+                       ne.lng = Math.max(ne2.lng, ne.lng);\r
                }\r
+\r
                return this;\r
        },\r
 \r
-       // extend the bounds by a percentage\r
-       pad: function (bufferRatio) { // (Number) -> LatLngBounds\r
+       // @method pad(bufferRatio: Number): LatLngBounds\r
+       // Returns bigger bounds created by extending the current bounds by a given percentage in each direction.\r
+       pad: function (bufferRatio) {\r
                var sw = this._southWest,\r
                    ne = this._northEast,\r
                    heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio,\r
@@ -1267,46 +1808,70 @@ L.LatLngBounds.prototype = {
                        new L.LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer));\r
        },\r
 \r
-       getCenter: function () { // -> LatLng\r
+       // @method getCenter(): LatLng\r
+       // Returns the center point of the bounds.\r
+       getCenter: function () {\r
                return new L.LatLng(\r
                        (this._southWest.lat + this._northEast.lat) / 2,\r
                        (this._southWest.lng + this._northEast.lng) / 2);\r
        },\r
 \r
+       // @method getSouthWest(): LatLng\r
+       // Returns the south-west point of the bounds.\r
        getSouthWest: function () {\r
                return this._southWest;\r
        },\r
 \r
+       // @method getNorthEast(): LatLng\r
+       // Returns the north-east point of the bounds.\r
        getNorthEast: function () {\r
                return this._northEast;\r
        },\r
 \r
+       // @method getNorthWest(): LatLng\r
+       // Returns the north-west point of the bounds.\r
        getNorthWest: function () {\r
                return new L.LatLng(this.getNorth(), this.getWest());\r
        },\r
 \r
+       // @method getSouthEast(): LatLng\r
+       // Returns the south-east point of the bounds.\r
        getSouthEast: function () {\r
                return new L.LatLng(this.getSouth(), this.getEast());\r
        },\r
 \r
+       // @method getWest(): Number\r
+       // Returns the west longitude of the bounds\r
        getWest: function () {\r
                return this._southWest.lng;\r
        },\r
 \r
+       // @method getSouth(): Number\r
+       // Returns the south latitude of the bounds\r
        getSouth: function () {\r
                return this._southWest.lat;\r
        },\r
 \r
+       // @method getEast(): Number\r
+       // Returns the east longitude of the bounds\r
        getEast: function () {\r
                return this._northEast.lng;\r
        },\r
 \r
+       // @method getNorth(): Number\r
+       // Returns the north latitude of the bounds\r
        getNorth: function () {\r
                return this._northEast.lat;\r
        },\r
 \r
+       // @method contains(otherBounds: LatLngBounds): Boolean\r
+       // Returns `true` if the rectangle contains the given one.\r
+\r
+       // @alternative\r
+       // @method contains (latlng: LatLng): Boolean\r
+       // Returns `true` if the rectangle contains the given point.\r
        contains: function (obj) { // (LatLngBounds) or (LatLng) -> Boolean\r
-               if (typeof obj[0] === 'number' || obj instanceof L.LatLng) {\r
+               if (typeof obj[0] === 'number' || obj instanceof L.LatLng || 'lat' in obj) {\r
                        obj = L.latLng(obj);\r
                } else {\r
                        obj = L.latLngBounds(obj);\r
@@ -1327,7 +1892,9 @@ L.LatLngBounds.prototype = {
                       (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);\r
        },\r
 \r
-       intersects: function (bounds) { // (LatLngBounds)\r
+       // @method intersects(otherBounds: LatLngBounds): Boolean\r
+       // Returns `true` if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common.\r
+       intersects: function (bounds) {\r
                bounds = L.latLngBounds(bounds);\r
 \r
                var sw = this._southWest,\r
@@ -1341,11 +1908,31 @@ L.LatLngBounds.prototype = {
                return latIntersects && lngIntersects;\r
        },\r
 \r
+       // @method overlaps(otherBounds: Bounds): Boolean\r
+       // Returns `true` if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area.\r
+       overlaps: function (bounds) {\r
+               bounds = L.latLngBounds(bounds);\r
+\r
+               var sw = this._southWest,\r
+                   ne = this._northEast,\r
+                   sw2 = bounds.getSouthWest(),\r
+                   ne2 = bounds.getNorthEast(),\r
+\r
+                   latOverlaps = (ne2.lat > sw.lat) && (sw2.lat < ne.lat),\r
+                   lngOverlaps = (ne2.lng > sw.lng) && (sw2.lng < ne.lng);\r
+\r
+               return latOverlaps && lngOverlaps;\r
+       },\r
+\r
+       // @method toBBoxString(): String\r
+       // Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data.\r
        toBBoxString: function () {\r
                return [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(',');\r
        },\r
 \r
-       equals: function (bounds) { // (LatLngBounds)\r
+       // @method equals(otherBounds: LatLngBounds): Boolean\r
+       // Returns `true` if the rectangle is equivalent (within a small margin of error) to the given bounds.\r
+       equals: function (bounds) {\r
                if (!bounds) { return false; }\r
 \r
                bounds = L.latLngBounds(bounds);\r
@@ -1354,108 +1941,241 @@ L.LatLngBounds.prototype = {
                       this._northEast.equals(bounds.getNorthEast());\r
        },\r
 \r
+       // @method isValid(): Boolean\r
+       // Returns `true` if the bounds are properly initialized.\r
        isValid: function () {\r
                return !!(this._southWest && this._northEast);\r
        }\r
 };\r
 \r
-//TODO International date line?\r
+// TODO International date line?\r
 \r
-L.latLngBounds = function (a, b) { // (LatLngBounds) or (LatLng, LatLng)\r
-       if (!a || a instanceof L.LatLngBounds) {\r
+// @factory L.latLngBounds(corner1: LatLng, corner2: LatLng)\r
+// Creates a `LatLngBounds` object by defining two diagonally opposite corners of the rectangle.\r
+\r
+// @alternative\r
+// @factory L.latLngBounds(latlngs: LatLng[])\r
+// Creates a `LatLngBounds` object defined by the geographical points it contains. Very useful for zooming the map to fit a particular set of locations with [`fitBounds`](#map-fitbounds).\r
+L.latLngBounds = function (a, b) {\r
+       if (a instanceof L.LatLngBounds) {\r
                return a;\r
        }\r
        return new L.LatLngBounds(a, b);\r
 };\r
 
 
+
 /*\r
- * L.Projection contains various geographical projections used by CRS classes.\r
+ * @namespace Projection\r
+ * @section\r
+ * Leaflet comes with a set of already defined Projections out of the box:\r
+ *\r
+ * @projection L.Projection.LonLat\r
+ *\r
+ * Equirectangular, or Plate Carree projection — the most simple projection,\r
+ * mostly used by GIS enthusiasts. Directly maps `x` as longitude, and `y` as\r
+ * latitude. Also suitable for flat worlds, e.g. game maps. Used by the\r
+ * `EPSG:3395` and `Simple` CRS.\r
  */\r
 \r
 L.Projection = {};\r
+\r
+L.Projection.LonLat = {\r
+       project: function (latlng) {\r
+               return new L.Point(latlng.lng, latlng.lat);\r
+       },\r
+\r
+       unproject: function (point) {\r
+               return new L.LatLng(point.y, point.x);\r
+       },\r
+\r
+       bounds: L.bounds([-180, -90], [180, 90])\r
+};\r
+
 
 
 /*\r
- * Spherical Mercator is the most popular map projection, used by EPSG:3857 CRS used by default.\r
+ * @namespace Projection\r
+ * @projection L.Projection.SphericalMercator\r
+ *\r
+ * Spherical Mercator projection — the most common projection for online maps,\r
+ * used by almost all free and commercial tile providers. Assumes that Earth is\r
+ * a sphere. Used by the `EPSG:3857` CRS.\r
  */\r
 \r
 L.Projection.SphericalMercator = {\r
+\r
+       R: 6378137,\r
        MAX_LATITUDE: 85.0511287798,\r
 \r
-       project: function (latlng) { // (LatLng) -> Point\r
-               var d = L.LatLng.DEG_TO_RAD,\r
+       project: function (latlng) {\r
+               var d = Math.PI / 180,\r
                    max = this.MAX_LATITUDE,\r
                    lat = Math.max(Math.min(max, latlng.lat), -max),\r
-                   x = latlng.lng * d,\r
-                   y = lat * d;\r
+                   sin = Math.sin(lat * d);\r
 \r
-               y = Math.log(Math.tan((Math.PI / 4) + (y / 2)));\r
-\r
-               return new L.Point(x, y);\r
+               return new L.Point(\r
+                               this.R * latlng.lng * d,\r
+                               this.R * Math.log((1 + sin) / (1 - sin)) / 2);\r
        },\r
 \r
-       unproject: function (point) { // (Point, Boolean) -> LatLng\r
-               var d = L.LatLng.RAD_TO_DEG,\r
-                   lng = point.x * d,\r
-                   lat = (2 * Math.atan(Math.exp(point.y)) - (Math.PI / 2)) * d;\r
-\r
-               return new L.LatLng(lat, lng);\r
-       }\r
-};\r
-
-
-/*\r
- * Simple equirectangular (Plate Carree) projection, used by CRS like EPSG:4326 and Simple.\r
- */\r
+       unproject: function (point) {\r
+               var d = 180 / Math.PI;\r
 \r
-L.Projection.LonLat = {\r
-       project: function (latlng) {\r
-               return new L.Point(latlng.lng, latlng.lat);\r
+               return new L.LatLng(\r
+                       (2 * Math.atan(Math.exp(point.y / this.R)) - (Math.PI / 2)) * d,\r
+                       point.x * d / this.R);\r
        },\r
 \r
-       unproject: function (point) {\r
-               return new L.LatLng(point.y, point.x);\r
-       }\r
+       bounds: (function () {\r
+               var d = 6378137 * Math.PI;\r
+               return L.bounds([-d, -d], [d, d]);\r
+       })()\r
 };\r
 
 
+
 /*\r
- * L.CRS is a base object for all defined CRS (Coordinate Reference Systems) in Leaflet.\r
+ * @class CRS\r
+ * @aka L.CRS\r
+ * Abstract class that defines coordinate reference systems for projecting\r
+ * geographical points into pixel (screen) coordinates and back (and to\r
+ * coordinates in other units for [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services). See\r
+ * [spatial reference system](http://en.wikipedia.org/wiki/Coordinate_reference_system).\r
+ *\r
+ * Leaflet defines the most usual CRSs by default. If you want to use a\r
+ * CRS not defined by default, take a look at the\r
+ * [Proj4Leaflet](https://github.com/kartena/Proj4Leaflet) plugin.\r
  */\r
 \r
 L.CRS = {\r
-       latLngToPoint: function (latlng, zoom) { // (LatLng, Number) -> Point\r
+       // @method latLngToPoint(latlng: LatLng, zoom: Number): Point\r
+       // Projects geographical coordinates into pixel coordinates for a given zoom.\r
+       latLngToPoint: function (latlng, zoom) {\r
                var projectedPoint = this.projection.project(latlng),\r
                    scale = this.scale(zoom);\r
 \r
                return this.transformation._transform(projectedPoint, scale);\r
        },\r
 \r
-       pointToLatLng: function (point, zoom) { // (Point, Number[, Boolean]) -> LatLng\r
+       // @method pointToLatLng(point: Point, zoom: Number): LatLng\r
+       // The inverse of `latLngToPoint`. Projects pixel coordinates on a given\r
+       // zoom into geographical coordinates.\r
+       pointToLatLng: function (point, zoom) {\r
                var scale = this.scale(zoom),\r
                    untransformedPoint = this.transformation.untransform(point, scale);\r
 \r
                return this.projection.unproject(untransformedPoint);\r
        },\r
 \r
+       // @method project(latlng: LatLng): Point\r
+       // Projects geographical coordinates into coordinates in units accepted for\r
+       // this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).\r
        project: function (latlng) {\r
                return this.projection.project(latlng);\r
        },\r
 \r
+       // @method unproject(point: Point): LatLng\r
+       // Given a projected coordinate returns the corresponding LatLng.\r
+       // The inverse of `project`.\r
+       unproject: function (point) {\r
+               return this.projection.unproject(point);\r
+       },\r
+\r
+       // @method scale(zoom: Number): Number\r
+       // Returns the scale used when transforming projected coordinates into\r
+       // pixel coordinates for a particular zoom. For example, it returns\r
+       // `256 * 2^zoom` for Mercator-based CRS.\r
        scale: function (zoom) {\r
                return 256 * Math.pow(2, zoom);\r
        },\r
 \r
-       getSize: function (zoom) {\r
-               var s = this.scale(zoom);\r
-               return L.point(s, s);\r
+       // @method zoom(scale: Number): Number\r
+       // Inverse of `scale()`, returns the zoom level corresponding to a scale\r
+       // factor of `scale`.\r
+       zoom: function (scale) {\r
+               return Math.log(scale / 256) / Math.LN2;\r
+       },\r
+\r
+       // @method getProjectedBounds(zoom: Number): Bounds\r
+       // Returns the projection's bounds scaled and transformed for the provided `zoom`.\r
+       getProjectedBounds: function (zoom) {\r
+               if (this.infinite) { return null; }\r
+\r
+               var b = this.projection.bounds,\r
+                   s = this.scale(zoom),\r
+                   min = this.transformation.transform(b.min, s),\r
+                   max = this.transformation.transform(b.max, s);\r
+\r
+               return L.bounds(min, max);\r
+       },\r
+\r
+       // @method distance(latlng1: LatLng, latlng2: LatLng): Number\r
+       // Returns the distance between two geographical coordinates.\r
+\r
+       // @property code: String\r
+       // Standard code name of the CRS passed into WMS services (e.g. `'EPSG:3857'`)\r
+       //\r
+       // @property wrapLng: Number[]\r
+       // An array of two numbers defining whether the longitude (horizontal) coordinate\r
+       // axis wraps around a given range and how. Defaults to `[-180, 180]` in most\r
+       // geographical CRSs. If `undefined`, the longitude axis does not wrap around.\r
+       //\r
+       // @property wrapLat: Number[]\r
+       // Like `wrapLng`, but for the latitude (vertical) axis.\r
+\r
+       // wrapLng: [min, max],\r
+       // wrapLat: [min, max],\r
+\r
+       // @property infinite: Boolean\r
+       // If true, the coordinate space will be unbounded (infinite in both axes)\r
+       infinite: false,\r
+\r
+       // @method wrapLatLng(latlng: LatLng): LatLng\r
+       // Returns a `LatLng` where lat and lng has been wrapped according to the\r
+       // CRS's `wrapLat` and `wrapLng` properties, if they are outside the CRS's bounds.\r
+       // Only accepts actual `L.LatLng` instances, not arrays.\r
+       wrapLatLng: function (latlng) {\r
+               var lng = this.wrapLng ? L.Util.wrapNum(latlng.lng, this.wrapLng, true) : latlng.lng,\r
+                   lat = this.wrapLat ? L.Util.wrapNum(latlng.lat, this.wrapLat, true) : latlng.lat,\r
+                   alt = latlng.alt;\r
+\r
+               return L.latLng(lat, lng, alt);\r
+       },\r
+\r
+       // @method wrapLatLngBounds(bounds: LatLngBounds): LatLngBounds\r
+       // Returns a `LatLngBounds` with the same size as the given one, ensuring\r
+       // that its center is within the CRS's bounds.\r
+       // Only accepts actual `L.LatLngBounds` instances, not arrays.\r
+       wrapLatLngBounds: function (bounds) {\r
+               var center = bounds.getCenter(),\r
+                   newCenter = this.wrapLatLng(center),\r
+                   latShift = center.lat - newCenter.lat,\r
+                   lngShift = center.lng - newCenter.lng;\r
+\r
+               if (latShift === 0 && lngShift === 0) {\r
+                       return bounds;\r
+               }\r
+\r
+               var sw = bounds.getSouthWest(),\r
+                   ne = bounds.getNorthEast(),\r
+                   newSw = L.latLng({lat: sw.lat - latShift, lng: sw.lng - lngShift}),\r
+                   newNe = L.latLng({lat: ne.lat - latShift, lng: ne.lng - lngShift});\r
+\r
+               return new L.LatLngBounds(newSw, newNe);\r
        }\r
 };\r
 
 
+
 /*
- * A simple CRS that can be used for flat non-Earth maps like panoramas or game maps.
+ * @namespace CRS
+ * @crs L.CRS.Simple
+ *
+ * A simple CRS that maps longitude and latitude into `x` and `y` directly.
+ * May be used for maps of flat surfaces (e.g. game maps). Note that the `y`
+ * axis should still be inverted (going from bottom to top). `distance()` returns
+ * simple euclidean distance.
  */
 
 L.CRS.Simple = L.extend({}, L.CRS, {
@@ -1464,26 +2184,73 @@ L.CRS.Simple = L.extend({}, L.CRS, {
 
        scale: function (zoom) {
                return Math.pow(2, zoom);
+       },
+
+       zoom: function (scale) {
+               return Math.log(scale) / Math.LN2;
+       },
+
+       distance: function (latlng1, latlng2) {
+               var dx = latlng2.lng - latlng1.lng,
+                   dy = latlng2.lat - latlng1.lat;
+
+               return Math.sqrt(dx * dx + dy * dy);
+       },
+
+       infinite: true
+});
+
+
+
+/*
+ * @namespace CRS
+ * @crs L.CRS.Earth
+ *
+ * Serves as the base for CRS that are global such that they cover the earth.
+ * Can only be used as the base for other CRS and cannot be used directly,
+ * since it does not have a `code`, `projection` or `transformation`. `distance()` returns
+ * meters.
+ */
+
+L.CRS.Earth = L.extend({}, L.CRS, {
+       wrapLng: [-180, 180],
+
+       // Mean Earth Radius, as recommended for use by
+       // the International Union of Geodesy and Geophysics,
+       // see http://rosettacode.org/wiki/Haversine_formula
+       R: 6371000,
+
+       // distance between two geographical points using spherical law of cosines approximation
+       distance: function (latlng1, latlng2) {
+               var rad = Math.PI / 180,
+                   lat1 = latlng1.lat * rad,
+                   lat2 = latlng2.lat * rad,
+                   a = Math.sin(lat1) * Math.sin(lat2) +
+                       Math.cos(lat1) * Math.cos(lat2) * Math.cos((latlng2.lng - latlng1.lng) * rad);
+
+               return this.R * Math.acos(Math.min(a, 1));
        }
 });
 
 
+
 /*\r
- * L.CRS.EPSG3857 (Spherical Mercator) is the most common CRS for web mapping\r
- * and is used by Leaflet by default.\r
+ * @namespace CRS\r
+ * @crs L.CRS.EPSG3857\r
+ *\r
+ * The most common CRS for online maps, used by almost all free and commercial\r
+ * tile providers. Uses Spherical Mercator projection. Set in by default in\r
+ * Map's `crs` option.\r
  */\r
 \r
-L.CRS.EPSG3857 = L.extend({}, L.CRS, {\r
+L.CRS.EPSG3857 = L.extend({}, L.CRS.Earth, {\r
        code: 'EPSG:3857',\r
-\r
        projection: L.Projection.SphericalMercator,\r
-       transformation: new L.Transformation(0.5 / Math.PI, 0.5, -0.5 / Math.PI, 0.5),\r
 \r
-       project: function (latlng) { // (LatLng) -> Point\r
-               var projectedPoint = this.projection.project(latlng),\r
-                   earthRadius = 6378137;\r
-               return projectedPoint.multiplyBy(earthRadius);\r
-       }\r
+       transformation: (function () {\r
+               var scale = 0.5 / (Math.PI * L.Projection.SphericalMercator.R);\r
+               return new L.Transformation(scale, 0.5, -scale, 0.5);\r
+       }())\r
 });\r
 \r
 L.CRS.EPSG900913 = L.extend({}, L.CRS.EPSG3857, {\r
@@ -1491,44 +2258,140 @@ L.CRS.EPSG900913 = L.extend({}, L.CRS.EPSG3857, {
 });\r
 
 
+
 /*\r
- * L.CRS.EPSG4326 is a CRS popular among advanced GIS specialists.\r
+ * @namespace CRS\r
+ * @crs L.CRS.EPSG4326\r
+ *\r
+ * A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.\r
+ *\r
+ * Leaflet 1.0.x complies with the [TMS coordinate scheme for EPSG:4326](https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-geodetic),\r
+ * which is a breaking change from 0.7.x behaviour.  If you are using a `TileLayer`\r
+ * with this CRS, ensure that there are two 256x256 pixel tiles covering the\r
+ * whole earth at zoom level zero, and that the tile coordinate origin is (-180,+90),\r
+ * or (-180,-90) for `TileLayer`s with [the `tms` option](#tilelayer-tms) set.\r
  */\r
 \r
-L.CRS.EPSG4326 = L.extend({}, L.CRS, {\r
+L.CRS.EPSG4326 = L.extend({}, L.CRS.Earth, {\r
        code: 'EPSG:4326',\r
-\r
        projection: L.Projection.LonLat,\r
-       transformation: new L.Transformation(1 / 360, 0.5, -1 / 360, 0.5)\r
+       transformation: new L.Transformation(1 / 180, 1, -1 / 180, 0.5)\r
 });\r
 
 
+
 /*\r
- * L.Map is the central class of the API - it is used to create a map.\r
+ * @class Map\r
+ * @aka L.Map\r
+ * @inherits Evented\r
+ *\r
+ * The central class of the API — it is used to create a map on a page and manipulate it.\r
+ *\r
+ * @example\r
+ *\r
+ * ```js\r
+ * // initialize the map on the "map" div with a given center and zoom\r
+ * var map = L.map('map', {\r
+ *     center: [51.505, -0.09],\r
+ *     zoom: 13\r
+ * });\r
+ * ```\r
+ *\r
  */\r
 \r
-L.Map = L.Class.extend({\r
-\r
-       includes: L.Mixin.Events,\r
+L.Map = L.Evented.extend({\r
 \r
        options: {\r
+               // @section Map State Options\r
+               // @option crs: CRS = L.CRS.EPSG3857\r
+               // The [Coordinate Reference System](#crs) to use. Don't change this if you're not\r
+               // sure what it means.\r
                crs: L.CRS.EPSG3857,\r
 \r
-               /*\r
-               center: LatLng,\r
-               zoom: Number,\r
-               layers: Array,\r
-               */\r
-\r
-               fadeAnimation: L.DomUtil.TRANSITION && !L.Browser.android23,\r
-               trackResize: true,\r
-               markerZoomAnimation: L.DomUtil.TRANSITION && L.Browser.any3d\r
+               // @option center: LatLng = undefined\r
+               // Initial geographic center of the map\r
+               center: undefined,\r
+\r
+               // @option zoom: Number = undefined\r
+               // Initial map zoom level\r
+               zoom: undefined,\r
+\r
+               // @option minZoom: Number = undefined\r
+               // Minimum zoom level of the map. Overrides any `minZoom` option set on map layers.\r
+               minZoom: undefined,\r
+\r
+               // @option maxZoom: Number = undefined\r
+               // Maximum zoom level of the map. Overrides any `maxZoom` option set on map layers.\r
+               maxZoom: undefined,\r
+\r
+               // @option layers: Layer[] = []\r
+               // Array of layers that will be added to the map initially\r
+               layers: [],\r
+\r
+               // @option maxBounds: LatLngBounds = null\r
+               // When this option is set, the map restricts the view to the given\r
+               // geographical bounds, bouncing the user back if the user tries to pan\r
+               // outside the view. To set the restriction dynamically, use\r
+               // [`setMaxBounds`](#map-setmaxbounds) method.\r
+               maxBounds: undefined,\r
+\r
+               // @option renderer: Renderer = *\r
+               // The default method for drawing vector layers on the map. `L.SVG`\r
+               // or `L.Canvas` by default depending on browser support.\r
+               renderer: undefined,\r
+\r
+\r
+               // @section Animation Options\r
+               // @option zoomAnimation: Boolean = true\r
+               // Whether the map zoom animation is enabled. By default it's enabled\r
+               // in all browsers that support CSS3 Transitions except Android.\r
+               zoomAnimation: true,\r
+\r
+               // @option zoomAnimationThreshold: Number = 4\r
+               // Won't animate zoom if the zoom difference exceeds this value.\r
+               zoomAnimationThreshold: 4,\r
+\r
+               // @option fadeAnimation: Boolean = true\r
+               // Whether the tile fade animation is enabled. By default it's enabled\r
+               // in all browsers that support CSS3 Transitions except Android.\r
+               fadeAnimation: true,\r
+\r
+               // @option markerZoomAnimation: Boolean = true\r
+               // Whether markers animate their zoom with the zoom animation, if disabled\r
+               // they will disappear for the length of the animation. By default it's\r
+               // enabled in all browsers that support CSS3 Transitions except Android.\r
+               markerZoomAnimation: true,\r
+\r
+               // @option transform3DLimit: Number = 2^23\r
+               // Defines the maximum size of a CSS translation transform. The default\r
+               // value should not be changed unless a web browser positions layers in\r
+               // the wrong place after doing a large `panBy`.\r
+               transform3DLimit: 8388608, // Precision limit of a 32-bit float\r
+\r
+               // @section Interaction Options\r
+               // @option zoomSnap: Number = 1\r
+               // Forces the map's zoom level to always be a multiple of this, particularly\r
+               // right after a [`fitBounds()`](#map-fitbounds) or a pinch-zoom.\r
+               // By default, the zoom level snaps to the nearest integer; lower values\r
+               // (e.g. `0.5` or `0.1`) allow for greater granularity. A value of `0`\r
+               // means the zoom level will not be snapped after `fitBounds` or a pinch-zoom.\r
+               zoomSnap: 1,\r
+\r
+               // @option zoomDelta: Number = 1\r
+               // Controls how much the map's zoom level will change after a\r
+               // [`zoomIn()`](#map-zoomin), [`zoomOut()`](#map-zoomout), pressing `+`\r
+               // or `-` on the keyboard, or using the [zoom controls](#control-zoom).\r
+               // Values smaller than `1` (e.g. `0.5`) allow for greater granularity.\r
+               zoomDelta: 1,\r
+\r
+               // @option trackResize: Boolean = true\r
+               // Whether the map automatically handles browser window resize to update itself.\r
+               trackResize: true\r
        },\r
 \r
        initialize: function (id, options) { // (HTMLElement or String, Object)\r
                options = L.setOptions(this, options);\r
 \r
-\r
                this._initContainer(id);\r
                this._initLayout();\r
 \r
@@ -1541,47 +2404,104 @@ L.Map = L.Class.extend({
                        this.setMaxBounds(options.maxBounds);\r
                }\r
 \r
+               if (options.zoom !== undefined) {\r
+                       this._zoom = this._limitZoom(options.zoom);\r
+               }\r
+\r
                if (options.center && options.zoom !== undefined) {\r
                        this.setView(L.latLng(options.center), options.zoom, {reset: true});\r
                }\r
 \r
                this._handlers = [];\r
-\r
                this._layers = {};\r
                this._zoomBoundLayers = {};\r
-               this._tileLayersNum = 0;\r
+               this._sizeChanged = true;\r
 \r
                this.callInitHooks();\r
 \r
-               this._addLayers(options.layers);\r
+               // don't animate on browsers without hardware-accelerated transitions or old Android/Opera\r
+               this._zoomAnimated = L.DomUtil.TRANSITION && L.Browser.any3d && !L.Browser.mobileOpera &&\r
+                               this.options.zoomAnimation;\r
+\r
+               // zoom transitions run with the same duration for all layers, so if one of transitionend events\r
+               // happens after starting zoom animation (propagating to the map pane), we know that it ended globally\r
+               if (this._zoomAnimated) {\r
+                       this._createAnimProxy();\r
+                       L.DomEvent.on(this._proxy, L.DomUtil.TRANSITION_END, this._catchTransitionEnd, this);\r
+               }\r
+\r
+               this._addLayers(this.options.layers);\r
        },\r
 \r
 \r
-       // public methods that modify map state\r
+       // @section Methods for modifying map state\r
+\r
+       // @method setView(center: LatLng, zoom: Number, options?: Zoom/pan options): this\r
+       // Sets the view of the map (geographical center and zoom) with the given\r
+       // animation options.\r
+       setView: function (center, zoom, options) {\r
+\r
+               zoom = zoom === undefined ? this._zoom : this._limitZoom(zoom);\r
+               center = this._limitCenter(L.latLng(center), zoom, this.options.maxBounds);\r
+               options = options || {};\r
+\r
+               this._stop();\r
+\r
+               if (this._loaded && !options.reset && options !== true) {\r
+\r
+                       if (options.animate !== undefined) {\r
+                               options.zoom = L.extend({animate: options.animate}, options.zoom);\r
+                               options.pan = L.extend({animate: options.animate, duration: options.duration}, options.pan);\r
+                       }\r
+\r
+                       // try animating pan or zoom\r
+                       var moved = (this._zoom !== zoom) ?\r
+                               this._tryAnimatedZoom && this._tryAnimatedZoom(center, zoom, options.zoom) :\r
+                               this._tryAnimatedPan(center, options.pan);\r
+\r
+                       if (moved) {\r
+                               // prevent resize handler call, the view will refresh after animation anyway\r
+                               clearTimeout(this._sizeTimer);\r
+                               return this;\r
+                       }\r
+               }\r
+\r
+               // animation didn't start, just reset the map view\r
+               this._resetView(center, zoom);\r
 \r
-       // replaced by animation-powered implementation in Map.PanAnimation.js\r
-       setView: function (center, zoom) {\r
-               zoom = zoom === undefined ? this.getZoom() : zoom;\r
-               this._resetView(L.latLng(center), this._limitZoom(zoom));\r
                return this;\r
        },\r
 \r
+       // @method setZoom(zoom: Number, options: Zoom/pan options): this\r
+       // Sets the zoom of the map.\r
        setZoom: function (zoom, options) {\r
                if (!this._loaded) {\r
-                       this._zoom = this._limitZoom(zoom);\r
+                       this._zoom = zoom;\r
                        return this;\r
                }\r
                return this.setView(this.getCenter(), zoom, {zoom: options});\r
        },\r
 \r
+       // @method zoomIn(delta?: Number, options?: Zoom options): this\r
+       // Increases the zoom of the map by `delta` ([`zoomDelta`](#map-zoomdelta) by default).\r
        zoomIn: function (delta, options) {\r
-               return this.setZoom(this._zoom + (delta || 1), options);\r
+               delta = delta || (L.Browser.any3d ? this.options.zoomDelta : 1);\r
+               return this.setZoom(this._zoom + delta, options);\r
        },\r
 \r
+       // @method zoomOut(delta?: Number, options?: Zoom options): this\r
+       // Decreases the zoom of the map by `delta` ([`zoomDelta`](#map-zoomdelta) by default).\r
        zoomOut: function (delta, options) {\r
-               return this.setZoom(this._zoom - (delta || 1), options);\r
+               delta = delta || (L.Browser.any3d ? this.options.zoomDelta : 1);\r
+               return this.setZoom(this._zoom - delta, options);\r
        },\r
 \r
+       // @method setZoomAround(latlng: LatLng, zoom: Number, options: Zoom options): this\r
+       // Zooms the map while keeping a specified geographical point on the map\r
+       // stationary (e.g. used internally for scroll zoom and double-click zoom).\r
+       // @alternative\r
+       // @method setZoomAround(offset: Point, zoom: Number, options: Zoom options): this\r
+       // Zooms the map while keeping a specified pixel on the map (relative to the top-left corner) stationary.\r
        setZoomAround: function (latlng, zoom, options) {\r
                var scale = this.getZoomScale(zoom),\r
                    viewHalf = this.getSize().divideBy(2),\r
@@ -1593,7 +2513,7 @@ L.Map = L.Class.extend({
                return this.setView(newCenter, zoom, {zoom: options});\r
        },\r
 \r
-       fitBounds: function (bounds, options) {\r
+       _getBoundsCenterZoom: function (bounds, options) {\r
 \r
                options = options || {};\r
                bounds = bounds.getBounds ? bounds.getBounds() : L.latLngBounds(bounds);\r
@@ -1603,7 +2523,7 @@ L.Map = L.Class.extend({
 \r
                    zoom = this.getBoundsZoom(bounds, false, paddingTL.add(paddingBR));\r
 \r
-               zoom = (options.maxZoom) ? Math.min(options.maxZoom, zoom) : zoom;\r
+               zoom = (typeof options.maxZoom === 'number') ? Math.min(options.maxZoom, zoom) : zoom;\r
 \r
                var paddingOffset = paddingBR.subtract(paddingTL).divideBy(2),\r
 \r
@@ -1611,127 +2531,249 @@ L.Map = L.Class.extend({
                    nePoint = this.project(bounds.getNorthEast(), zoom),\r
                    center = this.unproject(swPoint.add(nePoint).divideBy(2).add(paddingOffset), zoom);\r
 \r
-               return this.setView(center, zoom, options);\r
+               return {\r
+                       center: center,\r
+                       zoom: zoom\r
+               };\r
+       },\r
+\r
+       // @method fitBounds(bounds: LatLngBounds, options?: fitBounds options): this\r
+       // Sets a map view that contains the given geographical bounds with the\r
+       // maximum zoom level possible.\r
+       fitBounds: function (bounds, options) {\r
+\r
+               bounds = L.latLngBounds(bounds);\r
+\r
+               if (!bounds.isValid()) {\r
+                       throw new Error('Bounds are not valid.');\r
+               }\r
+\r
+               var target = this._getBoundsCenterZoom(bounds, options);\r
+               return this.setView(target.center, target.zoom, options);\r
        },\r
 \r
+       // @method fitWorld(options?: fitBounds options): this\r
+       // Sets a map view that mostly contains the whole world with the maximum\r
+       // zoom level possible.\r
        fitWorld: function (options) {\r
                return this.fitBounds([[-90, -180], [90, 180]], options);\r
        },\r
 \r
+       // @method panTo(latlng: LatLng, options?: Pan options): this\r
+       // Pans the map to a given center.\r
        panTo: function (center, options) { // (LatLng)\r
                return this.setView(center, this._zoom, {pan: options});\r
        },\r
 \r
-       panBy: function (offset) { // (Point)\r
-               // replaced with animated panBy in Map.PanAnimation.js\r
-               this.fire('movestart');\r
-\r
-               this._rawPanBy(L.point(offset));\r
+       // @method panBy(offset: Point): this\r
+       // Pans the map by a given number of pixels (animated).\r
+       panBy: function (offset, options) {\r
+               offset = L.point(offset).round();\r
+               options = options || {};\r
 \r
-               this.fire('move');\r
-               return this.fire('moveend');\r
-       },\r
+               if (!offset.x && !offset.y) {\r
+                       return this.fire('moveend');\r
+               }\r
+               // If we pan too far, Chrome gets issues with tiles\r
+               // and makes them disappear or appear in the wrong place (slightly offset) #2602\r
+               if (options.animate !== true && !this.getSize().contains(offset)) {\r
+                       this._resetView(this.unproject(this.project(this.getCenter()).add(offset)), this.getZoom());\r
+                       return this;\r
+               }\r
 \r
-       setMaxBounds: function (bounds) {\r
-               bounds = L.latLngBounds(bounds);\r
+               if (!this._panAnim) {\r
+                       this._panAnim = new L.PosAnimation();\r
 \r
-               this.options.maxBounds = bounds;\r
+                       this._panAnim.on({\r
+                               'step': this._onPanTransitionStep,\r
+                               'end': this._onPanTransitionEnd\r
+                       }, this);\r
+               }\r
 \r
-               if (!bounds) {\r
-                       return this.off('moveend', this._panInsideMaxBounds, this);\r
+               // don't fire movestart if animating inertia\r
+               if (!options.noMoveStart) {\r
+                       this.fire('movestart');\r
                }\r
 \r
-               if (this._loaded) {\r
-                       this._panInsideMaxBounds();\r
+               // animate pan unless animate: false specified\r
+               if (options.animate !== false) {\r
+                       L.DomUtil.addClass(this._mapPane, 'leaflet-pan-anim');\r
+\r
+                       var newPos = this._getMapPanePos().subtract(offset).round();\r
+                       this._panAnim.run(this._mapPane, newPos, options.duration || 0.25, options.easeLinearity);\r
+               } else {\r
+                       this._rawPanBy(offset);\r
+                       this.fire('move').fire('moveend');\r
                }\r
 \r
-               return this.on('moveend', this._panInsideMaxBounds, this);\r
+               return this;\r
        },\r
 \r
-       panInsideBounds: function (bounds, options) {\r
-               var center = this.getCenter(),\r
-                       newCenter = this._limitCenter(center, this._zoom, bounds);\r
+       // @method flyTo(latlng: LatLng, zoom?: Number, options?: Zoom/pan options): this\r
+       // Sets the view of the map (geographical center and zoom) performing a smooth\r
+       // pan-zoom animation.\r
+       flyTo: function (targetCenter, targetZoom, options) {\r
 \r
-               if (center.equals(newCenter)) { return this; }\r
+               options = options || {};\r
+               if (options.animate === false || !L.Browser.any3d) {\r
+                       return this.setView(targetCenter, targetZoom, options);\r
+               }\r
 \r
-               return this.panTo(newCenter, options);\r
-       },\r
+               this._stop();\r
 \r
-       addLayer: function (layer) {\r
-               // TODO method is too big, refactor\r
+               var from = this.project(this.getCenter()),\r
+                   to = this.project(targetCenter),\r
+                   size = this.getSize(),\r
+                   startZoom = this._zoom;\r
 \r
-               var id = L.stamp(layer);\r
+               targetCenter = L.latLng(targetCenter);\r
+               targetZoom = targetZoom === undefined ? startZoom : targetZoom;\r
 \r
-               if (this._layers[id]) { return this; }\r
+               var w0 = Math.max(size.x, size.y),\r
+                   w1 = w0 * this.getZoomScale(startZoom, targetZoom),\r
+                   u1 = (to.distanceTo(from)) || 1,\r
+                   rho = 1.42,\r
+                   rho2 = rho * rho;\r
 \r
-               this._layers[id] = layer;\r
+               function r(i) {\r
+                       var s1 = i ? -1 : 1,\r
+                           s2 = i ? w1 : w0,\r
+                           t1 = w1 * w1 - w0 * w0 + s1 * rho2 * rho2 * u1 * u1,\r
+                           b1 = 2 * s2 * rho2 * u1,\r
+                           b = t1 / b1,\r
+                           sq = Math.sqrt(b * b + 1) - b;\r
 \r
-               // TODO getMaxZoom, getMinZoom in ILayer (instead of options)\r
-               if (layer.options && (!isNaN(layer.options.maxZoom) || !isNaN(layer.options.minZoom))) {\r
-                       this._zoomBoundLayers[id] = layer;\r
-                       this._updateZoomLevels();\r
-               }\r
+                           // workaround for floating point precision bug when sq = 0, log = -Infinite,\r
+                           // thus triggering an infinite loop in flyTo\r
+                           var log = sq < 0.000000001 ? -18 : Math.log(sq);\r
 \r
-               // TODO looks ugly, refactor!!!\r
-               if (this.options.zoomAnimation && L.TileLayer && (layer instanceof L.TileLayer)) {\r
-                       this._tileLayersNum++;\r
-                       this._tileLayersToLoad++;\r
-                       layer.on('load', this._onTileLayerLoad, this);\r
+                       return log;\r
                }\r
 \r
-               if (this._loaded) {\r
-                       this._layerAdd(layer);\r
+               function sinh(n) { return (Math.exp(n) - Math.exp(-n)) / 2; }\r
+               function cosh(n) { return (Math.exp(n) + Math.exp(-n)) / 2; }\r
+               function tanh(n) { return sinh(n) / cosh(n); }\r
+\r
+               var r0 = r(0);\r
+\r
+               function w(s) { return w0 * (cosh(r0) / cosh(r0 + rho * s)); }\r
+               function u(s) { return w0 * (cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2; }\r
+\r
+               function easeOut(t) { return 1 - Math.pow(1 - t, 1.5); }\r
+\r
+               var start = Date.now(),\r
+                   S = (r(1) - r0) / rho,\r
+                   duration = options.duration ? 1000 * options.duration : 1000 * S * 0.8;\r
+\r
+               function frame() {\r
+                       var t = (Date.now() - start) / duration,\r
+                           s = easeOut(t) * S;\r
+\r
+                       if (t <= 1) {\r
+                               this._flyToFrame = L.Util.requestAnimFrame(frame, this);\r
+\r
+                               this._move(\r
+                                       this.unproject(from.add(to.subtract(from).multiplyBy(u(s) / u1)), startZoom),\r
+                                       this.getScaleZoom(w0 / w(s), startZoom),\r
+                                       {flyTo: true});\r
+\r
+                       } else {\r
+                               this\r
+                                       ._move(targetCenter, targetZoom)\r
+                                       ._moveEnd(true);\r
+                       }\r
                }\r
 \r
+               this._moveStart(true);\r
+\r
+               frame.call(this);\r
                return this;\r
        },\r
 \r
-       removeLayer: function (layer) {\r
-               var id = L.stamp(layer);\r
+       // @method flyToBounds(bounds: LatLngBounds, options?: fitBounds options): this\r
+       // Sets the view of the map with a smooth animation like [`flyTo`](#map-flyto),\r
+       // but takes a bounds parameter like [`fitBounds`](#map-fitbounds).\r
+       flyToBounds: function (bounds, options) {\r
+               var target = this._getBoundsCenterZoom(bounds, options);\r
+               return this.flyTo(target.center, target.zoom, options);\r
+       },\r
 \r
-               if (!this._layers[id]) { return this; }\r
+       // @method setMaxBounds(bounds: Bounds): this\r
+       // Restricts the map view to the given bounds (see the [maxBounds](#map-maxbounds) option).\r
+       setMaxBounds: function (bounds) {\r
+               bounds = L.latLngBounds(bounds);\r
 \r
-               if (this._loaded) {\r
-                       layer.onRemove(this);\r
+               if (!bounds.isValid()) {\r
+                       this.options.maxBounds = null;\r
+                       return this.off('moveend', this._panInsideMaxBounds);\r
+               } else if (this.options.maxBounds) {\r
+                       this.off('moveend', this._panInsideMaxBounds);\r
                }\r
 \r
-               delete this._layers[id];\r
+               this.options.maxBounds = bounds;\r
 \r
                if (this._loaded) {\r
-                       this.fire('layerremove', {layer: layer});\r
+                       this._panInsideMaxBounds();\r
                }\r
 \r
-               if (this._zoomBoundLayers[id]) {\r
-                       delete this._zoomBoundLayers[id];\r
-                       this._updateZoomLevels();\r
-               }\r
+               return this.on('moveend', this._panInsideMaxBounds);\r
+       },\r
+\r
+       // @method setMinZoom(zoom: Number): this\r
+       // Sets the lower limit for the available zoom levels (see the [minZoom](#map-minzoom) option).\r
+       setMinZoom: function (zoom) {\r
+               this.options.minZoom = zoom;\r
 \r
-               // TODO looks ugly, refactor\r
-               if (this.options.zoomAnimation && L.TileLayer && (layer instanceof L.TileLayer)) {\r
-                       this._tileLayersNum--;\r
-                       this._tileLayersToLoad--;\r
-                       layer.off('load', this._onTileLayerLoad, this);\r
+               if (this._loaded && this.getZoom() < this.options.minZoom) {\r
+                       return this.setZoom(zoom);\r
                }\r
 \r
                return this;\r
        },\r
 \r
-       hasLayer: function (layer) {\r
-               if (!layer) { return false; }\r
-\r
-               return (L.stamp(layer) in this._layers);\r
-       },\r
+       // @method setMaxZoom(zoom: Number): this\r
+       // Sets the upper limit for the available zoom levels (see the [maxZoom](#map-maxzoom) option).\r
+       setMaxZoom: function (zoom) {\r
+               this.options.maxZoom = zoom;\r
 \r
-       eachLayer: function (method, context) {\r
-               for (var i in this._layers) {\r
-                       method.call(context, this._layers[i]);\r
+               if (this._loaded && (this.getZoom() > this.options.maxZoom)) {\r
+                       return this.setZoom(zoom);\r
                }\r
+\r
                return this;\r
        },\r
 \r
-       invalidateSize: function (options) {\r
-               if (!this._loaded) { return this; }\r
-\r
+       // @method panInsideBounds(bounds: LatLngBounds, options?: Pan options): this\r
+       // Pans the map to the closest view that would lie inside the given bounds (if it's not already), controlling the animation using the options specific, if any.\r
+       panInsideBounds: function (bounds, options) {\r
+               this._enforcingBounds = true;\r
+               var center = this.getCenter(),\r
+                   newCenter = this._limitCenter(center, this._zoom, L.latLngBounds(bounds));\r
+\r
+               if (!center.equals(newCenter)) {\r
+                       this.panTo(newCenter, options);\r
+               }\r
+\r
+               this._enforcingBounds = false;\r
+               return this;\r
+       },\r
+\r
+       // @method invalidateSize(options: Zoom/Pan options): this\r
+       // Checks if the map container size changed and updates the map if so —\r
+       // call it after you've changed the map size dynamically, also animating\r
+       // pan by default. If `options.pan` is `false`, panning will not occur.\r
+       // If `options.debounceMoveend` is `true`, it will delay `moveend` event so\r
+       // that it doesn't happen often even if the method is called many\r
+       // times in a row.\r
+\r
+       // @alternative\r
+       // @method invalidateSize(animate: Boolean): this\r
+       // Checks if the map container size changed and updates the map if so —\r
+       // call it after you've changed the map size dynamically, also animating\r
+       // pan by default.\r
+       invalidateSize: function (options) {\r
+               if (!this._loaded) { return this; }\r
+\r
                options = L.extend({\r
                        animate: false,\r
                        pan: true\r
@@ -1739,7 +2781,7 @@ L.Map = L.Class.extend({
 \r
                var oldSize = this.getSize();\r
                this._sizeChanged = true;\r
-               this._initialCenter = null;\r
+               this._lastCenter = null;\r
 \r
                var newSize = this.getSize(),\r
                    oldCenter = oldSize.divideBy(2).round(),\r
@@ -1766,13 +2808,134 @@ L.Map = L.Class.extend({
                        }\r
                }\r
 \r
+               // @section Map state change events\r
+               // @event resize: ResizeEvent\r
+               // Fired when the map is resized.\r
                return this.fire('resize', {\r
                        oldSize: oldSize,\r
                        newSize: newSize\r
                });\r
        },\r
 \r
+       // @section Methods for modifying map state\r
+       // @method stop(): this\r
+       // Stops the currently running `panTo` or `flyTo` animation, if any.\r
+       stop: function () {\r
+               this.setZoom(this._limitZoom(this._zoom));\r
+               if (!this.options.zoomSnap) {\r
+                       this.fire('viewreset');\r
+               }\r
+               return this._stop();\r
+       },\r
+\r
+       // @section Geolocation methods\r
+       // @method locate(options?: Locate options): this\r
+       // Tries to locate the user using the Geolocation API, firing a [`locationfound`](#map-locationfound)\r
+       // event with location data on success or a [`locationerror`](#map-locationerror) event on failure,\r
+       // and optionally sets the map view to the user's location with respect to\r
+       // detection accuracy (or to the world view if geolocation failed).\r
+       // Note that, if your page doesn't use HTTPS, this method will fail in\r
+       // modern browsers ([Chrome 50 and newer](https://sites.google.com/a/chromium.org/dev/Home/chromium-security/deprecating-powerful-features-on-insecure-origins))\r
+       // See `Locate options` for more details.\r
+       locate: function (options) {\r
+\r
+               options = this._locateOptions = L.extend({\r
+                       timeout: 10000,\r
+                       watch: false\r
+                       // setView: false\r
+                       // maxZoom: <Number>\r
+                       // maximumAge: 0\r
+                       // enableHighAccuracy: false\r
+               }, options);\r
+\r
+               if (!('geolocation' in navigator)) {\r
+                       this._handleGeolocationError({\r
+                               code: 0,\r
+                               message: 'Geolocation not supported.'\r
+                       });\r
+                       return this;\r
+               }\r
+\r
+               var onResponse = L.bind(this._handleGeolocationResponse, this),\r
+                   onError = L.bind(this._handleGeolocationError, this);\r
+\r
+               if (options.watch) {\r
+                       this._locationWatchId =\r
+                               navigator.geolocation.watchPosition(onResponse, onError, options);\r
+               } else {\r
+                       navigator.geolocation.getCurrentPosition(onResponse, onError, options);\r
+               }\r
+               return this;\r
+       },\r
+\r
+       // @method stopLocate(): this\r
+       // Stops watching location previously initiated by `map.locate({watch: true})`\r
+       // and aborts resetting the map view if map.locate was called with\r
+       // `{setView: true}`.\r
+       stopLocate: function () {\r
+               if (navigator.geolocation && navigator.geolocation.clearWatch) {\r
+                       navigator.geolocation.clearWatch(this._locationWatchId);\r
+               }\r
+               if (this._locateOptions) {\r
+                       this._locateOptions.setView = false;\r
+               }\r
+               return this;\r
+       },\r
+\r
+       _handleGeolocationError: function (error) {\r
+               var c = error.code,\r
+                   message = error.message ||\r
+                           (c === 1 ? 'permission denied' :\r
+                           (c === 2 ? 'position unavailable' : 'timeout'));\r
+\r
+               if (this._locateOptions.setView && !this._loaded) {\r
+                       this.fitWorld();\r
+               }\r
+\r
+               // @section Location events\r
+               // @event locationerror: ErrorEvent\r
+               // Fired when geolocation (using the [`locate`](#map-locate) method) failed.\r
+               this.fire('locationerror', {\r
+                       code: c,\r
+                       message: 'Geolocation error: ' + message + '.'\r
+               });\r
+       },\r
+\r
+       _handleGeolocationResponse: function (pos) {\r
+               var lat = pos.coords.latitude,\r
+                   lng = pos.coords.longitude,\r
+                   latlng = new L.LatLng(lat, lng),\r
+                   bounds = latlng.toBounds(pos.coords.accuracy),\r
+                   options = this._locateOptions;\r
+\r
+               if (options.setView) {\r
+                       var zoom = this.getBoundsZoom(bounds);\r
+                       this.setView(latlng, options.maxZoom ? Math.min(zoom, options.maxZoom) : zoom);\r
+               }\r
+\r
+               var data = {\r
+                       latlng: latlng,\r
+                       bounds: bounds,\r
+                       timestamp: pos.timestamp\r
+               };\r
+\r
+               for (var i in pos.coords) {\r
+                       if (typeof pos.coords[i] === 'number') {\r
+                               data[i] = pos.coords[i];\r
+                       }\r
+               }\r
+\r
+               // @event locationfound: LocationEvent\r
+               // Fired when geolocation (using the [`locate`](#map-locate) method)\r
+               // went successfully.\r
+               this.fire('locationfound', data);\r
+       },\r
+\r
        // TODO handler.addTo\r
+       // TODO Appropiate docs section?\r
+       // @section Other Methods\r
+       // @method addHandler(name: String, HandlerClass: Function): this\r
+       // Adds a new `Handler` to the map, given its name and constructor function.\r
        addHandler: function (name, HandlerClass) {\r
                if (!HandlerClass) { return this; }\r
 \r
@@ -1787,46 +2950,85 @@ L.Map = L.Class.extend({
                return this;\r
        },\r
 \r
+       // @method remove(): this\r
+       // Destroys the map and clears all related event listeners.\r
        remove: function () {\r
-               if (this._loaded) {\r
-                       this.fire('unload');\r
-               }\r
 \r
-               this._initEvents('off');\r
+               this._initEvents(true);\r
+\r
+               if (this._containerId !== this._container._leaflet_id) {\r
+                       throw new Error('Map container is being reused by another instance');\r
+               }\r
 \r
                try {\r
                        // throws error in IE6-8\r
-                       delete this._container._leaflet;\r
+                       delete this._container._leaflet_id;\r
+                       delete this._containerId;\r
                } catch (e) {\r
-                       this._container._leaflet = undefined;\r
+                       /*eslint-disable */\r
+                       this._container._leaflet_id = undefined;\r
+                       /*eslint-enable */\r
+                       this._containerId = undefined;\r
                }\r
 \r
-               this._clearPanes();\r
+               L.DomUtil.remove(this._mapPane);\r
+\r
                if (this._clearControlPos) {\r
                        this._clearControlPos();\r
                }\r
 \r
                this._clearHandlers();\r
 \r
+               if (this._loaded) {\r
+                       // @section Map state change events\r
+                       // @event unload: Event\r
+                       // Fired when the map is destroyed with [remove](#map-remove) method.\r
+                       this.fire('unload');\r
+               }\r
+\r
+               for (var i in this._layers) {\r
+                       this._layers[i].remove();\r
+               }\r
+\r
                return this;\r
        },\r
 \r
+       // @section Other Methods\r
+       // @method createPane(name: String, container?: HTMLElement): HTMLElement\r
+       // Creates a new [map pane](#map-pane) with the given name if it doesn't exist already,\r
+       // then returns it. The pane is created as a children of `container`, or\r
+       // as a children of the main map pane if not set.\r
+       createPane: function (name, container) {\r
+               var className = 'leaflet-pane' + (name ? ' leaflet-' + name.replace('Pane', '') + '-pane' : ''),\r
+                   pane = L.DomUtil.create('div', className, container || this._mapPane);\r
 \r
-       // public methods for getting map state\r
+               if (name) {\r
+                       this._panes[name] = pane;\r
+               }\r
+               return pane;\r
+       },\r
 \r
-       getCenter: function () { // (Boolean) -> LatLng\r
+       // @section Methods for Getting Map State\r
+\r
+       // @method getCenter(): LatLng\r
+       // Returns the geographical center of the map view\r
+       getCenter: function () {\r
                this._checkIfLoaded();\r
 \r
-               if (this._initialCenter && !this._moved()) {\r
-                       return this._initialCenter;\r
+               if (this._lastCenter && !this._moved()) {\r
+                       return this._lastCenter;\r
                }\r
                return this.layerPointToLatLng(this._getCenterLayerPoint());\r
        },\r
 \r
+       // @method getZoom(): Number\r
+       // Returns the current zoom level of the map view\r
        getZoom: function () {\r
                return this._zoom;\r
        },\r
 \r
+       // @method getBounds(): LatLngBounds\r
+       // Returns the geographical bounds visible in the current map view\r
        getBounds: function () {\r
                var bounds = this.getPixelBounds(),\r
                    sw = this.unproject(bounds.getBottomLeft()),\r
@@ -1835,136 +3037,239 @@ L.Map = L.Class.extend({
                return new L.LatLngBounds(sw, ne);\r
        },\r
 \r
+       // @method getMinZoom(): Number\r
+       // Returns the minimum zoom level of the map (if set in the `minZoom` option of the map or of any layers), or `0` by default.\r
        getMinZoom: function () {\r
-               return this.options.minZoom === undefined ?\r
-                       (this._layersMinZoom === undefined ? 0 : this._layersMinZoom) :\r
-                       this.options.minZoom;\r
+               return this.options.minZoom === undefined ? this._layersMinZoom || 0 : this.options.minZoom;\r
        },\r
 \r
+       // @method getMaxZoom(): Number\r
+       // Returns the maximum zoom level of the map (if set in the `maxZoom` option of the map or of any layers).\r
        getMaxZoom: function () {\r
                return this.options.maxZoom === undefined ?\r
                        (this._layersMaxZoom === undefined ? Infinity : this._layersMaxZoom) :\r
                        this.options.maxZoom;\r
        },\r
 \r
+       // @method getBoundsZoom(bounds: LatLngBounds, inside?: Boolean): Number\r
+       // Returns the maximum zoom level on which the given bounds fit to the map\r
+       // view in its entirety. If `inside` (optional) is set to `true`, the method\r
+       // instead returns the minimum zoom level on which the map view fits into\r
+       // the given bounds in its entirety.\r
        getBoundsZoom: function (bounds, inside, padding) { // (LatLngBounds[, Boolean, Point]) -> Number\r
                bounds = L.latLngBounds(bounds);\r
+               padding = L.point(padding || [0, 0]);\r
 \r
-               var zoom = this.getMinZoom() - (inside ? 1 : 0),\r
-                   maxZoom = this.getMaxZoom(),\r
-                   size = this.getSize(),\r
-\r
+               var zoom = this.getZoom() || 0,\r
+                   min = this.getMinZoom(),\r
+                   max = this.getMaxZoom(),\r
                    nw = bounds.getNorthWest(),\r
                    se = bounds.getSouthEast(),\r
+                   size = this.getSize().subtract(padding),\r
+                   boundsSize = L.bounds(this.project(se, zoom), this.project(nw, zoom)).getSize(),\r
+                   snap = L.Browser.any3d ? this.options.zoomSnap : 1;\r
 \r
-                   zoomNotFound = true,\r
-                   boundsSize;\r
-\r
-               padding = L.point(padding || [0, 0]);\r
-\r
-               do {\r
-                       zoom++;\r
-                       boundsSize = this.project(se, zoom).subtract(this.project(nw, zoom)).add(padding);\r
-                       zoomNotFound = !inside ? size.contains(boundsSize) : boundsSize.x < size.x || boundsSize.y < size.y;\r
-\r
-               } while (zoomNotFound && zoom <= maxZoom);\r
+               var scale = Math.min(size.x / boundsSize.x, size.y / boundsSize.y);\r
+               zoom = this.getScaleZoom(scale, zoom);\r
 \r
-               if (zoomNotFound && inside) {\r
-                       return null;\r
+               if (snap) {\r
+                       zoom = Math.round(zoom / (snap / 100)) * (snap / 100); // don't jump if within 1% of a snap level\r
+                       zoom = inside ? Math.ceil(zoom / snap) * snap : Math.floor(zoom / snap) * snap;\r
                }\r
 \r
-               return inside ? zoom : zoom - 1;\r
+               return Math.max(min, Math.min(max, zoom));\r
        },\r
 \r
+       // @method getSize(): Point\r
+       // Returns the current size of the map container (in pixels).\r
        getSize: function () {\r
                if (!this._size || this._sizeChanged) {\r
                        this._size = new L.Point(\r
-                               this._container.clientWidth,\r
-                               this._container.clientHeight);\r
+                               this._container.clientWidth || 0,\r
+                               this._container.clientHeight || 0);\r
 \r
                        this._sizeChanged = false;\r
                }\r
                return this._size.clone();\r
        },\r
 \r
-       getPixelBounds: function () {\r
-               var topLeftPoint = this._getTopLeftPoint();\r
+       // @method getPixelBounds(): Bounds\r
+       // Returns the bounds of the current map view in projected pixel\r
+       // coordinates (sometimes useful in layer and overlay implementations).\r
+       getPixelBounds: function (center, zoom) {\r
+               var topLeftPoint = this._getTopLeftPoint(center, zoom);\r
                return new L.Bounds(topLeftPoint, topLeftPoint.add(this.getSize()));\r
        },\r
 \r
+       // TODO: Check semantics - isn't the pixel origin the 0,0 coord relative to\r
+       // the map pane? "left point of the map layer" can be confusing, specially\r
+       // since there can be negative offsets.\r
+       // @method getPixelOrigin(): Point\r
+       // Returns the projected pixel coordinates of the top left point of\r
+       // the map layer (useful in custom layer and overlay implementations).\r
        getPixelOrigin: function () {\r
                this._checkIfLoaded();\r
-               return this._initialTopLeftPoint;\r
+               return this._pixelOrigin;\r
        },\r
 \r
+       // @method getPixelWorldBounds(zoom?: Number): Bounds\r
+       // Returns the world's bounds in pixel coordinates for zoom level `zoom`.\r
+       // If `zoom` is omitted, the map's current zoom level is used.\r
+       getPixelWorldBounds: function (zoom) {\r
+               return this.options.crs.getProjectedBounds(zoom === undefined ? this.getZoom() : zoom);\r
+       },\r
+\r
+       // @section Other Methods\r
+\r
+       // @method getPane(pane: String|HTMLElement): HTMLElement\r
+       // Returns a [map pane](#map-pane), given its name or its HTML element (its identity).\r
+       getPane: function (pane) {\r
+               return typeof pane === 'string' ? this._panes[pane] : pane;\r
+       },\r
+\r
+       // @method getPanes(): Object\r
+       // Returns a plain object containing the names of all [panes](#map-pane) as keys and\r
+       // the panes as values.\r
        getPanes: function () {\r
                return this._panes;\r
        },\r
 \r
+       // @method getContainer: HTMLElement\r
+       // Returns the HTML element that contains the map.\r
        getContainer: function () {\r
                return this._container;\r
        },\r
 \r
 \r
-       // TODO replace with universal implementation after refactoring projections\r
+       // @section Conversion Methods\r
 \r
-       getZoomScale: function (toZoom) {\r
+       // @method getZoomScale(toZoom: Number, fromZoom: Number): Number\r
+       // Returns the scale factor to be applied to a map transition from zoom level\r
+       // `fromZoom` to `toZoom`. Used internally to help with zoom animations.\r
+       getZoomScale: function (toZoom, fromZoom) {\r
+               // TODO replace with universal implementation after refactoring projections\r
                var crs = this.options.crs;\r
-               return crs.scale(toZoom) / crs.scale(this._zoom);\r
+               fromZoom = fromZoom === undefined ? this._zoom : fromZoom;\r
+               return crs.scale(toZoom) / crs.scale(fromZoom);\r
        },\r
 \r
-       getScaleZoom: function (scale) {\r
-               return this._zoom + (Math.log(scale) / Math.LN2);\r
+       // @method getScaleZoom(scale: Number, fromZoom: Number): Number\r
+       // Returns the zoom level that the map would end up at, if it is at `fromZoom`\r
+       // level and everything is scaled by a factor of `scale`. Inverse of\r
+       // [`getZoomScale`](#map-getZoomScale).\r
+       getScaleZoom: function (scale, fromZoom) {\r
+               var crs = this.options.crs;\r
+               fromZoom = fromZoom === undefined ? this._zoom : fromZoom;\r
+               var zoom = crs.zoom(scale * crs.scale(fromZoom));\r
+               return isNaN(zoom) ? Infinity : zoom;\r
        },\r
 \r
-\r
-       // conversion methods\r
-\r
-       project: function (latlng, zoom) { // (LatLng[, Number]) -> Point\r
+       // @method project(latlng: LatLng, zoom: Number): Point\r
+       // Projects a geographical coordinate `LatLng` according to the projection\r
+       // of the map's CRS, then scales it according to `zoom` and the CRS's\r
+       // `Transformation`. The result is pixel coordinate relative to\r
+       // the CRS origin.\r
+       project: function (latlng, zoom) {\r
                zoom = zoom === undefined ? this._zoom : zoom;\r
                return this.options.crs.latLngToPoint(L.latLng(latlng), zoom);\r
        },\r
 \r
-       unproject: function (point, zoom) { // (Point[, Number]) -> LatLng\r
+       // @method unproject(point: Point, zoom: Number): LatLng\r
+       // Inverse of [`project`](#map-project).\r
+       unproject: function (point, zoom) {\r
                zoom = zoom === undefined ? this._zoom : zoom;\r
                return this.options.crs.pointToLatLng(L.point(point), zoom);\r
        },\r
 \r
-       layerPointToLatLng: function (point) { // (Point)\r
+       // @method layerPointToLatLng(point: Point): LatLng\r
+       // Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin),\r
+       // returns the corresponding geographical coordinate (for the current zoom level).\r
+       layerPointToLatLng: function (point) {\r
                var projectedPoint = L.point(point).add(this.getPixelOrigin());\r
                return this.unproject(projectedPoint);\r
        },\r
 \r
-       latLngToLayerPoint: function (latlng) { // (LatLng)\r
+       // @method latLngToLayerPoint(latlng: LatLng): Point\r
+       // Given a geographical coordinate, returns the corresponding pixel coordinate\r
+       // relative to the [origin pixel](#map-getpixelorigin).\r
+       latLngToLayerPoint: function (latlng) {\r
                var projectedPoint = this.project(L.latLng(latlng))._round();\r
                return projectedPoint._subtract(this.getPixelOrigin());\r
        },\r
 \r
+       // @method wrapLatLng(latlng: LatLng): LatLng\r
+       // Returns a `LatLng` where `lat` and `lng` has been wrapped according to the\r
+       // map's CRS's `wrapLat` and `wrapLng` properties, if they are outside the\r
+       // CRS's bounds.\r
+       // By default this means longitude is wrapped around the dateline so its\r
+       // value is between -180 and +180 degrees.\r
+       wrapLatLng: function (latlng) {\r
+               return this.options.crs.wrapLatLng(L.latLng(latlng));\r
+       },\r
+\r
+       // @method wrapLatLngBounds(bounds: LatLngBounds): LatLngBounds\r
+       // Returns a `LatLngBounds` with the same size as the given one, ensuring that\r
+       // its center is within the CRS's bounds.\r
+       // By default this means the center longitude is wrapped around the dateline so its\r
+       // value is between -180 and +180 degrees, and the majority of the bounds\r
+       // overlaps the CRS's bounds.\r
+       wrapLatLngBounds: function (latlng) {\r
+               return this.options.crs.wrapLatLngBounds(L.latLngBounds(latlng));\r
+       },\r
+\r
+       // @method distance(latlng1: LatLng, latlng2: LatLng): Number\r
+       // Returns the distance between two geographical coordinates according to\r
+       // the map's CRS. By default this measures distance in meters.\r
+       distance: function (latlng1, latlng2) {\r
+               return this.options.crs.distance(L.latLng(latlng1), L.latLng(latlng2));\r
+       },\r
+\r
+       // @method containerPointToLayerPoint(point: Point): Point\r
+       // Given a pixel coordinate relative to the map container, returns the corresponding\r
+       // pixel coordinate relative to the [origin pixel](#map-getpixelorigin).\r
        containerPointToLayerPoint: function (point) { // (Point)\r
                return L.point(point).subtract(this._getMapPanePos());\r
        },\r
 \r
+       // @method layerPointToContainerPoint(point: Point): Point\r
+       // Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin),\r
+       // returns the corresponding pixel coordinate relative to the map container.\r
        layerPointToContainerPoint: function (point) { // (Point)\r
                return L.point(point).add(this._getMapPanePos());\r
        },\r
 \r
+       // @method containerPointToLatLng(point: Point): LatLng\r
+       // Given a pixel coordinate relative to the map container, returns\r
+       // the corresponding geographical coordinate (for the current zoom level).\r
        containerPointToLatLng: function (point) {\r
                var layerPoint = this.containerPointToLayerPoint(L.point(point));\r
                return this.layerPointToLatLng(layerPoint);\r
        },\r
 \r
+       // @method latLngToContainerPoint(latlng: LatLng): Point\r
+       // Given a geographical coordinate, returns the corresponding pixel coordinate\r
+       // relative to the map container.\r
        latLngToContainerPoint: function (latlng) {\r
                return this.layerPointToContainerPoint(this.latLngToLayerPoint(L.latLng(latlng)));\r
        },\r
 \r
-       mouseEventToContainerPoint: function (e) { // (MouseEvent)\r
+       // @method mouseEventToContainerPoint(ev: MouseEvent): Point\r
+       // Given a MouseEvent object, returns the pixel coordinate relative to the\r
+       // map container where the event took place.\r
+       mouseEventToContainerPoint: function (e) {\r
                return L.DomEvent.getMousePosition(e, this._container);\r
        },\r
 \r
-       mouseEventToLayerPoint: function (e) { // (MouseEvent)\r
+       // @method mouseEventToLayerPoint(ev: MouseEvent): Point\r
+       // Given a MouseEvent object, returns the pixel coordinate relative to\r
+       // the [origin pixel](#map-getpixelorigin) where the event took place.\r
+       mouseEventToLayerPoint: function (e) {\r
                return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(e));\r
        },\r
 \r
+       // @method mouseEventToLatLng(ev: MouseEvent): LatLng\r
+       // Given a MouseEvent object, returns geographical coordinate where the\r
+       // event took place.\r
        mouseEventToLatLng: function (e) { // (MouseEvent)\r
                return this.layerPointToLatLng(this.mouseEventToLayerPoint(e));\r
        },\r
@@ -1977,21 +3282,25 @@ L.Map = L.Class.extend({
 \r
                if (!container) {\r
                        throw new Error('Map container not found.');\r
-               } else if (container._leaflet) {\r
+               } else if (container._leaflet_id) {\r
                        throw new Error('Map container is already initialized.');\r
                }\r
 \r
-               container._leaflet = true;\r
+               L.DomEvent.addListener(container, 'scroll', this._onScroll, this);\r
+               this._containerId = L.Util.stamp(container);\r
        },\r
 \r
        _initLayout: function () {\r
                var container = this._container;\r
 \r
+               this._fadeAnimated = this.options.fadeAnimation && L.Browser.any3d;\r
+\r
                L.DomUtil.addClass(container, 'leaflet-container' +\r
                        (L.Browser.touch ? ' leaflet-touch' : '') +\r
                        (L.Browser.retina ? ' leaflet-retina' : '') +\r
                        (L.Browser.ielt9 ? ' leaflet-oldie' : '') +\r
-                       (this.options.fadeAnimation ? ' leaflet-fade-anim' : ''));\r
+                       (L.Browser.safari ? ' leaflet-safari' : '') +\r
+                       (this._fadeAnimated ? ' leaflet-fade-anim' : ''));\r
 \r
                var position = L.DomUtil.getStyle(container, 'position');\r
 \r
@@ -2008,86 +3317,133 @@ L.Map = L.Class.extend({
 \r
        _initPanes: function () {\r
                var panes = this._panes = {};\r
-\r
-               this._mapPane = panes.mapPane = this._createPane('leaflet-map-pane', this._container);\r
-\r
-               this._tilePane = panes.tilePane = this._createPane('leaflet-tile-pane', this._mapPane);\r
-               panes.objectsPane = this._createPane('leaflet-objects-pane', this._mapPane);\r
-               panes.shadowPane = this._createPane('leaflet-shadow-pane');\r
-               panes.overlayPane = this._createPane('leaflet-overlay-pane');\r
-               panes.markerPane = this._createPane('leaflet-marker-pane');\r
-               panes.popupPane = this._createPane('leaflet-popup-pane');\r
-\r
-               var zoomHide = ' leaflet-zoom-hide';\r
+               this._paneRenderers = {};\r
+\r
+               // @section\r
+               //\r
+               // Panes are DOM elements used to control the ordering of layers on the map. You\r
+               // can access panes with [`map.getPane`](#map-getpane) or\r
+               // [`map.getPanes`](#map-getpanes) methods. New panes can be created with the\r
+               // [`map.createPane`](#map-createpane) method.\r
+               //\r
+               // Every map has the following default panes that differ only in zIndex.\r
+               //\r
+               // @pane mapPane: HTMLElement = 'auto'\r
+               // Pane that contains all other map panes\r
+\r
+               this._mapPane = this.createPane('mapPane', this._container);\r
+               L.DomUtil.setPosition(this._mapPane, new L.Point(0, 0));\r
+\r
+               // @pane tilePane: HTMLElement = 200\r
+               // Pane for `GridLayer`s and `TileLayer`s\r
+               this.createPane('tilePane');\r
+               // @pane overlayPane: HTMLElement = 400\r
+               // Pane for vector overlays (`Path`s), like `Polyline`s and `Polygon`s\r
+               this.createPane('shadowPane');\r
+               // @pane shadowPane: HTMLElement = 500\r
+               // Pane for overlay shadows (e.g. `Marker` shadows)\r
+               this.createPane('overlayPane');\r
+               // @pane markerPane: HTMLElement = 600\r
+               // Pane for `Icon`s of `Marker`s\r
+               this.createPane('markerPane');\r
+               // @pane tooltipPane: HTMLElement = 650\r
+               // Pane for tooltip.\r
+               this.createPane('tooltipPane');\r
+               // @pane popupPane: HTMLElement = 700\r
+               // Pane for `Popup`s.\r
+               this.createPane('popupPane');\r
 \r
                if (!this.options.markerZoomAnimation) {\r
-                       L.DomUtil.addClass(panes.markerPane, zoomHide);\r
-                       L.DomUtil.addClass(panes.shadowPane, zoomHide);\r
-                       L.DomUtil.addClass(panes.popupPane, zoomHide);\r
+                       L.DomUtil.addClass(panes.markerPane, 'leaflet-zoom-hide');\r
+                       L.DomUtil.addClass(panes.shadowPane, 'leaflet-zoom-hide');\r
                }\r
        },\r
 \r
-       _createPane: function (className, container) {\r
-               return L.DomUtil.create('div', className, container || this._panes.objectsPane);\r
-       },\r
 \r
-       _clearPanes: function () {\r
-               this._container.removeChild(this._mapPane);\r
-       },\r
+       // private methods that modify map state\r
 \r
-       _addLayers: function (layers) {\r
-               layers = layers ? (L.Util.isArray(layers) ? layers : [layers]) : [];\r
+       // @section Map state change events\r
+       _resetView: function (center, zoom) {\r
+               L.DomUtil.setPosition(this._mapPane, new L.Point(0, 0));\r
 \r
-               for (var i = 0, len = layers.length; i < len; i++) {\r
-                       this.addLayer(layers[i]);\r
-               }\r
-       },\r
+               var loading = !this._loaded;\r
+               this._loaded = true;\r
+               zoom = this._limitZoom(zoom);\r
 \r
+               this.fire('viewprereset');\r
 \r
-       // private methods that modify map state\r
+               var zoomChanged = this._zoom !== zoom;\r
+               this\r
+                       ._moveStart(zoomChanged)\r
+                       ._move(center, zoom)\r
+                       ._moveEnd(zoomChanged);\r
 \r
-       _resetView: function (center, zoom, preserveMapOffset, afterZoomAnim) {\r
+               // @event viewreset: Event\r
+               // Fired when the map needs to redraw its content (this usually happens\r
+               // on map zoom or load). Very useful for creating custom overlays.\r
+               this.fire('viewreset');\r
 \r
-               var zoomChanged = (this._zoom !== zoom);\r
+               // @event load: Event\r
+               // Fired when the map is initialized (when its center and zoom are set\r
+               // for the first time).\r
+               if (loading) {\r
+                       this.fire('load');\r
+               }\r
+       },\r
 \r
-               if (!afterZoomAnim) {\r
-                       this.fire('movestart');\r
+       _moveStart: function (zoomChanged) {\r
+               // @event zoomstart: Event\r
+               // Fired when the map zoom is about to change (e.g. before zoom animation).\r
+               // @event movestart: Event\r
+               // Fired when the view of the map starts changing (e.g. user starts dragging the map).\r
+               if (zoomChanged) {\r
+                       this.fire('zoomstart');\r
+               }\r
+               return this.fire('movestart');\r
+       },\r
 \r
-                       if (zoomChanged) {\r
-                               this.fire('zoomstart');\r
-                       }\r
+       _move: function (center, zoom, data) {\r
+               if (zoom === undefined) {\r
+                       zoom = this._zoom;\r
                }\r
+               var zoomChanged = this._zoom !== zoom;\r
 \r
                this._zoom = zoom;\r
-               this._initialCenter = center;\r
+               this._lastCenter = center;\r
+               this._pixelOrigin = this._getNewPixelOrigin(center);\r
 \r
-               this._initialTopLeftPoint = this._getNewTopLeftPoint(center);\r
-\r
-               if (!preserveMapOffset) {\r
-                       L.DomUtil.setPosition(this._mapPane, new L.Point(0, 0));\r
-               } else {\r
-                       this._initialTopLeftPoint._add(this._getMapPanePos());\r
+               // @event zoom: Event\r
+               // Fired repeatedly during any change in zoom level, including zoom\r
+               // and fly animations.\r
+               if (zoomChanged || (data && data.pinch)) {      // Always fire 'zoom' if pinching because #3530\r
+                       this.fire('zoom', data);\r
                }\r
 \r
-               this._tileLayersToLoad = this._tileLayersNum;\r
-\r
-               var loading = !this._loaded;\r
-               this._loaded = true;\r
-\r
-               this.fire('viewreset', {hard: !preserveMapOffset});\r
+               // @event move: Event\r
+               // Fired repeatedly during any movement of the map, including pan and\r
+               // fly animations.\r
+               return this.fire('move', data);\r
+       },\r
 \r
-               if (loading) {\r
-                       this.fire('load');\r
-                       this.eachLayer(this._layerAdd, this);\r
+       _moveEnd: function (zoomChanged) {\r
+               // @event zoomend: Event\r
+               // Fired when the map has changed, after any animations.\r
+               if (zoomChanged) {\r
+                       this.fire('zoomend');\r
                }\r
 \r
-               this.fire('move');\r
+               // @event moveend: Event\r
+               // Fired when the center of the map stops changing (e.g. user stopped\r
+               // dragging the map).\r
+               return this.fire('moveend');\r
+       },\r
 \r
-               if (zoomChanged || afterZoomAnim) {\r
-                       this.fire('zoomend');\r
+       _stop: function () {\r
+               L.Util.cancelAnimFrame(this._flyToFrame);\r
+               if (this._panAnim) {\r
+                       this._panAnim.stop();\r
                }\r
-\r
-               this.fire('moveend', {hard: !preserveMapOffset});\r
+               return this;\r
        },\r
 \r
        _rawPanBy: function (offset) {\r
@@ -2098,36 +3454,10 @@ L.Map = L.Class.extend({
                return this.getMaxZoom() - this.getMinZoom();\r
        },\r
 \r
-       _updateZoomLevels: function () {\r
-               var i,\r
-                       minZoom = Infinity,\r
-                       maxZoom = -Infinity,\r
-                       oldZoomSpan = this._getZoomSpan();\r
-\r
-               for (i in this._zoomBoundLayers) {\r
-                       var layer = this._zoomBoundLayers[i];\r
-                       if (!isNaN(layer.options.minZoom)) {\r
-                               minZoom = Math.min(minZoom, layer.options.minZoom);\r
-                       }\r
-                       if (!isNaN(layer.options.maxZoom)) {\r
-                               maxZoom = Math.max(maxZoom, layer.options.maxZoom);\r
-                       }\r
-               }\r
-\r
-               if (i === undefined) { // we have no tilelayers\r
-                       this._layersMaxZoom = this._layersMinZoom = undefined;\r
-               } else {\r
-                       this._layersMaxZoom = maxZoom;\r
-                       this._layersMinZoom = minZoom;\r
-               }\r
-\r
-               if (oldZoomSpan !== this._getZoomSpan()) {\r
-                       this.fire('zoomlevelschange');\r
-               }\r
-       },\r
-\r
        _panInsideMaxBounds: function () {\r
-               this.panInsideBounds(this.options.maxBounds);\r
+               if (!this._enforcingBounds) {\r
+                       this.panInsideBounds(this.options.maxBounds);\r
+               }\r
        },\r
 \r
        _checkIfLoaded: function () {\r
@@ -2136,101 +3466,186 @@ L.Map = L.Class.extend({
                }\r
        },\r
 \r
-       // map events\r
+       // DOM event handling\r
 \r
-       _initEvents: function (onOff) {\r
+       // @section Interaction events\r
+       _initEvents: function (remove) {\r
                if (!L.DomEvent) { return; }\r
 \r
-               onOff = onOff || 'on';\r
-\r
-               L.DomEvent[onOff](this._container, 'click', this._onMouseClick, this);\r
-\r
-               var events = ['dblclick', 'mousedown', 'mouseup', 'mouseenter',\r
-                             'mouseleave', 'mousemove', 'contextmenu'],\r
-                   i, len;\r
-\r
-               for (i = 0, len = events.length; i < len; i++) {\r
-                       L.DomEvent[onOff](this._container, events[i], this._fireMouseEvent, this);\r
-               }\r
+               this._targets = {};\r
+               this._targets[L.stamp(this._container)] = this;\r
+\r
+               var onOff = remove ? 'off' : 'on';\r
+\r
+               // @event click: MouseEvent\r
+               // Fired when the user clicks (or taps) the map.\r
+               // @event dblclick: MouseEvent\r
+               // Fired when the user double-clicks (or double-taps) the map.\r
+               // @event mousedown: MouseEvent\r
+               // Fired when the user pushes the mouse button on the map.\r
+               // @event mouseup: MouseEvent\r
+               // Fired when the user releases the mouse button on the map.\r
+               // @event mouseover: MouseEvent\r
+               // Fired when the mouse enters the map.\r
+               // @event mouseout: MouseEvent\r
+               // Fired when the mouse leaves the map.\r
+               // @event mousemove: MouseEvent\r
+               // Fired while the mouse moves over the map.\r
+               // @event contextmenu: MouseEvent\r
+               // Fired when the user pushes the right mouse button on the map, prevents\r
+               // default browser context menu from showing if there are listeners on\r
+               // this event. Also fired on mobile when the user holds a single touch\r
+               // for a second (also called long press).\r
+               // @event keypress: KeyboardEvent\r
+               // Fired when the user presses a key from the keyboard while the map is focused.\r
+               L.DomEvent[onOff](this._container, 'click dblclick mousedown mouseup ' +\r
+                       'mouseover mouseout mousemove contextmenu keypress', this._handleDOMEvent, this);\r
 \r
                if (this.options.trackResize) {\r
                        L.DomEvent[onOff](window, 'resize', this._onResize, this);\r
                }\r
+\r
+               if (L.Browser.any3d && this.options.transform3DLimit) {\r
+                       this[onOff]('moveend', this._onMoveEnd);\r
+               }\r
        },\r
 \r
        _onResize: function () {\r
                L.Util.cancelAnimFrame(this._resizeRequest);\r
                this._resizeRequest = L.Util.requestAnimFrame(\r
-                       function () { this.invalidateSize({debounceMoveend: true}); }, this, false, this._container);\r
+                       function () { this.invalidateSize({debounceMoveend: true}); }, this);\r
+       },\r
+\r
+       _onScroll: function () {\r
+               this._container.scrollTop  = 0;\r
+               this._container.scrollLeft = 0;\r
+       },\r
+\r
+       _onMoveEnd: function () {\r
+               var pos = this._getMapPanePos();\r
+               if (Math.max(Math.abs(pos.x), Math.abs(pos.y)) >= this.options.transform3DLimit) {\r
+                       // https://bugzilla.mozilla.org/show_bug.cgi?id=1203873 but Webkit also have\r
+                       // a pixel offset on very high values, see: http://jsfiddle.net/dg6r5hhb/\r
+                       this._resetView(this.getCenter(), this.getZoom());\r
+               }\r
        },\r
 \r
-       _onMouseClick: function (e) {\r
-               if (!this._loaded || (!e._simulated &&\r
-                       ((this.dragging && this.dragging.moved()) ||\r
-                        (this.boxZoom  && this.boxZoom.moved()))) ||\r
-                           L.DomEvent._skipped(e)) { return; }\r
+       _findEventTargets: function (e, type) {\r
+               var targets = [],\r
+                   target,\r
+                   isHover = type === 'mouseout' || type === 'mouseover',\r
+                   src = e.target || e.srcElement,\r
+                   dragging = false;\r
 \r
-               this.fire('preclick');\r
-               this._fireMouseEvent(e);\r
+               while (src) {\r
+                       target = this._targets[L.stamp(src)];\r
+                       if (target && (type === 'click' || type === 'preclick') && !e._simulated && this._draggableMoved(target)) {\r
+                               // Prevent firing click after you just dragged an object.\r
+                               dragging = true;\r
+                               break;\r
+                       }\r
+                       if (target && target.listens(type, true)) {\r
+                               if (isHover && !L.DomEvent._isExternalTarget(src, e)) { break; }\r
+                               targets.push(target);\r
+                               if (isHover) { break; }\r
+                       }\r
+                       if (src === this._container) { break; }\r
+                       src = src.parentNode;\r
+               }\r
+               if (!targets.length && !dragging && !isHover && L.DomEvent._isExternalTarget(src, e)) {\r
+                       targets = [this];\r
+               }\r
+               return targets;\r
        },\r
 \r
-       _fireMouseEvent: function (e) {\r
+       _handleDOMEvent: function (e) {\r
                if (!this._loaded || L.DomEvent._skipped(e)) { return; }\r
 \r
-               var type = e.type;\r
+               var type = e.type === 'keypress' && e.keyCode === 13 ? 'click' : e.type;\r
+\r
+               if (type === 'mousedown') {\r
+                       // prevents outline when clicking on keyboard-focusable element\r
+                       L.DomUtil.preventOutline(e.target || e.srcElement);\r
+               }\r
 \r
-               type = (type === 'mouseenter' ? 'mouseover' : (type === 'mouseleave' ? 'mouseout' : type));\r
+               this._fireDOMEvent(e, type);\r
+       },\r
 \r
-               if (!this.hasEventListeners(type)) { return; }\r
+       _fireDOMEvent: function (e, type, targets) {\r
 \r
-               if (type === 'contextmenu') {\r
-                       L.DomEvent.preventDefault(e);\r
+               if (e.type === 'click') {\r
+                       // Fire a synthetic 'preclick' event which propagates up (mainly for closing popups).\r
+                       // @event preclick: MouseEvent\r
+                       // Fired before mouse click on the map (sometimes useful when you\r
+                       // want something to happen on click before any existing click\r
+                       // handlers start running).\r
+                       var synth = L.Util.extend({}, e);\r
+                       synth.type = 'preclick';\r
+                       this._fireDOMEvent(synth, synth.type, targets);\r
                }\r
 \r
-               var containerPoint = this.mouseEventToContainerPoint(e),\r
-                   layerPoint = this.containerPointToLayerPoint(containerPoint),\r
-                   latlng = this.layerPointToLatLng(layerPoint);\r
+               if (e._stopped) { return; }\r
 \r
-               this.fire(type, {\r
-                       latlng: latlng,\r
-                       layerPoint: layerPoint,\r
-                       containerPoint: containerPoint,\r
+               // Find the layer the event is propagating from and its parents.\r
+               targets = (targets || []).concat(this._findEventTargets(e, type));\r
+\r
+               if (!targets.length) { return; }\r
+\r
+               var target = targets[0];\r
+               if (type === 'contextmenu' && target.listens(type, true)) {\r
+                       L.DomEvent.preventDefault(e);\r
+               }\r
+\r
+               var data = {\r
                        originalEvent: e\r
-               });\r
-       },\r
+               };\r
+\r
+               if (e.type !== 'keypress') {\r
+                       var isMarker = target instanceof L.Marker;\r
+                       data.containerPoint = isMarker ?\r
+                                       this.latLngToContainerPoint(target.getLatLng()) : this.mouseEventToContainerPoint(e);\r
+                       data.layerPoint = this.containerPointToLayerPoint(data.containerPoint);\r
+                       data.latlng = isMarker ? target.getLatLng() : this.layerPointToLatLng(data.layerPoint);\r
+               }\r
 \r
-       _onTileLayerLoad: function () {\r
-               this._tileLayersToLoad--;\r
-               if (this._tileLayersNum && !this._tileLayersToLoad) {\r
-                       this.fire('tilelayersload');\r
+               for (var i = 0; i < targets.length; i++) {\r
+                       targets[i].fire(type, data, true);\r
+                       if (data.originalEvent._stopped ||\r
+                               (targets[i].options.nonBubblingEvents && L.Util.indexOf(targets[i].options.nonBubblingEvents, type) !== -1)) { return; }\r
                }\r
        },\r
 \r
+       _draggableMoved: function (obj) {\r
+               obj = obj.dragging && obj.dragging.enabled() ? obj : this;\r
+               return (obj.dragging && obj.dragging.moved()) || (this.boxZoom && this.boxZoom.moved());\r
+       },\r
+\r
        _clearHandlers: function () {\r
                for (var i = 0, len = this._handlers.length; i < len; i++) {\r
                        this._handlers[i].disable();\r
                }\r
        },\r
 \r
+       // @section Other Methods\r
+\r
+       // @method whenReady(fn: Function, context?: Object): this\r
+       // Runs the given function `fn` when the map gets initialized with\r
+       // a view (center and zoom) and at least one layer, or immediately\r
+       // if it's already initialized, optionally passing a function context.\r
        whenReady: function (callback, context) {\r
                if (this._loaded) {\r
-                       callback.call(context || this, this);\r
+                       callback.call(context || this, {target: this});\r
                } else {\r
                        this.on('load', callback, context);\r
                }\r
                return this;\r
        },\r
 \r
-       _layerAdd: function (layer) {\r
-               layer.onAdd(this);\r
-               this.fire('layeradd', {layer: layer});\r
-       },\r
-\r
 \r
        // private methods for getting map state\r
 \r
        _getMapPanePos: function () {\r
-               return L.DomUtil.getPosition(this._mapPane);\r
+               return L.DomUtil.getPosition(this._mapPane) || new L.Point(0, 0);\r
        },\r
 \r
        _moved: function () {\r
@@ -2238,19 +3653,31 @@ L.Map = L.Class.extend({
                return pos && !pos.equals([0, 0]);\r
        },\r
 \r
-       _getTopLeftPoint: function () {\r
-               return this.getPixelOrigin().subtract(this._getMapPanePos());\r
+       _getTopLeftPoint: function (center, zoom) {\r
+               var pixelOrigin = center && zoom !== undefined ?\r
+                       this._getNewPixelOrigin(center, zoom) :\r
+                       this.getPixelOrigin();\r
+               return pixelOrigin.subtract(this._getMapPanePos());\r
        },\r
 \r
-       _getNewTopLeftPoint: function (center, zoom) {\r
+       _getNewPixelOrigin: function (center, zoom) {\r
                var viewHalf = this.getSize()._divideBy(2);\r
-               // TODO round on display, not calculation to increase precision?\r
-               return this.project(center, zoom)._subtract(viewHalf)._round();\r
+               return this.project(center, zoom)._subtract(viewHalf)._add(this._getMapPanePos())._round();\r
        },\r
 \r
-       _latLngToNewLayerPoint: function (latlng, newZoom, newCenter) {\r
-               var topLeft = this._getNewTopLeftPoint(newCenter, newZoom).add(this._getMapPanePos());\r
-               return this.project(latlng, newZoom)._subtract(topLeft);\r
+       _latLngToNewLayerPoint: function (latlng, zoom, center) {\r
+               var topLeft = this._getNewPixelOrigin(center, zoom);\r
+               return this.project(latlng, zoom)._subtract(topLeft);\r
+       },\r
+\r
+       _latLngBoundsToNewLayerBounds: function (latLngBounds, zoom, center) {\r
+               var topLeft = this._getNewPixelOrigin(center, zoom);\r
+               return L.bounds([\r
+                       this.project(latLngBounds.getSouthWest(), zoom)._subtract(topLeft),\r
+                       this.project(latLngBounds.getNorthWest(), zoom)._subtract(topLeft),\r
+                       this.project(latLngBounds.getSouthEast(), zoom)._subtract(topLeft),\r
+                       this.project(latLngBounds.getNorthEast(), zoom)._subtract(topLeft)\r
+               ]);\r
        },\r
 \r
        // layer point of the current center\r
@@ -2273,6 +3700,13 @@ L.Map = L.Class.extend({
                    viewBounds = new L.Bounds(centerPoint.subtract(viewHalf), centerPoint.add(viewHalf)),\r
                    offset = this._getBoundsOffset(viewBounds, bounds, zoom);\r
 \r
+               // If offset is less than a pixel, ignore.\r
+               // This prevents unstable projections from getting into\r
+               // an infinite loop of tiny offsets.\r
+               if (offset.round().equals([0, 0])) {\r
+                       return center;\r
+               }\r
+\r
                return this.unproject(centerPoint.add(offset), zoom);\r
        },\r
 \r
@@ -2288,11 +3722,15 @@ L.Map = L.Class.extend({
 \r
        // returns offset needed for pxBounds to get inside maxBounds at a specified zoom\r
        _getBoundsOffset: function (pxBounds, maxBounds, zoom) {\r
-               var nwOffset = this.project(maxBounds.getNorthWest(), zoom).subtract(pxBounds.min),\r
-                   seOffset = this.project(maxBounds.getSouthEast(), zoom).subtract(pxBounds.max),\r
+               var projectedMaxBounds = L.bounds(\r
+                       this.project(maxBounds.getNorthEast(), zoom),\r
+                       this.project(maxBounds.getSouthWest(), zoom)\r
+                   ),\r
+                   minOffset = projectedMaxBounds.min.subtract(pxBounds.min),\r
+                   maxOffset = projectedMaxBounds.max.subtract(pxBounds.max),\r
 \r
-                   dx = this._rebound(nwOffset.x, -seOffset.x),\r
-                   dy = this._rebound(nwOffset.y, -seOffset.y);\r
+                   dx = this._rebound(minOffset.x, -maxOffset.x),\r
+                   dy = this._rebound(minOffset.y, -maxOffset.y);\r
 \r
                return new L.Point(dx, dy);\r
        },\r
@@ -2305,6864 +3743,9509 @@ L.Map = L.Class.extend({
 \r
        _limitZoom: function (zoom) {\r
                var min = this.getMinZoom(),\r
-                   max = this.getMaxZoom();\r
-\r
+                   max = this.getMaxZoom(),\r
+                   snap = L.Browser.any3d ? this.options.zoomSnap : 1;\r
+               if (snap) {\r
+                       zoom = Math.round(zoom / snap) * snap;\r
+               }\r
                return Math.max(min, Math.min(max, zoom));\r
-       }\r
-});\r
+       },\r
 \r
-L.map = function (id, options) {\r
-       return new L.Map(id, options);\r
-};\r
-
-
-/*\r
- * Mercator projection that takes into account that the Earth is not a perfect sphere.\r
- * Less popular than spherical mercator; used by projections like EPSG:3395.\r
- */\r
+       _onPanTransitionStep: function () {\r
+               this.fire('move');\r
+       },\r
 \r
-L.Projection.Mercator = {\r
-       MAX_LATITUDE: 85.0840591556,\r
+       _onPanTransitionEnd: function () {\r
+               L.DomUtil.removeClass(this._mapPane, 'leaflet-pan-anim');\r
+               this.fire('moveend');\r
+       },\r
 \r
-       R_MINOR: 6356752.314245179,\r
-       R_MAJOR: 6378137,\r
+       _tryAnimatedPan: function (center, options) {\r
+               // difference between the new and current centers in pixels\r
+               var offset = this._getCenterOffset(center)._floor();\r
 \r
-       project: function (latlng) { // (LatLng) -> Point\r
-               var d = L.LatLng.DEG_TO_RAD,\r
-                   max = this.MAX_LATITUDE,\r
-                   lat = Math.max(Math.min(max, latlng.lat), -max),\r
-                   r = this.R_MAJOR,\r
-                   r2 = this.R_MINOR,\r
-                   x = latlng.lng * d * r,\r
-                   y = lat * d,\r
-                   tmp = r2 / r,\r
-                   eccent = Math.sqrt(1.0 - tmp * tmp),\r
-                   con = eccent * Math.sin(y);\r
-\r
-               con = Math.pow((1 - con) / (1 + con), eccent * 0.5);\r
-\r
-               var ts = Math.tan(0.5 * ((Math.PI * 0.5) - y)) / con;\r
-               y = -r * Math.log(ts);\r
-\r
-               return new L.Point(x, y);\r
-       },\r
-\r
-       unproject: function (point) { // (Point, Boolean) -> LatLng\r
-               var d = L.LatLng.RAD_TO_DEG,\r
-                   r = this.R_MAJOR,\r
-                   r2 = this.R_MINOR,\r
-                   lng = point.x * d / r,\r
-                   tmp = r2 / r,\r
-                   eccent = Math.sqrt(1 - (tmp * tmp)),\r
-                   ts = Math.exp(- point.y / r),\r
-                   phi = (Math.PI / 2) - 2 * Math.atan(ts),\r
-                   numIter = 15,\r
-                   tol = 1e-7,\r
-                   i = numIter,\r
-                   dphi = 0.1,\r
-                   con;\r
-\r
-               while ((Math.abs(dphi) > tol) && (--i > 0)) {\r
-                       con = eccent * Math.sin(phi);\r
-                       dphi = (Math.PI / 2) - 2 * Math.atan(ts *\r
-                                   Math.pow((1.0 - con) / (1.0 + con), 0.5 * eccent)) - phi;\r
-                       phi += dphi;\r
-               }\r
+               // don't animate too far unless animate: true specified in options\r
+               if ((options && options.animate) !== true && !this.getSize().contains(offset)) { return false; }\r
 \r
-               return new L.LatLng(phi * d, lng);\r
-       }\r
-};\r
-
-
+               this.panBy(offset, options);\r
 \r
-L.CRS.EPSG3395 = L.extend({}, L.CRS, {\r
-       code: 'EPSG:3395',\r
+               return true;\r
+       },\r
 \r
-       projection: L.Projection.Mercator,\r
+       _createAnimProxy: function () {\r
 \r
-       transformation: (function () {\r
-               var m = L.Projection.Mercator,\r
-                   r = m.R_MAJOR,\r
-                   scale = 0.5 / (Math.PI * r);\r
+               var proxy = this._proxy = L.DomUtil.create('div', 'leaflet-proxy leaflet-zoom-animated');\r
+               this._panes.mapPane.appendChild(proxy);\r
 \r
-               return new L.Transformation(scale, 0.5, -scale, 0.5);\r
-       }())\r
-});\r
-
-
-/*\r
- * L.TileLayer is used for standard xyz-numbered tile layers.\r
- */\r
+               this.on('zoomanim', function (e) {\r
+                       var prop = L.DomUtil.TRANSFORM,\r
+                           transform = proxy.style[prop];\r
 \r
-L.TileLayer = L.Class.extend({\r
-       includes: L.Mixin.Events,\r
+                       L.DomUtil.setTransform(proxy, this.project(e.center, e.zoom), this.getZoomScale(e.zoom, 1));\r
 \r
-       options: {\r
-               minZoom: 0,\r
-               maxZoom: 18,\r
-               tileSize: 256,\r
-               subdomains: 'abc',\r
-               errorTileUrl: '',\r
-               attribution: '',\r
-               zoomOffset: 0,\r
-               opacity: 1,\r
-               /*\r
-               maxNativeZoom: null,\r
-               zIndex: null,\r
-               tms: false,\r
-               continuousWorld: false,\r
-               noWrap: false,\r
-               zoomReverse: false,\r
-               detectRetina: false,\r
-               reuseTiles: false,\r
-               bounds: false,\r
-               */\r
-               unloadInvisibleTiles: L.Browser.mobile,\r
-               updateWhenIdle: L.Browser.mobile\r
+                       // workaround for case when transform is the same and so transitionend event is not fired\r
+                       if (transform === proxy.style[prop] && this._animatingZoom) {\r
+                               this._onZoomTransitionEnd();\r
+                       }\r
+               }, this);\r
+\r
+               this.on('load moveend', function () {\r
+                       var c = this.getCenter(),\r
+                           z = this.getZoom();\r
+                       L.DomUtil.setTransform(proxy, this.project(c, z), this.getZoomScale(z, 1));\r
+               }, this);\r
        },\r
 \r
-       initialize: function (url, options) {\r
-               options = L.setOptions(this, options);\r
+       _catchTransitionEnd: function (e) {\r
+               if (this._animatingZoom && e.propertyName.indexOf('transform') >= 0) {\r
+                       this._onZoomTransitionEnd();\r
+               }\r
+       },\r
 \r
-               // detecting retina displays, adjusting tileSize and zoom levels\r
-               if (options.detectRetina && L.Browser.retina && options.maxZoom > 0) {\r
+       _nothingToAnimate: function () {\r
+               return !this._container.getElementsByClassName('leaflet-zoom-animated').length;\r
+       },\r
 \r
-                       options.tileSize = Math.floor(options.tileSize / 2);\r
-                       options.zoomOffset++;\r
+       _tryAnimatedZoom: function (center, zoom, options) {\r
 \r
-                       if (options.minZoom > 0) {\r
-                               options.minZoom--;\r
-                       }\r
-                       this.options.maxZoom--;\r
-               }\r
+               if (this._animatingZoom) { return true; }\r
 \r
-               if (options.bounds) {\r
-                       options.bounds = L.latLngBounds(options.bounds);\r
-               }\r
+               options = options || {};\r
 \r
-               this._url = url;\r
+               // don't animate if disabled, not supported or zoom difference is too large\r
+               if (!this._zoomAnimated || options.animate === false || this._nothingToAnimate() ||\r
+                       Math.abs(zoom - this._zoom) > this.options.zoomAnimationThreshold) { return false; }\r
 \r
-               var subdomains = this.options.subdomains;\r
+               // offset is the pixel coords of the zoom origin relative to the current center\r
+               var scale = this.getZoomScale(zoom),\r
+                   offset = this._getCenterOffset(center)._divideBy(1 - 1 / scale);\r
 \r
-               if (typeof subdomains === 'string') {\r
-                       this.options.subdomains = subdomains.split('');\r
-               }\r
-       },\r
+               // don't animate if the zoom origin isn't within one screen from the current center, unless forced\r
+               if (options.animate !== true && !this.getSize().contains(offset)) { return false; }\r
 \r
-       onAdd: function (map) {\r
-               this._map = map;\r
-               this._animated = map._zoomAnimated;\r
+               L.Util.requestAnimFrame(function () {\r
+                       this\r
+                           ._moveStart(true)\r
+                           ._animateZoom(center, zoom, true);\r
+               }, this);\r
 \r
-               // create a container div for tiles\r
-               this._initContainer();\r
+               return true;\r
+       },\r
 \r
-               // set up events\r
-               map.on({\r
-                       'viewreset': this._reset,\r
-                       'moveend': this._update\r
-               }, this);\r
+       _animateZoom: function (center, zoom, startAnim, noUpdate) {\r
+               if (startAnim) {\r
+                       this._animatingZoom = true;\r
 \r
-               if (this._animated) {\r
-                       map.on({\r
-                               'zoomanim': this._animateZoom,\r
-                               'zoomend': this._endZoomAnim\r
-                       }, this);\r
-               }\r
+                       // remember what center/zoom to set after animation\r
+                       this._animateToCenter = center;\r
+                       this._animateToZoom = zoom;\r
 \r
-               if (!this.options.updateWhenIdle) {\r
-                       this._limitedUpdate = L.Util.limitExecByInterval(this._update, 150, this);\r
-                       map.on('move', this._limitedUpdate, this);\r
+                       L.DomUtil.addClass(this._mapPane, 'leaflet-zoom-anim');\r
                }\r
 \r
-               this._reset();\r
-               this._update();\r
-       },\r
+               // @event zoomanim: ZoomAnimEvent\r
+               // Fired on every frame of a zoom animation\r
+               this.fire('zoomanim', {\r
+                       center: center,\r
+                       zoom: zoom,\r
+                       noUpdate: noUpdate\r
+               });\r
 \r
-       addTo: function (map) {\r
-               map.addLayer(this);\r
-               return this;\r
+               // Work around webkit not firing 'transitionend', see https://github.com/Leaflet/Leaflet/issues/3689, 2693\r
+               setTimeout(L.bind(this._onZoomTransitionEnd, this), 250);\r
        },\r
 \r
-       onRemove: function (map) {\r
-               this._container.parentNode.removeChild(this._container);\r
+       _onZoomTransitionEnd: function () {\r
+               if (!this._animatingZoom) { return; }\r
 \r
-               map.off({\r
-                       'viewreset': this._reset,\r
-                       'moveend': this._update\r
-               }, this);\r
+               L.DomUtil.removeClass(this._mapPane, 'leaflet-zoom-anim');\r
 \r
-               if (this._animated) {\r
-                       map.off({\r
-                               'zoomanim': this._animateZoom,\r
-                               'zoomend': this._endZoomAnim\r
-                       }, this);\r
-               }\r
+               this._animatingZoom = false;\r
 \r
-               if (!this.options.updateWhenIdle) {\r
-                       map.off('move', this._limitedUpdate, this);\r
-               }\r
+               this._move(this._animateToCenter, this._animateToZoom);\r
 \r
-               this._container = null;\r
-               this._map = null;\r
-       },\r
+               // This anim frame should prevent an obscure iOS webkit tile loading race condition.\r
+               L.Util.requestAnimFrame(function () {\r
+                       this._moveEnd(true);\r
+               }, this);\r
+       }\r
+});\r
 \r
-       bringToFront: function () {\r
-               var pane = this._map._panes.tilePane;\r
+// @section\r
 \r
-               if (this._container) {\r
-                       pane.appendChild(this._container);\r
-                       this._setAutoZIndex(pane, Math.max);\r
-               }\r
+// @factory L.map(id: String, options?: Map options)\r
+// Instantiates a map object given the DOM ID of a `<div>` element\r
+// and optionally an object literal with `Map options`.\r
+//\r
+// @alternative\r
+// @factory L.map(el: HTMLElement, options?: Map options)\r
+// Instantiates a map object given an instance of a `<div>` HTML element\r
+// and optionally an object literal with `Map options`.\r
+L.map = function (id, options) {\r
+       return new L.Map(id, options);\r
+};\r
+
+
+
+
+/*
+ * @class Layer
+ * @inherits Evented
+ * @aka L.Layer
+ * @aka ILayer
+ *
+ * A set of methods from the Layer base class that all Leaflet layers use.
+ * Inherits all methods, options and events from `L.Evented`.
+ *
+ * @example
+ *
+ * ```js
+ * var layer = L.Marker(latlng).addTo(map);
+ * layer.addTo(map);
+ * layer.remove();
+ * ```
+ *
+ * @event add: Event
+ * Fired after the layer is added to a map
+ *
+ * @event remove: Event
+ * Fired after the layer is removed from a map
+ */
+
+
+L.Layer = L.Evented.extend({
+
+       // Classes extending `L.Layer` will inherit the following options:
+       options: {
+               // @option pane: String = 'overlayPane'
+               // By default the layer will be added to the map's [overlay pane](#map-overlaypane). Overriding this option will cause the layer to be placed on another pane by default.
+               pane: 'overlayPane',
+               nonBubblingEvents: [],  // Array of events that should not be bubbled to DOM parents (like the map),
+
+               // @option attribution: String = null
+               // String to be shown in the attribution control, describes the layer data, e.g. "© Mapbox".
+               attribution: null
+       },
+
+       /* @section
+        * Classes extending `L.Layer` will inherit the following methods:
+        *
+        * @method addTo(map: Map): this
+        * Adds the layer to the given map
+        */
+       addTo: function (map) {
+               map.addLayer(this);
+               return this;
+       },
+
+       // @method remove: this
+       // Removes the layer from the map it is currently active on.
+       remove: function () {
+               return this.removeFrom(this._map || this._mapToAdd);
+       },
+
+       // @method removeFrom(map: Map): this
+       // Removes the layer from the given map
+       removeFrom: function (obj) {
+               if (obj) {
+                       obj.removeLayer(this);
+               }
+               return this;
+       },
+
+       // @method getPane(name? : String): HTMLElement
+       // Returns the `HTMLElement` representing the named pane on the map. If `name` is omitted, returns the pane for this layer.
+       getPane: function (name) {
+               return this._map.getPane(name ? (this.options[name] || name) : this.options.pane);
+       },
+
+       addInteractiveTarget: function (targetEl) {
+               this._map._targets[L.stamp(targetEl)] = this;
+               return this;
+       },
+
+       removeInteractiveTarget: function (targetEl) {
+               delete this._map._targets[L.stamp(targetEl)];
+               return this;
+       },
+
+       // @method getAttribution: String
+       // Used by the `attribution control`, returns the [attribution option](#gridlayer-attribution).
+       getAttribution: function () {
+               return this.options.attribution;
+       },
+
+       _layerAdd: function (e) {
+               var map = e.target;
+
+               // check in case layer gets added and then removed before the map is ready
+               if (!map.hasLayer(this)) { return; }
+
+               this._map = map;
+               this._zoomAnimated = map._zoomAnimated;
+
+               if (this.getEvents) {
+                       var events = this.getEvents();
+                       map.on(events, this);
+                       this.once('remove', function () {
+                               map.off(events, this);
+                       }, this);
+               }
+
+               this.onAdd(map);
+
+               if (this.getAttribution && map.attributionControl) {
+                       map.attributionControl.addAttribution(this.getAttribution());
+               }
+
+               this.fire('add');
+               map.fire('layeradd', {layer: this});
+       }
+});
+
+/* @section Extension methods
+ * @uninheritable
+ *
+ * Every layer should extend from `L.Layer` and (re-)implement the following methods.
+ *
+ * @method onAdd(map: Map): this
+ * Should contain code that creates DOM elements for the layer, adds them to `map panes` where they should belong and puts listeners on relevant map events. Called on [`map.addLayer(layer)`](#map-addlayer).
+ *
+ * @method onRemove(map: Map): this
+ * Should contain all clean up code that removes the layer's elements from the DOM and removes listeners previously added in [`onAdd`](#layer-onadd). Called on [`map.removeLayer(layer)`](#map-removelayer).
+ *
+ * @method getEvents(): Object
+ * This optional method should return an object like `{ viewreset: this._reset }` for [`addEventListener`](#evented-addeventlistener). The event handlers in this object will be automatically added and removed from the map with your layer.
+ *
+ * @method getAttribution(): String
+ * This optional method should return a string containing HTML to be shown on the `Attribution control` whenever the layer is visible.
+ *
+ * @method beforeAdd(map: Map): this
+ * Optional method. Called on [`map.addLayer(layer)`](#map-addlayer), before the layer is added to the map, before events are initialized, without waiting until the map is in a usable state. Use for early initialization only.
+ */
+
+
+/* @namespace Map
+ * @section Layer events
+ *
+ * @event layeradd: LayerEvent
+ * Fired when a new layer is added to the map.
+ *
+ * @event layerremove: LayerEvent
+ * Fired when some layer is removed from the map
+ *
+ * @section Methods for Layers and Controls
+ */
+L.Map.include({
+       // @method addLayer(layer: Layer): this
+       // Adds the given layer to the map
+       addLayer: function (layer) {
+               var id = L.stamp(layer);
+               if (this._layers[id]) { return this; }
+               this._layers[id] = layer;
+
+               layer._mapToAdd = this;
+
+               if (layer.beforeAdd) {
+                       layer.beforeAdd(this);
+               }
+
+               this.whenReady(layer._layerAdd, layer);
+
+               return this;
+       },
+
+       // @method removeLayer(layer: Layer): this
+       // Removes the given layer from the map.
+       removeLayer: function (layer) {
+               var id = L.stamp(layer);
+
+               if (!this._layers[id]) { return this; }
+
+               if (this._loaded) {
+                       layer.onRemove(this);
+               }
+
+               if (layer.getAttribution && this.attributionControl) {
+                       this.attributionControl.removeAttribution(layer.getAttribution());
+               }
+
+               delete this._layers[id];
+
+               if (this._loaded) {
+                       this.fire('layerremove', {layer: layer});
+                       layer.fire('remove');
+               }
+
+               layer._map = layer._mapToAdd = null;
+
+               return this;
+       },
+
+       // @method hasLayer(layer: Layer): Boolean
+       // Returns `true` if the given layer is currently added to the map
+       hasLayer: function (layer) {
+               return !!layer && (L.stamp(layer) in this._layers);
+       },
+
+       /* @method eachLayer(fn: Function, context?: Object): this
+        * Iterates over the layers of the map, optionally specifying context of the iterator function.
+        * ```
+        * map.eachLayer(function(layer){
+        *     layer.bindPopup('Hello');
+        * });
+        * ```
+        */
+       eachLayer: function (method, context) {
+               for (var i in this._layers) {
+                       method.call(context, this._layers[i]);
+               }
+               return this;
+       },
+
+       _addLayers: function (layers) {
+               layers = layers ? (L.Util.isArray(layers) ? layers : [layers]) : [];
+
+               for (var i = 0, len = layers.length; i < len; i++) {
+                       this.addLayer(layers[i]);
+               }
+       },
+
+       _addZoomLimit: function (layer) {
+               if (isNaN(layer.options.maxZoom) || !isNaN(layer.options.minZoom)) {
+                       this._zoomBoundLayers[L.stamp(layer)] = layer;
+                       this._updateZoomLevels();
+               }
+       },
+
+       _removeZoomLimit: function (layer) {
+               var id = L.stamp(layer);
+
+               if (this._zoomBoundLayers[id]) {
+                       delete this._zoomBoundLayers[id];
+                       this._updateZoomLevels();
+               }
+       },
+
+       _updateZoomLevels: function () {
+               var minZoom = Infinity,
+                   maxZoom = -Infinity,
+                   oldZoomSpan = this._getZoomSpan();
+
+               for (var i in this._zoomBoundLayers) {
+                       var options = this._zoomBoundLayers[i].options;
+
+                       minZoom = options.minZoom === undefined ? minZoom : Math.min(minZoom, options.minZoom);
+                       maxZoom = options.maxZoom === undefined ? maxZoom : Math.max(maxZoom, options.maxZoom);
+               }
+
+               this._layersMaxZoom = maxZoom === -Infinity ? undefined : maxZoom;
+               this._layersMinZoom = minZoom === Infinity ? undefined : minZoom;
+
+               // @section Map state change events
+               // @event zoomlevelschange: Event
+               // Fired when the number of zoomlevels on the map is changed due
+               // to adding or removing a layer.
+               if (oldZoomSpan !== this._getZoomSpan()) {
+                       this.fire('zoomlevelschange');
+               }
+
+               if (this.options.maxZoom === undefined && this._layersMaxZoom && this.getZoom() > this._layersMaxZoom) {
+                       this.setZoom(this._layersMaxZoom);
+               }
+               if (this.options.minZoom === undefined && this._layersMinZoom && this.getZoom() < this._layersMinZoom) {
+                       this.setZoom(this._layersMinZoom);
+               }
+       }
+});
+
+
+
+/*\r
+ * @namespace DomEvent\r
+ * Utility functions to work with the [DOM events](https://developer.mozilla.org/docs/Web/API/Event), used by Leaflet internally.\r
+ */\r
 \r
-               return this;\r
-       },\r
+// Inspired by John Resig, Dean Edwards and YUI addEvent implementations.\r
 \r
-       bringToBack: function () {\r
-               var pane = this._map._panes.tilePane;\r
 \r
-               if (this._container) {\r
-                       pane.insertBefore(this._container, pane.firstChild);\r
-                       this._setAutoZIndex(pane, Math.min);\r
-               }\r
 \r
-               return this;\r
-       },\r
+var eventsKey = '_leaflet_events';\r
 \r
-       getAttribution: function () {\r
-               return this.options.attribution;\r
-       },\r
+L.DomEvent = {\r
 \r
-       getContainer: function () {\r
-               return this._container;\r
-       },\r
+       // @function on(el: HTMLElement, types: String, fn: Function, context?: Object): this\r
+       // Adds a listener function (`fn`) to a particular DOM event type of the\r
+       // element `el`. You can optionally specify the context of the listener\r
+       // (object the `this` keyword will point to). You can also pass several\r
+       // space-separated types (e.g. `'click dblclick'`).\r
 \r
-       setOpacity: function (opacity) {\r
-               this.options.opacity = opacity;\r
+       // @alternative\r
+       // @function on(el: HTMLElement, eventMap: Object, context?: Object): this\r
+       // Adds a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}`\r
+       on: function (obj, types, fn, context) {\r
 \r
-               if (this._map) {\r
-                       this._updateOpacity();\r
+               if (typeof types === 'object') {\r
+                       for (var type in types) {\r
+                               this._on(obj, type, types[type], fn);\r
+                       }\r
+               } else {\r
+                       types = L.Util.splitWords(types);\r
+\r
+                       for (var i = 0, len = types.length; i < len; i++) {\r
+                               this._on(obj, types[i], fn, context);\r
+                       }\r
                }\r
 \r
                return this;\r
        },\r
 \r
-       setZIndex: function (zIndex) {\r
-               this.options.zIndex = zIndex;\r
-               this._updateZIndex();\r
+       // @function off(el: HTMLElement, types: String, fn: Function, context?: Object): this\r
+       // Removes a previously added listener function. If no function is specified,\r
+       // it will remove all the listeners of that particular DOM event from the element.\r
+       // Note that if you passed a custom context to on, you must pass the same\r
+       // context to `off` in order to remove the listener.\r
 \r
-               return this;\r
-       },\r
+       // @alternative\r
+       // @function off(el: HTMLElement, eventMap: Object, context?: Object): this\r
+       // Removes a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}`\r
+       off: function (obj, types, fn, context) {\r
 \r
-       setUrl: function (url, noRedraw) {\r
-               this._url = url;\r
+               if (typeof types === 'object') {\r
+                       for (var type in types) {\r
+                               this._off(obj, type, types[type], fn);\r
+                       }\r
+               } else {\r
+                       types = L.Util.splitWords(types);\r
 \r
-               if (!noRedraw) {\r
-                       this.redraw();\r
+                       for (var i = 0, len = types.length; i < len; i++) {\r
+                               this._off(obj, types[i], fn, context);\r
+                       }\r
                }\r
 \r
                return this;\r
        },\r
 \r
-       redraw: function () {\r
-               if (this._map) {\r
-                       this._reset({hard: true});\r
-                       this._update();\r
-               }\r
-               return this;\r
-       },\r
+       _on: function (obj, type, fn, context) {\r
+               var id = type + L.stamp(fn) + (context ? '_' + L.stamp(context) : '');\r
 \r
-       _updateZIndex: function () {\r
-               if (this._container && this.options.zIndex !== undefined) {\r
-                       this._container.style.zIndex = this.options.zIndex;\r
-               }\r
-       },\r
+               if (obj[eventsKey] && obj[eventsKey][id]) { return this; }\r
 \r
-       _setAutoZIndex: function (pane, compare) {\r
+               var handler = function (e) {\r
+                       return fn.call(context || obj, e || window.event);\r
+               };\r
 \r
-               var layers = pane.children,\r
-                   edgeZIndex = -compare(Infinity, -Infinity), // -Infinity for max, Infinity for min\r
-                   zIndex, i, len;\r
+               var originalHandler = handler;\r
 \r
-               for (i = 0, len = layers.length; i < len; i++) {\r
+               if (L.Browser.pointer && type.indexOf('touch') === 0) {\r
+                       this.addPointerListener(obj, type, handler, id);\r
 \r
-                       if (layers[i] !== this._container) {\r
-                               zIndex = parseInt(layers[i].style.zIndex, 10);\r
+               } else if (L.Browser.touch && (type === 'dblclick') && this.addDoubleTapListener &&\r
+                          !(L.Browser.pointer && L.Browser.chrome)) {\r
+                       // Chrome >55 does not need the synthetic dblclicks from addDoubleTapListener\r
+                       // See #5180\r
+                       this.addDoubleTapListener(obj, handler, id);\r
 \r
-                               if (!isNaN(zIndex)) {\r
-                                       edgeZIndex = compare(edgeZIndex, zIndex);\r
-                               }\r
-                       }\r
-               }\r
+               } else if ('addEventListener' in obj) {\r
 \r
-               this.options.zIndex = this._container.style.zIndex =\r
-                       (isFinite(edgeZIndex) ? edgeZIndex : 0) + compare(1, -1);\r
-       },\r
+                       if (type === 'mousewheel') {\r
+                               obj.addEventListener('onwheel' in obj ? 'wheel' : 'mousewheel', handler, false);\r
 \r
-       _updateOpacity: function () {\r
-               var i,\r
-                   tiles = this._tiles;\r
+                       } else if ((type === 'mouseenter') || (type === 'mouseleave')) {\r
+                               handler = function (e) {\r
+                                       e = e || window.event;\r
+                                       if (L.DomEvent._isExternalTarget(obj, e)) {\r
+                                               originalHandler(e);\r
+                                       }\r
+                               };\r
+                               obj.addEventListener(type === 'mouseenter' ? 'mouseover' : 'mouseout', handler, false);\r
 \r
-               if (L.Browser.ielt9) {\r
-                       for (i in tiles) {\r
-                               L.DomUtil.setOpacity(tiles[i], this.options.opacity);\r
+                       } else {\r
+                               if (type === 'click' && L.Browser.android) {\r
+                                       handler = function (e) {\r
+                                               return L.DomEvent._filterClick(e, originalHandler);\r
+                                       };\r
+                               }\r
+                               obj.addEventListener(type, handler, false);\r
                        }\r
-               } else {\r
-                       L.DomUtil.setOpacity(this._container, this.options.opacity);\r
+\r
+               } else if ('attachEvent' in obj) {\r
+                       obj.attachEvent('on' + type, handler);\r
                }\r
+\r
+               obj[eventsKey] = obj[eventsKey] || {};\r
+               obj[eventsKey][id] = handler;\r
+\r
+               return this;\r
        },\r
 \r
-       _initContainer: function () {\r
-               var tilePane = this._map._panes.tilePane;\r
+       _off: function (obj, type, fn, context) {\r
 \r
-               if (!this._container) {\r
-                       this._container = L.DomUtil.create('div', 'leaflet-layer');\r
+               var id = type + L.stamp(fn) + (context ? '_' + L.stamp(context) : ''),\r
+                   handler = obj[eventsKey] && obj[eventsKey][id];\r
 \r
-                       this._updateZIndex();\r
+               if (!handler) { return this; }\r
 \r
-                       if (this._animated) {\r
-                               var className = 'leaflet-tile-container';\r
+               if (L.Browser.pointer && type.indexOf('touch') === 0) {\r
+                       this.removePointerListener(obj, type, id);\r
 \r
-                               this._bgBuffer = L.DomUtil.create('div', className, this._container);\r
-                               this._tileContainer = L.DomUtil.create('div', className, this._container);\r
+               } else if (L.Browser.touch && (type === 'dblclick') && this.removeDoubleTapListener) {\r
+                       this.removeDoubleTapListener(obj, id);\r
 \r
-                       } else {\r
-                               this._tileContainer = this._container;\r
-                       }\r
+               } else if ('removeEventListener' in obj) {\r
 \r
-                       tilePane.appendChild(this._container);\r
+                       if (type === 'mousewheel') {\r
+                               obj.removeEventListener('onwheel' in obj ? 'wheel' : 'mousewheel', handler, false);\r
 \r
-                       if (this.options.opacity < 1) {\r
-                               this._updateOpacity();\r
+                       } else {\r
+                               obj.removeEventListener(\r
+                                       type === 'mouseenter' ? 'mouseover' :\r
+                                       type === 'mouseleave' ? 'mouseout' : type, handler, false);\r
                        }\r
-               }\r
-       },\r
 \r
-       _reset: function (e) {\r
-               for (var key in this._tiles) {\r
-                       this.fire('tileunload', {tile: this._tiles[key]});\r
+               } else if ('detachEvent' in obj) {\r
+                       obj.detachEvent('on' + type, handler);\r
                }\r
 \r
-               this._tiles = {};\r
-               this._tilesToLoad = 0;\r
+               obj[eventsKey][id] = null;\r
 \r
-               if (this.options.reuseTiles) {\r
-                       this._unusedTiles = [];\r
-               }\r
+               return this;\r
+       },\r
 \r
-               this._tileContainer.innerHTML = '';\r
+       // @function stopPropagation(ev: DOMEvent): this\r
+       // Stop the given event from propagation to parent elements. Used inside the listener functions:\r
+       // ```js\r
+       // L.DomEvent.on(div, 'click', function (ev) {\r
+       //      L.DomEvent.stopPropagation(ev);\r
+       // });\r
+       // ```\r
+       stopPropagation: function (e) {\r
 \r
-               if (this._animated && e && e.hard) {\r
-                       this._clearBgBuffer();\r
+               if (e.stopPropagation) {\r
+                       e.stopPropagation();\r
+               } else if (e.originalEvent) {  // In case of Leaflet event.\r
+                       e.originalEvent._stopped = true;\r
+               } else {\r
+                       e.cancelBubble = true;\r
                }\r
+               L.DomEvent._skipped(e);\r
 \r
-               this._initContainer();\r
+               return this;\r
        },\r
 \r
-       _getTileSize: function () {\r
-               var map = this._map,\r
-                   zoom = map.getZoom() + this.options.zoomOffset,\r
-                   zoomN = this.options.maxNativeZoom,\r
-                   tileSize = this.options.tileSize;\r
+       // @function disableScrollPropagation(el: HTMLElement): this\r
+       // Adds `stopPropagation` to the element's `'mousewheel'` events (plus browser variants).\r
+       disableScrollPropagation: function (el) {\r
+               return L.DomEvent.on(el, 'mousewheel', L.DomEvent.stopPropagation);\r
+       },\r
 \r
-               if (zoomN && zoom > zoomN) {\r
-                       tileSize = Math.round(map.getZoomScale(zoom) / map.getZoomScale(zoomN) * tileSize);\r
-               }\r
+       // @function disableClickPropagation(el: HTMLElement): this\r
+       // Adds `stopPropagation` to the element's `'click'`, `'doubleclick'`,\r
+       // `'mousedown'` and `'touchstart'` events (plus browser variants).\r
+       disableClickPropagation: function (el) {\r
+               var stop = L.DomEvent.stopPropagation;\r
 \r
-               return tileSize;\r
+               L.DomEvent.on(el, L.Draggable.START.join(' '), stop);\r
+\r
+               return L.DomEvent.on(el, {\r
+                       click: L.DomEvent._fakeStop,\r
+                       dblclick: stop\r
+               });\r
        },\r
 \r
-       _update: function () {\r
+       // @function preventDefault(ev: DOMEvent): this\r
+       // Prevents the default action of the DOM Event `ev` from happening (such as\r
+       // following a link in the href of the a element, or doing a POST request\r
+       // with page reload when a `<form>` is submitted).\r
+       // Use it inside listener functions.\r
+       preventDefault: function (e) {\r
 \r
-               if (!this._map) { return; }\r
-\r
-               var map = this._map,\r
-                   bounds = map.getPixelBounds(),\r
-                   zoom = map.getZoom(),\r
-                   tileSize = this._getTileSize();\r
-\r
-               if (zoom > this.options.maxZoom || zoom < this.options.minZoom) {\r
-                       return;\r
-               }\r
-\r
-               var tileBounds = L.bounds(\r
-                       bounds.min.divideBy(tileSize)._floor(),\r
-                       bounds.max.divideBy(tileSize)._floor());\r
-\r
-               this._addTilesFromCenterOut(tileBounds);\r
-\r
-               if (this.options.unloadInvisibleTiles || this.options.reuseTiles) {\r
-                       this._removeOtherTiles(tileBounds);\r
-               }\r
-       },\r
-\r
-       _addTilesFromCenterOut: function (bounds) {\r
-               var queue = [],\r
-                   center = bounds.getCenter();\r
-\r
-               var j, i, point;\r
-\r
-               for (j = bounds.min.y; j <= bounds.max.y; j++) {\r
-                       for (i = bounds.min.x; i <= bounds.max.x; i++) {\r
-                               point = new L.Point(i, j);\r
-\r
-                               if (this._tileShouldBeLoaded(point)) {\r
-                                       queue.push(point);\r
-                               }\r
-                       }\r
-               }\r
-\r
-               var tilesToLoad = queue.length;\r
-\r
-               if (tilesToLoad === 0) { return; }\r
-\r
-               // load tiles in order of their distance to center\r
-               queue.sort(function (a, b) {\r
-                       return a.distanceTo(center) - b.distanceTo(center);\r
-               });\r
-\r
-               var fragment = document.createDocumentFragment();\r
-\r
-               // if its the first batch of tiles to load\r
-               if (!this._tilesToLoad) {\r
-                       this.fire('loading');\r
-               }\r
-\r
-               this._tilesToLoad += tilesToLoad;\r
-\r
-               for (i = 0; i < tilesToLoad; i++) {\r
-                       this._addTile(queue[i], fragment);\r
-               }\r
-\r
-               this._tileContainer.appendChild(fragment);\r
-       },\r
-\r
-       _tileShouldBeLoaded: function (tilePoint) {\r
-               if ((tilePoint.x + ':' + tilePoint.y) in this._tiles) {\r
-                       return false; // already loaded\r
-               }\r
-\r
-               var options = this.options;\r
-\r
-               if (!options.continuousWorld) {\r
-                       var limit = this._getWrapTileNum();\r
-\r
-                       // don't load if exceeds world bounds\r
-                       if ((options.noWrap && (tilePoint.x < 0 || tilePoint.x >= limit.x)) ||\r
-                               tilePoint.y < 0 || tilePoint.y >= limit.y) { return false; }\r
-               }\r
-\r
-               if (options.bounds) {\r
-                       var tileSize = this._getTileSize(),\r
-                           nwPoint = tilePoint.multiplyBy(tileSize),\r
-                           sePoint = nwPoint.add([tileSize, tileSize]),\r
-                           nw = this._map.unproject(nwPoint),\r
-                           se = this._map.unproject(sePoint);\r
-\r
-                       // TODO temporary hack, will be removed after refactoring projections\r
-                       // https://github.com/Leaflet/Leaflet/issues/1618\r
-                       if (!options.continuousWorld && !options.noWrap) {\r
-                               nw = nw.wrap();\r
-                               se = se.wrap();\r
-                       }\r
-\r
-                       if (!options.bounds.intersects([nw, se])) { return false; }\r
-               }\r
-\r
-               return true;\r
-       },\r
-\r
-       _removeOtherTiles: function (bounds) {\r
-               var kArr, x, y, key;\r
-\r
-               for (key in this._tiles) {\r
-                       kArr = key.split(':');\r
-                       x = parseInt(kArr[0], 10);\r
-                       y = parseInt(kArr[1], 10);\r
-\r
-                       // remove tile if it's out of bounds\r
-                       if (x < bounds.min.x || x > bounds.max.x || y < bounds.min.y || y > bounds.max.y) {\r
-                               this._removeTile(key);\r
-                       }\r
-               }\r
-       },\r
-\r
-       _removeTile: function (key) {\r
-               var tile = this._tiles[key];\r
-\r
-               this.fire('tileunload', {tile: tile, url: tile.src});\r
-\r
-               if (this.options.reuseTiles) {\r
-                       L.DomUtil.removeClass(tile, 'leaflet-tile-loaded');\r
-                       this._unusedTiles.push(tile);\r
-\r
-               } else if (tile.parentNode === this._tileContainer) {\r
-                       this._tileContainer.removeChild(tile);\r
-               }\r
-\r
-               // for https://github.com/CloudMade/Leaflet/issues/137\r
-               if (!L.Browser.android) {\r
-                       tile.onload = null;\r
-                       tile.src = L.Util.emptyImageUrl;\r
+               if (e.preventDefault) {\r
+                       e.preventDefault();\r
+               } else {\r
+                       e.returnValue = false;\r
                }\r
-\r
-               delete this._tiles[key];\r
+               return this;\r
        },\r
 \r
-       _addTile: function (tilePoint, container) {\r
-               var tilePos = this._getTilePos(tilePoint);\r
-\r
-               // get unused tile - or create a new tile\r
-               var tile = this._getTile();\r
-\r
-               /*\r
-               Chrome 20 layouts much faster with top/left (verify with timeline, frames)\r
-               Android 4 browser has display issues with top/left and requires transform instead\r
-               (other browsers don't currently care) - see debug/hacks/jitter.html for an example\r
-               */\r
-               L.DomUtil.setPosition(tile, tilePos, L.Browser.chrome);\r
-\r
-               this._tiles[tilePoint.x + ':' + tilePoint.y] = tile;\r
-\r
-               this._loadTile(tile, tilePoint);\r
-\r
-               if (tile.parentNode !== this._tileContainer) {\r
-                       container.appendChild(tile);\r
-               }\r
+       // @function stop(ev): this\r
+       // Does `stopPropagation` and `preventDefault` at the same time.\r
+       stop: function (e) {\r
+               return L.DomEvent\r
+                       .preventDefault(e)\r
+                       .stopPropagation(e);\r
        },\r
 \r
-       _getZoomForUrl: function () {\r
-\r
-               var options = this.options,\r
-                   zoom = this._map.getZoom();\r
-\r
-               if (options.zoomReverse) {\r
-                       zoom = options.maxZoom - zoom;\r
+       // @function getMousePosition(ev: DOMEvent, container?: HTMLElement): Point\r
+       // Gets normalized mouse position from a DOM event relative to the\r
+       // `container` or to the whole page if not specified.\r
+       getMousePosition: function (e, container) {\r
+               if (!container) {\r
+                       return new L.Point(e.clientX, e.clientY);\r
                }\r
 \r
-               zoom += options.zoomOffset;\r
+               var rect = container.getBoundingClientRect();\r
 \r
-               return options.maxNativeZoom ? Math.min(zoom, options.maxNativeZoom) : zoom;\r
+               return new L.Point(\r
+                       e.clientX - rect.left - container.clientLeft,\r
+                       e.clientY - rect.top - container.clientTop);\r
        },\r
 \r
-       _getTilePos: function (tilePoint) {\r
-               var origin = this._map.getPixelOrigin(),\r
-                   tileSize = this._getTileSize();\r
+       // Chrome on Win scrolls double the pixels as in other platforms (see #4538),\r
+       // and Firefox scrolls device pixels, not CSS pixels\r
+       _wheelPxFactor: (L.Browser.win && L.Browser.chrome) ? 2 :\r
+                       L.Browser.gecko ? window.devicePixelRatio :\r
+                       1,\r
 \r
-               return tilePoint.multiplyBy(tileSize).subtract(origin);\r
+       // @function getWheelDelta(ev: DOMEvent): Number\r
+       // Gets normalized wheel delta from a mousewheel DOM event, in vertical\r
+       // pixels scrolled (negative if scrolling down).\r
+       // Events from pointing devices without precise scrolling are mapped to\r
+       // a best guess of 60 pixels.\r
+       getWheelDelta: function (e) {\r
+               return (L.Browser.edge) ? e.wheelDeltaY / 2 : // Don't trust window-geometry-based delta\r
+                      (e.deltaY && e.deltaMode === 0) ? -e.deltaY / L.DomEvent._wheelPxFactor : // Pixels\r
+                      (e.deltaY && e.deltaMode === 1) ? -e.deltaY * 20 : // Lines\r
+                      (e.deltaY && e.deltaMode === 2) ? -e.deltaY * 60 : // Pages\r
+                      (e.deltaX || e.deltaZ) ? 0 :     // Skip horizontal/depth wheel events\r
+                      e.wheelDelta ? (e.wheelDeltaY || e.wheelDelta) / 2 : // Legacy IE pixels\r
+                      (e.detail && Math.abs(e.detail) < 32765) ? -e.detail * 20 : // Legacy Moz lines\r
+                      e.detail ? e.detail / -32765 * 60 : // Legacy Moz pages\r
+                      0;\r
        },\r
 \r
-       // image-specific code (override to implement e.g. Canvas or SVG tile layer)\r
+       _skipEvents: {},\r
 \r
-       getTileUrl: function (tilePoint) {\r
-               return L.Util.template(this._url, L.extend({\r
-                       s: this._getSubdomain(tilePoint),\r
-                       z: tilePoint.z,\r
-                       x: tilePoint.x,\r
-                       y: tilePoint.y\r
-               }, this.options));\r
+       _fakeStop: function (e) {\r
+               // fakes stopPropagation by setting a special event flag, checked/reset with L.DomEvent._skipped(e)\r
+               L.DomEvent._skipEvents[e.type] = true;\r
        },\r
 \r
-       _getWrapTileNum: function () {\r
-               var crs = this._map.options.crs,\r
-                   size = crs.getSize(this._map.getZoom());\r
-               return size.divideBy(this._getTileSize())._floor();\r
+       _skipped: function (e) {\r
+               var skipped = this._skipEvents[e.type];\r
+               // reset when checking, as it's only used in map container and propagates outside of the map\r
+               this._skipEvents[e.type] = false;\r
+               return skipped;\r
        },\r
 \r
-       _adjustTilePoint: function (tilePoint) {\r
-\r
-               var limit = this._getWrapTileNum();\r
-\r
-               // wrap tile coordinates\r
-               if (!this.options.continuousWorld && !this.options.noWrap) {\r
-                       tilePoint.x = ((tilePoint.x % limit.x) + limit.x) % limit.x;\r
-               }\r
-\r
-               if (this.options.tms) {\r
-                       tilePoint.y = limit.y - tilePoint.y - 1;\r
-               }\r
+       // check if element really left/entered the event target (for mouseenter/mouseleave)\r
+       _isExternalTarget: function (el, e) {\r
 \r
-               tilePoint.z = this._getZoomForUrl();\r
-       },\r
+               var related = e.relatedTarget;\r
 \r
-       _getSubdomain: function (tilePoint) {\r
-               var index = Math.abs(tilePoint.x + tilePoint.y) % this.options.subdomains.length;\r
-               return this.options.subdomains[index];\r
-       },\r
+               if (!related) { return true; }\r
 \r
-       _getTile: function () {\r
-               if (this.options.reuseTiles && this._unusedTiles.length > 0) {\r
-                       var tile = this._unusedTiles.pop();\r
-                       this._resetTile(tile);\r
-                       return tile;\r
+               try {\r
+                       while (related && (related !== el)) {\r
+                               related = related.parentNode;\r
+                       }\r
+               } catch (err) {\r
+                       return false;\r
                }\r
-               return this._createTile();\r
+               return (related !== el);\r
        },\r
 \r
-       // Override if data stored on a tile needs to be cleaned up before reuse\r
-       _resetTile: function (/*tile*/) {},\r
-\r
-       _createTile: function () {\r
-               var tile = L.DomUtil.create('img', 'leaflet-tile');\r
-               tile.style.width = tile.style.height = this._getTileSize() + 'px';\r
-               tile.galleryimg = 'no';\r
+       // this is a horrible workaround for a bug in Android where a single touch triggers two click events\r
+       _filterClick: function (e, handler) {\r
+               var timeStamp = (e.timeStamp || (e.originalEvent && e.originalEvent.timeStamp)),\r
+                   elapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);\r
 \r
-               tile.onselectstart = tile.onmousemove = L.Util.falseFn;\r
+               // are they closer together than 500ms yet more than 100ms?\r
+               // Android typically triggers them ~300ms apart while multiple listeners\r
+               // on the same event should be triggered far faster;\r
+               // or check if click is simulated on the element, and if it is, reject any non-simulated events\r
 \r
-               if (L.Browser.ielt9 && this.options.opacity !== undefined) {\r
-                       L.DomUtil.setOpacity(tile, this.options.opacity);\r
-               }\r
-               // without this hack, tiles disappear after zoom on Chrome for Android\r
-               // https://github.com/Leaflet/Leaflet/issues/2078\r
-               if (L.Browser.mobileWebkit3d) {\r
-                       tile.style.WebkitBackfaceVisibility = 'hidden';\r
+               if ((elapsed && elapsed > 100 && elapsed < 500) || (e.target._simulatedClick && !e._simulated)) {\r
+                       L.DomEvent.stop(e);\r
+                       return;\r
                }\r
-               return tile;\r
-       },\r
-\r
-       _loadTile: function (tile, tilePoint) {\r
-               tile._layer  = this;\r
-               tile.onload  = this._tileOnLoad;\r
-               tile.onerror = this._tileOnError;\r
-\r
-               this._adjustTilePoint(tilePoint);\r
-               tile.src     = this.getTileUrl(tilePoint);\r
-\r
-               this.fire('tileloadstart', {\r
-                       tile: tile,\r
-                       url: tile.src\r
-               });\r
-       },\r
+               L.DomEvent._lastClick = timeStamp;\r
 \r
-       _tileLoaded: function () {\r
-               this._tilesToLoad--;\r
+               handler(e);\r
+       }\r
+};\r
 \r
-               if (this._animated) {\r
-                       L.DomUtil.addClass(this._tileContainer, 'leaflet-zoom-animated');\r
-               }\r
+// @function addListener(…): this\r
+// Alias to [`L.DomEvent.on`](#domevent-on)\r
+L.DomEvent.addListener = L.DomEvent.on;\r
 \r
-               if (!this._tilesToLoad) {\r
-                       this.fire('load');\r
+// @function removeListener(…): this\r
+// Alias to [`L.DomEvent.off`](#domevent-off)\r
+L.DomEvent.removeListener = L.DomEvent.off;\r
+
+
+
+/*
+ * @class PosAnimation
+ * @aka L.PosAnimation
+ * @inherits Evented
+ * Used internally for panning animations, utilizing CSS3 Transitions for modern browsers and a timer fallback for IE6-9.
+ *
+ * @example
+ * ```js
+ * var fx = new L.PosAnimation();
+ * fx.run(el, [300, 500], 0.5);
+ * ```
+ *
+ * @constructor L.PosAnimation()
+ * Creates a `PosAnimation` object.
+ *
+ */
+
+L.PosAnimation = L.Evented.extend({
+
+       // @method run(el: HTMLElement, newPos: Point, duration?: Number, easeLinearity?: Number)
+       // Run an animation of a given element to a new position, optionally setting
+       // duration in seconds (`0.25` by default) and easing linearity factor (3rd
+       // argument of the [cubic bezier curve](http://cubic-bezier.com/#0,0,.5,1),
+       // `0.5` by default).
+       run: function (el, newPos, duration, easeLinearity) {
+               this.stop();
+
+               this._el = el;
+               this._inProgress = true;
+               this._duration = duration || 0.25;
+               this._easeOutPower = 1 / Math.max(easeLinearity || 0.5, 0.2);
+
+               this._startPos = L.DomUtil.getPosition(el);
+               this._offset = newPos.subtract(this._startPos);
+               this._startTime = +new Date();
+
+               // @event start: Event
+               // Fired when the animation starts
+               this.fire('start');
+
+               this._animate();
+       },
+
+       // @method stop()
+       // Stops the animation (if currently running).
+       stop: function () {
+               if (!this._inProgress) { return; }
+
+               this._step(true);
+               this._complete();
+       },
+
+       _animate: function () {
+               // animation loop
+               this._animId = L.Util.requestAnimFrame(this._animate, this);
+               this._step();
+       },
+
+       _step: function (round) {
+               var elapsed = (+new Date()) - this._startTime,
+                   duration = this._duration * 1000;
+
+               if (elapsed < duration) {
+                       this._runFrame(this._easeOut(elapsed / duration), round);
+               } else {
+                       this._runFrame(1);
+                       this._complete();
+               }
+       },
+
+       _runFrame: function (progress, round) {
+               var pos = this._startPos.add(this._offset.multiplyBy(progress));
+               if (round) {
+                       pos._round();
+               }
+               L.DomUtil.setPosition(this._el, pos);
+
+               // @event step: Event
+               // Fired continuously during the animation.
+               this.fire('step');
+       },
+
+       _complete: function () {
+               L.Util.cancelAnimFrame(this._animId);
+
+               this._inProgress = false;
+               // @event end: Event
+               // Fired when the animation ends.
+               this.fire('end');
+       },
+
+       _easeOut: function (t) {
+               return 1 - Math.pow(1 - t, this._easeOutPower);
+       }
+});
+
+
+
+/*\r
+ * @namespace Projection\r
+ * @projection L.Projection.Mercator\r
+ *\r
+ * Elliptical Mercator projection — more complex than Spherical Mercator. Takes into account that Earth is a geoid, not a perfect sphere. Used by the EPSG:3395 CRS.\r
+ */\r
 \r
-                       if (this._animated) {\r
-                               // clear scaled tiles after all new tiles are loaded (for performance)\r
-                               clearTimeout(this._clearBgBufferTimer);\r
-                               this._clearBgBufferTimer = setTimeout(L.bind(this._clearBgBuffer, this), 500);\r
-                       }\r
-               }\r
-       },\r
+L.Projection.Mercator = {\r
+       R: 6378137,\r
+       R_MINOR: 6356752.314245179,\r
 \r
-       _tileOnLoad: function () {\r
-               var layer = this._layer;\r
+       bounds: L.bounds([-20037508.34279, -15496570.73972], [20037508.34279, 18764656.23138]),\r
 \r
-               //Only if we are loading an actual image\r
-               if (this.src !== L.Util.emptyImageUrl) {\r
-                       L.DomUtil.addClass(this, 'leaflet-tile-loaded');\r
+       project: function (latlng) {\r
+               var d = Math.PI / 180,\r
+                   r = this.R,\r
+                   y = latlng.lat * d,\r
+                   tmp = this.R_MINOR / r,\r
+                   e = Math.sqrt(1 - tmp * tmp),\r
+                   con = e * Math.sin(y);\r
 \r
-                       layer.fire('tileload', {\r
-                               tile: this,\r
-                               url: this.src\r
-                       });\r
-               }\r
+               var ts = Math.tan(Math.PI / 4 - y / 2) / Math.pow((1 - con) / (1 + con), e / 2);\r
+               y = -r * Math.log(Math.max(ts, 1E-10));\r
 \r
-               layer._tileLoaded();\r
+               return new L.Point(latlng.lng * d * r, y);\r
        },\r
 \r
-       _tileOnError: function () {\r
-               var layer = this._layer;\r
-\r
-               layer.fire('tileerror', {\r
-                       tile: this,\r
-                       url: this.src\r
-               });\r
-\r
-               var newUrl = layer.options.errorTileUrl;\r
-               if (newUrl) {\r
-                       this.src = newUrl;\r
+       unproject: function (point) {\r
+               var d = 180 / Math.PI,\r
+                   r = this.R,\r
+                   tmp = this.R_MINOR / r,\r
+                   e = Math.sqrt(1 - tmp * tmp),\r
+                   ts = Math.exp(-point.y / r),\r
+                   phi = Math.PI / 2 - 2 * Math.atan(ts);\r
+\r
+               for (var i = 0, dphi = 0.1, con; i < 15 && Math.abs(dphi) > 1e-7; i++) {\r
+                       con = e * Math.sin(phi);\r
+                       con = Math.pow((1 - con) / (1 + con), e / 2);\r
+                       dphi = Math.PI / 2 - 2 * Math.atan(ts * con) - phi;\r
+                       phi += dphi;\r
                }\r
 \r
-               layer._tileLoaded();\r
+               return new L.LatLng(phi * d, point.x * d / r);\r
        }\r
-});\r
-\r
-L.tileLayer = function (url, options) {\r
-       return new L.TileLayer(url, options);\r
 };\r
 
 
+
 /*\r
- * L.TileLayer.WMS is used for putting WMS tile layers on the map.\r
+ * @namespace CRS\r
+ * @crs L.CRS.EPSG3395\r
+ *\r
+ * Rarely used by some commercial tile providers. Uses Elliptical Mercator projection.\r
  */\r
 \r
-L.TileLayer.WMS = L.TileLayer.extend({\r
-\r
-       defaultWmsParams: {\r
-               service: 'WMS',\r
-               request: 'GetMap',\r
-               version: '1.1.1',\r
-               layers: '',\r
-               styles: '',\r
-               format: 'image/jpeg',\r
-               transparent: false\r
-       },\r
-\r
-       initialize: function (url, options) { // (String, Object)\r
-\r
-               this._url = url;\r
-\r
-               var wmsParams = L.extend({}, this.defaultWmsParams),\r
-                   tileSize = options.tileSize || this.options.tileSize;\r
-\r
-               if (options.detectRetina && L.Browser.retina) {\r
-                       wmsParams.width = wmsParams.height = tileSize * 2;\r
-               } else {\r
-                       wmsParams.width = wmsParams.height = tileSize;\r
-               }\r
-\r
-               for (var i in options) {\r
-                       // all keys that are not TileLayer options go to WMS params\r
-                       if (!this.options.hasOwnProperty(i) && i !== 'crs') {\r
-                               wmsParams[i] = options[i];\r
-                       }\r
-               }\r
-\r
-               this.wmsParams = wmsParams;\r
-\r
-               L.setOptions(this, options);\r
-       },\r
+L.CRS.EPSG3395 = L.extend({}, L.CRS.Earth, {\r
+       code: 'EPSG:3395',\r
+       projection: L.Projection.Mercator,\r
 \r
-       onAdd: function (map) {\r
-\r
-               this._crs = this.options.crs || map.options.crs;\r
-\r
-               this._wmsVersion = parseFloat(this.wmsParams.version);\r
-\r
-               var projectionKey = this._wmsVersion >= 1.3 ? 'crs' : 'srs';\r
-               this.wmsParams[projectionKey] = this._crs.code;\r
-\r
-               L.TileLayer.prototype.onAdd.call(this, map);\r
-       },\r
-\r
-       getTileUrl: function (tilePoint) { // (Point, Number) -> String\r
-\r
-               var map = this._map,\r
-                   tileSize = this.options.tileSize,\r
-\r
-                   nwPoint = tilePoint.multiplyBy(tileSize),\r
-                   sePoint = nwPoint.add([tileSize, tileSize]),\r
-\r
-                   nw = this._crs.project(map.unproject(nwPoint, tilePoint.z)),\r
-                   se = this._crs.project(map.unproject(sePoint, tilePoint.z)),\r
-                   bbox = this._wmsVersion >= 1.3 && this._crs === L.CRS.EPSG4326 ?\r
-                       [se.y, nw.x, nw.y, se.x].join(',') :\r
-                       [nw.x, se.y, se.x, nw.y].join(','),\r
-\r
-                   url = L.Util.template(this._url, {s: this._getSubdomain(tilePoint)});\r
-\r
-               return url + L.Util.getParamString(this.wmsParams, url, true) + '&BBOX=' + bbox;\r
-       },\r
-\r
-       setParams: function (params, noRedraw) {\r
-\r
-               L.extend(this.wmsParams, params);\r
-\r
-               if (!noRedraw) {\r
-                       this.redraw();\r
-               }\r
-\r
-               return this;\r
-       }\r
+       transformation: (function () {\r
+               var scale = 0.5 / (Math.PI * L.Projection.Mercator.R);\r
+               return new L.Transformation(scale, 0.5, -scale, 0.5);\r
+       }())\r
 });\r
-\r
-L.tileLayer.wms = function (url, options) {\r
-       return new L.TileLayer.WMS(url, options);\r
-};\r
 
 
-/*\r
- * L.TileLayer.Canvas is a class that you can use as a base for creating\r
- * dynamically drawn Canvas-based tile layers.\r
- */\r
-\r
-L.TileLayer.Canvas = L.TileLayer.extend({\r
-       options: {\r
-               async: false\r
-       },\r
-\r
-       initialize: function (options) {\r
-               L.setOptions(this, options);\r
-       },\r
-\r
-       redraw: function () {\r
-               if (this._map) {\r
-                       this._reset({hard: true});\r
-                       this._update();\r
-               }\r
-\r
-               for (var i in this._tiles) {\r
-                       this._redrawTile(this._tiles[i]);\r
-               }\r
-               return this;\r
-       },\r
-\r
-       _redrawTile: function (tile) {\r
-               this.drawTile(tile, tile._tilePoint, this._map._zoom);\r
-       },\r
-\r
-       _createTile: function () {\r
-               var tile = L.DomUtil.create('canvas', 'leaflet-tile');\r
-               tile.width = tile.height = this.options.tileSize;\r
-               tile.onselectstart = tile.onmousemove = L.Util.falseFn;\r
-               return tile;\r
-       },\r
-\r
-       _loadTile: function (tile, tilePoint) {\r
-               tile._layer = this;\r
-               tile._tilePoint = tilePoint;\r
-\r
-               this._redrawTile(tile);\r
-\r
-               if (!this.options.async) {\r
-                       this.tileDrawn(tile);\r
-               }\r
-       },\r
-\r
-       drawTile: function (/*tile, tilePoint*/) {\r
-               // override with rendering code\r
-       },\r
-\r
-       tileDrawn: function (tile) {\r
-               this._tileOnLoad.call(tile);\r
-       }\r
-});\r
-\r
-\r
-L.tileLayer.canvas = function (options) {\r
-       return new L.TileLayer.Canvas(options);\r
-};\r
 
+/*
+ * @class GridLayer
+ * @inherits Layer
+ * @aka L.GridLayer
+ *
+ * Generic class for handling a tiled grid of HTML elements. This is the base class for all tile layers and replaces `TileLayer.Canvas`.
+ * GridLayer can be extended to create a tiled grid of HTML elements like `<canvas>`, `<img>` or `<div>`. GridLayer will handle creating and animating these DOM elements for you.
+ *
+ *
+ * @section Synchronous usage
+ * @example
+ *
+ * To create a custom layer, extend GridLayer and implement the `createTile()` method, which will be passed a `Point` object with the `x`, `y`, and `z` (zoom level) coordinates to draw your tile.
+ *
+ * ```js
+ * var CanvasLayer = L.GridLayer.extend({
+ *     createTile: function(coords){
+ *         // create a <canvas> element for drawing
+ *         var tile = L.DomUtil.create('canvas', 'leaflet-tile');
+ *
+ *         // setup tile width and height according to the options
+ *         var size = this.getTileSize();
+ *         tile.width = size.x;
+ *         tile.height = size.y;
+ *
+ *         // get a canvas context and draw something on it using coords.x, coords.y and coords.z
+ *         var ctx = tile.getContext('2d');
+ *
+ *         // return the tile so it can be rendered on screen
+ *         return tile;
+ *     }
+ * });
+ * ```
+ *
+ * @section Asynchronous usage
+ * @example
+ *
+ * Tile creation can also be asynchronous, this is useful when using a third-party drawing library. Once the tile is finished drawing it can be passed to the `done()` callback.
+ *
+ * ```js
+ * var CanvasLayer = L.GridLayer.extend({
+ *     createTile: function(coords, done){
+ *         var error;
+ *
+ *         // create a <canvas> element for drawing
+ *         var tile = L.DomUtil.create('canvas', 'leaflet-tile');
+ *
+ *         // setup tile width and height according to the options
+ *         var size = this.getTileSize();
+ *         tile.width = size.x;
+ *         tile.height = size.y;
+ *
+ *         // draw something asynchronously and pass the tile to the done() callback
+ *         setTimeout(function() {
+ *             done(error, tile);
+ *         }, 1000);
+ *
+ *         return tile;
+ *     }
+ * });
+ * ```
+ *
+ * @section
+ */
 
-/*\r
- * L.ImageOverlay is used to overlay images over the map (to specific geographical bounds).\r
- */\r
-\r
-L.ImageOverlay = L.Class.extend({\r
-       includes: L.Mixin.Events,\r
-\r
-       options: {\r
-               opacity: 1\r
-       },\r
-\r
-       initialize: function (url, bounds, options) { // (String, LatLngBounds, Object)\r
-               this._url = url;\r
-               this._bounds = L.latLngBounds(bounds);\r
-\r
-               L.setOptions(this, options);\r
-       },\r
-\r
-       onAdd: function (map) {\r
-               this._map = map;\r
-\r
-               if (!this._image) {\r
-                       this._initImage();\r
-               }\r
-\r
-               map._panes.overlayPane.appendChild(this._image);\r
-\r
-               map.on('viewreset', this._reset, this);\r
-\r
-               if (map.options.zoomAnimation && L.Browser.any3d) {\r
-                       map.on('zoomanim', this._animateZoom, this);\r
-               }\r
-\r
-               this._reset();\r
-       },\r
-\r
-       onRemove: function (map) {\r
-               map.getPanes().overlayPane.removeChild(this._image);\r
-\r
-               map.off('viewreset', this._reset, this);\r
-\r
-               if (map.options.zoomAnimation) {\r
-                       map.off('zoomanim', this._animateZoom, this);\r
-               }\r
-       },\r
-\r
-       addTo: function (map) {\r
-               map.addLayer(this);\r
-               return this;\r
-       },\r
-\r
-       setOpacity: function (opacity) {\r
-               this.options.opacity = opacity;\r
-               this._updateOpacity();\r
-               return this;\r
-       },\r
-\r
-       // TODO remove bringToFront/bringToBack duplication from TileLayer/Path\r
-       bringToFront: function () {\r
-               if (this._image) {\r
-                       this._map._panes.overlayPane.appendChild(this._image);\r
-               }\r
-               return this;\r
-       },\r
-\r
-       bringToBack: function () {\r
-               var pane = this._map._panes.overlayPane;\r
-               if (this._image) {\r
-                       pane.insertBefore(this._image, pane.firstChild);\r
-               }\r
-               return this;\r
-       },\r
-\r
-       setUrl: function (url) {\r
-               this._url = url;\r
-               this._image.src = this._url;\r
-       },\r
-\r
-       getAttribution: function () {\r
-               return this.options.attribution;\r
-       },\r
-\r
-       _initImage: function () {\r
-               this._image = L.DomUtil.create('img', 'leaflet-image-layer');\r
-\r
-               if (this._map.options.zoomAnimation && L.Browser.any3d) {\r
-                       L.DomUtil.addClass(this._image, 'leaflet-zoom-animated');\r
-               } else {\r
-                       L.DomUtil.addClass(this._image, 'leaflet-zoom-hide');\r
-               }\r
-\r
-               this._updateOpacity();\r
-\r
-               //TODO createImage util method to remove duplication\r
-               L.extend(this._image, {\r
-                       galleryimg: 'no',\r
-                       onselectstart: L.Util.falseFn,\r
-                       onmousemove: L.Util.falseFn,\r
-                       onload: L.bind(this._onImageLoad, this),\r
-                       src: this._url\r
-               });\r
-       },\r
-\r
-       _animateZoom: function (e) {\r
-               var map = this._map,\r
-                   image = this._image,\r
-                   scale = map.getZoomScale(e.zoom),\r
-                   nw = this._bounds.getNorthWest(),\r
-                   se = this._bounds.getSouthEast(),\r
-\r
-                   topLeft = map._latLngToNewLayerPoint(nw, e.zoom, e.center),\r
-                   size = map._latLngToNewLayerPoint(se, e.zoom, e.center)._subtract(topLeft),\r
-                   origin = topLeft._add(size._multiplyBy((1 / 2) * (1 - 1 / scale)));\r
-\r
-               image.style[L.DomUtil.TRANSFORM] =\r
-                       L.DomUtil.getTranslateString(origin) + ' scale(' + scale + ') ';\r
-       },\r
-\r
-       _reset: function () {\r
-               var image   = this._image,\r
-                   topLeft = this._map.latLngToLayerPoint(this._bounds.getNorthWest()),\r
-                   size = this._map.latLngToLayerPoint(this._bounds.getSouthEast())._subtract(topLeft);\r
-\r
-               L.DomUtil.setPosition(image, topLeft);\r
-\r
-               image.style.width  = size.x + 'px';\r
-               image.style.height = size.y + 'px';\r
-       },\r
-\r
-       _onImageLoad: function () {\r
-               this.fire('load');\r
-       },\r
-\r
-       _updateOpacity: function () {\r
-               L.DomUtil.setOpacity(this._image, this.options.opacity);\r
-       }\r
-});\r
-\r
-L.imageOverlay = function (url, bounds, options) {\r
-       return new L.ImageOverlay(url, bounds, options);\r
-};\r
 
+L.GridLayer = L.Layer.extend({
 
-/*\r
- * L.Icon is an image-based icon class that you can use with L.Marker for custom markers.\r
- */\r
-\r
-L.Icon = L.Class.extend({\r
-       options: {\r
-               /*\r
-               iconUrl: (String) (required)\r
-               iconRetinaUrl: (String) (optional, used for retina devices if detected)\r
-               iconSize: (Point) (can be set through CSS)\r
-               iconAnchor: (Point) (centered by default, can be set in CSS with negative margins)\r
-               popupAnchor: (Point) (if not specified, popup opens in the anchor point)\r
-               shadowUrl: (String) (no shadow by default)\r
-               shadowRetinaUrl: (String) (optional, used for retina devices if detected)\r
-               shadowSize: (Point)\r
-               shadowAnchor: (Point)\r
-               */\r
-               className: ''\r
-       },\r
-\r
-       initialize: function (options) {\r
-               L.setOptions(this, options);\r
-       },\r
-\r
-       createIcon: function (oldIcon) {\r
-               return this._createIcon('icon', oldIcon);\r
-       },\r
-\r
-       createShadow: function (oldIcon) {\r
-               return this._createIcon('shadow', oldIcon);\r
-       },\r
-\r
-       _createIcon: function (name, oldIcon) {\r
-               var src = this._getIconUrl(name);\r
-\r
-               if (!src) {\r
-                       if (name === 'icon') {\r
-                               throw new Error('iconUrl not set in Icon options (see the docs).');\r
-                       }\r
-                       return null;\r
-               }\r
-\r
-               var img;\r
-               if (!oldIcon || oldIcon.tagName !== 'IMG') {\r
-                       img = this._createImg(src);\r
-               } else {\r
-                       img = this._createImg(src, oldIcon);\r
-               }\r
-               this._setIconStyles(img, name);\r
-\r
-               return img;\r
-       },\r
-\r
-       _setIconStyles: function (img, name) {\r
-               var options = this.options,\r
-                   size = L.point(options[name + 'Size']),\r
-                   anchor;\r
-\r
-               if (name === 'shadow') {\r
-                       anchor = L.point(options.shadowAnchor || options.iconAnchor);\r
-               } else {\r
-                       anchor = L.point(options.iconAnchor);\r
-               }\r
-\r
-               if (!anchor && size) {\r
-                       anchor = size.divideBy(2, true);\r
-               }\r
-\r
-               img.className = 'leaflet-marker-' + name + ' ' + options.className;\r
-\r
-               if (anchor) {\r
-                       img.style.marginLeft = (-anchor.x) + 'px';\r
-                       img.style.marginTop  = (-anchor.y) + 'px';\r
-               }\r
-\r
-               if (size) {\r
-                       img.style.width  = size.x + 'px';\r
-                       img.style.height = size.y + 'px';\r
-               }\r
-       },\r
-\r
-       _createImg: function (src, el) {\r
-               el = el || document.createElement('img');\r
-               el.src = src;\r
-               return el;\r
-       },\r
-\r
-       _getIconUrl: function (name) {\r
-               if (L.Browser.retina && this.options[name + 'RetinaUrl']) {\r
-                       return this.options[name + 'RetinaUrl'];\r
-               }\r
-               return this.options[name + 'Url'];\r
-       }\r
-});\r
-\r
-L.icon = function (options) {\r
-       return new L.Icon(options);\r
-};\r
+       // @section
+       // @aka GridLayer options
+       options: {
+               // @option tileSize: Number|Point = 256
+               // Width and height of tiles in the grid. Use a number if width and height are equal, or `L.point(width, height)` otherwise.
+               tileSize: 256,
+
+               // @option opacity: Number = 1.0
+               // Opacity of the tiles. Can be used in the `createTile()` function.
+               opacity: 1,
+
+               // @option updateWhenIdle: Boolean = depends
+               // If `false`, new tiles are loaded during panning, otherwise only after it (for better performance). `true` by default on mobile browsers, otherwise `false`.
+               updateWhenIdle: L.Browser.mobile,
+
+               // @option updateWhenZooming: Boolean = true
+               // By default, a smooth zoom animation (during a [touch zoom](#map-touchzoom) or a [`flyTo()`](#map-flyto)) will update grid layers every integer zoom level. Setting this option to `false` will update the grid layer only when the smooth animation ends.
+               updateWhenZooming: true,
+
+               // @option updateInterval: Number = 200
+               // Tiles will not update more than once every `updateInterval` milliseconds when panning.
+               updateInterval: 200,
+
+               // @option zIndex: Number = 1
+               // The explicit zIndex of the tile layer.
+               zIndex: 1,
+
+               // @option bounds: LatLngBounds = undefined
+               // If set, tiles will only be loaded inside the set `LatLngBounds`.
+               bounds: null,
+
+               // @option minZoom: Number = 0
+               // The minimum zoom level that tiles will be loaded at. By default the entire map.
+               minZoom: 0,
+
+               // @option maxZoom: Number = undefined
+               // The maximum zoom level that tiles will be loaded at.
+               maxZoom: undefined,
+
+               // @option noWrap: Boolean = false
+               // Whether the layer is wrapped around the antimeridian. If `true`, the
+               // GridLayer will only be displayed once at low zoom levels. Has no
+               // effect when the [map CRS](#map-crs) doesn't wrap around. Can be used
+               // in combination with [`bounds`](#gridlayer-bounds) to prevent requesting
+               // tiles outside the CRS limits.
+               noWrap: false,
+
+               // @option pane: String = 'tilePane'
+               // `Map pane` where the grid layer will be added.
+               pane: 'tilePane',
+
+               // @option className: String = ''
+               // A custom class name to assign to the tile layer. Empty by default.
+               className: '',
+
+               // @option keepBuffer: Number = 2
+               // When panning the map, keep this many rows and columns of tiles before unloading them.
+               keepBuffer: 2
+       },
 
+       initialize: function (options) {
+               L.setOptions(this, options);
+       },
 
-/*
- * L.Icon.Default is the blue marker icon used by default in Leaflet.
- */
+       onAdd: function () {
+               this._initContainer();
 
-L.Icon.Default = L.Icon.extend({
+               this._levels = {};
+               this._tiles = {};
 
-       options: {
-               iconSize: [25, 41],
-               iconAnchor: [12, 41],
-               popupAnchor: [1, -34],
+               this._resetView();
+               this._update();
+       },
 
-               shadowSize: [41, 41]
+       beforeAdd: function (map) {
+               map._addZoomLimit(this);
        },
 
-       _getIconUrl: function (name) {
-               var key = name + 'Url';
+       onRemove: function (map) {
+               this._removeAllTiles();
+               L.DomUtil.remove(this._container);
+               map._removeZoomLimit(this);
+               this._container = null;
+               this._tileZoom = null;
+       },
 
-               if (this.options[key]) {
-                       return this.options[key];
+       // @method bringToFront: this
+       // Brings the tile layer to the top of all tile layers.
+       bringToFront: function () {
+               if (this._map) {
+                       L.DomUtil.toFront(this._container);
+                       this._setAutoZIndex(Math.max);
                }
+               return this;
+       },
 
-               if (L.Browser.retina && name === 'icon') {
-                       name += '-2x';
+       // @method bringToBack: this
+       // Brings the tile layer to the bottom of all tile layers.
+       bringToBack: function () {
+               if (this._map) {
+                       L.DomUtil.toBack(this._container);
+                       this._setAutoZIndex(Math.min);
                }
+               return this;
+       },
+
+       // @method getContainer: HTMLElement
+       // Returns the HTML element that contains the tiles for this layer.
+       getContainer: function () {
+               return this._container;
+       },
+
+       // @method setOpacity(opacity: Number): this
+       // Changes the [opacity](#gridlayer-opacity) of the grid layer.
+       setOpacity: function (opacity) {
+               this.options.opacity = opacity;
+               this._updateOpacity();
+               return this;
+       },
+
+       // @method setZIndex(zIndex: Number): this
+       // Changes the [zIndex](#gridlayer-zindex) of the grid layer.
+       setZIndex: function (zIndex) {
+               this.options.zIndex = zIndex;
+               this._updateZIndex();
 
-               var path = L.Icon.Default.imagePath;
-
-               if (!path) {
-                       throw new Error('Couldn\'t autodetect L.Icon.Default.imagePath, set it manually.');
+               return this;
+       },
+
+       // @method isLoading: Boolean
+       // Returns `true` if any tile in the grid layer has not finished loading.
+       isLoading: function () {
+               return this._loading;
+       },
+
+       // @method redraw: this
+       // Causes the layer to clear all the tiles and request them again.
+       redraw: function () {
+               if (this._map) {
+                       this._removeAllTiles();
+                       this._update();
                }
+               return this;
+       },
 
-               return path + '/marker-' + name + '.png';
-       }
-});
+       getEvents: function () {
+               var events = {
+                       viewprereset: this._invalidateAll,
+                       viewreset: this._resetView,
+                       zoom: this._resetView,
+                       moveend: this._onMoveEnd
+               };
+
+               if (!this.options.updateWhenIdle) {
+                       // update tiles on move, but not more often than once per given interval
+                       if (!this._onMove) {
+                               this._onMove = L.Util.throttle(this._onMoveEnd, this.options.updateInterval, this);
+                       }
+
+                       events.move = this._onMove;
+               }
+
+               if (this._zoomAnimated) {
+                       events.zoomanim = this._animateZoom;
+               }
 
-L.Icon.Default.imagePath = (function () {
-       var scripts = document.getElementsByTagName('script'),
-           leafletRe = /[\/^]leaflet[\-\._]?([\w\-\._]*)\.js\??/;
+               return events;
+       },
 
-       var i, len, src, matches, path;
+       // @section Extension methods
+       // Layers extending `GridLayer` shall reimplement the following method.
+       // @method createTile(coords: Object, done?: Function): HTMLElement
+       // Called only internally, must be overriden by classes extending `GridLayer`.
+       // Returns the `HTMLElement` corresponding to the given `coords`. If the `done` callback
+       // is specified, it must be called when the tile has finished loading and drawing.
+       createTile: function () {
+               return document.createElement('div');
+       },
 
-       for (i = 0, len = scripts.length; i < len; i++) {
-               src = scripts[i].src;
-               matches = src.match(leafletRe);
+       // @section
+       // @method getTileSize: Point
+       // Normalizes the [tileSize option](#gridlayer-tilesize) into a point. Used by the `createTile()` method.
+       getTileSize: function () {
+               var s = this.options.tileSize;
+               return s instanceof L.Point ? s : new L.Point(s, s);
+       },
 
-               if (matches) {
-                       path = src.split(leafletRe)[0];
-                       return (path ? path + '/' : '') + 'images';
+       _updateZIndex: function () {
+               if (this._container && this.options.zIndex !== undefined && this.options.zIndex !== null) {
+                       this._container.style.zIndex = this.options.zIndex;
                }
-       }
-}());
+       },
 
+       _setAutoZIndex: function (compare) {
+               // go through all other layers of the same pane, set zIndex to max + 1 (front) or min - 1 (back)
 
-/*\r
- * L.Marker is used to display clickable/draggable icons on the map.\r
- */\r
-\r
-L.Marker = L.Class.extend({\r
-\r
-       includes: L.Mixin.Events,\r
-\r
-       options: {\r
-               icon: new L.Icon.Default(),\r
-               title: '',\r
-               alt: '',\r
-               clickable: true,\r
-               draggable: false,\r
-               keyboard: true,\r
-               zIndexOffset: 0,\r
-               opacity: 1,\r
-               riseOnHover: false,\r
-               riseOffset: 250\r
-       },\r
-\r
-       initialize: function (latlng, options) {\r
-               L.setOptions(this, options);\r
-               this._latlng = L.latLng(latlng);\r
-       },\r
-\r
-       onAdd: function (map) {\r
-               this._map = map;\r
-\r
-               map.on('viewreset', this.update, this);\r
-\r
-               this._initIcon();\r
-               this.update();\r
-               this.fire('add');\r
-\r
-               if (map.options.zoomAnimation && map.options.markerZoomAnimation) {\r
-                       map.on('zoomanim', this._animateZoom, this);\r
-               }\r
-       },\r
-\r
-       addTo: function (map) {\r
-               map.addLayer(this);\r
-               return this;\r
-       },\r
-\r
-       onRemove: function (map) {\r
-               if (this.dragging) {\r
-                       this.dragging.disable();\r
-               }\r
-\r
-               this._removeIcon();\r
-               this._removeShadow();\r
-\r
-               this.fire('remove');\r
-\r
-               map.off({\r
-                       'viewreset': this.update,\r
-                       'zoomanim': this._animateZoom\r
-               }, this);\r
-\r
-               this._map = null;\r
-       },\r
-\r
-       getLatLng: function () {\r
-               return this._latlng;\r
-       },\r
-\r
-       setLatLng: function (latlng) {\r
-               this._latlng = L.latLng(latlng);\r
-\r
-               this.update();\r
-\r
-               return this.fire('move', { latlng: this._latlng });\r
-       },\r
-\r
-       setZIndexOffset: function (offset) {\r
-               this.options.zIndexOffset = offset;\r
-               this.update();\r
-\r
-               return this;\r
-       },\r
-\r
-       setIcon: function (icon) {\r
-\r
-               this.options.icon = icon;\r
-\r
-               if (this._map) {\r
-                       this._initIcon();\r
-                       this.update();\r
-               }\r
-\r
-               if (this._popup) {\r
-                       this.bindPopup(this._popup);\r
-               }\r
-\r
-               return this;\r
-       },\r
-\r
-       update: function () {\r
-               if (this._icon) {\r
-                       this._setPos(this._map.latLngToLayerPoint(this._latlng).round());\r
-               }\r
-               return this;\r
-       },\r
-\r
-       _initIcon: function () {\r
-               var options = this.options,\r
-                   map = this._map,\r
-                   animation = (map.options.zoomAnimation && map.options.markerZoomAnimation),\r
-                   classToAdd = animation ? 'leaflet-zoom-animated' : 'leaflet-zoom-hide';\r
-\r
-               var icon = options.icon.createIcon(this._icon),\r
-                       addIcon = false;\r
-\r
-               // if we're not reusing the icon, remove the old one and init new one\r
-               if (icon !== this._icon) {\r
-                       if (this._icon) {\r
-                               this._removeIcon();\r
-                       }\r
-                       addIcon = true;\r
-\r
-                       if (options.title) {\r
-                               icon.title = options.title;\r
-                       }\r
-\r
-                       if (options.alt) {\r
-                               icon.alt = options.alt;\r
-                       }\r
-               }\r
-\r
-               L.DomUtil.addClass(icon, classToAdd);\r
-\r
-               if (options.keyboard) {\r
-                       icon.tabIndex = '0';\r
-               }\r
-\r
-               this._icon = icon;\r
-\r
-               this._initInteraction();\r
-\r
-               if (options.riseOnHover) {\r
-                       L.DomEvent\r
-                               .on(icon, 'mouseover', this._bringToFront, this)\r
-                               .on(icon, 'mouseout', this._resetZIndex, this);\r
-               }\r
-\r
-               var newShadow = options.icon.createShadow(this._shadow),\r
-                       addShadow = false;\r
-\r
-               if (newShadow !== this._shadow) {\r
-                       this._removeShadow();\r
-                       addShadow = true;\r
-               }\r
-\r
-               if (newShadow) {\r
-                       L.DomUtil.addClass(newShadow, classToAdd);\r
-               }\r
-               this._shadow = newShadow;\r
-\r
-\r
-               if (options.opacity < 1) {\r
-                       this._updateOpacity();\r
-               }\r
-\r
-\r
-               var panes = this._map._panes;\r
-\r
-               if (addIcon) {\r
-                       panes.markerPane.appendChild(this._icon);\r
-               }\r
-\r
-               if (newShadow && addShadow) {\r
-                       panes.shadowPane.appendChild(this._shadow);\r
-               }\r
-       },\r
-\r
-       _removeIcon: function () {\r
-               if (this.options.riseOnHover) {\r
-                       L.DomEvent\r
-                           .off(this._icon, 'mouseover', this._bringToFront)\r
-                           .off(this._icon, 'mouseout', this._resetZIndex);\r
-               }\r
-\r
-               this._map._panes.markerPane.removeChild(this._icon);\r
-\r
-               this._icon = null;\r
-       },\r
-\r
-       _removeShadow: function () {\r
-               if (this._shadow) {\r
-                       this._map._panes.shadowPane.removeChild(this._shadow);\r
-               }\r
-               this._shadow = null;\r
-       },\r
-\r
-       _setPos: function (pos) {\r
-               L.DomUtil.setPosition(this._icon, pos);\r
-\r
-               if (this._shadow) {\r
-                       L.DomUtil.setPosition(this._shadow, pos);\r
-               }\r
-\r
-               this._zIndex = pos.y + this.options.zIndexOffset;\r
-\r
-               this._resetZIndex();\r
-       },\r
-\r
-       _updateZIndex: function (offset) {\r
-               this._icon.style.zIndex = this._zIndex + offset;\r
-       },\r
-\r
-       _animateZoom: function (opt) {\r
-               var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round();\r
-\r
-               this._setPos(pos);\r
-       },\r
-\r
-       _initInteraction: function () {\r
-\r
-               if (!this.options.clickable) { return; }\r
-\r
-               // TODO refactor into something shared with Map/Path/etc. to DRY it up\r
-\r
-               var icon = this._icon,\r
-                   events = ['dblclick', 'mousedown', 'mouseover', 'mouseout', 'contextmenu'];\r
-\r
-               L.DomUtil.addClass(icon, 'leaflet-clickable');\r
-               L.DomEvent.on(icon, 'click', this._onMouseClick, this);\r
-               L.DomEvent.on(icon, 'keypress', this._onKeyPress, this);\r
-\r
-               for (var i = 0; i < events.length; i++) {\r
-                       L.DomEvent.on(icon, events[i], this._fireMouseEvent, this);\r
-               }\r
-\r
-               if (L.Handler.MarkerDrag) {\r
-                       this.dragging = new L.Handler.MarkerDrag(this);\r
-\r
-                       if (this.options.draggable) {\r
-                               this.dragging.enable();\r
-                       }\r
-               }\r
-       },\r
-\r
-       _onMouseClick: function (e) {\r
-               var wasDragged = this.dragging && this.dragging.moved();\r
-\r
-               if (this.hasEventListeners(e.type) || wasDragged) {\r
-                       L.DomEvent.stopPropagation(e);\r
-               }\r
-\r
-               if (wasDragged) { return; }\r
-\r
-               if ((!this.dragging || !this.dragging._enabled) && this._map.dragging && this._map.dragging.moved()) { return; }\r
-\r
-               this.fire(e.type, {\r
-                       originalEvent: e,\r
-                       latlng: this._latlng\r
-               });\r
-       },\r
-\r
-       _onKeyPress: function (e) {\r
-               if (e.keyCode === 13) {\r
-                       this.fire('click', {\r
-                               originalEvent: e,\r
-                               latlng: this._latlng\r
-                       });\r
-               }\r
-       },\r
-\r
-       _fireMouseEvent: function (e) {\r
-\r
-               this.fire(e.type, {\r
-                       originalEvent: e,\r
-                       latlng: this._latlng\r
-               });\r
-\r
-               // TODO proper custom event propagation\r
-               // this line will always be called if marker is in a FeatureGroup\r
-               if (e.type === 'contextmenu' && this.hasEventListeners(e.type)) {\r
-                       L.DomEvent.preventDefault(e);\r
-               }\r
-               if (e.type !== 'mousedown') {\r
-                       L.DomEvent.stopPropagation(e);\r
-               } else {\r
-                       L.DomEvent.preventDefault(e);\r
-               }\r
-       },\r
-\r
-       setOpacity: function (opacity) {\r
-               this.options.opacity = opacity;\r
-               if (this._map) {\r
-                       this._updateOpacity();\r
-               }\r
-\r
-               return this;\r
-       },\r
-\r
-       _updateOpacity: function () {\r
-               L.DomUtil.setOpacity(this._icon, this.options.opacity);\r
-               if (this._shadow) {\r
-                       L.DomUtil.setOpacity(this._shadow, this.options.opacity);\r
-               }\r
-       },\r
-\r
-       _bringToFront: function () {\r
-               this._updateZIndex(this.options.riseOffset);\r
-       },\r
-\r
-       _resetZIndex: function () {\r
-               this._updateZIndex(0);\r
-       }\r
-});\r
-\r
-L.marker = function (latlng, options) {\r
-       return new L.Marker(latlng, options);\r
-};\r
+               var layers = this.getPane().children,
+                   edgeZIndex = -compare(-Infinity, Infinity); // -Infinity for max, Infinity for min
 
+               for (var i = 0, len = layers.length, zIndex; i < len; i++) {
 
-/*
- * L.DivIcon is a lightweight HTML-based icon class (as opposed to the image-based L.Icon)
- * to use with L.Marker.
- */
+                       zIndex = layers[i].style.zIndex;
 
-L.DivIcon = L.Icon.extend({
-       options: {
-               iconSize: [12, 12], // also can be set through CSS
-               /*
-               iconAnchor: (Point)
-               popupAnchor: (Point)
-               html: (String)
-               bgPos: (Point)
-               */
-               className: 'leaflet-div-icon',
-               html: false
+                       if (layers[i] !== this._container && zIndex) {
+                               edgeZIndex = compare(edgeZIndex, +zIndex);
+                       }
+               }
+
+               if (isFinite(edgeZIndex)) {
+                       this.options.zIndex = edgeZIndex + compare(-1, 1);
+                       this._updateZIndex();
+               }
        },
 
-       createIcon: function (oldIcon) {
-               var div = (oldIcon && oldIcon.tagName === 'DIV') ? oldIcon : document.createElement('div'),
-                   options = this.options;
+       _updateOpacity: function () {
+               if (!this._map) { return; }
+
+               // IE doesn't inherit filter opacity properly, so we're forced to set it on tiles
+               if (L.Browser.ielt9) { return; }
+
+               L.DomUtil.setOpacity(this._container, this.options.opacity);
+
+               var now = +new Date(),
+                   nextFrame = false,
+                   willPrune = false;
+
+               for (var key in this._tiles) {
+                       var tile = this._tiles[key];
+                       if (!tile.current || !tile.loaded) { continue; }
+
+                       var fade = Math.min(1, (now - tile.loaded) / 200);
+
+                       L.DomUtil.setOpacity(tile.el, fade);
+                       if (fade < 1) {
+                               nextFrame = true;
+                       } else {
+                               if (tile.active) { willPrune = true; }
+                               tile.active = true;
+                       }
+               }
+
+               if (willPrune && !this._noPrune) { this._pruneTiles(); }
+
+               if (nextFrame) {
+                       L.Util.cancelAnimFrame(this._fadeFrame);
+                       this._fadeFrame = L.Util.requestAnimFrame(this._updateOpacity, this);
+               }
+       },
+
+       _initContainer: function () {
+               if (this._container) { return; }
+
+               this._container = L.DomUtil.create('div', 'leaflet-layer ' + (this.options.className || ''));
+               this._updateZIndex();
+
+               if (this.options.opacity < 1) {
+                       this._updateOpacity();
+               }
+
+               this.getPane().appendChild(this._container);
+       },
+
+       _updateLevels: function () {
+
+               var zoom = this._tileZoom,
+                   maxZoom = this.options.maxZoom;
+
+               if (zoom === undefined) { return undefined; }
+
+               for (var z in this._levels) {
+                       if (this._levels[z].el.children.length || z === zoom) {
+                               this._levels[z].el.style.zIndex = maxZoom - Math.abs(zoom - z);
+                       } else {
+                               L.DomUtil.remove(this._levels[z].el);
+                               this._removeTilesAtZoom(z);
+                               delete this._levels[z];
+                       }
+               }
+
+               var level = this._levels[zoom],
+                   map = this._map;
+
+               if (!level) {
+                       level = this._levels[zoom] = {};
+
+                       level.el = L.DomUtil.create('div', 'leaflet-tile-container leaflet-zoom-animated', this._container);
+                       level.el.style.zIndex = maxZoom;
+
+                       level.origin = map.project(map.unproject(map.getPixelOrigin()), zoom).round();
+                       level.zoom = zoom;
+
+                       this._setZoomTransform(level, map.getCenter(), map.getZoom());
+
+                       // force the browser to consider the newly added element for transition
+                       L.Util.falseFn(level.el.offsetWidth);
+               }
+
+               this._level = level;
+
+               return level;
+       },
+
+       _pruneTiles: function () {
+               if (!this._map) {
+                       return;
+               }
+
+               var key, tile;
+
+               var zoom = this._map.getZoom();
+               if (zoom > this.options.maxZoom ||
+                       zoom < this.options.minZoom) {
+                       this._removeAllTiles();
+                       return;
+               }
+
+               for (key in this._tiles) {
+                       tile = this._tiles[key];
+                       tile.retain = tile.current;
+               }
+
+               for (key in this._tiles) {
+                       tile = this._tiles[key];
+                       if (tile.current && !tile.active) {
+                               var coords = tile.coords;
+                               if (!this._retainParent(coords.x, coords.y, coords.z, coords.z - 5)) {
+                                       this._retainChildren(coords.x, coords.y, coords.z, coords.z + 2);
+                               }
+                       }
+               }
+
+               for (key in this._tiles) {
+                       if (!this._tiles[key].retain) {
+                               this._removeTile(key);
+                       }
+               }
+       },
+
+       _removeTilesAtZoom: function (zoom) {
+               for (var key in this._tiles) {
+                       if (this._tiles[key].coords.z !== zoom) {
+                               continue;
+                       }
+                       this._removeTile(key);
+               }
+       },
+
+       _removeAllTiles: function () {
+               for (var key in this._tiles) {
+                       this._removeTile(key);
+               }
+       },
+
+       _invalidateAll: function () {
+               for (var z in this._levels) {
+                       L.DomUtil.remove(this._levels[z].el);
+                       delete this._levels[z];
+               }
+               this._removeAllTiles();
+
+               this._tileZoom = null;
+       },
+
+       _retainParent: function (x, y, z, minZoom) {
+               var x2 = Math.floor(x / 2),
+                   y2 = Math.floor(y / 2),
+                   z2 = z - 1,
+                   coords2 = new L.Point(+x2, +y2);
+               coords2.z = +z2;
+
+               var key = this._tileCoordsToKey(coords2),
+                   tile = this._tiles[key];
+
+               if (tile && tile.active) {
+                       tile.retain = true;
+                       return true;
+
+               } else if (tile && tile.loaded) {
+                       tile.retain = true;
+               }
+
+               if (z2 > minZoom) {
+                       return this._retainParent(x2, y2, z2, minZoom);
+               }
+
+               return false;
+       },
+
+       _retainChildren: function (x, y, z, maxZoom) {
+
+               for (var i = 2 * x; i < 2 * x + 2; i++) {
+                       for (var j = 2 * y; j < 2 * y + 2; j++) {
+
+                               var coords = new L.Point(i, j);
+                               coords.z = z + 1;
+
+                               var key = this._tileCoordsToKey(coords),
+                                   tile = this._tiles[key];
+
+                               if (tile && tile.active) {
+                                       tile.retain = true;
+                                       continue;
+
+                               } else if (tile && tile.loaded) {
+                                       tile.retain = true;
+                               }
+
+                               if (z + 1 < maxZoom) {
+                                       this._retainChildren(i, j, z + 1, maxZoom);
+                               }
+                       }
+               }
+       },
+
+       _resetView: function (e) {
+               var animating = e && (e.pinch || e.flyTo);
+               this._setView(this._map.getCenter(), this._map.getZoom(), animating, animating);
+       },
+
+       _animateZoom: function (e) {
+               this._setView(e.center, e.zoom, true, e.noUpdate);
+       },
 
-               if (options.html !== false) {
-                       div.innerHTML = options.html;
+       _setView: function (center, zoom, noPrune, noUpdate) {
+               var tileZoom = Math.round(zoom);
+               if ((this.options.maxZoom !== undefined && tileZoom > this.options.maxZoom) ||
+                   (this.options.minZoom !== undefined && tileZoom < this.options.minZoom)) {
+                       tileZoom = undefined;
+               }
+
+               var tileZoomChanged = this.options.updateWhenZooming && (tileZoom !== this._tileZoom);
+
+               if (!noUpdate || tileZoomChanged) {
+
+                       this._tileZoom = tileZoom;
+
+                       if (this._abortLoading) {
+                               this._abortLoading();
+                       }
+
+                       this._updateLevels();
+                       this._resetGrid();
+
+                       if (tileZoom !== undefined) {
+                               this._update(center);
+                       }
+
+                       if (!noPrune) {
+                               this._pruneTiles();
+                       }
+
+                       // Flag to prevent _updateOpacity from pruning tiles during
+                       // a zoom anim or a pinch gesture
+                       this._noPrune = !!noPrune;
+               }
+
+               this._setZoomTransforms(center, zoom);
+       },
+
+       _setZoomTransforms: function (center, zoom) {
+               for (var i in this._levels) {
+                       this._setZoomTransform(this._levels[i], center, zoom);
+               }
+       },
+
+       _setZoomTransform: function (level, center, zoom) {
+               var scale = this._map.getZoomScale(zoom, level.zoom),
+                   translate = level.origin.multiplyBy(scale)
+                       .subtract(this._map._getNewPixelOrigin(center, zoom)).round();
+
+               if (L.Browser.any3d) {
+                       L.DomUtil.setTransform(level.el, translate, scale);
                } else {
-                       div.innerHTML = '';
+                       L.DomUtil.setPosition(level.el, translate);
                }
+       },
 
-               if (options.bgPos) {
-                       div.style.backgroundPosition =
-                               (-options.bgPos.x) + 'px ' + (-options.bgPos.y) + 'px';
+       _resetGrid: function () {
+               var map = this._map,
+                   crs = map.options.crs,
+                   tileSize = this._tileSize = this.getTileSize(),
+                   tileZoom = this._tileZoom;
+
+               var bounds = this._map.getPixelWorldBounds(this._tileZoom);
+               if (bounds) {
+                       this._globalTileRange = this._pxBoundsToTileRange(bounds);
                }
 
-               this._setIconStyles(div, 'icon');
-               return div;
+               this._wrapX = crs.wrapLng && !this.options.noWrap && [
+                       Math.floor(map.project([0, crs.wrapLng[0]], tileZoom).x / tileSize.x),
+                       Math.ceil(map.project([0, crs.wrapLng[1]], tileZoom).x / tileSize.y)
+               ];
+               this._wrapY = crs.wrapLat && !this.options.noWrap && [
+                       Math.floor(map.project([crs.wrapLat[0], 0], tileZoom).y / tileSize.x),
+                       Math.ceil(map.project([crs.wrapLat[1], 0], tileZoom).y / tileSize.y)
+               ];
        },
 
-       createShadow: function () {
-               return null;
-       }
-});
+       _onMoveEnd: function () {
+               if (!this._map || this._map._animatingZoom) { return; }
 
-L.divIcon = function (options) {
-       return new L.DivIcon(options);
-};
+               this._update();
+       },
 
+       _getTiledPixelBounds: function (center) {
+               var map = this._map,
+                   mapZoom = map._animatingZoom ? Math.max(map._animateToZoom, map.getZoom()) : map.getZoom(),
+                   scale = map.getZoomScale(mapZoom, this._tileZoom),
+                   pixelCenter = map.project(center, this._tileZoom).floor(),
+                   halfSize = map.getSize().divideBy(scale * 2);
 
-/*\r
- * L.Popup is used for displaying popups on the map.\r
- */\r
-\r
-L.Map.mergeOptions({\r
-       closePopupOnClick: true\r
-});\r
-\r
-L.Popup = L.Class.extend({\r
-       includes: L.Mixin.Events,\r
-\r
-       options: {\r
-               minWidth: 50,\r
-               maxWidth: 300,\r
-               // maxHeight: null,\r
-               autoPan: true,\r
-               closeButton: true,\r
-               offset: [0, 7],\r
-               autoPanPadding: [5, 5],\r
-               // autoPanPaddingTopLeft: null,\r
-               // autoPanPaddingBottomRight: null,\r
-               keepInView: false,\r
-               className: '',\r
-               zoomAnimation: true\r
-       },\r
-\r
-       initialize: function (options, source) {\r
-               L.setOptions(this, options);\r
-\r
-               this._source = source;\r
-               this._animated = L.Browser.any3d && this.options.zoomAnimation;\r
-               this._isOpen = false;\r
-       },\r
-\r
-       onAdd: function (map) {\r
-               this._map = map;\r
-\r
-               if (!this._container) {\r
-                       this._initLayout();\r
-               }\r
-\r
-               var animFade = map.options.fadeAnimation;\r
-\r
-               if (animFade) {\r
-                       L.DomUtil.setOpacity(this._container, 0);\r
-               }\r
-               map._panes.popupPane.appendChild(this._container);\r
-\r
-               map.on(this._getEvents(), this);\r
-\r
-               this.update();\r
-\r
-               if (animFade) {\r
-                       L.DomUtil.setOpacity(this._container, 1);\r
-               }\r
-\r
-               this.fire('open');\r
-\r
-               map.fire('popupopen', {popup: this});\r
-\r
-               if (this._source) {\r
-                       this._source.fire('popupopen', {popup: this});\r
-               }\r
-       },\r
-\r
-       addTo: function (map) {\r
-               map.addLayer(this);\r
-               return this;\r
-       },\r
-\r
-       openOn: function (map) {\r
-               map.openPopup(this);\r
-               return this;\r
-       },\r
-\r
-       onRemove: function (map) {\r
-               map._panes.popupPane.removeChild(this._container);\r
-\r
-               L.Util.falseFn(this._container.offsetWidth); // force reflow\r
-\r
-               map.off(this._getEvents(), this);\r
-\r
-               if (map.options.fadeAnimation) {\r
-                       L.DomUtil.setOpacity(this._container, 0);\r
-               }\r
-\r
-               this._map = null;\r
-\r
-               this.fire('close');\r
-\r
-               map.fire('popupclose', {popup: this});\r
-\r
-               if (this._source) {\r
-                       this._source.fire('popupclose', {popup: this});\r
-               }\r
-       },\r
-\r
-       getLatLng: function () {\r
-               return this._latlng;\r
-       },\r
-\r
-       setLatLng: function (latlng) {\r
-               this._latlng = L.latLng(latlng);\r
-               if (this._map) {\r
-                       this._updatePosition();\r
-                       this._adjustPan();\r
-               }\r
-               return this;\r
-       },\r
-\r
-       getContent: function () {\r
-               return this._content;\r
-       },\r
-\r
-       setContent: function (content) {\r
-               this._content = content;\r
-               this.update();\r
-               return this;\r
-       },\r
+               return new L.Bounds(pixelCenter.subtract(halfSize), pixelCenter.add(halfSize));
+       },
+
+       // Private method to load tiles in the grid's active zoom level according to map bounds
+       _update: function (center) {
+               var map = this._map;
+               if (!map) { return; }
+               var zoom = map.getZoom();
+
+               if (center === undefined) { center = map.getCenter(); }
+               if (this._tileZoom === undefined) { return; }   // if out of minzoom/maxzoom
+
+               var pixelBounds = this._getTiledPixelBounds(center),
+                   tileRange = this._pxBoundsToTileRange(pixelBounds),
+                   tileCenter = tileRange.getCenter(),
+                   queue = [],
+                   margin = this.options.keepBuffer,
+                   noPruneRange = new L.Bounds(tileRange.getBottomLeft().subtract([margin, -margin]),
+                                             tileRange.getTopRight().add([margin, -margin]));
+
+               for (var key in this._tiles) {
+                       var c = this._tiles[key].coords;
+                       if (c.z !== this._tileZoom || !noPruneRange.contains(L.point(c.x, c.y))) {
+                               this._tiles[key].current = false;
+                       }
+               }
+
+               // _update just loads more tiles. If the tile zoom level differs too much
+               // from the map's, let _setView reset levels and prune old tiles.
+               if (Math.abs(zoom - this._tileZoom) > 1) { this._setView(center, zoom); return; }
+
+               // create a queue of coordinates to load tiles from
+               for (var j = tileRange.min.y; j <= tileRange.max.y; j++) {
+                       for (var i = tileRange.min.x; i <= tileRange.max.x; i++) {
+                               var coords = new L.Point(i, j);
+                               coords.z = this._tileZoom;
+
+                               if (!this._isValidTile(coords)) { continue; }
+
+                               var tile = this._tiles[this._tileCoordsToKey(coords)];
+                               if (tile) {
+                                       tile.current = true;
+                               } else {
+                                       queue.push(coords);
+                               }
+                       }
+               }
+
+               // sort tile queue to load tiles in order of their distance to center
+               queue.sort(function (a, b) {
+                       return a.distanceTo(tileCenter) - b.distanceTo(tileCenter);
+               });
+
+               if (queue.length !== 0) {
+                       // if it's the first batch of tiles to load
+                       if (!this._loading) {
+                               this._loading = true;
+                               // @event loading: Event
+                               // Fired when the grid layer starts loading tiles.
+                               this.fire('loading');
+                       }
+
+                       // create DOM fragment to append tiles in one batch
+                       var fragment = document.createDocumentFragment();
+
+                       for (i = 0; i < queue.length; i++) {
+                               this._addTile(queue[i], fragment);
+                       }
+
+                       this._level.el.appendChild(fragment);
+               }
+       },
+
+       _isValidTile: function (coords) {
+               var crs = this._map.options.crs;
+
+               if (!crs.infinite) {
+                       // don't load tile if it's out of bounds and not wrapped
+                       var bounds = this._globalTileRange;
+                       if ((!crs.wrapLng && (coords.x < bounds.min.x || coords.x > bounds.max.x)) ||
+                           (!crs.wrapLat && (coords.y < bounds.min.y || coords.y > bounds.max.y))) { return false; }
+               }
+
+               if (!this.options.bounds) { return true; }
+
+               // don't load tile if it doesn't intersect the bounds in options
+               var tileBounds = this._tileCoordsToBounds(coords);
+               return L.latLngBounds(this.options.bounds).overlaps(tileBounds);
+       },
+
+       _keyToBounds: function (key) {
+               return this._tileCoordsToBounds(this._keyToTileCoords(key));
+       },
+
+       // converts tile coordinates to its geographical bounds
+       _tileCoordsToBounds: function (coords) {
+
+               var map = this._map,
+                   tileSize = this.getTileSize(),
+
+                   nwPoint = coords.scaleBy(tileSize),
+                   sePoint = nwPoint.add(tileSize),
+
+                   nw = map.unproject(nwPoint, coords.z),
+                   se = map.unproject(sePoint, coords.z),
+                   bounds = new L.LatLngBounds(nw, se);
+
+               if (!this.options.noWrap) {
+                       map.wrapLatLngBounds(bounds);
+               }
+
+               return bounds;
+       },
+
+       // converts tile coordinates to key for the tile cache
+       _tileCoordsToKey: function (coords) {
+               return coords.x + ':' + coords.y + ':' + coords.z;
+       },
+
+       // converts tile cache key to coordinates
+       _keyToTileCoords: function (key) {
+               var k = key.split(':'),
+                   coords = new L.Point(+k[0], +k[1]);
+               coords.z = +k[2];
+               return coords;
+       },
+
+       _removeTile: function (key) {
+               var tile = this._tiles[key];
+               if (!tile) { return; }
+
+               L.DomUtil.remove(tile.el);
+
+               delete this._tiles[key];
+
+               // @event tileunload: TileEvent
+               // Fired when a tile is removed (e.g. when a tile goes off the screen).
+               this.fire('tileunload', {
+                       tile: tile.el,
+                       coords: this._keyToTileCoords(key)
+               });
+       },
+
+       _initTile: function (tile) {
+               L.DomUtil.addClass(tile, 'leaflet-tile');
+
+               var tileSize = this.getTileSize();
+               tile.style.width = tileSize.x + 'px';
+               tile.style.height = tileSize.y + 'px';
+
+               tile.onselectstart = L.Util.falseFn;
+               tile.onmousemove = L.Util.falseFn;
+
+               // update opacity on tiles in IE7-8 because of filter inheritance problems
+               if (L.Browser.ielt9 && this.options.opacity < 1) {
+                       L.DomUtil.setOpacity(tile, this.options.opacity);
+               }
+
+               // without this hack, tiles disappear after zoom on Chrome for Android
+               // https://github.com/Leaflet/Leaflet/issues/2078
+               if (L.Browser.android && !L.Browser.android23) {
+                       tile.style.WebkitBackfaceVisibility = 'hidden';
+               }
+       },
+
+       _addTile: function (coords, container) {
+               var tilePos = this._getTilePos(coords),
+                   key = this._tileCoordsToKey(coords);
+
+               var tile = this.createTile(this._wrapCoords(coords), L.bind(this._tileReady, this, coords));
+
+               this._initTile(tile);
+
+               // if createTile is defined with a second argument ("done" callback),
+               // we know that tile is async and will be ready later; otherwise
+               if (this.createTile.length < 2) {
+                       // mark tile as ready, but delay one frame for opacity animation to happen
+                       L.Util.requestAnimFrame(L.bind(this._tileReady, this, coords, null, tile));
+               }
+
+               L.DomUtil.setPosition(tile, tilePos);
+
+               // save tile in cache
+               this._tiles[key] = {
+                       el: tile,
+                       coords: coords,
+                       current: true
+               };
+
+               container.appendChild(tile);
+               // @event tileloadstart: TileEvent
+               // Fired when a tile is requested and starts loading.
+               this.fire('tileloadstart', {
+                       tile: tile,
+                       coords: coords
+               });
+       },
+
+       _tileReady: function (coords, err, tile) {
+               if (!this._map) { return; }
+
+               if (err) {
+                       // @event tileerror: TileErrorEvent
+                       // Fired when there is an error loading a tile.
+                       this.fire('tileerror', {
+                               error: err,
+                               tile: tile,
+                               coords: coords
+                       });
+               }
+
+               var key = this._tileCoordsToKey(coords);
+
+               tile = this._tiles[key];
+               if (!tile) { return; }
+
+               tile.loaded = +new Date();
+               if (this._map._fadeAnimated) {
+                       L.DomUtil.setOpacity(tile.el, 0);
+                       L.Util.cancelAnimFrame(this._fadeFrame);
+                       this._fadeFrame = L.Util.requestAnimFrame(this._updateOpacity, this);
+               } else {
+                       tile.active = true;
+                       this._pruneTiles();
+               }
+
+               if (!err) {
+                       L.DomUtil.addClass(tile.el, 'leaflet-tile-loaded');
+
+                       // @event tileload: TileEvent
+                       // Fired when a tile loads.
+                       this.fire('tileload', {
+                               tile: tile.el,
+                               coords: coords
+                       });
+               }
+
+               if (this._noTilesToLoad()) {
+                       this._loading = false;
+                       // @event load: Event
+                       // Fired when the grid layer loaded all visible tiles.
+                       this.fire('load');
+
+                       if (L.Browser.ielt9 || !this._map._fadeAnimated) {
+                               L.Util.requestAnimFrame(this._pruneTiles, this);
+                       } else {
+                               // Wait a bit more than 0.2 secs (the duration of the tile fade-in)
+                               // to trigger a pruning.
+                               setTimeout(L.bind(this._pruneTiles, this), 250);
+                       }
+               }
+       },
+
+       _getTilePos: function (coords) {
+               return coords.scaleBy(this.getTileSize()).subtract(this._level.origin);
+       },
+
+       _wrapCoords: function (coords) {
+               var newCoords = new L.Point(
+                       this._wrapX ? L.Util.wrapNum(coords.x, this._wrapX) : coords.x,
+                       this._wrapY ? L.Util.wrapNum(coords.y, this._wrapY) : coords.y);
+               newCoords.z = coords.z;
+               return newCoords;
+       },
+
+       _pxBoundsToTileRange: function (bounds) {
+               var tileSize = this.getTileSize();
+               return new L.Bounds(
+                       bounds.min.unscaleBy(tileSize).floor(),
+                       bounds.max.unscaleBy(tileSize).ceil().subtract([1, 1]));
+       },
+
+       _noTilesToLoad: function () {
+               for (var key in this._tiles) {
+                       if (!this._tiles[key].loaded) { return false; }
+               }
+               return true;
+       }
+});
+
+// @factory L.gridLayer(options?: GridLayer options)
+// Creates a new instance of GridLayer with the supplied options.
+L.gridLayer = function (options) {
+       return new L.GridLayer(options);
+};
+
+
+
+/*\r
+ * @class TileLayer\r
+ * @inherits GridLayer\r
+ * @aka L.TileLayer\r
+ * Used to load and display tile layers on the map. Extends `GridLayer`.\r
+ *\r
+ * @example\r
+ *\r
+ * ```js\r
+ * L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png?{foo}', {foo: 'bar'}).addTo(map);\r
+ * ```\r
+ *\r
+ * @section URL template\r
+ * @example\r
+ *\r
+ * A string of the following form:\r
+ *\r
+ * ```\r
+ * 'http://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png'\r
+ * ```\r
+ *\r
+ * `{s}` means one of the available subdomains (used sequentially to help with browser parallel requests per domain limitation; subdomain values are specified in options; `a`, `b` or `c` by default, can be omitted), `{z}` — zoom level, `{x}` and `{y}` — tile coordinates. `{r}` can be used to add @2x to the URL to load retina tiles.\r
+ *\r
+ * You can use custom keys in the template, which will be [evaluated](#util-template) from TileLayer options, like this:\r
+ *\r
+ * ```\r
+ * L.tileLayer('http://{s}.somedomain.com/{foo}/{z}/{x}/{y}.png', {foo: 'bar'});\r
+ * ```\r
+ */\r
 \r
-       update: function () {\r
-               if (!this._map) { return; }\r
 \r
-               this._container.style.visibility = 'hidden';\r
+L.TileLayer = L.GridLayer.extend({\r
 \r
-               this._updateContent();\r
-               this._updateLayout();\r
-               this._updatePosition();\r
+       // @section\r
+       // @aka TileLayer options\r
+       options: {\r
+               // @option minZoom: Number = 0\r
+               // Minimum zoom number.\r
+               minZoom: 0,\r
 \r
-               this._container.style.visibility = '';\r
+               // @option maxZoom: Number = 18\r
+               // Maximum zoom number.\r
+               maxZoom: 18,\r
 \r
-               this._adjustPan();\r
+               // @option maxNativeZoom: Number = null\r
+               // Maximum zoom number the tile source has available. If it is specified,\r
+               // the tiles on all zoom levels higher than `maxNativeZoom` will be loaded\r
+               // from `maxNativeZoom` level and auto-scaled.\r
+               maxNativeZoom: null,\r
+\r
+               // @option minNativeZoom: Number = null\r
+               // Minimum zoom number the tile source has available. If it is specified,\r
+               // the tiles on all zoom levels lower than `minNativeZoom` will be loaded\r
+               // from `minNativeZoom` level and auto-scaled.\r
+               minNativeZoom: null,\r
+\r
+               // @option subdomains: String|String[] = 'abc'\r
+               // Subdomains of the tile service. Can be passed in the form of one string (where each letter is a subdomain name) or an array of strings.\r
+               subdomains: 'abc',\r
+\r
+               // @option errorTileUrl: String = ''\r
+               // URL to the tile image to show in place of the tile that failed to load.\r
+               errorTileUrl: '',\r
+\r
+               // @option zoomOffset: Number = 0\r
+               // The zoom number used in tile URLs will be offset with this value.\r
+               zoomOffset: 0,\r
+\r
+               // @option tms: Boolean = false\r
+               // If `true`, inverses Y axis numbering for tiles (turn this on for [TMS](https://en.wikipedia.org/wiki/Tile_Map_Service) services).\r
+               tms: false,\r
+\r
+               // @option zoomReverse: Boolean = false\r
+               // If set to true, the zoom number used in tile URLs will be reversed (`maxZoom - zoom` instead of `zoom`)\r
+               zoomReverse: false,\r
+\r
+               // @option detectRetina: Boolean = false\r
+               // If `true` and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution.\r
+               detectRetina: false,\r
+\r
+               // @option crossOrigin: Boolean = false\r
+               // If true, all tiles will have their crossOrigin attribute set to ''. This is needed if you want to access tile pixel data.\r
+               crossOrigin: false\r
        },\r
 \r
-       _getEvents: function () {\r
-               var events = {\r
-                       viewreset: this._updatePosition\r
-               };\r
+       initialize: function (url, options) {\r
 \r
-               if (this._animated) {\r
-                       events.zoomanim = this._zoomAnimation;\r
-               }\r
-               if ('closeOnClick' in this.options ? this.options.closeOnClick : this._map.options.closePopupOnClick) {\r
-                       events.preclick = this._close;\r
+               this._url = url;\r
+\r
+               options = L.setOptions(this, options);\r
+\r
+               // detecting retina displays, adjusting tileSize and zoom levels\r
+               if (options.detectRetina && L.Browser.retina && options.maxZoom > 0) {\r
+\r
+                       options.tileSize = Math.floor(options.tileSize / 2);\r
+\r
+                       if (!options.zoomReverse) {\r
+                               options.zoomOffset++;\r
+                               options.maxZoom--;\r
+                       } else {\r
+                               options.zoomOffset--;\r
+                               options.minZoom++;\r
+                       }\r
+\r
+                       options.minZoom = Math.max(0, options.minZoom);\r
                }\r
-               if (this.options.keepInView) {\r
-                       events.moveend = this._adjustPan;\r
+\r
+               if (typeof options.subdomains === 'string') {\r
+                       options.subdomains = options.subdomains.split('');\r
                }\r
 \r
-               return events;\r
+               // for https://github.com/Leaflet/Leaflet/issues/137\r
+               if (!L.Browser.android) {\r
+                       this.on('tileunload', this._onTileRemove);\r
+               }\r
        },\r
 \r
-       _close: function () {\r
-               if (this._map) {\r
-                       this._map.closePopup(this);\r
+       // @method setUrl(url: String, noRedraw?: Boolean): this\r
+       // Updates the layer's URL template and redraws it (unless `noRedraw` is set to `true`).\r
+       setUrl: function (url, noRedraw) {\r
+               this._url = url;\r
+\r
+               if (!noRedraw) {\r
+                       this.redraw();\r
                }\r
+               return this;\r
        },\r
 \r
-       _initLayout: function () {\r
-               var prefix = 'leaflet-popup',\r
-                       containerClass = prefix + ' ' + this.options.className + ' leaflet-zoom-' +\r
-                               (this._animated ? 'animated' : 'hide'),\r
-                       container = this._container = L.DomUtil.create('div', containerClass),\r
-                       closeButton;\r
+       // @method createTile(coords: Object, done?: Function): HTMLElement\r
+       // Called only internally, overrides GridLayer's [`createTile()`](#gridlayer-createtile)\r
+       // to return an `<img>` HTML element with the appropiate image URL given `coords`. The `done`\r
+       // callback is called when the tile has been loaded.\r
+       createTile: function (coords, done) {\r
+               var tile = document.createElement('img');\r
 \r
-               if (this.options.closeButton) {\r
-                       closeButton = this._closeButton =\r
-                               L.DomUtil.create('a', prefix + '-close-button', container);\r
-                       closeButton.href = '#close';\r
-                       closeButton.innerHTML = '&#215;';\r
-                       L.DomEvent.disableClickPropagation(closeButton);\r
+               L.DomEvent.on(tile, 'load', L.bind(this._tileOnLoad, this, done, tile));\r
+               L.DomEvent.on(tile, 'error', L.bind(this._tileOnError, this, done, tile));\r
 \r
-                       L.DomEvent.on(closeButton, 'click', this._onCloseButtonClick, this);\r
+               if (this.options.crossOrigin) {\r
+                       tile.crossOrigin = '';\r
                }\r
 \r
-               var wrapper = this._wrapper =\r
-                       L.DomUtil.create('div', prefix + '-content-wrapper', container);\r
-               L.DomEvent.disableClickPropagation(wrapper);\r
+               /*\r
+                Alt tag is set to empty string to keep screen readers from reading URL and for compliance reasons\r
+                http://www.w3.org/TR/WCAG20-TECHS/H67\r
+               */\r
+               tile.alt = '';\r
 \r
-               this._contentNode = L.DomUtil.create('div', prefix + '-content', wrapper);\r
+               /*\r
+                Set role="presentation" to force screen readers to ignore this\r
+                https://www.w3.org/TR/wai-aria/roles#textalternativecomputation\r
+               */\r
+               tile.setAttribute('role', 'presentation');\r
 \r
-               L.DomEvent.disableScrollPropagation(this._contentNode);\r
-               L.DomEvent.on(wrapper, 'contextmenu', L.DomEvent.stopPropagation);\r
+               tile.src = this.getTileUrl(coords);\r
 \r
-               this._tipContainer = L.DomUtil.create('div', prefix + '-tip-container', container);\r
-               this._tip = L.DomUtil.create('div', prefix + '-tip', this._tipContainer);\r
+               return tile;\r
        },\r
 \r
-       _updateContent: function () {\r
-               if (!this._content) { return; }\r
-\r
-               if (typeof this._content === 'string') {\r
-                       this._contentNode.innerHTML = this._content;\r
-               } else {\r
-                       while (this._contentNode.hasChildNodes()) {\r
-                               this._contentNode.removeChild(this._contentNode.firstChild);\r
+       // @section Extension methods\r
+       // @uninheritable\r
+       // Layers extending `TileLayer` might reimplement the following method.\r
+       // @method getTileUrl(coords: Object): String\r
+       // Called only internally, returns the URL for a tile given its coordinates.\r
+       // Classes extending `TileLayer` can override this function to provide custom tile URL naming schemes.\r
+       getTileUrl: function (coords) {\r
+               var data = {\r
+                       r: L.Browser.retina ? '@2x' : '',\r
+                       s: this._getSubdomain(coords),\r
+                       x: coords.x,\r
+                       y: coords.y,\r
+                       z: this._getZoomForUrl()\r
+               };\r
+               if (this._map && !this._map.options.crs.infinite) {\r
+                       var invertedY = this._globalTileRange.max.y - coords.y;\r
+                       if (this.options.tms) {\r
+                               data['y'] = invertedY;\r
                        }\r
-                       this._contentNode.appendChild(this._content);\r
+                       data['-y'] = invertedY;\r
                }\r
-               this.fire('contentupdate');\r
-       },\r
-\r
-       _updateLayout: function () {\r
-               var container = this._contentNode,\r
-                   style = container.style;\r
 \r
-               style.width = '';\r
-               style.whiteSpace = 'nowrap';\r
+               return L.Util.template(this._url, L.extend(data, this.options));\r
+       },\r
 \r
-               var width = container.offsetWidth;\r
-               width = Math.min(width, this.options.maxWidth);\r
-               width = Math.max(width, this.options.minWidth);\r
+       _tileOnLoad: function (done, tile) {\r
+               // For https://github.com/Leaflet/Leaflet/issues/3332\r
+               if (L.Browser.ielt9) {\r
+                       setTimeout(L.bind(done, this, null, tile), 0);\r
+               } else {\r
+                       done(null, tile);\r
+               }\r
+       },\r
 \r
-               style.width = (width + 1) + 'px';\r
-               style.whiteSpace = '';\r
+       _tileOnError: function (done, tile, e) {\r
+               var errorUrl = this.options.errorTileUrl;\r
+               if (errorUrl && tile.src !== errorUrl) {\r
+                       tile.src = errorUrl;\r
+               }\r
+               done(e, tile);\r
+       },\r
 \r
-               style.height = '';\r
+       getTileSize: function () {\r
+               var map = this._map,\r
+               tileSize = L.GridLayer.prototype.getTileSize.call(this),\r
+               zoom = this._tileZoom + this.options.zoomOffset,\r
+               minNativeZoom = this.options.minNativeZoom,\r
+               maxNativeZoom = this.options.maxNativeZoom;\r
 \r
-               var height = container.offsetHeight,\r
-                   maxHeight = this.options.maxHeight,\r
-                   scrolledClass = 'leaflet-popup-scrolled';\r
+               // decrease tile size when scaling below minNativeZoom\r
+               if (minNativeZoom !== null && zoom < minNativeZoom) {\r
+                       return tileSize.divideBy(map.getZoomScale(minNativeZoom, zoom)).round();\r
+               }\r
 \r
-               if (maxHeight && height > maxHeight) {\r
-                       style.height = maxHeight + 'px';\r
-                       L.DomUtil.addClass(container, scrolledClass);\r
-               } else {\r
-                       L.DomUtil.removeClass(container, scrolledClass);\r
+               // increase tile size when scaling above maxNativeZoom\r
+               if (maxNativeZoom !== null && zoom > maxNativeZoom) {\r
+                       return tileSize.divideBy(map.getZoomScale(maxNativeZoom, zoom)).round();\r
                }\r
 \r
-               this._containerWidth = this._container.offsetWidth;\r
+               return tileSize;\r
        },\r
 \r
-       _updatePosition: function () {\r
-               if (!this._map) { return; }\r
+       _onTileRemove: function (e) {\r
+               e.tile.onload = null;\r
+       },\r
 \r
-               var pos = this._map.latLngToLayerPoint(this._latlng),\r
-                   animated = this._animated,\r
-                   offset = L.point(this.options.offset);\r
+       _getZoomForUrl: function () {\r
+               var zoom = this._tileZoom,\r
+               maxZoom = this.options.maxZoom,\r
+               zoomReverse = this.options.zoomReverse,\r
+               zoomOffset = this.options.zoomOffset,\r
+               minNativeZoom = this.options.minNativeZoom,\r
+               maxNativeZoom = this.options.maxNativeZoom;\r
 \r
-               if (animated) {\r
-                       L.DomUtil.setPosition(this._container, pos);\r
+               if (zoomReverse) {\r
+                       zoom = maxZoom - zoom;\r
                }\r
 \r
-               this._containerBottom = -offset.y - (animated ? 0 : pos.y);\r
-               this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x + (animated ? 0 : pos.x);\r
+               zoom += zoomOffset;\r
 \r
-               // bottom position the popup in case the height of the popup changes (images loading etc)\r
-               this._container.style.bottom = this._containerBottom + 'px';\r
-               this._container.style.left = this._containerLeft + 'px';\r
-       },\r
+               if (minNativeZoom !== null && zoom < minNativeZoom) {\r
+                       return minNativeZoom;\r
+               }\r
 \r
-       _zoomAnimation: function (opt) {\r
-               var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center);\r
+               if (maxNativeZoom !== null && zoom > maxNativeZoom) {\r
+                       return maxNativeZoom;\r
+               }\r
 \r
-               L.DomUtil.setPosition(this._container, pos);\r
+               return zoom;\r
        },\r
 \r
-       _adjustPan: function () {\r
-               if (!this.options.autoPan) { return; }\r
+       _getSubdomain: function (tilePoint) {\r
+               var index = Math.abs(tilePoint.x + tilePoint.y) % this.options.subdomains.length;\r
+               return this.options.subdomains[index];\r
+       },\r
 \r
-               var map = this._map,\r
-                   containerHeight = this._container.offsetHeight,\r
-                   containerWidth = this._containerWidth,\r
+       // stops loading all tiles in the background layer\r
+       _abortLoading: function () {\r
+               var i, tile;\r
+               for (i in this._tiles) {\r
+                       if (this._tiles[i].coords.z !== this._tileZoom) {\r
+                               tile = this._tiles[i].el;\r
 \r
-                   layerPos = new L.Point(this._containerLeft, -containerHeight - this._containerBottom);\r
+                               tile.onload = L.Util.falseFn;\r
+                               tile.onerror = L.Util.falseFn;\r
 \r
-               if (this._animated) {\r
-                       layerPos._add(L.DomUtil.getPosition(this._container));\r
+                               if (!tile.complete) {\r
+                                       tile.src = L.Util.emptyImageUrl;\r
+                                       L.DomUtil.remove(tile);\r
+                               }\r
+                       }\r
                }\r
+       }\r
+});\r
 \r
-               var containerPos = map.layerPointToContainerPoint(layerPos),\r
-                   padding = L.point(this.options.autoPanPadding),\r
-                   paddingTL = L.point(this.options.autoPanPaddingTopLeft || padding),\r
-                   paddingBR = L.point(this.options.autoPanPaddingBottomRight || padding),\r
-                   size = map.getSize(),\r
-                   dx = 0,\r
-                   dy = 0;\r
 \r
-               if (containerPos.x + containerWidth + paddingBR.x > size.x) { // right\r
-                       dx = containerPos.x + containerWidth - size.x + paddingBR.x;\r
-               }\r
-               if (containerPos.x - dx - paddingTL.x < 0) { // left\r
-                       dx = containerPos.x - paddingTL.x;\r
-               }\r
-               if (containerPos.y + containerHeight + paddingBR.y > size.y) { // bottom\r
-                       dy = containerPos.y + containerHeight - size.y + paddingBR.y;\r
-               }\r
-               if (containerPos.y - dy - paddingTL.y < 0) { // top\r
-                       dy = containerPos.y - paddingTL.y;\r
-               }\r
+// @factory L.tilelayer(urlTemplate: String, options?: TileLayer options)\r
+// Instantiates a tile layer object given a `URL template` and optionally an options object.\r
 \r
-               if (dx || dy) {\r
-                       map\r
-                           .fire('autopanstart')\r
-                           .panBy([dx, dy]);\r
-               }\r
+L.tileLayer = function (url, options) {\r
+       return new L.TileLayer(url, options);\r
+};\r
+
+
+
+/*\r
+ * @class TileLayer.WMS\r
+ * @inherits TileLayer\r
+ * @aka L.TileLayer.WMS\r
+ * Used to display [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services as tile layers on the map. Extends `TileLayer`.\r
+ *\r
+ * @example\r
+ *\r
+ * ```js\r
+ * var nexrad = L.tileLayer.wms("http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi", {\r
+ *     layers: 'nexrad-n0r-900913',\r
+ *     format: 'image/png',\r
+ *     transparent: true,\r
+ *     attribution: "Weather data © 2012 IEM Nexrad"\r
+ * });\r
+ * ```\r
+ */\r
+\r
+L.TileLayer.WMS = L.TileLayer.extend({\r
+\r
+       // @section\r
+       // @aka TileLayer.WMS options\r
+       // If any custom options not documented here are used, they will be sent to the\r
+       // WMS server as extra parameters in each request URL. This can be useful for\r
+       // [non-standard vendor WMS parameters](http://docs.geoserver.org/stable/en/user/services/wms/vendor.html).\r
+       defaultWmsParams: {\r
+               service: 'WMS',\r
+               request: 'GetMap',\r
+\r
+               // @option layers: String = ''\r
+               // **(required)** Comma-separated list of WMS layers to show.\r
+               layers: '',\r
+\r
+               // @option styles: String = ''\r
+               // Comma-separated list of WMS styles.\r
+               styles: '',\r
+\r
+               // @option format: String = 'image/jpeg'\r
+               // WMS image format (use `'image/png'` for layers with transparency).\r
+               format: 'image/jpeg',\r
+\r
+               // @option transparent: Boolean = false\r
+               // If `true`, the WMS service will return images with transparency.\r
+               transparent: false,\r
+\r
+               // @option version: String = '1.1.1'\r
+               // Version of the WMS service to use\r
+               version: '1.1.1'\r
        },\r
 \r
-       _onCloseButtonClick: function (e) {\r
-               this._close();\r
-               L.DomEvent.stop(e);\r
-       }\r
-});\r
+       options: {\r
+               // @option crs: CRS = null\r
+               // Coordinate Reference System to use for the WMS requests, defaults to\r
+               // map CRS. Don't change this if you're not sure what it means.\r
+               crs: null,\r
 \r
-L.popup = function (options, source) {\r
-       return new L.Popup(options, source);\r
-};\r
+               // @option uppercase: Boolean = false\r
+               // If `true`, WMS request parameter keys will be uppercase.\r
+               uppercase: false\r
+       },\r
 \r
+       initialize: function (url, options) {\r
 \r
-L.Map.include({\r
-       openPopup: function (popup, latlng, options) { // (Popup) or (String || HTMLElement, LatLng[, Object])\r
-               this.closePopup();\r
+               this._url = url;\r
 \r
-               if (!(popup instanceof L.Popup)) {\r
-                       var content = popup;\r
+               var wmsParams = L.extend({}, this.defaultWmsParams);\r
 \r
-                       popup = new L.Popup(options)\r
-                           .setLatLng(latlng)\r
-                           .setContent(content);\r
+               // all keys that are not TileLayer options go to WMS params\r
+               for (var i in options) {\r
+                       if (!(i in this.options)) {\r
+                               wmsParams[i] = options[i];\r
+                       }\r
                }\r
-               popup._isOpen = true;\r
 \r
-               this._popup = popup;\r
-               return this.addLayer(popup);\r
+               options = L.setOptions(this, options);\r
+\r
+               wmsParams.width = wmsParams.height = options.tileSize * (options.detectRetina && L.Browser.retina ? 2 : 1);\r
+\r
+               this.wmsParams = wmsParams;\r
        },\r
 \r
-       closePopup: function (popup) {\r
-               if (!popup || popup === this._popup) {\r
-                       popup = this._popup;\r
-                       this._popup = null;\r
-               }\r
-               if (popup) {\r
-                       this.removeLayer(popup);\r
-                       popup._isOpen = false;\r
+       onAdd: function (map) {\r
+\r
+               this._crs = this.options.crs || map.options.crs;\r
+               this._wmsVersion = parseFloat(this.wmsParams.version);\r
+\r
+               var projectionKey = this._wmsVersion >= 1.3 ? 'crs' : 'srs';\r
+               this.wmsParams[projectionKey] = this._crs.code;\r
+\r
+               L.TileLayer.prototype.onAdd.call(this, map);\r
+       },\r
+\r
+       getTileUrl: function (coords) {\r
+\r
+               var tileBounds = this._tileCoordsToBounds(coords),\r
+                   nw = this._crs.project(tileBounds.getNorthWest()),\r
+                   se = this._crs.project(tileBounds.getSouthEast()),\r
+\r
+                   bbox = (this._wmsVersion >= 1.3 && this._crs === L.CRS.EPSG4326 ?\r
+                           [se.y, nw.x, nw.y, se.x] :\r
+                           [nw.x, se.y, se.x, nw.y]).join(','),\r
+\r
+                   url = L.TileLayer.prototype.getTileUrl.call(this, coords);\r
+\r
+               return url +\r
+                       L.Util.getParamString(this.wmsParams, url, this.options.uppercase) +\r
+                       (this.options.uppercase ? '&BBOX=' : '&bbox=') + bbox;\r
+       },\r
+\r
+       // @method setParams(params: Object, noRedraw?: Boolean): this\r
+       // Merges an object with the new parameters and re-requests tiles on the current screen (unless `noRedraw` was set to true).\r
+       setParams: function (params, noRedraw) {\r
+\r
+               L.extend(this.wmsParams, params);\r
+\r
+               if (!noRedraw) {\r
+                       this.redraw();\r
                }\r
+\r
                return this;\r
        }\r
 });\r
+\r
+\r
+// @factory L.tileLayer.wms(baseUrl: String, options: TileLayer.WMS options)\r
+// Instantiates a WMS tile layer object given a base URL of the WMS service and a WMS parameters/options object.\r
+L.tileLayer.wms = function (url, options) {\r
+       return new L.TileLayer.WMS(url, options);\r
+};\r
+
 
 
 /*\r
- * Popup extension to L.Marker, adding popup-related methods.\r
+ * @class ImageOverlay\r
+ * @aka L.ImageOverlay\r
+ * @inherits Interactive layer\r
+ *\r
+ * Used to load and display a single image over specific bounds of the map. Extends `Layer`.\r
+ *\r
+ * @example\r
+ *\r
+ * ```js\r
+ * var imageUrl = 'http://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg',\r
+ *     imageBounds = [[40.712216, -74.22655], [40.773941, -74.12544]];\r
+ * L.imageOverlay(imageUrl, imageBounds).addTo(map);\r
+ * ```\r
  */\r
 \r
-L.Marker.include({\r
-       openPopup: function () {\r
-               if (this._popup && this._map && !this._map.hasLayer(this._popup)) {\r
-                       this._popup.setLatLng(this._latlng);\r
-                       this._map.openPopup(this._popup);\r
-               }\r
+L.ImageOverlay = L.Layer.extend({\r
 \r
-               return this;\r
-       },\r
+       // @section\r
+       // @aka ImageOverlay options\r
+       options: {\r
+               // @option opacity: Number = 1.0\r
+               // The opacity of the image overlay.\r
+               opacity: 1,\r
 \r
-       closePopup: function () {\r
-               if (this._popup) {\r
-                       this._popup._close();\r
-               }\r
-               return this;\r
-       },\r
+               // @option alt: String = ''\r
+               // Text for the `alt` attribute of the image (useful for accessibility).\r
+               alt: '',\r
 \r
-       togglePopup: function () {\r
-               if (this._popup) {\r
-                       if (this._popup._isOpen) {\r
-                               this.closePopup();\r
-                       } else {\r
-                               this.openPopup();\r
-                       }\r
-               }\r
-               return this;\r
-       },\r
+               // @option interactive: Boolean = false\r
+               // If `true`, the image overlay will emit [mouse events](#interactive-layer) when clicked or hovered.\r
+               interactive: false,\r
 \r
-       bindPopup: function (content, options) {\r
-               var anchor = L.point(this.options.icon.options.popupAnchor || [0, 0]);\r
+               // @option crossOrigin: Boolean = false\r
+               // If true, the image will have its crossOrigin attribute set to ''. This is needed if you want to access image pixel data.\r
+               crossOrigin: false\r
+       },\r
 \r
-               anchor = anchor.add(L.Popup.prototype.options.offset);\r
+       initialize: function (url, bounds, options) { // (String, LatLngBounds, Object)\r
+               this._url = url;\r
+               this._bounds = L.latLngBounds(bounds);\r
 \r
-               if (options && options.offset) {\r
-                       anchor = anchor.add(options.offset);\r
-               }\r
+               L.setOptions(this, options);\r
+       },\r
 \r
-               options = L.extend({offset: anchor}, options);\r
+       onAdd: function () {\r
+               if (!this._image) {\r
+                       this._initImage();\r
 \r
-               if (!this._popupHandlersAdded) {\r
-                       this\r
-                           .on('click', this.togglePopup, this)\r
-                           .on('remove', this.closePopup, this)\r
-                           .on('move', this._movePopup, this);\r
-                       this._popupHandlersAdded = true;\r
+                       if (this.options.opacity < 1) {\r
+                               this._updateOpacity();\r
+                       }\r
                }\r
 \r
-               if (content instanceof L.Popup) {\r
-                       L.setOptions(content, options);\r
-                       this._popup = content;\r
-                       content._source = this;\r
-               } else {\r
-                       this._popup = new L.Popup(options, this)\r
-                               .setContent(content);\r
+               if (this.options.interactive) {\r
+                       L.DomUtil.addClass(this._image, 'leaflet-interactive');\r
+                       this.addInteractiveTarget(this._image);\r
                }\r
 \r
-               return this;\r
+               this.getPane().appendChild(this._image);\r
+               this._reset();\r
        },\r
 \r
-       setPopupContent: function (content) {\r
-               if (this._popup) {\r
-                       this._popup.setContent(content);\r
+       onRemove: function () {\r
+               L.DomUtil.remove(this._image);\r
+               if (this.options.interactive) {\r
+                       this.removeInteractiveTarget(this._image);\r
                }\r
-               return this;\r
        },\r
 \r
-       unbindPopup: function () {\r
-               if (this._popup) {\r
-                       this._popup = null;\r
-                       this\r
-                           .off('click', this.togglePopup, this)\r
-                           .off('remove', this.closePopup, this)\r
-                           .off('move', this._movePopup, this);\r
-                       this._popupHandlersAdded = false;\r
+       // @method setOpacity(opacity: Number): this\r
+       // Sets the opacity of the overlay.\r
+       setOpacity: function (opacity) {\r
+               this.options.opacity = opacity;\r
+\r
+               if (this._image) {\r
+                       this._updateOpacity();\r
                }\r
                return this;\r
        },\r
 \r
-       getPopup: function () {\r
-               return this._popup;\r
+       setStyle: function (styleOpts) {\r
+               if (styleOpts.opacity) {\r
+                       this.setOpacity(styleOpts.opacity);\r
+               }\r
+               return this;\r
        },\r
 \r
-       _movePopup: function (e) {\r
-               this._popup.setLatLng(e.latlng);\r
-       }\r
-});\r
-
-
-/*\r
- * L.LayerGroup is a class to combine several layers into one so that\r
- * you can manipulate the group (e.g. add/remove it) as one layer.\r
- */\r
-\r
-L.LayerGroup = L.Class.extend({\r
-       initialize: function (layers) {\r
-               this._layers = {};\r
-\r
-               var i, len;\r
-\r
-               if (layers) {\r
-                       for (i = 0, len = layers.length; i < len; i++) {\r
-                               this.addLayer(layers[i]);\r
-                       }\r
+       // @method bringToFront(): this\r
+       // Brings the layer to the top of all overlays.\r
+       bringToFront: function () {\r
+               if (this._map) {\r
+                       L.DomUtil.toFront(this._image);\r
                }\r
+               return this;\r
        },\r
 \r
-       addLayer: function (layer) {\r
-               var id = this.getLayerId(layer);\r
-\r
-               this._layers[id] = layer;\r
-\r
+       // @method bringToBack(): this\r
+       // Brings the layer to the bottom of all overlays.\r
+       bringToBack: function () {\r
                if (this._map) {\r
-                       this._map.addLayer(layer);\r
+                       L.DomUtil.toBack(this._image);\r
                }\r
-\r
                return this;\r
        },\r
 \r
-       removeLayer: function (layer) {\r
-               var id = layer in this._layers ? layer : this.getLayerId(layer);\r
+       // @method setUrl(url: String): this\r
+       // Changes the URL of the image.\r
+       setUrl: function (url) {\r
+               this._url = url;\r
 \r
-               if (this._map && this._layers[id]) {\r
-                       this._map.removeLayer(this._layers[id]);\r
+               if (this._image) {\r
+                       this._image.src = url;\r
                }\r
-\r
-               delete this._layers[id];\r
-\r
                return this;\r
        },\r
 \r
-       hasLayer: function (layer) {\r
-               if (!layer) { return false; }\r
-\r
-               return (layer in this._layers || this.getLayerId(layer) in this._layers);\r
-       },\r
+       // @method setBounds(bounds: LatLngBounds): this\r
+       // Update the bounds that this ImageOverlay covers\r
+       setBounds: function (bounds) {\r
+               this._bounds = bounds;\r
 \r
-       clearLayers: function () {\r
-               this.eachLayer(this.removeLayer, this);\r
+               if (this._map) {\r
+                       this._reset();\r
+               }\r
                return this;\r
        },\r
 \r
-       invoke: function (methodName) {\r
-               var args = Array.prototype.slice.call(arguments, 1),\r
-                   i, layer;\r
-\r
-               for (i in this._layers) {\r
-                       layer = this._layers[i];\r
+       getEvents: function () {\r
+               var events = {\r
+                       zoom: this._reset,\r
+                       viewreset: this._reset\r
+               };\r
 \r
-                       if (layer[methodName]) {\r
-                               layer[methodName].apply(layer, args);\r
-                       }\r
+               if (this._zoomAnimated) {\r
+                       events.zoomanim = this._animateZoom;\r
                }\r
 \r
-               return this;\r
+               return events;\r
        },\r
 \r
-       onAdd: function (map) {\r
-               this._map = map;\r
-               this.eachLayer(map.addLayer, map);\r
+       // @method getBounds(): LatLngBounds\r
+       // Get the bounds that this ImageOverlay covers\r
+       getBounds: function () {\r
+               return this._bounds;\r
        },\r
 \r
-       onRemove: function (map) {\r
-               this.eachLayer(map.removeLayer, map);\r
-               this._map = null;\r
+       // @method getElement(): HTMLElement\r
+       // Get the img element that represents the ImageOverlay on the map\r
+       getElement: function () {\r
+               return this._image;\r
        },\r
 \r
-       addTo: function (map) {\r
-               map.addLayer(this);\r
-               return this;\r
-       },\r
+       _initImage: function () {\r
+               var img = this._image = L.DomUtil.create('img',\r
+                               'leaflet-image-layer ' + (this._zoomAnimated ? 'leaflet-zoom-animated' : ''));\r
 \r
-       eachLayer: function (method, context) {\r
-               for (var i in this._layers) {\r
-                       method.call(context, this._layers[i]);\r
+               img.onselectstart = L.Util.falseFn;\r
+               img.onmousemove = L.Util.falseFn;\r
+\r
+               img.onload = L.bind(this.fire, this, 'load');\r
+\r
+               if (this.options.crossOrigin) {\r
+                       img.crossOrigin = '';\r
                }\r
-               return this;\r
-       },\r
 \r
-       getLayer: function (id) {\r
-               return this._layers[id];\r
+               img.src = this._url;\r
+               img.alt = this.options.alt;\r
        },\r
 \r
-       getLayers: function () {\r
-               var layers = [];\r
+       _animateZoom: function (e) {\r
+               var scale = this._map.getZoomScale(e.zoom),\r
+                   offset = this._map._latLngBoundsToNewLayerBounds(this._bounds, e.zoom, e.center).min;\r
 \r
-               for (var i in this._layers) {\r
-                       layers.push(this._layers[i]);\r
-               }\r
-               return layers;\r
+               L.DomUtil.setTransform(this._image, offset, scale);\r
        },\r
 \r
-       setZIndex: function (zIndex) {\r
-               return this.invoke('setZIndex', zIndex);\r
+       _reset: function () {\r
+               var image = this._image,\r
+                   bounds = new L.Bounds(\r
+                       this._map.latLngToLayerPoint(this._bounds.getNorthWest()),\r
+                       this._map.latLngToLayerPoint(this._bounds.getSouthEast())),\r
+                   size = bounds.getSize();\r
+\r
+               L.DomUtil.setPosition(image, bounds.min);\r
+\r
+               image.style.width  = size.x + 'px';\r
+               image.style.height = size.y + 'px';\r
        },\r
 \r
-       getLayerId: function (layer) {\r
-               return L.stamp(layer);\r
+       _updateOpacity: function () {\r
+               L.DomUtil.setOpacity(this._image, this.options.opacity);\r
        }\r
 });\r
 \r
-L.layerGroup = function (layers) {\r
-       return new L.LayerGroup(layers);\r
+// @factory L.imageOverlay(imageUrl: String, bounds: LatLngBounds, options?: ImageOverlay options)\r
+// Instantiates an image overlay object given the URL of the image and the\r
+// geographical bounds it is tied to.\r
+L.imageOverlay = function (url, bounds, options) {\r
+       return new L.ImageOverlay(url, bounds, options);\r
 };\r
 
 
+
 /*\r
- * L.FeatureGroup extends L.LayerGroup by introducing mouse events and additional methods\r
- * shared between a group of interactive layers (like vectors or markers).\r
+ * @class Icon\r
+ * @aka L.Icon\r
+ * @inherits Layer\r
+ *\r
+ * Represents an icon to provide when creating a marker.\r
+ *\r
+ * @example\r
+ *\r
+ * ```js\r
+ * var myIcon = L.icon({\r
+ *     iconUrl: 'my-icon.png',\r
+ *     iconRetinaUrl: 'my-icon@2x.png',\r
+ *     iconSize: [38, 95],\r
+ *     iconAnchor: [22, 94],\r
+ *     popupAnchor: [-3, -76],\r
+ *     shadowUrl: 'my-icon-shadow.png',\r
+ *     shadowRetinaUrl: 'my-icon-shadow@2x.png',\r
+ *     shadowSize: [68, 95],\r
+ *     shadowAnchor: [22, 94]\r
+ * });\r
+ *\r
+ * L.marker([50.505, 30.57], {icon: myIcon}).addTo(map);\r
+ * ```\r
+ *\r
+ * `L.Icon.Default` extends `L.Icon` and is the blue icon Leaflet uses for markers by default.\r
+ *\r
  */\r
 \r
-L.FeatureGroup = L.LayerGroup.extend({\r
-       includes: L.Mixin.Events,\r
+L.Icon = L.Class.extend({\r
 \r
-       statics: {\r
-               EVENTS: 'click dblclick mouseover mouseout mousemove contextmenu popupopen popupclose'\r
-       },\r
+       /* @section\r
+        * @aka Icon options\r
+        *\r
+        * @option iconUrl: String = null\r
+        * **(required)** The URL to the icon image (absolute or relative to your script path).\r
+        *\r
+        * @option iconRetinaUrl: String = null\r
+        * The URL to a retina sized version of the icon image (absolute or relative to your\r
+        * script path). Used for Retina screen devices.\r
+        *\r
+        * @option iconSize: Point = null\r
+        * Size of the icon image in pixels.\r
+        *\r
+        * @option iconAnchor: Point = null\r
+        * The coordinates of the "tip" of the icon (relative to its top left corner). The icon\r
+        * will be aligned so that this point is at the marker's geographical location. Centered\r
+        * by default if size is specified, also can be set in CSS with negative margins.\r
+        *\r
+        * @option popupAnchor: Point = null\r
+        * The coordinates of the point from which popups will "open", relative to the icon anchor.\r
+        *\r
+        * @option shadowUrl: String = null\r
+        * The URL to the icon shadow image. If not specified, no shadow image will be created.\r
+        *\r
+        * @option shadowRetinaUrl: String = null\r
+        *\r
+        * @option shadowSize: Point = null\r
+        * Size of the shadow image in pixels.\r
+        *\r
+        * @option shadowAnchor: Point = null\r
+        * The coordinates of the "tip" of the shadow (relative to its top left corner) (the same\r
+        * as iconAnchor if not specified).\r
+        *\r
+        * @option className: String = ''\r
+        * A custom class name to assign to both icon and shadow images. Empty by default.\r
+        */\r
 \r
-       addLayer: function (layer) {\r
-               if (this.hasLayer(layer)) {\r
-                       return this;\r
-               }\r
-\r
-               if ('on' in layer) {\r
-                       layer.on(L.FeatureGroup.EVENTS, this._propagateEvent, this);\r
-               }\r
-\r
-               L.LayerGroup.prototype.addLayer.call(this, layer);\r
+       initialize: function (options) {\r
+               L.setOptions(this, options);\r
+       },\r
 \r
-               if (this._popupContent && layer.bindPopup) {\r
-                       layer.bindPopup(this._popupContent, this._popupOptions);\r
-               }\r
+       // @method createIcon(oldIcon?: HTMLElement): HTMLElement\r
+       // Called internally when the icon has to be shown, returns a `<img>` HTML element\r
+       // styled according to the options.\r
+       createIcon: function (oldIcon) {\r
+               return this._createIcon('icon', oldIcon);\r
+       },\r
 \r
-               return this.fire('layeradd', {layer: layer});\r
+       // @method createShadow(oldIcon?: HTMLElement): HTMLElement\r
+       // As `createIcon`, but for the shadow beneath it.\r
+       createShadow: function (oldIcon) {\r
+               return this._createIcon('shadow', oldIcon);\r
        },\r
 \r
-       removeLayer: function (layer) {\r
-               if (!this.hasLayer(layer)) {\r
-                       return this;\r
-               }\r
-               if (layer in this._layers) {\r
-                       layer = this._layers[layer];\r
-               }\r
+       _createIcon: function (name, oldIcon) {\r
+               var src = this._getIconUrl(name);\r
 \r
-               if ('off' in layer) {\r
-                       layer.off(L.FeatureGroup.EVENTS, this._propagateEvent, this);\r
+               if (!src) {\r
+                       if (name === 'icon') {\r
+                               throw new Error('iconUrl not set in Icon options (see the docs).');\r
+                       }\r
+                       return null;\r
                }\r
 \r
-               L.LayerGroup.prototype.removeLayer.call(this, layer);\r
-\r
-               if (this._popupContent) {\r
-                       this.invoke('unbindPopup');\r
-               }\r
+               var img = this._createImg(src, oldIcon && oldIcon.tagName === 'IMG' ? oldIcon : null);\r
+               this._setIconStyles(img, name);\r
 \r
-               return this.fire('layerremove', {layer: layer});\r
+               return img;\r
        },\r
 \r
-       bindPopup: function (content, options) {\r
-               this._popupContent = content;\r
-               this._popupOptions = options;\r
-               return this.invoke('bindPopup', content, options);\r
-       },\r
+       _setIconStyles: function (img, name) {\r
+               var options = this.options;\r
+               var sizeOption = options[name + 'Size'];\r
 \r
-       openPopup: function (latlng) {\r
-               // open popup on the first layer\r
-               for (var id in this._layers) {\r
-                       this._layers[id].openPopup(latlng);\r
-                       break;\r
+               if (typeof sizeOption === 'number') {\r
+                       sizeOption = [sizeOption, sizeOption];\r
                }\r
-               return this;\r
-       },\r
-\r
-       setStyle: function (style) {\r
-               return this.invoke('setStyle', style);\r
-       },\r
 \r
-       bringToFront: function () {\r
-               return this.invoke('bringToFront');\r
-       },\r
+               var size = L.point(sizeOption),\r
+                   anchor = L.point(name === 'shadow' && options.shadowAnchor || options.iconAnchor ||\r
+                           size && size.divideBy(2, true));\r
 \r
-       bringToBack: function () {\r
-               return this.invoke('bringToBack');\r
-       },\r
+               img.className = 'leaflet-marker-' + name + ' ' + (options.className || '');\r
 \r
-       getBounds: function () {\r
-               var bounds = new L.LatLngBounds();\r
+               if (anchor) {\r
+                       img.style.marginLeft = (-anchor.x) + 'px';\r
+                       img.style.marginTop  = (-anchor.y) + 'px';\r
+               }\r
 \r
-               this.eachLayer(function (layer) {\r
-                       bounds.extend(layer instanceof L.Marker ? layer.getLatLng() : layer.getBounds());\r
-               });\r
+               if (size) {\r
+                       img.style.width  = size.x + 'px';\r
+                       img.style.height = size.y + 'px';\r
+               }\r
+       },\r
 \r
-               return bounds;\r
+       _createImg: function (src, el) {\r
+               el = el || document.createElement('img');\r
+               el.src = src;\r
+               return el;\r
        },\r
 \r
-       _propagateEvent: function (e) {\r
-               e = L.extend({\r
-                       layer: e.target,\r
-                       target: this\r
-               }, e);\r
-               this.fire(e.type, e);\r
+       _getIconUrl: function (name) {\r
+               return L.Browser.retina && this.options[name + 'RetinaUrl'] || this.options[name + 'Url'];\r
        }\r
 });\r
 \r
-L.featureGroup = function (layers) {\r
-       return new L.FeatureGroup(layers);\r
+\r
+// @factory L.icon(options: Icon options)\r
+// Creates an icon instance with the given options.\r
+L.icon = function (options) {\r
+       return new L.Icon(options);\r
 };\r
 
 
+
+/*
+ * @miniclass Icon.Default (Icon)
+ * @aka L.Icon.Default
+ * @section
+ *
+ * A trivial subclass of `Icon`, represents the icon to use in `Marker`s when
+ * no icon is specified. Points to the blue marker image distributed with Leaflet
+ * releases.
+ *
+ * In order to customize the default icon, just change the properties of `L.Icon.Default.prototype.options`
+ * (which is a set of `Icon options`).
+ *
+ * If you want to _completely_ replace the default icon, override the
+ * `L.Marker.prototype.options.icon` with your own icon instead.
+ */
+
+L.Icon.Default = L.Icon.extend({
+
+       options: {
+               iconUrl:       'marker-icon.png',
+               iconRetinaUrl: 'marker-icon-2x.png',
+               shadowUrl:     'marker-shadow.png',
+               iconSize:    [25, 41],
+               iconAnchor:  [12, 41],
+               popupAnchor: [1, -34],
+               tooltipAnchor: [16, -28],
+               shadowSize:  [41, 41]
+       },
+
+       _getIconUrl: function (name) {
+               if (!L.Icon.Default.imagePath) {        // Deprecated, backwards-compatibility only
+                       L.Icon.Default.imagePath = this._detectIconPath();
+               }
+
+               // @option imagePath: String
+               // `L.Icon.Default` will try to auto-detect the absolute location of the
+               // blue icon images. If you are placing these images in a non-standard
+               // way, set this option to point to the right absolute path.
+               return (this.options.imagePath || L.Icon.Default.imagePath) + L.Icon.prototype._getIconUrl.call(this, name);
+       },
+
+       _detectIconPath: function () {
+               var el = L.DomUtil.create('div',  'leaflet-default-icon-path', document.body);
+               var path = L.DomUtil.getStyle(el, 'background-image') ||
+                          L.DomUtil.getStyle(el, 'backgroundImage');   // IE8
+
+               document.body.removeChild(el);
+
+               return path.indexOf('url') === 0 ?
+                       path.replace(/^url\([\"\']?/, '').replace(/marker-icon\.png[\"\']?\)$/, '') : '';
+       }
+});
+
+
+
 /*\r
- * L.Path is a base class for rendering vector paths on a map. Inherited by Polyline, Circle, etc.\r
+ * @class Marker\r
+ * @inherits Interactive layer\r
+ * @aka L.Marker\r
+ * L.Marker is used to display clickable/draggable icons on the map. Extends `Layer`.\r
+ *\r
+ * @example\r
+ *\r
+ * ```js\r
+ * L.marker([50.5, 30.5]).addTo(map);\r
+ * ```\r
  */\r
 \r
-L.Path = L.Class.extend({\r
-       includes: [L.Mixin.Events],\r
-\r
-       statics: {\r
-               // how much to extend the clip area around the map view\r
-               // (relative to its size, e.g. 0.5 is half the screen in each direction)\r
-               // set it so that SVG element doesn't exceed 1280px (vectors flicker on dragend if it is)\r
-               CLIP_PADDING: (function () {\r
-                       var max = L.Browser.mobile ? 1280 : 2000,\r
-                           target = (max / Math.max(window.outerWidth, window.outerHeight) - 1) / 2;\r
-                       return Math.max(0, Math.min(0.5, target));\r
-               })()\r
-       },\r
+L.Marker = L.Layer.extend({\r
 \r
+       // @section\r
+       // @aka Marker options\r
        options: {\r
-               stroke: true,\r
-               color: '#0033ff',\r
-               dashArray: null,\r
-               lineCap: null,\r
-               lineJoin: null,\r
-               weight: 5,\r
-               opacity: 0.5,\r
+               // @option icon: Icon = *\r
+               // Icon class to use for rendering the marker. See [Icon documentation](#L.Icon) for details on how to customize the marker icon. If not specified, a new `L.Icon.Default` is used.\r
+               icon: new L.Icon.Default(),\r
+\r
+               // Option inherited from "Interactive layer" abstract class\r
+               interactive: true,\r
+\r
+               // @option draggable: Boolean = false\r
+               // Whether the marker is draggable with mouse/touch or not.\r
+               draggable: false,\r
+\r
+               // @option keyboard: Boolean = true\r
+               // Whether the marker can be tabbed to with a keyboard and clicked by pressing enter.\r
+               keyboard: true,\r
+\r
+               // @option title: String = ''\r
+               // Text for the browser tooltip that appear on marker hover (no tooltip by default).\r
+               title: '',\r
+\r
+               // @option alt: String = ''\r
+               // Text for the `alt` attribute of the icon image (useful for accessibility).\r
+               alt: '',\r
+\r
+               // @option zIndexOffset: Number = 0\r
+               // By default, marker images zIndex is set automatically based on its latitude. Use this option if you want to put the marker on top of all others (or below), specifying a high value like `1000` (or high negative value, respectively).\r
+               zIndexOffset: 0,\r
+\r
+               // @option opacity: Number = 1.0\r
+               // The opacity of the marker.\r
+               opacity: 1,\r
+\r
+               // @option riseOnHover: Boolean = false\r
+               // If `true`, the marker will get on top of others when you hover the mouse over it.\r
+               riseOnHover: false,\r
+\r
+               // @option riseOffset: Number = 250\r
+               // The z-index offset used for the `riseOnHover` feature.\r
+               riseOffset: 250,\r
 \r
-               fill: false,\r
-               fillColor: null, //same as color by default\r
-               fillOpacity: 0.2,\r
+               // @option pane: String = 'markerPane'\r
+               // `Map pane` where the markers icon will be added.\r
+               pane: 'markerPane',\r
 \r
-               clickable: true\r
+               // FIXME: shadowPane is no longer a valid option\r
+               nonBubblingEvents: ['click', 'dblclick', 'mouseover', 'mouseout', 'contextmenu']\r
        },\r
 \r
-       initialize: function (options) {\r
+       /* @section\r
+        *\r
+        * In addition to [shared layer methods](#Layer) like `addTo()` and `remove()` and [popup methods](#Popup) like bindPopup() you can also use the following methods:\r
+        */\r
+\r
+       initialize: function (latlng, options) {\r
                L.setOptions(this, options);\r
+               this._latlng = L.latLng(latlng);\r
        },\r
 \r
        onAdd: function (map) {\r
-               this._map = map;\r
+               this._zoomAnimated = this._zoomAnimated && map.options.markerZoomAnimation;\r
 \r
-               if (!this._container) {\r
-                       this._initElements();\r
-                       this._initEvents();\r
+               if (this._zoomAnimated) {\r
+                       map.on('zoomanim', this._animateZoom, this);\r
                }\r
 \r
-               this.projectLatlngs();\r
-               this._updatePath();\r
+               this._initIcon();\r
+               this.update();\r
+       },\r
 \r
-               if (this._container) {\r
-                       this._map._pathRoot.appendChild(this._container);\r
+       onRemove: function (map) {\r
+               if (this.dragging && this.dragging.enabled()) {\r
+                       this.options.draggable = true;\r
+                       this.dragging.removeHooks();\r
                }\r
 \r
-               this.fire('add');\r
+               if (this._zoomAnimated) {\r
+                       map.off('zoomanim', this._animateZoom, this);\r
+               }\r
 \r
-               map.on({\r
-                       'viewreset': this.projectLatlngs,\r
-                       'moveend': this._updatePath\r
-               }, this);\r
+               this._removeIcon();\r
+               this._removeShadow();\r
        },\r
 \r
-       addTo: function (map) {\r
-               map.addLayer(this);\r
-               return this;\r
+       getEvents: function () {\r
+               return {\r
+                       zoom: this.update,\r
+                       viewreset: this.update\r
+               };\r
        },\r
 \r
-       onRemove: function (map) {\r
-               map._pathRoot.removeChild(this._container);\r
-\r
-               // Need to fire remove event before we set _map to null as the event hooks might need the object\r
-               this.fire('remove');\r
-               this._map = null;\r
+       // @method getLatLng: LatLng\r
+       // Returns the current geographical position of the marker.\r
+       getLatLng: function () {\r
+               return this._latlng;\r
+       },\r
 \r
-               if (L.Browser.vml) {\r
-                       this._container = null;\r
-                       this._stroke = null;\r
-                       this._fill = null;\r
-               }\r
+       // @method setLatLng(latlng: LatLng): this\r
+       // Changes the marker position to the given point.\r
+       setLatLng: function (latlng) {\r
+               var oldLatLng = this._latlng;\r
+               this._latlng = L.latLng(latlng);\r
+               this.update();\r
 \r
-               map.off({\r
-                       'viewreset': this.projectLatlngs,\r
-                       'moveend': this._updatePath\r
-               }, this);\r
+               // @event move: Event\r
+               // Fired when the marker is moved via [`setLatLng`](#marker-setlatlng) or by [dragging](#marker-dragging). Old and new coordinates are included in event arguments as `oldLatLng`, `latlng`.\r
+               return this.fire('move', {oldLatLng: oldLatLng, latlng: this._latlng});\r
        },\r
 \r
-       projectLatlngs: function () {\r
-               // do all projection stuff here\r
+       // @method setZIndexOffset(offset: Number): this\r
+       // Changes the [zIndex offset](#marker-zindexoffset) of the marker.\r
+       setZIndexOffset: function (offset) {\r
+               this.options.zIndexOffset = offset;\r
+               return this.update();\r
        },\r
 \r
-       setStyle: function (style) {\r
-               L.setOptions(this, style);\r
-\r
-               if (this._container) {\r
-                       this._updateStyle();\r
-               }\r
+       // @method setIcon(icon: Icon): this\r
+       // Changes the marker icon.\r
+       setIcon: function (icon) {\r
 \r
-               return this;\r
-       },\r
+               this.options.icon = icon;\r
 \r
-       redraw: function () {\r
                if (this._map) {\r
-                       this.projectLatlngs();\r
-                       this._updatePath();\r
+                       this._initIcon();\r
+                       this.update();\r
                }\r
-               return this;\r
-       }\r
-});\r
-\r
-L.Map.include({\r
-       _updatePathViewport: function () {\r
-               var p = L.Path.CLIP_PADDING,\r
-                   size = this.getSize(),\r
-                   panePos = L.DomUtil.getPosition(this._mapPane),\r
-                   min = panePos.multiplyBy(-1)._subtract(size.multiplyBy(p)._round()),\r
-                   max = min.add(size.multiplyBy(1 + p * 2)._round());\r
-\r
-               this._pathViewport = new L.Bounds(min, max);\r
-       }\r
-});\r
-
-
-/*\r
- * Extends L.Path with SVG-specific rendering code.\r
- */\r
-\r
-L.Path.SVG_NS = 'http://www.w3.org/2000/svg';\r
 \r
-L.Browser.svg = !!(document.createElementNS && document.createElementNS(L.Path.SVG_NS, 'svg').createSVGRect);\r
+               if (this._popup) {\r
+                       this.bindPopup(this._popup, this._popup.options);\r
+               }\r
 \r
-L.Path = L.Path.extend({\r
-       statics: {\r
-               SVG: L.Browser.svg\r
+               return this;\r
        },\r
 \r
-       bringToFront: function () {\r
-               var root = this._map._pathRoot,\r
-                   path = this._container;\r
-\r
-               if (path && root.lastChild !== path) {\r
-                       root.appendChild(path);\r
-               }\r
-               return this;\r
+       getElement: function () {\r
+               return this._icon;\r
        },\r
 \r
-       bringToBack: function () {\r
-               var root = this._map._pathRoot,\r
-                   path = this._container,\r
-                   first = root.firstChild;\r
+       update: function () {\r
 \r
-               if (path && first !== path) {\r
-                       root.insertBefore(path, first);\r
+               if (this._icon) {\r
+                       var pos = this._map.latLngToLayerPoint(this._latlng).round();\r
+                       this._setPos(pos);\r
                }\r
+\r
                return this;\r
        },\r
 \r
-       getPathString: function () {\r
-               // form path string here\r
-       },\r
+       _initIcon: function () {\r
+               var options = this.options,\r
+                   classToAdd = 'leaflet-zoom-' + (this._zoomAnimated ? 'animated' : 'hide');\r
 \r
-       _createElement: function (name) {\r
-               return document.createElementNS(L.Path.SVG_NS, name);\r
-       },\r
+               var icon = options.icon.createIcon(this._icon),\r
+                   addIcon = false;\r
 \r
-       _initElements: function () {\r
-               this._map._initPathRoot();\r
-               this._initPath();\r
-               this._initStyle();\r
-       },\r
+               // if we're not reusing the icon, remove the old one and init new one\r
+               if (icon !== this._icon) {\r
+                       if (this._icon) {\r
+                               this._removeIcon();\r
+                       }\r
+                       addIcon = true;\r
 \r
-       _initPath: function () {\r
-               this._container = this._createElement('g');\r
+                       if (options.title) {\r
+                               icon.title = options.title;\r
+                       }\r
+                       if (options.alt) {\r
+                               icon.alt = options.alt;\r
+                       }\r
+               }\r
 \r
-               this._path = this._createElement('path');\r
+               L.DomUtil.addClass(icon, classToAdd);\r
 \r
-               if (this.options.className) {\r
-                       L.DomUtil.addClass(this._path, this.options.className);\r
+               if (options.keyboard) {\r
+                       icon.tabIndex = '0';\r
                }\r
 \r
-               this._container.appendChild(this._path);\r
-       },\r
+               this._icon = icon;\r
 \r
-       _initStyle: function () {\r
-               if (this.options.stroke) {\r
-                       this._path.setAttribute('stroke-linejoin', 'round');\r
-                       this._path.setAttribute('stroke-linecap', 'round');\r
+               if (options.riseOnHover) {\r
+                       this.on({\r
+                               mouseover: this._bringToFront,\r
+                               mouseout: this._resetZIndex\r
+                       });\r
                }\r
-               if (this.options.fill) {\r
-                       this._path.setAttribute('fill-rule', 'evenodd');\r
+\r
+               var newShadow = options.icon.createShadow(this._shadow),\r
+                   addShadow = false;\r
+\r
+               if (newShadow !== this._shadow) {\r
+                       this._removeShadow();\r
+                       addShadow = true;\r
                }\r
-               if (this.options.pointerEvents) {\r
-                       this._path.setAttribute('pointer-events', this.options.pointerEvents);\r
+\r
+               if (newShadow) {\r
+                       L.DomUtil.addClass(newShadow, classToAdd);\r
+                       newShadow.alt = '';\r
                }\r
-               if (!this.options.clickable && !this.options.pointerEvents) {\r
-                       this._path.setAttribute('pointer-events', 'none');\r
+               this._shadow = newShadow;\r
+\r
+\r
+               if (options.opacity < 1) {\r
+                       this._updateOpacity();\r
                }\r
-               this._updateStyle();\r
-       },\r
 \r
-       _updateStyle: function () {\r
-               if (this.options.stroke) {\r
-                       this._path.setAttribute('stroke', this.options.color);\r
-                       this._path.setAttribute('stroke-opacity', this.options.opacity);\r
-                       this._path.setAttribute('stroke-width', this.options.weight);\r
-                       if (this.options.dashArray) {\r
-                               this._path.setAttribute('stroke-dasharray', this.options.dashArray);\r
-                       } else {\r
-                               this._path.removeAttribute('stroke-dasharray');\r
-                       }\r
-                       if (this.options.lineCap) {\r
-                               this._path.setAttribute('stroke-linecap', this.options.lineCap);\r
-                       }\r
-                       if (this.options.lineJoin) {\r
-                               this._path.setAttribute('stroke-linejoin', this.options.lineJoin);\r
-                       }\r
-               } else {\r
-                       this._path.setAttribute('stroke', 'none');\r
+\r
+               if (addIcon) {\r
+                       this.getPane().appendChild(this._icon);\r
                }\r
-               if (this.options.fill) {\r
-                       this._path.setAttribute('fill', this.options.fillColor || this.options.color);\r
-                       this._path.setAttribute('fill-opacity', this.options.fillOpacity);\r
-               } else {\r
-                       this._path.setAttribute('fill', 'none');\r
+               this._initInteraction();\r
+               if (newShadow && addShadow) {\r
+                       this.getPane('shadowPane').appendChild(this._shadow);\r
                }\r
        },\r
 \r
-       _updatePath: function () {\r
-               var str = this.getPathString();\r
-               if (!str) {\r
-                       // fix webkit empty string parsing bug\r
-                       str = 'M0 0';\r
+       _removeIcon: function () {\r
+               if (this.options.riseOnHover) {\r
+                       this.off({\r
+                               mouseover: this._bringToFront,\r
+                               mouseout: this._resetZIndex\r
+                       });\r
                }\r
-               this._path.setAttribute('d', str);\r
-       },\r
 \r
-       // TODO remove duplication with L.Map\r
-       _initEvents: function () {\r
-               if (this.options.clickable) {\r
-                       if (L.Browser.svg || !L.Browser.vml) {\r
-                               L.DomUtil.addClass(this._path, 'leaflet-clickable');\r
-                       }\r
+               L.DomUtil.remove(this._icon);\r
+               this.removeInteractiveTarget(this._icon);\r
 \r
-                       L.DomEvent.on(this._container, 'click', this._onMouseClick, this);\r
+               this._icon = null;\r
+       },\r
 \r
-                       var events = ['dblclick', 'mousedown', 'mouseover',\r
-                                     'mouseout', 'mousemove', 'contextmenu'];\r
-                       for (var i = 0; i < events.length; i++) {\r
-                               L.DomEvent.on(this._container, events[i], this._fireMouseEvent, this);\r
-                       }\r
+       _removeShadow: function () {\r
+               if (this._shadow) {\r
+                       L.DomUtil.remove(this._shadow);\r
                }\r
+               this._shadow = null;\r
        },\r
 \r
-       _onMouseClick: function (e) {\r
-               if (this._map.dragging && this._map.dragging.moved()) { return; }\r
-\r
-               this._fireMouseEvent(e);\r
-       },\r
+       _setPos: function (pos) {\r
+               L.DomUtil.setPosition(this._icon, pos);\r
 \r
-       _fireMouseEvent: function (e) {\r
-               if (!this._map || !this.hasEventListeners(e.type)) { return; }\r
-\r
-               var map = this._map,\r
-                   containerPoint = map.mouseEventToContainerPoint(e),\r
-                   layerPoint = map.containerPointToLayerPoint(containerPoint),\r
-                   latlng = map.layerPointToLatLng(layerPoint);\r
-\r
-               this.fire(e.type, {\r
-                       latlng: latlng,\r
-                       layerPoint: layerPoint,\r
-                       containerPoint: containerPoint,\r
-                       originalEvent: e\r
-               });\r
-\r
-               if (e.type === 'contextmenu') {\r
-                       L.DomEvent.preventDefault(e);\r
-               }\r
-               if (e.type !== 'mousemove') {\r
-                       L.DomEvent.stopPropagation(e);\r
-               }\r
-       }\r
-});\r
-\r
-L.Map.include({\r
-       _initPathRoot: function () {\r
-               if (!this._pathRoot) {\r
-                       this._pathRoot = L.Path.prototype._createElement('svg');\r
-                       this._panes.overlayPane.appendChild(this._pathRoot);\r
-\r
-                       if (this.options.zoomAnimation && L.Browser.any3d) {\r
-                               L.DomUtil.addClass(this._pathRoot, 'leaflet-zoom-animated');\r
-\r
-                               this.on({\r
-                                       'zoomanim': this._animatePathZoom,\r
-                                       'zoomend': this._endPathZoom\r
-                               });\r
-                       } else {\r
-                               L.DomUtil.addClass(this._pathRoot, 'leaflet-zoom-hide');\r
-                       }\r
-\r
-                       this.on('moveend', this._updateSvgViewport);\r
-                       this._updateSvgViewport();\r
+               if (this._shadow) {\r
+                       L.DomUtil.setPosition(this._shadow, pos);\r
                }\r
-       },\r
 \r
-       _animatePathZoom: function (e) {\r
-               var scale = this.getZoomScale(e.zoom),\r
-                   offset = this._getCenterOffset(e.center)._multiplyBy(-scale)._add(this._pathViewport.min);\r
-\r
-               this._pathRoot.style[L.DomUtil.TRANSFORM] =\r
-                       L.DomUtil.getTranslateString(offset) + ' scale(' + scale + ') ';\r
+               this._zIndex = pos.y + this.options.zIndexOffset;\r
 \r
-               this._pathZooming = true;\r
+               this._resetZIndex();\r
        },\r
 \r
-       _endPathZoom: function () {\r
-               this._pathZooming = false;\r
+       _updateZIndex: function (offset) {\r
+               this._icon.style.zIndex = this._zIndex + offset;\r
        },\r
 \r
-       _updateSvgViewport: function () {\r
-\r
-               if (this._pathZooming) {\r
-                       // Do not update SVGs while a zoom animation is going on otherwise the animation will break.\r
-                       // When the zoom animation ends we will be updated again anyway\r
-                       // This fixes the case where you do a momentum move and zoom while the move is still ongoing.\r
-                       return;\r
-               }\r
+       _animateZoom: function (opt) {\r
+               var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round();\r
 \r
-               this._updatePathViewport();\r
+               this._setPos(pos);\r
+       },\r
 \r
-               var vp = this._pathViewport,\r
-                   min = vp.min,\r
-                   max = vp.max,\r
-                   width = max.x - min.x,\r
-                   height = max.y - min.y,\r
-                   root = this._pathRoot,\r
-                   pane = this._panes.overlayPane;\r
+       _initInteraction: function () {\r
 \r
-               // Hack to make flicker on drag end on mobile webkit less irritating\r
-               if (L.Browser.mobileWebkit) {\r
-                       pane.removeChild(root);\r
-               }\r
+               if (!this.options.interactive) { return; }\r
 \r
-               L.DomUtil.setPosition(root, min);\r
-               root.setAttribute('width', width);\r
-               root.setAttribute('height', height);\r
-               root.setAttribute('viewBox', [min.x, min.y, width, height].join(' '));\r
+               L.DomUtil.addClass(this._icon, 'leaflet-interactive');\r
 \r
-               if (L.Browser.mobileWebkit) {\r
-                       pane.appendChild(root);\r
-               }\r
-       }\r
-});\r
-
-
-/*\r
- * Popup extension to L.Path (polylines, polygons, circles), adding popup-related methods.\r
- */\r
+               this.addInteractiveTarget(this._icon);\r
 \r
-L.Path.include({\r
+               if (L.Handler.MarkerDrag) {\r
+                       var draggable = this.options.draggable;\r
+                       if (this.dragging) {\r
+                               draggable = this.dragging.enabled();\r
+                               this.dragging.disable();\r
+                       }\r
 \r
-       bindPopup: function (content, options) {\r
+                       this.dragging = new L.Handler.MarkerDrag(this);\r
 \r
-               if (content instanceof L.Popup) {\r
-                       this._popup = content;\r
-               } else {\r
-                       if (!this._popup || options) {\r
-                               this._popup = new L.Popup(options, this);\r
+                       if (draggable) {\r
+                               this.dragging.enable();\r
                        }\r
-                       this._popup.setContent(content);\r
                }\r
+       },\r
 \r
-               if (!this._popupHandlersAdded) {\r
-                       this\r
-                           .on('click', this._openPopup, this)\r
-                           .on('remove', this.closePopup, this);\r
-\r
-                       this._popupHandlersAdded = true;\r
+       // @method setOpacity(opacity: Number): this\r
+       // Changes the opacity of the marker.\r
+       setOpacity: function (opacity) {\r
+               this.options.opacity = opacity;\r
+               if (this._map) {\r
+                       this._updateOpacity();\r
                }\r
 \r
                return this;\r
        },\r
 \r
-       unbindPopup: function () {\r
-               if (this._popup) {\r
-                       this._popup = null;\r
-                       this\r
-                           .off('click', this._openPopup)\r
-                           .off('remove', this.closePopup);\r
+       _updateOpacity: function () {\r
+               var opacity = this.options.opacity;\r
 \r
-                       this._popupHandlersAdded = false;\r
+               L.DomUtil.setOpacity(this._icon, opacity);\r
+\r
+               if (this._shadow) {\r
+                       L.DomUtil.setOpacity(this._shadow, opacity);\r
                }\r
-               return this;\r
        },\r
 \r
-       openPopup: function (latlng) {\r
-\r
-               if (this._popup) {\r
-                       // open the popup from one of the path's points if not specified\r
-                       latlng = latlng || this._latlng ||\r
-                                this._latlngs[Math.floor(this._latlngs.length / 2)];\r
-\r
-                       this._openPopup({latlng: latlng});\r
-               }\r
+       _bringToFront: function () {\r
+               this._updateZIndex(this.options.riseOffset);\r
+       },\r
 \r
-               return this;\r
+       _resetZIndex: function () {\r
+               this._updateZIndex(0);\r
        },\r
 \r
-       closePopup: function () {\r
-               if (this._popup) {\r
-                       this._popup._close();\r
-               }\r
-               return this;\r
+       _getPopupAnchor: function () {\r
+               return this.options.icon.options.popupAnchor || [0, 0];\r
        },\r
 \r
-       _openPopup: function (e) {\r
-               this._popup.setLatLng(e.latlng);\r
-               this._map.openPopup(this._popup);\r
+       _getTooltipAnchor: function () {\r
+               return this.options.icon.options.tooltipAnchor || [0, 0];\r
        }\r
 });\r
+\r
+\r
+// factory L.marker(latlng: LatLng, options? : Marker options)\r
+\r
+// @factory L.marker(latlng: LatLng, options? : Marker options)\r
+// Instantiates a Marker object given a geographical point and optionally an options object.\r
+L.marker = function (latlng, options) {\r
+       return new L.Marker(latlng, options);\r
+};\r
+
+
+
+/*
+ * @class DivIcon
+ * @aka L.DivIcon
+ * @inherits Icon
+ *
+ * Represents a lightweight icon for markers that uses a simple `<div>`
+ * element instead of an image. Inherits from `Icon` but ignores the `iconUrl` and shadow options.
+ *
+ * @example
+ * ```js
+ * var myIcon = L.divIcon({className: 'my-div-icon'});
+ * // you can set .my-div-icon styles in CSS
+ *
+ * L.marker([50.505, 30.57], {icon: myIcon}).addTo(map);
+ * ```
+ *
+ * By default, it has a 'leaflet-div-icon' CSS class and is styled as a little white square with a shadow.
+ */
+
+L.DivIcon = L.Icon.extend({
+       options: {
+               // @section
+               // @aka DivIcon options
+               iconSize: [12, 12], // also can be set through CSS
+
+               // iconAnchor: (Point),
+               // popupAnchor: (Point),
+
+               // @option html: String = ''
+               // Custom HTML code to put inside the div element, empty by default.
+               html: false,
+
+               // @option bgPos: Point = [0, 0]
+               // Optional relative position of the background, in pixels
+               bgPos: null,
+
+               className: 'leaflet-div-icon'
+       },
+
+       createIcon: function (oldIcon) {
+               var div = (oldIcon && oldIcon.tagName === 'DIV') ? oldIcon : document.createElement('div'),
+                   options = this.options;
+
+               div.innerHTML = options.html !== false ? options.html : '';
+
+               if (options.bgPos) {
+                       var bgPos = L.point(options.bgPos);
+                       div.style.backgroundPosition = (-bgPos.x) + 'px ' + (-bgPos.y) + 'px';
+               }
+               this._setIconStyles(div, 'icon');
+
+               return div;
+       },
+
+       createShadow: function () {
+               return null;
+       }
+});
+
+// @factory L.divIcon(options: DivIcon options)
+// Creates a `DivIcon` instance with the given options.
+L.divIcon = function (options) {
+       return new L.DivIcon(options);
+};
+
 
 
 /*\r
- * Vector rendering for IE6-8 through VML.\r
- * Thanks to Dmitry Baranovsky and his Raphael library for inspiration!\r
+ * @class DivOverlay\r
+ * @inherits Layer\r
+ * @aka L.DivOverlay\r
+ * Base model for L.Popup and L.Tooltip. Inherit from it for custom popup like plugins.\r
  */\r
 \r
-L.Browser.vml = !L.Browser.svg && (function () {\r
-       try {\r
-               var div = document.createElement('div');\r
-               div.innerHTML = '<v:shape adj="1"/>';\r
-\r
-               var shape = div.firstChild;\r
-               shape.style.behavior = 'url(#default#VML)';\r
+// @namespace DivOverlay\r
+L.DivOverlay = L.Layer.extend({\r
 \r
-               return shape && (typeof shape.adj === 'object');\r
+       // @section\r
+       // @aka DivOverlay options\r
+       options: {\r
+               // @option offset: Point = Point(0, 7)\r
+               // The offset of the popup position. Useful to control the anchor\r
+               // of the popup when opening it on some overlays.\r
+               offset: [0, 7],\r
 \r
-       } catch (e) {\r
-               return false;\r
-       }\r
-}());\r
+               // @option className: String = ''\r
+               // A custom CSS class name to assign to the popup.\r
+               className: '',\r
 \r
-L.Path = L.Browser.svg || !L.Browser.vml ? L.Path : L.Path.extend({\r
-       statics: {\r
-               VML: true,\r
-               CLIP_PADDING: 0.02\r
+               // @option pane: String = 'popupPane'\r
+               // `Map pane` where the popup will be added.\r
+               pane: 'popupPane'\r
        },\r
 \r
-       _createElement: (function () {\r
-               try {\r
-                       document.namespaces.add('lvml', 'urn:schemas-microsoft-com:vml');\r
-                       return function (name) {\r
-                               return document.createElement('<lvml:' + name + ' class="lvml">');\r
-                       };\r
-               } catch (e) {\r
-                       return function (name) {\r
-                               return document.createElement(\r
-                                       '<' + name + ' xmlns="urn:schemas-microsoft.com:vml" class="lvml">');\r
-                       };\r
-               }\r
-       }()),\r
+       initialize: function (options, source) {\r
+               L.setOptions(this, options);\r
+\r
+               this._source = source;\r
+       },\r
 \r
-       _initPath: function () {\r
-               var container = this._container = this._createElement('shape');\r
+       onAdd: function (map) {\r
+               this._zoomAnimated = map._zoomAnimated;\r
 \r
-               L.DomUtil.addClass(container, 'leaflet-vml-shape' +\r
-                       (this.options.className ? ' ' + this.options.className : ''));\r
+               if (!this._container) {\r
+                       this._initLayout();\r
+               }\r
 \r
-               if (this.options.clickable) {\r
-                       L.DomUtil.addClass(container, 'leaflet-clickable');\r
+               if (map._fadeAnimated) {\r
+                       L.DomUtil.setOpacity(this._container, 0);\r
                }\r
 \r
-               container.coordsize = '1 1';\r
+               clearTimeout(this._removeTimeout);\r
+               this.getPane().appendChild(this._container);\r
+               this.update();\r
 \r
-               this._path = this._createElement('path');\r
-               container.appendChild(this._path);\r
+               if (map._fadeAnimated) {\r
+                       L.DomUtil.setOpacity(this._container, 1);\r
+               }\r
 \r
-               this._map._pathRoot.appendChild(container);\r
+               this.bringToFront();\r
        },\r
 \r
-       _initStyle: function () {\r
-               this._updateStyle();\r
+       onRemove: function (map) {\r
+               if (map._fadeAnimated) {\r
+                       L.DomUtil.setOpacity(this._container, 0);\r
+                       this._removeTimeout = setTimeout(L.bind(L.DomUtil.remove, L.DomUtil, this._container), 200);\r
+               } else {\r
+                       L.DomUtil.remove(this._container);\r
+               }\r
        },\r
 \r
-       _updateStyle: function () {\r
-               var stroke = this._stroke,\r
-                   fill = this._fill,\r
-                   options = this.options,\r
-                   container = this._container;\r
-\r
-               container.stroked = options.stroke;\r
-               container.filled = options.fill;\r
-\r
-               if (options.stroke) {\r
-                       if (!stroke) {\r
-                               stroke = this._stroke = this._createElement('stroke');\r
-                               stroke.endcap = 'round';\r
-                               container.appendChild(stroke);\r
-                       }\r
-                       stroke.weight = options.weight + 'px';\r
-                       stroke.color = options.color;\r
-                       stroke.opacity = options.opacity;\r
-\r
-                       if (options.dashArray) {\r
-                               stroke.dashStyle = L.Util.isArray(options.dashArray) ?\r
-                                   options.dashArray.join(' ') :\r
-                                   options.dashArray.replace(/( *, *)/g, ' ');\r
-                       } else {\r
-                               stroke.dashStyle = '';\r
-                       }\r
-                       if (options.lineCap) {\r
-                               stroke.endcap = options.lineCap.replace('butt', 'flat');\r
-                       }\r
-                       if (options.lineJoin) {\r
-                               stroke.joinstyle = options.lineJoin;\r
-                       }\r
+       // @namespace Popup\r
+       // @method getLatLng: LatLng\r
+       // Returns the geographical point of popup.\r
+       getLatLng: function () {\r
+               return this._latlng;\r
+       },\r
 \r
-               } else if (stroke) {\r
-                       container.removeChild(stroke);\r
-                       this._stroke = null;\r
+       // @method setLatLng(latlng: LatLng): this\r
+       // Sets the geographical point where the popup will open.\r
+       setLatLng: function (latlng) {\r
+               this._latlng = L.latLng(latlng);\r
+               if (this._map) {\r
+                       this._updatePosition();\r
+                       this._adjustPan();\r
                }\r
+               return this;\r
+       },\r
 \r
-               if (options.fill) {\r
-                       if (!fill) {\r
-                               fill = this._fill = this._createElement('fill');\r
-                               container.appendChild(fill);\r
-                       }\r
-                       fill.color = options.fillColor || options.color;\r
-                       fill.opacity = options.fillOpacity;\r
+       // @method getContent: String|HTMLElement\r
+       // Returns the content of the popup.\r
+       getContent: function () {\r
+               return this._content;\r
+       },\r
 \r
-               } else if (fill) {\r
-                       container.removeChild(fill);\r
-                       this._fill = null;\r
-               }\r
+       // @method setContent(htmlContent: String|HTMLElement|Function): this\r
+       // Sets the HTML content of the popup. If a function is passed the source layer will be passed to the function. The function should return a `String` or `HTMLElement` to be used in the popup.\r
+       setContent: function (content) {\r
+               this._content = content;\r
+               this.update();\r
+               return this;\r
+       },\r
+\r
+       // @method getElement: String|HTMLElement\r
+       // Alias for [getContent()](#popup-getcontent)\r
+       getElement: function () {\r
+               return this._container;\r
        },\r
 \r
-       _updatePath: function () {\r
-               var style = this._container.style;\r
+       // @method update: null\r
+       // Updates the popup content, layout and position. Useful for updating the popup after something inside changed, e.g. image loaded.\r
+       update: function () {\r
+               if (!this._map) { return; }\r
+\r
+               this._container.style.visibility = 'hidden';\r
 \r
-               style.display = 'none';\r
-               this._path.v = this.getPathString() + ' '; // the space fixes IE empty path string bug\r
-               style.display = '';\r
-       }\r
-});\r
+               this._updateContent();\r
+               this._updateLayout();\r
+               this._updatePosition();\r
 \r
-L.Map.include(L.Browser.svg || !L.Browser.vml ? {} : {\r
-       _initPathRoot: function () {\r
-               if (this._pathRoot) { return; }\r
+               this._container.style.visibility = '';\r
 \r
-               var root = this._pathRoot = document.createElement('div');\r
-               root.className = 'leaflet-vml-container';\r
-               this._panes.overlayPane.appendChild(root);\r
+               this._adjustPan();\r
+       },\r
 \r
-               this.on('moveend', this._updatePathViewport);\r
-               this._updatePathViewport();\r
-       }\r
-});\r
-
-
-/*\r
- * Vector rendering for all browsers that support canvas.\r
- */\r
+       getEvents: function () {\r
+               var events = {\r
+                       zoom: this._updatePosition,\r
+                       viewreset: this._updatePosition\r
+               };\r
 \r
-L.Browser.canvas = (function () {\r
-       return !!document.createElement('canvas').getContext;\r
-}());\r
+               if (this._zoomAnimated) {\r
+                       events.zoomanim = this._animateZoom;\r
+               }\r
+               return events;\r
+       },\r
 \r
-L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path : L.Path.extend({\r
-       statics: {\r
-               //CLIP_PADDING: 0.02, // not sure if there's a need to set it to a small value\r
-               CANVAS: true,\r
-               SVG: false\r
+       // @method isOpen: Boolean\r
+       // Returns `true` when the popup is visible on the map.\r
+       isOpen: function () {\r
+               return !!this._map && this._map.hasLayer(this);\r
        },\r
 \r
-       redraw: function () {\r
+       // @method bringToFront: this\r
+       // Brings this popup in front of other popups (in the same map pane).\r
+       bringToFront: function () {\r
                if (this._map) {\r
-                       this.projectLatlngs();\r
-                       this._requestUpdate();\r
+                       L.DomUtil.toFront(this._container);\r
                }\r
                return this;\r
        },\r
 \r
-       setStyle: function (style) {\r
-               L.setOptions(this, style);\r
-\r
+       // @method bringToBack: this\r
+       // Brings this popup to the back of other popups (in the same map pane).\r
+       bringToBack: function () {\r
                if (this._map) {\r
-                       this._updateStyle();\r
-                       this._requestUpdate();\r
+                       L.DomUtil.toBack(this._container);\r
                }\r
                return this;\r
        },\r
 \r
-       onRemove: function (map) {\r
-               map\r
-                   .off('viewreset', this.projectLatlngs, this)\r
-                   .off('moveend', this._updatePath, this);\r
-\r
-               if (this.options.clickable) {\r
-                       this._map.off('click', this._onClick, this);\r
-                       this._map.off('mousemove', this._onMouseMove, this);\r
-               }\r
+       _updateContent: function () {\r
+               if (!this._content) { return; }\r
 \r
-               this._requestUpdate();\r
-               \r
-               this.fire('remove');\r
-               this._map = null;\r
-       },\r
+               var node = this._contentNode;\r
+               var content = (typeof this._content === 'function') ? this._content(this._source || this) : this._content;\r
 \r
-       _requestUpdate: function () {\r
-               if (this._map && !L.Path._updateRequest) {\r
-                       L.Path._updateRequest = L.Util.requestAnimFrame(this._fireMapMoveEnd, this._map);\r
+               if (typeof content === 'string') {\r
+                       node.innerHTML = content;\r
+               } else {\r
+                       while (node.hasChildNodes()) {\r
+                               node.removeChild(node.firstChild);\r
+                       }\r
+                       node.appendChild(content);\r
                }\r
+               this.fire('contentupdate');\r
        },\r
 \r
-       _fireMapMoveEnd: function () {\r
-               L.Path._updateRequest = null;\r
-               this.fire('moveend');\r
-       },\r
-\r
-       _initElements: function () {\r
-               this._map._initPathRoot();\r
-               this._ctx = this._map._canvasCtx;\r
-       },\r
+       _updatePosition: function () {\r
+               if (!this._map) { return; }\r
 \r
-       _updateStyle: function () {\r
-               var options = this.options;\r
+               var pos = this._map.latLngToLayerPoint(this._latlng),\r
+                   offset = L.point(this.options.offset),\r
+                   anchor = this._getAnchor();\r
 \r
-               if (options.stroke) {\r
-                       this._ctx.lineWidth = options.weight;\r
-                       this._ctx.strokeStyle = options.color;\r
-               }\r
-               if (options.fill) {\r
-                       this._ctx.fillStyle = options.fillColor || options.color;\r
+               if (this._zoomAnimated) {\r
+                       L.DomUtil.setPosition(this._container, pos.add(anchor));\r
+               } else {\r
+                       offset = offset.add(pos).add(anchor);\r
                }\r
 \r
-               if (options.lineCap) {\r
-                       this._ctx.lineCap = options.lineCap;\r
-               }\r
-               if (options.lineJoin) {\r
-                       this._ctx.lineJoin = options.lineJoin;\r
-               }\r
+               var bottom = this._containerBottom = -offset.y,\r
+                   left = this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x;\r
+\r
+               // bottom position the popup in case the height of the popup changes (images loading etc)\r
+               this._container.style.bottom = bottom + 'px';\r
+               this._container.style.left = left + 'px';\r
        },\r
 \r
-       _drawPath: function () {\r
-               var i, j, len, len2, point, drawMethod;\r
+       _getAnchor: function () {\r
+               return [0, 0];\r
+       }\r
 \r
-               this._ctx.beginPath();\r
+});\r
+
+
+
+/*\r
+ * @class Popup\r
+ * @inherits DivOverlay\r
+ * @aka L.Popup\r
+ * Used to open popups in certain places of the map. Use [Map.openPopup](#map-openpopup) to\r
+ * open popups while making sure that only one popup is open at one time\r
+ * (recommended for usability), or use [Map.addLayer](#map-addlayer) to open as many as you want.\r
+ *\r
+ * @example\r
+ *\r
+ * If you want to just bind a popup to marker click and then open it, it's really easy:\r
+ *\r
+ * ```js\r
+ * marker.bindPopup(popupContent).openPopup();\r
+ * ```\r
+ * Path overlays like polylines also have a `bindPopup` method.\r
+ * Here's a more complicated way to open a popup on a map:\r
+ *\r
+ * ```js\r
+ * var popup = L.popup()\r
+ *     .setLatLng(latlng)\r
+ *     .setContent('<p>Hello world!<br />This is a nice popup.</p>')\r
+ *     .openOn(map);\r
+ * ```\r
+ */\r
 \r
-               for (i = 0, len = this._parts.length; i < len; i++) {\r
-                       for (j = 0, len2 = this._parts[i].length; j < len2; j++) {\r
-                               point = this._parts[i][j];\r
-                               drawMethod = (j === 0 ? 'move' : 'line') + 'To';\r
 \r
-                               this._ctx[drawMethod](point.x, point.y);\r
-                       }\r
-                       // TODO refactor ugly hack\r
-                       if (this instanceof L.Polygon) {\r
-                               this._ctx.closePath();\r
-                       }\r
-               }\r
-       },\r
+// @namespace Popup\r
+L.Popup = L.DivOverlay.extend({\r
 \r
-       _checkIfEmpty: function () {\r
-               return !this._parts.length;\r
-       },\r
+       // @section\r
+       // @aka Popup options\r
+       options: {\r
+               // @option maxWidth: Number = 300\r
+               // Max width of the popup, in pixels.\r
+               maxWidth: 300,\r
 \r
-       _updatePath: function () {\r
-               if (this._checkIfEmpty()) { return; }\r
+               // @option minWidth: Number = 50\r
+               // Min width of the popup, in pixels.\r
+               minWidth: 50,\r
 \r
-               var ctx = this._ctx,\r
-                   options = this.options;\r
+               // @option maxHeight: Number = null\r
+               // If set, creates a scrollable container of the given height\r
+               // inside a popup if its content exceeds it.\r
+               maxHeight: null,\r
 \r
-               this._drawPath();\r
-               ctx.save();\r
-               this._updateStyle();\r
+               // @option autoPan: Boolean = true\r
+               // Set it to `false` if you don't want the map to do panning animation\r
+               // to fit the opened popup.\r
+               autoPan: true,\r
 \r
-               if (options.fill) {\r
-                       ctx.globalAlpha = options.fillOpacity;\r
-                       ctx.fill(options.fillRule || 'evenodd');\r
-               }\r
+               // @option autoPanPaddingTopLeft: Point = null\r
+               // The margin between the popup and the top left corner of the map\r
+               // view after autopanning was performed.\r
+               autoPanPaddingTopLeft: null,\r
 \r
-               if (options.stroke) {\r
-                       ctx.globalAlpha = options.opacity;\r
-                       ctx.stroke();\r
-               }\r
+               // @option autoPanPaddingBottomRight: Point = null\r
+               // The margin between the popup and the bottom right corner of the map\r
+               // view after autopanning was performed.\r
+               autoPanPaddingBottomRight: null,\r
+\r
+               // @option autoPanPadding: Point = Point(5, 5)\r
+               // Equivalent of setting both top left and bottom right autopan padding to the same value.\r
+               autoPanPadding: [5, 5],\r
+\r
+               // @option keepInView: Boolean = false\r
+               // Set it to `true` if you want to prevent users from panning the popup\r
+               // off of the screen while it is open.\r
+               keepInView: false,\r
+\r
+               // @option closeButton: Boolean = true\r
+               // Controls the presence of a close button in the popup.\r
+               closeButton: true,\r
 \r
-               ctx.restore();\r
+               // @option autoClose: Boolean = true\r
+               // Set it to `false` if you want to override the default behavior of\r
+               // the popup closing when user clicks the map (set globally by\r
+               // the Map's [closePopupOnClick](#map-closepopuponclick) option).\r
+               autoClose: true,\r
 \r
-               // TODO optimization: 1 fill/stroke for all features with equal style instead of 1 for each feature\r
+               // @option className: String = ''\r
+               // A custom CSS class name to assign to the popup.\r
+               className: ''\r
        },\r
 \r
-       _initEvents: function () {\r
-               if (this.options.clickable) {\r
-                       this._map.on('mousemove', this._onMouseMove, this);\r
-                       this._map.on('click dblclick contextmenu', this._fireMouseEvent, this);\r
-               }\r
+       // @namespace Popup\r
+       // @method openOn(map: Map): this\r
+       // Adds the popup to the map and closes the previous one. The same as `map.openPopup(popup)`.\r
+       openOn: function (map) {\r
+               map.openPopup(this);\r
+               return this;\r
        },\r
 \r
-       _fireMouseEvent: function (e) {\r
-               if (this._containsPoint(e.layerPoint)) {\r
-                       this.fire(e.type, e);\r
+       onAdd: function (map) {\r
+               L.DivOverlay.prototype.onAdd.call(this, map);\r
+\r
+               // @namespace Map\r
+               // @section Popup events\r
+               // @event popupopen: PopupEvent\r
+               // Fired when a popup is opened in the map\r
+               map.fire('popupopen', {popup: this});\r
+\r
+               if (this._source) {\r
+                       // @namespace Layer\r
+                       // @section Popup events\r
+                       // @event popupopen: PopupEvent\r
+                       // Fired when a popup bound to this layer is opened\r
+                       this._source.fire('popupopen', {popup: this}, true);\r
+                       // For non-path layers, we toggle the popup when clicking\r
+                       // again the layer, so prevent the map to reopen it.\r
+                       if (!(this._source instanceof L.Path)) {\r
+                               this._source.on('preclick', L.DomEvent.stopPropagation);\r
+                       }\r
                }\r
        },\r
 \r
-       _onMouseMove: function (e) {\r
-               if (!this._map || this._map._animatingZoom) { return; }\r
+       onRemove: function (map) {\r
+               L.DivOverlay.prototype.onRemove.call(this, map);\r
 \r
-               // TODO don't do on each move\r
-               if (this._containsPoint(e.layerPoint)) {\r
-                       this._ctx.canvas.style.cursor = 'pointer';\r
-                       this._mouseInside = true;\r
-                       this.fire('mouseover', e);\r
+               // @namespace Map\r
+               // @section Popup events\r
+               // @event popupclose: PopupEvent\r
+               // Fired when a popup in the map is closed\r
+               map.fire('popupclose', {popup: this});\r
 \r
-               } else if (this._mouseInside) {\r
-                       this._ctx.canvas.style.cursor = '';\r
-                       this._mouseInside = false;\r
-                       this.fire('mouseout', e);\r
+               if (this._source) {\r
+                       // @namespace Layer\r
+                       // @section Popup events\r
+                       // @event popupclose: PopupEvent\r
+                       // Fired when a popup bound to this layer is closed\r
+                       this._source.fire('popupclose', {popup: this}, true);\r
+                       if (!(this._source instanceof L.Path)) {\r
+                               this._source.off('preclick', L.DomEvent.stopPropagation);\r
+                       }\r
                }\r
-       }\r
-});\r
+       },\r
 \r
-L.Map.include((L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? {} : {\r
-       _initPathRoot: function () {\r
-               var root = this._pathRoot,\r
-                   ctx;\r
+       getEvents: function () {\r
+               var events = L.DivOverlay.prototype.getEvents.call(this);\r
 \r
-               if (!root) {\r
-                       root = this._pathRoot = document.createElement('canvas');\r
-                       root.style.position = 'absolute';\r
-                       ctx = this._canvasCtx = root.getContext('2d');\r
+               if ('closeOnClick' in this.options ? this.options.closeOnClick : this._map.options.closePopupOnClick) {\r
+                       events.preclick = this._close;\r
+               }\r
 \r
-                       ctx.lineCap = 'round';\r
-                       ctx.lineJoin = 'round';\r
+               if (this.options.keepInView) {\r
+                       events.moveend = this._adjustPan;\r
+               }\r
 \r
-                       this._panes.overlayPane.appendChild(root);\r
+               return events;\r
+       },\r
 \r
-                       if (this.options.zoomAnimation) {\r
-                               this._pathRoot.className = 'leaflet-zoom-animated';\r
-                               this.on('zoomanim', this._animatePathZoom);\r
-                               this.on('zoomend', this._endPathZoom);\r
-                       }\r
-                       this.on('moveend', this._updateCanvasViewport);\r
-                       this._updateCanvasViewport();\r
+       _close: function () {\r
+               if (this._map) {\r
+                       this._map.closePopup(this);\r
                }\r
        },\r
 \r
-       _updateCanvasViewport: function () {\r
-               // don't redraw while zooming. See _updateSvgViewport for more details\r
-               if (this._pathZooming) { return; }\r
-               this._updatePathViewport();\r
+       _initLayout: function () {\r
+               var prefix = 'leaflet-popup',\r
+                   container = this._container = L.DomUtil.create('div',\r
+                       prefix + ' ' + (this.options.className || '') +\r
+                       ' leaflet-zoom-animated');\r
 \r
-               var vp = this._pathViewport,\r
-                   min = vp.min,\r
-                   size = vp.max.subtract(min),\r
-                   root = this._pathRoot;\r
+               if (this.options.closeButton) {\r
+                       var closeButton = this._closeButton = L.DomUtil.create('a', prefix + '-close-button', container);\r
+                       closeButton.href = '#close';\r
+                       closeButton.innerHTML = '&#215;';\r
 \r
-               //TODO check if this works properly on mobile webkit\r
-               L.DomUtil.setPosition(root, min);\r
-               root.width = size.x;\r
-               root.height = size.y;\r
-               root.getContext('2d').translate(-min.x, -min.y);\r
-       }\r
-});\r
-
-
-/*\r
- * L.LineUtil contains different utility functions for line segments\r
- * and polylines (clipping, simplification, distances, etc.)\r
- */\r
+                       L.DomEvent.on(closeButton, 'click', this._onCloseButtonClick, this);\r
+               }\r
 \r
-/*jshint bitwise:false */ // allow bitwise operations for this file\r
+               var wrapper = this._wrapper = L.DomUtil.create('div', prefix + '-content-wrapper', container);\r
+               this._contentNode = L.DomUtil.create('div', prefix + '-content', wrapper);\r
 \r
-L.LineUtil = {\r
+               L.DomEvent\r
+                       .disableClickPropagation(wrapper)\r
+                       .disableScrollPropagation(this._contentNode)\r
+                       .on(wrapper, 'contextmenu', L.DomEvent.stopPropagation);\r
 \r
-       // Simplify polyline with vertex reduction and Douglas-Peucker simplification.\r
-       // Improves rendering performance dramatically by lessening the number of points to draw.\r
+               this._tipContainer = L.DomUtil.create('div', prefix + '-tip-container', container);\r
+               this._tip = L.DomUtil.create('div', prefix + '-tip', this._tipContainer);\r
+       },\r
 \r
-       simplify: function (/*Point[]*/ points, /*Number*/ tolerance) {\r
-               if (!tolerance || !points.length) {\r
-                       return points.slice();\r
-               }\r
+       _updateLayout: function () {\r
+               var container = this._contentNode,\r
+                   style = container.style;\r
 \r
-               var sqTolerance = tolerance * tolerance;\r
+               style.width = '';\r
+               style.whiteSpace = 'nowrap';\r
 \r
-               // stage 1: vertex reduction\r
-               points = this._reducePoints(points, sqTolerance);\r
+               var width = container.offsetWidth;\r
+               width = Math.min(width, this.options.maxWidth);\r
+               width = Math.max(width, this.options.minWidth);\r
 \r
-               // stage 2: Douglas-Peucker simplification\r
-               points = this._simplifyDP(points, sqTolerance);\r
+               style.width = (width + 1) + 'px';\r
+               style.whiteSpace = '';\r
 \r
-               return points;\r
-       },\r
+               style.height = '';\r
 \r
-       // distance from a point to a segment between two points\r
-       pointToSegmentDistance:  function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2) {\r
-               return Math.sqrt(this._sqClosestPointOnSegment(p, p1, p2, true));\r
+               var height = container.offsetHeight,\r
+                   maxHeight = this.options.maxHeight,\r
+                   scrolledClass = 'leaflet-popup-scrolled';\r
+\r
+               if (maxHeight && height > maxHeight) {\r
+                       style.height = maxHeight + 'px';\r
+                       L.DomUtil.addClass(container, scrolledClass);\r
+               } else {\r
+                       L.DomUtil.removeClass(container, scrolledClass);\r
+               }\r
+\r
+               this._containerWidth = this._container.offsetWidth;\r
        },\r
 \r
-       closestPointOnSegment: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2) {\r
-               return this._sqClosestPointOnSegment(p, p1, p2);\r
+       _animateZoom: function (e) {\r
+               var pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center),\r
+                   anchor = this._getAnchor();\r
+               L.DomUtil.setPosition(this._container, pos.add(anchor));\r
        },\r
 \r
-       // Douglas-Peucker simplification, see http://en.wikipedia.org/wiki/Douglas-Peucker_algorithm\r
-       _simplifyDP: function (points, sqTolerance) {\r
+       _adjustPan: function () {\r
+               if (!this.options.autoPan || (this._map._panAnim && this._map._panAnim._inProgress)) { return; }\r
 \r
-               var len = points.length,\r
-                   ArrayConstructor = typeof Uint8Array !== undefined + '' ? Uint8Array : Array,\r
-                   markers = new ArrayConstructor(len);\r
+               var map = this._map,\r
+                   marginBottom = parseInt(L.DomUtil.getStyle(this._container, 'marginBottom'), 10) || 0,\r
+                   containerHeight = this._container.offsetHeight + marginBottom,\r
+                   containerWidth = this._containerWidth,\r
+                   layerPos = new L.Point(this._containerLeft, -containerHeight - this._containerBottom);\r
 \r
-               markers[0] = markers[len - 1] = 1;\r
+               layerPos._add(L.DomUtil.getPosition(this._container));\r
 \r
-               this._simplifyDPStep(points, markers, sqTolerance, 0, len - 1);\r
+               var containerPos = map.layerPointToContainerPoint(layerPos),\r
+                   padding = L.point(this.options.autoPanPadding),\r
+                   paddingTL = L.point(this.options.autoPanPaddingTopLeft || padding),\r
+                   paddingBR = L.point(this.options.autoPanPaddingBottomRight || padding),\r
+                   size = map.getSize(),\r
+                   dx = 0,\r
+                   dy = 0;\r
 \r
-               var i,\r
-                   newPoints = [];\r
+               if (containerPos.x + containerWidth + paddingBR.x > size.x) { // right\r
+                       dx = containerPos.x + containerWidth - size.x + paddingBR.x;\r
+               }\r
+               if (containerPos.x - dx - paddingTL.x < 0) { // left\r
+                       dx = containerPos.x - paddingTL.x;\r
+               }\r
+               if (containerPos.y + containerHeight + paddingBR.y > size.y) { // bottom\r
+                       dy = containerPos.y + containerHeight - size.y + paddingBR.y;\r
+               }\r
+               if (containerPos.y - dy - paddingTL.y < 0) { // top\r
+                       dy = containerPos.y - paddingTL.y;\r
+               }\r
 \r
-               for (i = 0; i < len; i++) {\r
-                       if (markers[i]) {\r
-                               newPoints.push(points[i]);\r
-                       }\r
+               // @namespace Map\r
+               // @section Popup events\r
+               // @event autopanstart: Event\r
+               // Fired when the map starts autopanning when opening a popup.\r
+               if (dx || dy) {\r
+                       map\r
+                           .fire('autopanstart')\r
+                           .panBy([dx, dy]);\r
                }\r
+       },\r
 \r
-               return newPoints;\r
+       _onCloseButtonClick: function (e) {\r
+               this._close();\r
+               L.DomEvent.stop(e);\r
        },\r
 \r
-       _simplifyDPStep: function (points, markers, sqTolerance, first, last) {\r
+       _getAnchor: function () {\r
+               // Where should we anchor the popup on the source layer?\r
+               return L.point(this._source && this._source._getPopupAnchor ? this._source._getPopupAnchor() : [0, 0]);\r
+       }\r
 \r
-               var maxSqDist = 0,\r
-                   index, i, sqDist;\r
+});\r
 \r
-               for (i = first + 1; i <= last - 1; i++) {\r
-                       sqDist = this._sqClosestPointOnSegment(points[i], points[first], points[last], true);\r
+// @namespace Popup\r
+// @factory L.popup(options?: Popup options, source?: Layer)\r
+// Instantiates a `Popup` object given an optional `options` object that describes its appearance and location and an optional `source` object that is used to tag the popup with a reference to the Layer to which it refers.\r
+L.popup = function (options, source) {\r
+       return new L.Popup(options, source);\r
+};\r
 \r
-                       if (sqDist > maxSqDist) {\r
-                               index = i;\r
-                               maxSqDist = sqDist;\r
-                       }\r
-               }\r
 \r
-               if (maxSqDist > sqTolerance) {\r
-                       markers[index] = 1;\r
+/* @namespace Map\r
+ * @section Interaction Options\r
+ * @option closePopupOnClick: Boolean = true\r
+ * Set it to `false` if you don't want popups to close when user clicks the map.\r
+ */\r
+L.Map.mergeOptions({\r
+       closePopupOnClick: true\r
+});\r
 \r
-                       this._simplifyDPStep(points, markers, sqTolerance, first, index);\r
-                       this._simplifyDPStep(points, markers, sqTolerance, index, last);\r
+\r
+// @namespace Map\r
+// @section Methods for Layers and Controls\r
+L.Map.include({\r
+       // @method openPopup(popup: Popup): this\r
+       // Opens the specified popup while closing the previously opened (to make sure only one is opened at one time for usability).\r
+       // @alternative\r
+       // @method openPopup(content: String|HTMLElement, latlng: LatLng, options?: Popup options): this\r
+       // Creates a popup with the specified content and options and opens it in the given point on a map.\r
+       openPopup: function (popup, latlng, options) {\r
+               if (!(popup instanceof L.Popup)) {\r
+                       popup = new L.Popup(options).setContent(popup);\r
                }\r
-       },\r
 \r
-       // reduce points that are too close to each other to a single point\r
-       _reducePoints: function (points, sqTolerance) {\r
-               var reducedPoints = [points[0]];\r
+               if (latlng) {\r
+                       popup.setLatLng(latlng);\r
+               }\r
 \r
-               for (var i = 1, prev = 0, len = points.length; i < len; i++) {\r
-                       if (this._sqDist(points[i], points[prev]) > sqTolerance) {\r
-                               reducedPoints.push(points[i]);\r
-                               prev = i;\r
-                       }\r
+               if (this.hasLayer(popup)) {\r
+                       return this;\r
                }\r
-               if (prev < len - 1) {\r
-                       reducedPoints.push(points[len - 1]);\r
+\r
+               if (this._popup && this._popup.options.autoClose) {\r
+                       this.closePopup();\r
                }\r
-               return reducedPoints;\r
+\r
+               this._popup = popup;\r
+               return this.addLayer(popup);\r
        },\r
 \r
-       // Cohen-Sutherland line clipping algorithm.\r
-       // Used to avoid rendering parts of a polyline that are not currently visible.\r
+       // @method closePopup(popup?: Popup): this\r
+       // Closes the popup previously opened with [openPopup](#map-openpopup) (or the given one).\r
+       closePopup: function (popup) {\r
+               if (!popup || popup === this._popup) {\r
+                       popup = this._popup;\r
+                       this._popup = null;\r
+               }\r
+               if (popup) {\r
+                       this.removeLayer(popup);\r
+               }\r
+               return this;\r
+       }\r
+});\r
 \r
-       clipSegment: function (a, b, bounds, useLastCode) {\r
-               var codeA = useLastCode ? this._lastCode : this._getBitCode(a, bounds),\r
-                   codeB = this._getBitCode(b, bounds),\r
+/*\r
+ * @namespace Layer\r
+ * @section Popup methods example\r
+ *\r
+ * All layers share a set of methods convenient for binding popups to it.\r
+ *\r
+ * ```js\r
+ * var layer = L.Polygon(latlngs).bindPopup('Hi There!').addTo(map);\r
+ * layer.openPopup();\r
+ * layer.closePopup();\r
+ * ```\r
+ *\r
+ * Popups will also be automatically opened when the layer is clicked on and closed when the layer is removed from the map or another popup is opened.\r
+ */\r
 \r
-                   codeOut, p, newCode;\r
+// @section Popup methods\r
+L.Layer.include({\r
 \r
-               // save 2nd code to avoid calculating it on the next segment\r
-               this._lastCode = codeB;\r
+       // @method bindPopup(content: String|HTMLElement|Function|Popup, options?: Popup options): this\r
+       // Binds a popup to the layer with the passed `content` and sets up the\r
+       // neccessary event listeners. If a `Function` is passed it will receive\r
+       // the layer as the first argument and should return a `String` or `HTMLElement`.\r
+       bindPopup: function (content, options) {\r
 \r
-               while (true) {\r
-                       // if a,b is inside the clip window (trivial accept)\r
-                       if (!(codeA | codeB)) {\r
-                               return [a, b];\r
-                       // if a,b is outside the clip window (trivial reject)\r
-                       } else if (codeA & codeB) {\r
-                               return false;\r
-                       // other cases\r
-                       } else {\r
-                               codeOut = codeA || codeB;\r
-                               p = this._getEdgeIntersection(a, b, codeOut, bounds);\r
-                               newCode = this._getBitCode(p, bounds);\r
-\r
-                               if (codeOut === codeA) {\r
-                                       a = p;\r
-                                       codeA = newCode;\r
-                               } else {\r
-                                       b = p;\r
-                                       codeB = newCode;\r
-                               }\r
+               if (content instanceof L.Popup) {\r
+                       L.setOptions(content, options);\r
+                       this._popup = content;\r
+                       content._source = this;\r
+               } else {\r
+                       if (!this._popup || options) {\r
+                               this._popup = new L.Popup(options, this);\r
                        }\r
+                       this._popup.setContent(content);\r
                }\r
-       },\r
 \r
-       _getEdgeIntersection: function (a, b, code, bounds) {\r
-               var dx = b.x - a.x,\r
-                   dy = b.y - a.y,\r
-                   min = bounds.min,\r
-                   max = bounds.max;\r
+               if (!this._popupHandlersAdded) {\r
+                       this.on({\r
+                               click: this._openPopup,\r
+                               remove: this.closePopup,\r
+                               move: this._movePopup\r
+                       });\r
+                       this._popupHandlersAdded = true;\r
+               }\r
 \r
-               if (code & 8) { // top\r
-                       return new L.Point(a.x + dx * (max.y - a.y) / dy, max.y);\r
-               } else if (code & 4) { // bottom\r
-                       return new L.Point(a.x + dx * (min.y - a.y) / dy, min.y);\r
-               } else if (code & 2) { // right\r
-                       return new L.Point(max.x, a.y + dy * (max.x - a.x) / dx);\r
-               } else if (code & 1) { // left\r
-                       return new L.Point(min.x, a.y + dy * (min.x - a.x) / dx);\r
+               return this;\r
+       },\r
+\r
+       // @method unbindPopup(): this\r
+       // Removes the popup previously bound with `bindPopup`.\r
+       unbindPopup: function () {\r
+               if (this._popup) {\r
+                       this.off({\r
+                               click: this._openPopup,\r
+                               remove: this.closePopup,\r
+                               move: this._movePopup\r
+                       });\r
+                       this._popupHandlersAdded = false;\r
+                       this._popup = null;\r
                }\r
+               return this;\r
        },\r
 \r
-       _getBitCode: function (/*Point*/ p, bounds) {\r
-               var code = 0;\r
+       // @method openPopup(latlng?: LatLng): this\r
+       // Opens the bound popup at the specificed `latlng` or at the default popup anchor if no `latlng` is passed.\r
+       openPopup: function (layer, latlng) {\r
+               if (!(layer instanceof L.Layer)) {\r
+                       latlng = layer;\r
+                       layer = this;\r
+               }\r
 \r
-               if (p.x < bounds.min.x) { // left\r
-                       code |= 1;\r
-               } else if (p.x > bounds.max.x) { // right\r
-                       code |= 2;\r
+               if (layer instanceof L.FeatureGroup) {\r
+                       for (var id in this._layers) {\r
+                               layer = this._layers[id];\r
+                               break;\r
+                       }\r
                }\r
-               if (p.y < bounds.min.y) { // bottom\r
-                       code |= 4;\r
-               } else if (p.y > bounds.max.y) { // top\r
-                       code |= 8;\r
+\r
+               if (!latlng) {\r
+                       latlng = layer.getCenter ? layer.getCenter() : layer.getLatLng();\r
                }\r
 \r
-               return code;\r
-       },\r
-\r
-       // square distance (to avoid unnecessary Math.sqrt calls)\r
-       _sqDist: function (p1, p2) {\r
-               var dx = p2.x - p1.x,\r
-                   dy = p2.y - p1.y;\r
-               return dx * dx + dy * dy;\r
-       },\r
-\r
-       // return closest point on segment or distance to that point\r
-       _sqClosestPointOnSegment: function (p, p1, p2, sqDist) {\r
-               var x = p1.x,\r
-                   y = p1.y,\r
-                   dx = p2.x - x,\r
-                   dy = p2.y - y,\r
-                   dot = dx * dx + dy * dy,\r
-                   t;\r
+               if (this._popup && this._map) {\r
+                       // set popup source to this layer\r
+                       this._popup._source = layer;\r
 \r
-               if (dot > 0) {\r
-                       t = ((p.x - x) * dx + (p.y - y) * dy) / dot;\r
+                       // update the popup (content, layout, ect...)\r
+                       this._popup.update();\r
 \r
-                       if (t > 1) {\r
-                               x = p2.x;\r
-                               y = p2.y;\r
-                       } else if (t > 0) {\r
-                               x += dx * t;\r
-                               y += dy * t;\r
-                       }\r
+                       // open the popup on the map\r
+                       this._map.openPopup(this._popup, latlng);\r
                }\r
 \r
-               dx = p.x - x;\r
-               dy = p.y - y;\r
-\r
-               return sqDist ? dx * dx + dy * dy : new L.Point(x, y);\r
-       }\r
-};\r
-
-
-/*\r
- * L.Polyline is used to display polylines on a map.\r
- */\r
-\r
-L.Polyline = L.Path.extend({\r
-       initialize: function (latlngs, options) {\r
-               L.Path.prototype.initialize.call(this, options);\r
-\r
-               this._latlngs = this._convertLatLngs(latlngs);\r
-       },\r
-\r
-       options: {\r
-               // how much to simplify the polyline on each zoom level\r
-               // more = better performance and smoother look, less = more accurate\r
-               smoothFactor: 1.0,\r
-               noClip: false\r
-       },\r
-\r
-       projectLatlngs: function () {\r
-               this._originalPoints = [];\r
-\r
-               for (var i = 0, len = this._latlngs.length; i < len; i++) {\r
-                       this._originalPoints[i] = this._map.latLngToLayerPoint(this._latlngs[i]);\r
-               }\r
+               return this;\r
        },\r
 \r
-       getPathString: function () {\r
-               for (var i = 0, len = this._parts.length, str = ''; i < len; i++) {\r
-                       str += this._getPathPartStr(this._parts[i]);\r
+       // @method closePopup(): this\r
+       // Closes the popup bound to this layer if it is open.\r
+       closePopup: function () {\r
+               if (this._popup) {\r
+                       this._popup._close();\r
                }\r
-               return str;\r
-       },\r
-\r
-       getLatLngs: function () {\r
-               return this._latlngs;\r
-       },\r
-\r
-       setLatLngs: function (latlngs) {\r
-               this._latlngs = this._convertLatLngs(latlngs);\r
-               return this.redraw();\r
-       },\r
-\r
-       addLatLng: function (latlng) {\r
-               this._latlngs.push(L.latLng(latlng));\r
-               return this.redraw();\r
-       },\r
-\r
-       spliceLatLngs: function () { // (Number index, Number howMany)\r
-               var removed = [].splice.apply(this._latlngs, arguments);\r
-               this._convertLatLngs(this._latlngs, true);\r
-               this.redraw();\r
-               return removed;\r
+               return this;\r
        },\r
 \r
-       closestLayerPoint: function (p) {\r
-               var minDistance = Infinity, parts = this._parts, p1, p2, minPoint = null;\r
-\r
-               for (var j = 0, jLen = parts.length; j < jLen; j++) {\r
-                       var points = parts[j];\r
-                       for (var i = 1, len = points.length; i < len; i++) {\r
-                               p1 = points[i - 1];\r
-                               p2 = points[i];\r
-                               var sqDist = L.LineUtil._sqClosestPointOnSegment(p, p1, p2, true);\r
-                               if (sqDist < minDistance) {\r
-                                       minDistance = sqDist;\r
-                                       minPoint = L.LineUtil._sqClosestPointOnSegment(p, p1, p2);\r
-                               }\r
+       // @method togglePopup(): this\r
+       // Opens or closes the popup bound to this layer depending on its current state.\r
+       togglePopup: function (target) {\r
+               if (this._popup) {\r
+                       if (this._popup._map) {\r
+                               this.closePopup();\r
+                       } else {\r
+                               this.openPopup(target);\r
                        }\r
                }\r
-               if (minPoint) {\r
-                       minPoint.distance = Math.sqrt(minDistance);\r
-               }\r
-               return minPoint;\r
+               return this;\r
        },\r
 \r
-       getBounds: function () {\r
-               return new L.LatLngBounds(this.getLatLngs());\r
+       // @method isPopupOpen(): boolean\r
+       // Returns `true` if the popup bound to this layer is currently open.\r
+       isPopupOpen: function () {\r
+               return (this._popup ? this._popup.isOpen() : false);\r
        },\r
 \r
-       _convertLatLngs: function (latlngs, overwrite) {\r
-               var i, len, target = overwrite ? latlngs : [];\r
-\r
-               for (i = 0, len = latlngs.length; i < len; i++) {\r
-                       if (L.Util.isArray(latlngs[i]) && typeof latlngs[i][0] !== 'number') {\r
-                               return;\r
-                       }\r
-                       target[i] = L.latLng(latlngs[i]);\r
+       // @method setPopupContent(content: String|HTMLElement|Popup): this\r
+       // Sets the content of the popup bound to this layer.\r
+       setPopupContent: function (content) {\r
+               if (this._popup) {\r
+                       this._popup.setContent(content);\r
                }\r
-               return target;\r
+               return this;\r
        },\r
 \r
-       _initEvents: function () {\r
-               L.Path.prototype._initEvents.call(this);\r
+       // @method getPopup(): Popup\r
+       // Returns the popup bound to this layer.\r
+       getPopup: function () {\r
+               return this._popup;\r
        },\r
 \r
-       _getPathPartStr: function (points) {\r
-               var round = L.Path.VML;\r
+       _openPopup: function (e) {\r
+               var layer = e.layer || e.target;\r
 \r
-               for (var j = 0, len2 = points.length, str = '', p; j < len2; j++) {\r
-                       p = points[j];\r
-                       if (round) {\r
-                               p._round();\r
-                       }\r
-                       str += (j ? 'L' : 'M') + p.x + ' ' + p.y;\r
+               if (!this._popup) {\r
+                       return;\r
                }\r
-               return str;\r
-       },\r
-\r
-       _clipPoints: function () {\r
-               var points = this._originalPoints,\r
-                   len = points.length,\r
-                   i, k, segment;\r
 \r
-               if (this.options.noClip) {\r
-                       this._parts = [points];\r
+               if (!this._map) {\r
                        return;\r
                }\r
 \r
-               this._parts = [];\r
-\r
-               var parts = this._parts,\r
-                   vp = this._map._pathViewport,\r
-                   lu = L.LineUtil;\r
-\r
-               for (i = 0, k = 0; i < len - 1; i++) {\r
-                       segment = lu.clipSegment(points[i], points[i + 1], vp, i);\r
-                       if (!segment) {\r
-                               continue;\r
-                       }\r
-\r
-                       parts[k] = parts[k] || [];\r
-                       parts[k].push(segment[0]);\r
+               // prevent map click\r
+               L.DomEvent.stop(e);\r
 \r
-                       // if segment goes out of screen, or it's the last one, it's the end of the line part\r
-                       if ((segment[1] !== points[i + 1]) || (i === len - 2)) {\r
-                               parts[k].push(segment[1]);\r
-                               k++;\r
-                       }\r
+               // if this inherits from Path its a vector and we can just\r
+               // open the popup at the new location\r
+               if (layer instanceof L.Path) {\r
+                       this.openPopup(e.layer || e.target, e.latlng);\r
+                       return;\r
                }\r
-       },\r
-\r
-       // simplify each clipped part of the polyline\r
-       _simplifyPoints: function () {\r
-               var parts = this._parts,\r
-                   lu = L.LineUtil;\r
 \r
-               for (var i = 0, len = parts.length; i < len; i++) {\r
-                       parts[i] = lu.simplify(parts[i], this.options.smoothFactor);\r
+               // otherwise treat it like a marker and figure out\r
+               // if we should toggle it open/closed\r
+               if (this._map.hasLayer(this._popup) && this._popup._source === layer) {\r
+                       this.closePopup();\r
+               } else {\r
+                       this.openPopup(layer, e.latlng);\r
                }\r
        },\r
 \r
-       _updatePath: function () {\r
-               if (!this._map) { return; }\r
-\r
-               this._clipPoints();\r
-               this._simplifyPoints();\r
-\r
-               L.Path.prototype._updatePath.call(this);\r
+       _movePopup: function (e) {\r
+               this._popup.setLatLng(e.latlng);\r
        }\r
 });\r
-\r
-L.polyline = function (latlngs, options) {\r
-       return new L.Polyline(latlngs, options);\r
-};\r
 
 
-/*\r
- * L.PolyUtil contains utility functions for polygons (clipping, etc.).\r
- */\r
-\r
-/*jshint bitwise:false */ // allow bitwise operations here\r
-\r
-L.PolyUtil = {};\r
-\r
-/*\r
- * Sutherland-Hodgeman polygon clipping algorithm.\r
- * Used to avoid rendering parts of a polygon that are not currently visible.\r
- */\r
-L.PolyUtil.clipPolygon = function (points, bounds) {\r
-       var clippedPoints,\r
-           edges = [1, 4, 2, 8],\r
-           i, j, k,\r
-           a, b,\r
-           len, edge, p,\r
-           lu = L.LineUtil;\r
-\r
-       for (i = 0, len = points.length; i < len; i++) {\r
-               points[i]._code = lu._getBitCode(points[i], bounds);\r
-       }\r
-\r
-       // for each edge (left, bottom, right, top)\r
-       for (k = 0; k < 4; k++) {\r
-               edge = edges[k];\r
-               clippedPoints = [];\r
-\r
-               for (i = 0, len = points.length, j = len - 1; i < len; j = i++) {\r
-                       a = points[i];\r
-                       b = points[j];\r
-\r
-                       // if a is inside the clip window\r
-                       if (!(a._code & edge)) {\r
-                               // if b is outside the clip window (a->b goes out of screen)\r
-                               if (b._code & edge) {\r
-                                       p = lu._getEdgeIntersection(b, a, edge, bounds);\r
-                                       p._code = lu._getBitCode(p, bounds);\r
-                                       clippedPoints.push(p);\r
-                               }\r
-                               clippedPoints.push(a);\r
-\r
-                       // else if b is inside the clip window (a->b enters the screen)\r
-                       } else if (!(b._code & edge)) {\r
-                               p = lu._getEdgeIntersection(b, a, edge, bounds);\r
-                               p._code = lu._getBitCode(p, bounds);\r
-                               clippedPoints.push(p);\r
-                       }\r
-               }\r
-               points = clippedPoints;\r
-       }\r
-\r
-       return points;\r
-};\r
 
+/*
+ * @class Tooltip
+ * @inherits DivOverlay
+ * @aka L.Tooltip
+ * Used to display small texts on top of map layers.
+ *
+ * @example
+ *
+ * ```js
+ * marker.bindTooltip("my tooltip text").openTooltip();
+ * ```
+ * Note about tooltip offset. Leaflet takes two options in consideration
+ * for computing tooltip offseting:
+ * - the `offset` Tooltip option: it defaults to [0, 0], and it's specific to one tooltip.
+ *   Add a positive x offset to move the tooltip to the right, and a positive y offset to
+ *   move it to the bottom. Negatives will move to the left and top.
+ * - the `tooltipAnchor` Icon option: this will only be considered for Marker. You
+ *   should adapt this value if you use a custom icon.
+ */
 
-/*\r
- * L.Polygon is used to display polygons on a map.\r
- */\r
-\r
-L.Polygon = L.Polyline.extend({\r
-       options: {\r
-               fill: true\r
-       },\r
-\r
-       initialize: function (latlngs, options) {\r
-               L.Polyline.prototype.initialize.call(this, latlngs, options);\r
-               this._initWithHoles(latlngs);\r
-       },\r
-\r
-       _initWithHoles: function (latlngs) {\r
-               var i, len, hole;\r
-               if (latlngs && L.Util.isArray(latlngs[0]) && (typeof latlngs[0][0] !== 'number')) {\r
-                       this._latlngs = this._convertLatLngs(latlngs[0]);\r
-                       this._holes = latlngs.slice(1);\r
-\r
-                       for (i = 0, len = this._holes.length; i < len; i++) {\r
-                               hole = this._holes[i] = this._convertLatLngs(this._holes[i]);\r
-                               if (hole[0].equals(hole[hole.length - 1])) {\r
-                                       hole.pop();\r
-                               }\r
-                       }\r
-               }\r
-\r
-               // filter out last point if its equal to the first one\r
-               latlngs = this._latlngs;\r
-\r
-               if (latlngs.length >= 2 && latlngs[0].equals(latlngs[latlngs.length - 1])) {\r
-                       latlngs.pop();\r
-               }\r
-       },\r
-\r
-       projectLatlngs: function () {\r
-               L.Polyline.prototype.projectLatlngs.call(this);\r
-\r
-               // project polygon holes points\r
-               // TODO move this logic to Polyline to get rid of duplication\r
-               this._holePoints = [];\r
-\r
-               if (!this._holes) { return; }\r
-\r
-               var i, j, len, len2;\r
-\r
-               for (i = 0, len = this._holes.length; i < len; i++) {\r
-                       this._holePoints[i] = [];\r
-\r
-                       for (j = 0, len2 = this._holes[i].length; j < len2; j++) {\r
-                               this._holePoints[i][j] = this._map.latLngToLayerPoint(this._holes[i][j]);\r
-                       }\r
-               }\r
-       },\r
-\r
-       setLatLngs: function (latlngs) {\r
-               if (latlngs && L.Util.isArray(latlngs[0]) && (typeof latlngs[0][0] !== 'number')) {\r
-                       this._initWithHoles(latlngs);\r
-                       return this.redraw();\r
-               } else {\r
-                       return L.Polyline.prototype.setLatLngs.call(this, latlngs);\r
-               }\r
-       },\r
-\r
-       _clipPoints: function () {\r
-               var points = this._originalPoints,\r
-                   newParts = [];\r
-\r
-               this._parts = [points].concat(this._holePoints);\r
-\r
-               if (this.options.noClip) { return; }\r
-\r
-               for (var i = 0, len = this._parts.length; i < len; i++) {\r
-                       var clipped = L.PolyUtil.clipPolygon(this._parts[i], this._map._pathViewport);\r
-                       if (clipped.length) {\r
-                               newParts.push(clipped);\r
-                       }\r
-               }\r
-\r
-               this._parts = newParts;\r
-       },\r
-\r
-       _getPathPartStr: function (points) {\r
-               var str = L.Polyline.prototype._getPathPartStr.call(this, points);\r
-               return str + (L.Browser.svg ? 'z' : 'x');\r
-       }\r
-});\r
-\r
-L.polygon = function (latlngs, options) {\r
-       return new L.Polygon(latlngs, options);\r
-};\r
 
+// @namespace Tooltip
+L.Tooltip = L.DivOverlay.extend({
 
-/*\r
- * Contains L.MultiPolyline and L.MultiPolygon layers.\r
- */\r
-\r
-(function () {\r
-       function createMulti(Klass) {\r
-\r
-               return L.FeatureGroup.extend({\r
-\r
-                       initialize: function (latlngs, options) {\r
-                               this._layers = {};\r
-                               this._options = options;\r
-                               this.setLatLngs(latlngs);\r
-                       },\r
-\r
-                       setLatLngs: function (latlngs) {\r
-                               var i = 0,\r
-                                   len = latlngs.length;\r
-\r
-                               this.eachLayer(function (layer) {\r
-                                       if (i < len) {\r
-                                               layer.setLatLngs(latlngs[i++]);\r
-                                       } else {\r
-                                               this.removeLayer(layer);\r
-                                       }\r
-                               }, this);\r
-\r
-                               while (i < len) {\r
-                                       this.addLayer(new Klass(latlngs[i++], this._options));\r
-                               }\r
-\r
-                               return this;\r
-                       },\r
-\r
-                       getLatLngs: function () {\r
-                               var latlngs = [];\r
-\r
-                               this.eachLayer(function (layer) {\r
-                                       latlngs.push(layer.getLatLngs());\r
-                               });\r
-\r
-                               return latlngs;\r
-                       }\r
-               });\r
-       }\r
-\r
-       L.MultiPolyline = createMulti(L.Polyline);\r
-       L.MultiPolygon = createMulti(L.Polygon);\r
-\r
-       L.multiPolyline = function (latlngs, options) {\r
-               return new L.MultiPolyline(latlngs, options);\r
-       };\r
-\r
-       L.multiPolygon = function (latlngs, options) {\r
-               return new L.MultiPolygon(latlngs, options);\r
-       };\r
-}());\r
+       // @section
+       // @aka Tooltip options
+       options: {
+               // @option pane: String = 'tooltipPane'
+               // `Map pane` where the tooltip will be added.
+               pane: 'tooltipPane',
+
+               // @option offset: Point = Point(0, 0)
+               // Optional offset of the tooltip position.
+               offset: [0, 0],
+
+               // @option direction: String = 'auto'
+               // Direction where to open the tooltip. Possible values are: `right`, `left`,
+               // `top`, `bottom`, `center`, `auto`.
+               // `auto` will dynamicaly switch between `right` and `left` according to the tooltip
+               // position on the map.
+               direction: 'auto',
+
+               // @option permanent: Boolean = false
+               // Whether to open the tooltip permanently or only on mouseover.
+               permanent: false,
+
+               // @option sticky: Boolean = false
+               // If true, the tooltip will follow the mouse instead of being fixed at the feature center.
+               sticky: false,
+
+               // @option interactive: Boolean = false
+               // If true, the tooltip will listen to the feature events.
+               interactive: false,
+
+               // @option opacity: Number = 0.9
+               // Tooltip container opacity.
+               opacity: 0.9
+       },
 
+       onAdd: function (map) {
+               L.DivOverlay.prototype.onAdd.call(this, map);
+               this.setOpacity(this.options.opacity);
+
+               // @namespace Map
+               // @section Tooltip events
+               // @event tooltipopen: TooltipEvent
+               // Fired when a tooltip is opened in the map.
+               map.fire('tooltipopen', {tooltip: this});
+
+               if (this._source) {
+                       // @namespace Layer
+                       // @section Tooltip events
+                       // @event tooltipopen: TooltipEvent
+                       // Fired when a tooltip bound to this layer is opened.
+                       this._source.fire('tooltipopen', {tooltip: this}, true);
+               }
+       },
 
-/*\r
- * L.Rectangle extends Polygon and creates a rectangle when passed a LatLngBounds object.\r
- */\r
-\r
-L.Rectangle = L.Polygon.extend({\r
-       initialize: function (latLngBounds, options) {\r
-               L.Polygon.prototype.initialize.call(this, this._boundsToLatLngs(latLngBounds), options);\r
-       },\r
-\r
-       setBounds: function (latLngBounds) {\r
-               this.setLatLngs(this._boundsToLatLngs(latLngBounds));\r
-       },\r
-\r
-       _boundsToLatLngs: function (latLngBounds) {\r
-               latLngBounds = L.latLngBounds(latLngBounds);\r
-               return [\r
-                       latLngBounds.getSouthWest(),\r
-                       latLngBounds.getNorthWest(),\r
-                       latLngBounds.getNorthEast(),\r
-                       latLngBounds.getSouthEast()\r
-               ];\r
-       }\r
-});\r
-\r
-L.rectangle = function (latLngBounds, options) {\r
-       return new L.Rectangle(latLngBounds, options);\r
-};\r
+       onRemove: function (map) {
+               L.DivOverlay.prototype.onRemove.call(this, map);
+
+               // @namespace Map
+               // @section Tooltip events
+               // @event tooltipclose: TooltipEvent
+               // Fired when a tooltip in the map is closed.
+               map.fire('tooltipclose', {tooltip: this});
+
+               if (this._source) {
+                       // @namespace Layer
+                       // @section Tooltip events
+                       // @event tooltipclose: TooltipEvent
+                       // Fired when a tooltip bound to this layer is closed.
+                       this._source.fire('tooltipclose', {tooltip: this}, true);
+               }
+       },
 
+       getEvents: function () {
+               var events = L.DivOverlay.prototype.getEvents.call(this);
 
-/*\r
- * L.Circle is a circle overlay (with a certain radius in meters).\r
- */\r
-\r
-L.Circle = L.Path.extend({\r
-       initialize: function (latlng, radius, options) {\r
-               L.Path.prototype.initialize.call(this, options);\r
-\r
-               this._latlng = L.latLng(latlng);\r
-               this._mRadius = radius;\r
-       },\r
-\r
-       options: {\r
-               fill: true\r
-       },\r
-\r
-       setLatLng: function (latlng) {\r
-               this._latlng = L.latLng(latlng);\r
-               return this.redraw();\r
-       },\r
-\r
-       setRadius: function (radius) {\r
-               this._mRadius = radius;\r
-               return this.redraw();\r
-       },\r
-\r
-       projectLatlngs: function () {\r
-               var lngRadius = this._getLngRadius(),\r
-                   latlng = this._latlng,\r
-                   pointLeft = this._map.latLngToLayerPoint([latlng.lat, latlng.lng - lngRadius]);\r
-\r
-               this._point = this._map.latLngToLayerPoint(latlng);\r
-               this._radius = Math.max(this._point.x - pointLeft.x, 1);\r
-       },\r
-\r
-       getBounds: function () {\r
-               var lngRadius = this._getLngRadius(),\r
-                   latRadius = (this._mRadius / 40075017) * 360,\r
-                   latlng = this._latlng;\r
-\r
-               return new L.LatLngBounds(\r
-                       [latlng.lat - latRadius, latlng.lng - lngRadius],\r
-                       [latlng.lat + latRadius, latlng.lng + lngRadius]);\r
-       },\r
+               if (L.Browser.touch && !this.options.permanent) {
+                       events.preclick = this._close;
+               }
+
+               return events;
+       },
+
+       _close: function () {
+               if (this._map) {
+                       this._map.closeTooltip(this);
+               }
+       },
+
+       _initLayout: function () {
+               var prefix = 'leaflet-tooltip',
+                   className = prefix + ' ' + (this.options.className || '') + ' leaflet-zoom-' + (this._zoomAnimated ? 'animated' : 'hide');
+
+               this._contentNode = this._container = L.DomUtil.create('div', className);
+       },
+
+       _updateLayout: function () {},
+
+       _adjustPan: function () {},
+
+       _setPosition: function (pos) {
+               var map = this._map,
+                   container = this._container,
+                   centerPoint = map.latLngToContainerPoint(map.getCenter()),
+                   tooltipPoint = map.layerPointToContainerPoint(pos),
+                   direction = this.options.direction,
+                   tooltipWidth = container.offsetWidth,
+                   tooltipHeight = container.offsetHeight,
+                   offset = L.point(this.options.offset),
+                   anchor = this._getAnchor();
+
+               if (direction === 'top') {
+                       pos = pos.add(L.point(-tooltipWidth / 2 + offset.x, -tooltipHeight + offset.y + anchor.y, true));
+               } else if (direction === 'bottom') {
+                       pos = pos.subtract(L.point(tooltipWidth / 2 - offset.x, -offset.y, true));
+               } else if (direction === 'center') {
+                       pos = pos.subtract(L.point(tooltipWidth / 2 + offset.x, tooltipHeight / 2 - anchor.y + offset.y, true));
+               } else if (direction === 'right' || direction === 'auto' && tooltipPoint.x < centerPoint.x) {
+                       direction = 'right';
+                       pos = pos.add(L.point(offset.x + anchor.x, anchor.y - tooltipHeight / 2 + offset.y, true));
+               } else {
+                       direction = 'left';
+                       pos = pos.subtract(L.point(tooltipWidth + anchor.x - offset.x, tooltipHeight / 2 - anchor.y - offset.y, true));
+               }
+
+               L.DomUtil.removeClass(container, 'leaflet-tooltip-right');
+               L.DomUtil.removeClass(container, 'leaflet-tooltip-left');
+               L.DomUtil.removeClass(container, 'leaflet-tooltip-top');
+               L.DomUtil.removeClass(container, 'leaflet-tooltip-bottom');
+               L.DomUtil.addClass(container, 'leaflet-tooltip-' + direction);
+               L.DomUtil.setPosition(container, pos);
+       },
+
+       _updatePosition: function () {
+               var pos = this._map.latLngToLayerPoint(this._latlng);
+               this._setPosition(pos);
+       },
+
+       setOpacity: function (opacity) {
+               this.options.opacity = opacity;
+
+               if (this._container) {
+                       L.DomUtil.setOpacity(this._container, opacity);
+               }
+       },
+
+       _animateZoom: function (e) {
+               var pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center);
+               this._setPosition(pos);
+       },
+
+       _getAnchor: function () {
+               // Where should we anchor the tooltip on the source layer?
+               return L.point(this._source && this._source._getTooltipAnchor && !this.options.sticky ? this._source._getTooltipAnchor() : [0, 0]);
+       }
+
+});
+
+// @namespace Tooltip
+// @factory L.tooltip(options?: Tooltip options, source?: Layer)
+// Instantiates a Tooltip object given an optional `options` object that describes its appearance and location and an optional `source` object that is used to tag the tooltip with a reference to the Layer to which it refers.
+L.tooltip = function (options, source) {
+       return new L.Tooltip(options, source);
+};
+
+// @namespace Map
+// @section Methods for Layers and Controls
+L.Map.include({
+
+       // @method openTooltip(tooltip: Tooltip): this
+       // Opens the specified tooltip.
+       // @alternative
+       // @method openTooltip(content: String|HTMLElement, latlng: LatLng, options?: Tooltip options): this
+       // Creates a tooltip with the specified content and options and open it.
+       openTooltip: function (tooltip, latlng, options) {
+               if (!(tooltip instanceof L.Tooltip)) {
+                       tooltip = new L.Tooltip(options).setContent(tooltip);
+               }
+
+               if (latlng) {
+                       tooltip.setLatLng(latlng);
+               }
+
+               if (this.hasLayer(tooltip)) {
+                       return this;
+               }
+
+               return this.addLayer(tooltip);
+       },
+
+       // @method closeTooltip(tooltip?: Tooltip): this
+       // Closes the tooltip given as parameter.
+       closeTooltip: function (tooltip) {
+               if (tooltip) {
+                       this.removeLayer(tooltip);
+               }
+               return this;
+       }
+
+});
+
+/*
+ * @namespace Layer
+ * @section Tooltip methods example
+ *
+ * All layers share a set of methods convenient for binding tooltips to it.
+ *
+ * ```js
+ * var layer = L.Polygon(latlngs).bindTooltip('Hi There!').addTo(map);
+ * layer.openTooltip();
+ * layer.closeTooltip();
+ * ```
+ */
+
+// @section Tooltip methods
+L.Layer.include({
+
+       // @method bindTooltip(content: String|HTMLElement|Function|Tooltip, options?: Tooltip options): this
+       // Binds a tooltip to the layer with the passed `content` and sets up the
+       // neccessary event listeners. If a `Function` is passed it will receive
+       // the layer as the first argument and should return a `String` or `HTMLElement`.
+       bindTooltip: function (content, options) {
+
+               if (content instanceof L.Tooltip) {
+                       L.setOptions(content, options);
+                       this._tooltip = content;
+                       content._source = this;
+               } else {
+                       if (!this._tooltip || options) {
+                               this._tooltip = L.tooltip(options, this);
+                       }
+                       this._tooltip.setContent(content);
+
+               }
+
+               this._initTooltipInteractions();
+
+               if (this._tooltip.options.permanent && this._map && this._map.hasLayer(this)) {
+                       this.openTooltip();
+               }
+
+               return this;
+       },
+
+       // @method unbindTooltip(): this
+       // Removes the tooltip previously bound with `bindTooltip`.
+       unbindTooltip: function () {
+               if (this._tooltip) {
+                       this._initTooltipInteractions(true);
+                       this.closeTooltip();
+                       this._tooltip = null;
+               }
+               return this;
+       },
+
+       _initTooltipInteractions: function (remove) {
+               if (!remove && this._tooltipHandlersAdded) { return; }
+               var onOff = remove ? 'off' : 'on',
+                   events = {
+                       remove: this.closeTooltip,
+                       move: this._moveTooltip
+                   };
+               if (!this._tooltip.options.permanent) {
+                       events.mouseover = this._openTooltip;
+                       events.mouseout = this.closeTooltip;
+                       if (this._tooltip.options.sticky) {
+                               events.mousemove = this._moveTooltip;
+                       }
+                       if (L.Browser.touch) {
+                               events.click = this._openTooltip;
+                       }
+               } else {
+                       events.add = this._openTooltip;
+               }
+               this[onOff](events);
+               this._tooltipHandlersAdded = !remove;
+       },
+
+       // @method openTooltip(latlng?: LatLng): this
+       // Opens the bound tooltip at the specificed `latlng` or at the default tooltip anchor if no `latlng` is passed.
+       openTooltip: function (layer, latlng) {
+               if (!(layer instanceof L.Layer)) {
+                       latlng = layer;
+                       layer = this;
+               }
+
+               if (layer instanceof L.FeatureGroup) {
+                       for (var id in this._layers) {
+                               layer = this._layers[id];
+                               break;
+                       }
+               }
+
+               if (!latlng) {
+                       latlng = layer.getCenter ? layer.getCenter() : layer.getLatLng();
+               }
+
+               if (this._tooltip && this._map) {
+
+                       // set tooltip source to this layer
+                       this._tooltip._source = layer;
+
+                       // update the tooltip (content, layout, ect...)
+                       this._tooltip.update();
+
+                       // open the tooltip on the map
+                       this._map.openTooltip(this._tooltip, latlng);
+
+                       // Tooltip container may not be defined if not permanent and never
+                       // opened.
+                       if (this._tooltip.options.interactive && this._tooltip._container) {
+                               L.DomUtil.addClass(this._tooltip._container, 'leaflet-clickable');
+                               this.addInteractiveTarget(this._tooltip._container);
+                       }
+               }
+
+               return this;
+       },
+
+       // @method closeTooltip(): this
+       // Closes the tooltip bound to this layer if it is open.
+       closeTooltip: function () {
+               if (this._tooltip) {
+                       this._tooltip._close();
+                       if (this._tooltip.options.interactive && this._tooltip._container) {
+                               L.DomUtil.removeClass(this._tooltip._container, 'leaflet-clickable');
+                               this.removeInteractiveTarget(this._tooltip._container);
+                       }
+               }
+               return this;
+       },
+
+       // @method toggleTooltip(): this
+       // Opens or closes the tooltip bound to this layer depending on its current state.
+       toggleTooltip: function (target) {
+               if (this._tooltip) {
+                       if (this._tooltip._map) {
+                               this.closeTooltip();
+                       } else {
+                               this.openTooltip(target);
+                       }
+               }
+               return this;
+       },
+
+       // @method isTooltipOpen(): boolean
+       // Returns `true` if the tooltip bound to this layer is currently open.
+       isTooltipOpen: function () {
+               return this._tooltip.isOpen();
+       },
+
+       // @method setTooltipContent(content: String|HTMLElement|Tooltip): this
+       // Sets the content of the tooltip bound to this layer.
+       setTooltipContent: function (content) {
+               if (this._tooltip) {
+                       this._tooltip.setContent(content);
+               }
+               return this;
+       },
+
+       // @method getTooltip(): Tooltip
+       // Returns the tooltip bound to this layer.
+       getTooltip: function () {
+               return this._tooltip;
+       },
+
+       _openTooltip: function (e) {
+               var layer = e.layer || e.target;
+
+               if (!this._tooltip || !this._map) {
+                       return;
+               }
+               this.openTooltip(layer, this._tooltip.options.sticky ? e.latlng : undefined);
+       },
+
+       _moveTooltip: function (e) {
+               var latlng = e.latlng, containerPoint, layerPoint;
+               if (this._tooltip.options.sticky && e.originalEvent) {
+                       containerPoint = this._map.mouseEventToContainerPoint(e.originalEvent);
+                       layerPoint = this._map.containerPointToLayerPoint(containerPoint);
+                       latlng = this._map.layerPointToLatLng(layerPoint);
+               }
+               this._tooltip.setLatLng(latlng);
+       }
+});
+
+
+
+/*\r
+ * @class LayerGroup\r
+ * @aka L.LayerGroup\r
+ * @inherits Layer\r
+ *\r
+ * Used to group several layers and handle them as one. If you add it to the map,\r
+ * any layers added or removed from the group will be added/removed on the map as\r
+ * well. Extends `Layer`.\r
+ *\r
+ * @example\r
+ *\r
+ * ```js\r
+ * L.layerGroup([marker1, marker2])\r
+ *     .addLayer(polyline)\r
+ *     .addTo(map);\r
+ * ```\r
+ */\r
 \r
-       getLatLng: function () {\r
-               return this._latlng;\r
-       },\r
+L.LayerGroup = L.Layer.extend({\r
 \r
-       getPathString: function () {\r
-               var p = this._point,\r
-                   r = this._radius;\r
+       initialize: function (layers) {\r
+               this._layers = {};\r
 \r
-               if (this._checkIfEmpty()) {\r
-                       return '';\r
-               }\r
+               var i, len;\r
 \r
-               if (L.Browser.svg) {\r
-                       return 'M' + p.x + ',' + (p.y - r) +\r
-                              'A' + r + ',' + r + ',0,1,1,' +\r
-                              (p.x - 0.1) + ',' + (p.y - r) + ' z';\r
-               } else {\r
-                       p._round();\r
-                       r = Math.round(r);\r
-                       return 'AL ' + p.x + ',' + p.y + ' ' + r + ',' + r + ' 0,' + (65535 * 360);\r
+               if (layers) {\r
+                       for (i = 0, len = layers.length; i < len; i++) {\r
+                               this.addLayer(layers[i]);\r
+                       }\r
                }\r
        },\r
 \r
-       getRadius: function () {\r
-               return this._mRadius;\r
+       // @method addLayer(layer: Layer): this\r
+       // Adds the given layer to the group.\r
+       addLayer: function (layer) {\r
+               var id = this.getLayerId(layer);\r
+\r
+               this._layers[id] = layer;\r
+\r
+               if (this._map) {\r
+                       this._map.addLayer(layer);\r
+               }\r
+\r
+               return this;\r
        },\r
 \r
-       // TODO Earth hardcoded, move into projection code!\r
+       // @method removeLayer(layer: Layer): this\r
+       // Removes the given layer from the group.\r
+       // @alternative\r
+       // @method removeLayer(id: Number): this\r
+       // Removes the layer with the given internal ID from the group.\r
+       removeLayer: function (layer) {\r
+               var id = layer in this._layers ? layer : this.getLayerId(layer);\r
+\r
+               if (this._map && this._layers[id]) {\r
+                       this._map.removeLayer(this._layers[id]);\r
+               }\r
+\r
+               delete this._layers[id];\r
 \r
-       _getLatRadius: function () {\r
-               return (this._mRadius / 40075017) * 360;\r
+               return this;\r
        },\r
 \r
-       _getLngRadius: function () {\r
-               return this._getLatRadius() / Math.cos(L.LatLng.DEG_TO_RAD * this._latlng.lat);\r
+       // @method hasLayer(layer: Layer): Boolean\r
+       // Returns `true` if the given layer is currently added to the group.\r
+       hasLayer: function (layer) {\r
+               return !!layer && (layer in this._layers || this.getLayerId(layer) in this._layers);\r
        },\r
 \r
-       _checkIfEmpty: function () {\r
-               if (!this._map) {\r
-                       return false;\r
+       // @method clearLayers(): this\r
+       // Removes all the layers from the group.\r
+       clearLayers: function () {\r
+               for (var i in this._layers) {\r
+                       this.removeLayer(this._layers[i]);\r
                }\r
-               var vp = this._map._pathViewport,\r
-                   r = this._radius,\r
-                   p = this._point;\r
+               return this;\r
+       },\r
 \r
-               return p.x - r > vp.max.x || p.y - r > vp.max.y ||\r
-                      p.x + r < vp.min.x || p.y + r < vp.min.y;\r
-       }\r
-});\r
+       // @method invoke(methodName: String, …): this\r
+       // Calls `methodName` on every layer contained in this group, passing any\r
+       // additional parameters. Has no effect if the layers contained do not\r
+       // implement `methodName`.\r
+       invoke: function (methodName) {\r
+               var args = Array.prototype.slice.call(arguments, 1),\r
+                   i, layer;\r
 \r
-L.circle = function (latlng, radius, options) {\r
-       return new L.Circle(latlng, radius, options);\r
-};\r
-
-
-/*\r
- * L.CircleMarker is a circle overlay with a permanent pixel radius.\r
- */\r
+               for (i in this._layers) {\r
+                       layer = this._layers[i];\r
 \r
-L.CircleMarker = L.Circle.extend({\r
-       options: {\r
-               radius: 10,\r
-               weight: 2\r
-       },\r
+                       if (layer[methodName]) {\r
+                               layer[methodName].apply(layer, args);\r
+                       }\r
+               }\r
 \r
-       initialize: function (latlng, options) {\r
-               L.Circle.prototype.initialize.call(this, latlng, null, options);\r
-               this._radius = this.options.radius;\r
+               return this;\r
        },\r
 \r
-       projectLatlngs: function () {\r
-               this._point = this._map.latLngToLayerPoint(this._latlng);\r
+       onAdd: function (map) {\r
+               for (var i in this._layers) {\r
+                       map.addLayer(this._layers[i]);\r
+               }\r
        },\r
 \r
-       _updateStyle : function () {\r
-               L.Circle.prototype._updateStyle.call(this);\r
-               this.setRadius(this.options.radius);\r
+       onRemove: function (map) {\r
+               for (var i in this._layers) {\r
+                       map.removeLayer(this._layers[i]);\r
+               }\r
        },\r
 \r
-       setLatLng: function (latlng) {\r
-               L.Circle.prototype.setLatLng.call(this, latlng);\r
-               if (this._popup && this._popup._isOpen) {\r
-                       this._popup.setLatLng(latlng);\r
+       // @method eachLayer(fn: Function, context?: Object): this\r
+       // Iterates over the layers of the group, optionally specifying context of the iterator function.\r
+       // ```js\r
+       // group.eachLayer(function (layer) {\r
+       //      layer.bindPopup('Hello');\r
+       // });\r
+       // ```\r
+       eachLayer: function (method, context) {\r
+               for (var i in this._layers) {\r
+                       method.call(context, this._layers[i]);\r
                }\r
                return this;\r
        },\r
 \r
-       setRadius: function (radius) {\r
-               this.options.radius = this._radius = radius;\r
-               return this.redraw();\r
+       // @method getLayer(id: Number): Layer\r
+       // Returns the layer with the given internal ID.\r
+       getLayer: function (id) {\r
+               return this._layers[id];\r
        },\r
 \r
-       getRadius: function () {\r
-               return this._radius;\r
-       }\r
-});\r
-\r
-L.circleMarker = function (latlng, options) {\r
-       return new L.CircleMarker(latlng, options);\r
-};\r
-
-
-/*\r
- * Extends L.Polyline to be able to manually detect clicks on Canvas-rendered polylines.\r
- */\r
-\r
-L.Polyline.include(!L.Path.CANVAS ? {} : {\r
-       _containsPoint: function (p, closed) {\r
-               var i, j, k, len, len2, dist, part,\r
-                   w = this.options.weight / 2;\r
+       // @method getLayers(): Layer[]\r
+       // Returns an array of all the layers added to the group.\r
+       getLayers: function () {\r
+               var layers = [];\r
 \r
-               if (L.Browser.touch) {\r
-                       w += 10; // polyline click tolerance on touch devices\r
+               for (var i in this._layers) {\r
+                       layers.push(this._layers[i]);\r
                }\r
+               return layers;\r
+       },\r
 \r
-               for (i = 0, len = this._parts.length; i < len; i++) {\r
-                       part = this._parts[i];\r
-                       for (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) {\r
-                               if (!closed && (j === 0)) {\r
-                                       continue;\r
-                               }\r
-\r
-                               dist = L.LineUtil.pointToSegmentDistance(p, part[k], part[j]);\r
+       // @method setZIndex(zIndex: Number): this\r
+       // Calls `setZIndex` on every layer contained in this group, passing the z-index.\r
+       setZIndex: function (zIndex) {\r
+               return this.invoke('setZIndex', zIndex);\r
+       },\r
 \r
-                               if (dist <= w) {\r
-                                       return true;\r
-                               }\r
-                       }\r
-               }\r
-               return false;\r
+       // @method getLayerId(layer: Layer): Number\r
+       // Returns the internal ID for a layer\r
+       getLayerId: function (layer) {\r
+               return L.stamp(layer);\r
        }\r
 });\r
+\r
+\r
+// @factory L.layerGroup(layers: Layer[])\r
+// Create a layer group, optionally given an initial set of layers.\r
+L.layerGroup = function (layers) {\r
+       return new L.LayerGroup(layers);\r
+};\r
+
 
 
 /*\r
- * Extends L.Polygon to be able to manually detect clicks on Canvas-rendered polygons.\r
+ * @class FeatureGroup\r
+ * @aka L.FeatureGroup\r
+ * @inherits LayerGroup\r
+ *\r
+ * Extended `LayerGroup` that makes it easier to do the same thing to all its member layers:\r
+ *  * [`bindPopup`](#layer-bindpopup) binds a popup to all of the layers at once (likewise with [`bindTooltip`](#layer-bindtooltip))\r
+ *  * Events are propagated to the `FeatureGroup`, so if the group has an event\r
+ * handler, it will handle events from any of the layers. This includes mouse events\r
+ * and custom events.\r
+ *  * Has `layeradd` and `layerremove` events\r
+ *\r
+ * @example\r
+ *\r
+ * ```js\r
+ * L.featureGroup([marker1, marker2, polyline])\r
+ *     .bindPopup('Hello world!')\r
+ *     .on('click', function() { alert('Clicked on a member of the group!'); })\r
+ *     .addTo(map);\r
+ * ```\r
  */\r
 \r
-L.Polygon.include(!L.Path.CANVAS ? {} : {\r
-       _containsPoint: function (p) {\r
-               var inside = false,\r
-                   part, p1, p2,\r
-                   i, j, k,\r
-                   len, len2;\r
-\r
-               // TODO optimization: check if within bounds first\r
+L.FeatureGroup = L.LayerGroup.extend({\r
 \r
-               if (L.Polyline.prototype._containsPoint.call(this, p, true)) {\r
-                       // click on polygon border\r
-                       return true;\r
+       addLayer: function (layer) {\r
+               if (this.hasLayer(layer)) {\r
+                       return this;\r
                }\r
 \r
-               // ray casting algorithm for detecting if point is in polygon\r
+               layer.addEventParent(this);\r
 \r
-               for (i = 0, len = this._parts.length; i < len; i++) {\r
-                       part = this._parts[i];\r
+               L.LayerGroup.prototype.addLayer.call(this, layer);\r
 \r
-                       for (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) {\r
-                               p1 = part[j];\r
-                               p2 = part[k];\r
+               // @event layeradd: LayerEvent\r
+               // Fired when a layer is added to this `FeatureGroup`\r
+               return this.fire('layeradd', {layer: layer});\r
+       },\r
 \r
-                               if (((p1.y > p.y) !== (p2.y > p.y)) &&\r
-                                               (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) {\r
-                                       inside = !inside;\r
-                               }\r
-                       }\r
+       removeLayer: function (layer) {\r
+               if (!this.hasLayer(layer)) {\r
+                       return this;\r
+               }\r
+               if (layer in this._layers) {\r
+                       layer = this._layers[layer];\r
                }\r
 \r
-               return inside;\r
-       }\r
-});\r
-
-
-/*\r
- * Extends L.Circle with Canvas-specific code.\r
- */\r
+               layer.removeEventParent(this);\r
 \r
-L.Circle.include(!L.Path.CANVAS ? {} : {\r
-       _drawPath: function () {\r
-               var p = this._point;\r
-               this._ctx.beginPath();\r
-               this._ctx.arc(p.x, p.y, this._radius, 0, Math.PI * 2, false);\r
-       },\r
+               L.LayerGroup.prototype.removeLayer.call(this, layer);\r
 \r
-       _containsPoint: function (p) {\r
-               var center = this._point,\r
-                   w2 = this.options.stroke ? this.options.weight / 2 : 0;\r
+               // @event layerremove: LayerEvent\r
+               // Fired when a layer is removed from this `FeatureGroup`\r
+               return this.fire('layerremove', {layer: layer});\r
+       },\r
 \r
-               return (p.distanceTo(center) <= this._radius + w2);\r
+       // @method setStyle(style: Path options): this\r
+       // Sets the given path options to each layer of the group that has a `setStyle` method.\r
+       setStyle: function (style) {\r
+               return this.invoke('setStyle', style);\r
+       },\r
+\r
+       // @method bringToFront(): this\r
+       // Brings the layer group to the top of all other layers\r
+       bringToFront: function () {\r
+               return this.invoke('bringToFront');\r
+       },\r
+\r
+       // @method bringToBack(): this\r
+       // Brings the layer group to the top of all other layers\r
+       bringToBack: function () {\r
+               return this.invoke('bringToBack');\r
+       },\r
+\r
+       // @method getBounds(): LatLngBounds\r
+       // Returns the LatLngBounds of the Feature Group (created from bounds and coordinates of its children).\r
+       getBounds: function () {\r
+               var bounds = new L.LatLngBounds();\r
+\r
+               for (var id in this._layers) {\r
+                       var layer = this._layers[id];\r
+                       bounds.extend(layer.getBounds ? layer.getBounds() : layer.getLatLng());\r
+               }\r
+               return bounds;\r
        }\r
 });\r
+\r
+// @factory L.featureGroup(layers: Layer[])\r
+// Create a feature group, optionally given an initial set of layers.\r
+L.featureGroup = function (layers) {\r
+       return new L.FeatureGroup(layers);\r
+};\r
+
+
+
+/*
+ * @class Renderer
+ * @inherits Layer
+ * @aka L.Renderer
+ *
+ * Base class for vector renderer implementations (`SVG`, `Canvas`). Handles the
+ * DOM container of the renderer, its bounds, and its zoom animation.
+ *
+ * A `Renderer` works as an implicit layer group for all `Path`s - the renderer
+ * itself can be added or removed to the map. All paths use a renderer, which can
+ * be implicit (the map will decide the type of renderer and use it automatically)
+ * or explicit (using the [`renderer`](#path-renderer) option of the path).
+ *
+ * Do not use this class directly, use `SVG` and `Canvas` instead.
+ *
+ * @event update: Event
+ * Fired when the renderer updates its bounds, center and zoom, for example when
+ * its map has moved
+ */
+
+L.Renderer = L.Layer.extend({
+
+       // @section
+       // @aka Renderer options
+       options: {
+               // @option padding: Number = 0.1
+               // How much to extend the clip area around the map view (relative to its size)
+               // e.g. 0.1 would be 10% of map view in each direction
+               padding: 0.1
+       },
+
+       initialize: function (options) {
+               L.setOptions(this, options);
+               L.stamp(this);
+               this._layers = this._layers || {};
+       },
+
+       onAdd: function () {
+               if (!this._container) {
+                       this._initContainer(); // defined by renderer implementations
+
+                       if (this._zoomAnimated) {
+                               L.DomUtil.addClass(this._container, 'leaflet-zoom-animated');
+                       }
+               }
+
+               this.getPane().appendChild(this._container);
+               this._update();
+               this.on('update', this._updatePaths, this);
+       },
+
+       onRemove: function () {
+               L.DomUtil.remove(this._container);
+               this.off('update', this._updatePaths, this);
+       },
+
+       getEvents: function () {
+               var events = {
+                       viewreset: this._reset,
+                       zoom: this._onZoom,
+                       moveend: this._update,
+                       zoomend: this._onZoomEnd
+               };
+               if (this._zoomAnimated) {
+                       events.zoomanim = this._onAnimZoom;
+               }
+               return events;
+       },
+
+       _onAnimZoom: function (ev) {
+               this._updateTransform(ev.center, ev.zoom);
+       },
+
+       _onZoom: function () {
+               this._updateTransform(this._map.getCenter(), this._map.getZoom());
+       },
+
+       _updateTransform: function (center, zoom) {
+               var scale = this._map.getZoomScale(zoom, this._zoom),
+                   position = L.DomUtil.getPosition(this._container),
+                   viewHalf = this._map.getSize().multiplyBy(0.5 + this.options.padding),
+                   currentCenterPoint = this._map.project(this._center, zoom),
+                   destCenterPoint = this._map.project(center, zoom),
+                   centerOffset = destCenterPoint.subtract(currentCenterPoint),
+
+                   topLeftOffset = viewHalf.multiplyBy(-scale).add(position).add(viewHalf).subtract(centerOffset);
+
+               if (L.Browser.any3d) {
+                       L.DomUtil.setTransform(this._container, topLeftOffset, scale);
+               } else {
+                       L.DomUtil.setPosition(this._container, topLeftOffset);
+               }
+       },
+
+       _reset: function () {
+               this._update();
+               this._updateTransform(this._center, this._zoom);
+
+               for (var id in this._layers) {
+                       this._layers[id]._reset();
+               }
+       },
+
+       _onZoomEnd: function () {
+               for (var id in this._layers) {
+                       this._layers[id]._project();
+               }
+       },
+
+       _updatePaths: function () {
+               for (var id in this._layers) {
+                       this._layers[id]._update();
+               }
+       },
+
+       _update: function () {
+               // Update pixel bounds of renderer container (for positioning/sizing/clipping later)
+               // Subclasses are responsible of firing the 'update' event.
+               var p = this.options.padding,
+                   size = this._map.getSize(),
+                   min = this._map.containerPointToLayerPoint(size.multiplyBy(-p)).round();
+
+               this._bounds = new L.Bounds(min, min.add(size.multiplyBy(1 + p * 2)).round());
+
+               this._center = this._map.getCenter();
+               this._zoom = this._map.getZoom();
+       }
+});
+
+
+L.Map.include({
+       // @namespace Map; @method getRenderer(layer: Path): Renderer
+       // Returns the instance of `Renderer` that should be used to render the given
+       // `Path`. It will ensure that the `renderer` options of the map and paths
+       // are respected, and that the renderers do exist on the map.
+       getRenderer: function (layer) {
+               // @namespace Path; @option renderer: Renderer
+               // Use this specific instance of `Renderer` for this path. Takes
+               // precedence over the map's [default renderer](#map-renderer).
+               var renderer = layer.options.renderer || this._getPaneRenderer(layer.options.pane) || this.options.renderer || this._renderer;
+
+               if (!renderer) {
+                       // @namespace Map; @option preferCanvas: Boolean = false
+                       // Whether `Path`s should be rendered on a `Canvas` renderer.
+                       // By default, all `Path`s are rendered in a `SVG` renderer.
+                       renderer = this._renderer = (this.options.preferCanvas && L.canvas()) || L.svg();
+               }
+
+               if (!this.hasLayer(renderer)) {
+                       this.addLayer(renderer);
+               }
+               return renderer;
+       },
+
+       _getPaneRenderer: function (name) {
+               if (name === 'overlayPane' || name === undefined) {
+                       return false;
+               }
+
+               var renderer = this._paneRenderers[name];
+               if (renderer === undefined) {
+                       renderer = (L.SVG && L.svg({pane: name})) || (L.Canvas && L.canvas({pane: name}));
+                       this._paneRenderers[name] = renderer;
+               }
+               return renderer;
+       }
+});
+
 
 
 /*
- * CircleMarker canvas specific drawing parts.
+ * @class Path
+ * @aka L.Path
+ * @inherits Interactive layer
+ *
+ * An abstract class that contains options and constants shared between vector
+ * overlays (Polygon, Polyline, Circle). Do not use it directly. Extends `Layer`.
  */
 
-L.CircleMarker.include(!L.Path.CANVAS ? {} : {
-       _updateStyle: function () {
-               L.Path.prototype._updateStyle.call(this);
+L.Path = L.Layer.extend({
+
+       // @section
+       // @aka Path options
+       options: {
+               // @option stroke: Boolean = true
+               // Whether to draw stroke along the path. Set it to `false` to disable borders on polygons or circles.
+               stroke: true,
+
+               // @option color: String = '#3388ff'
+               // Stroke color
+               color: '#3388ff',
+
+               // @option weight: Number = 3
+               // Stroke width in pixels
+               weight: 3,
+
+               // @option opacity: Number = 1.0
+               // Stroke opacity
+               opacity: 1,
+
+               // @option lineCap: String= 'round'
+               // A string that defines [shape to be used at the end](https://developer.mozilla.org/docs/Web/SVG/Attribute/stroke-linecap) of the stroke.
+               lineCap: 'round',
+
+               // @option lineJoin: String = 'round'
+               // A string that defines [shape to be used at the corners](https://developer.mozilla.org/docs/Web/SVG/Attribute/stroke-linejoin) of the stroke.
+               lineJoin: 'round',
+
+               // @option dashArray: String = null
+               // A string that defines the stroke [dash pattern](https://developer.mozilla.org/docs/Web/SVG/Attribute/stroke-dasharray). Doesn't work on `Canvas`-powered layers in [some old browsers](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/setLineDash#Browser_compatibility).
+               dashArray: null,
+
+               // @option dashOffset: String = null
+               // A string that defines the [distance into the dash pattern to start the dash](https://developer.mozilla.org/docs/Web/SVG/Attribute/stroke-dashoffset). Doesn't work on `Canvas`-powered layers in [some old browsers](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/setLineDash#Browser_compatibility).
+               dashOffset: null,
+
+               // @option fill: Boolean = depends
+               // Whether to fill the path with color. Set it to `false` to disable filling on polygons or circles.
+               fill: false,
+
+               // @option fillColor: String = *
+               // Fill color. Defaults to the value of the [`color`](#path-color) option
+               fillColor: null,
+
+               // @option fillOpacity: Number = 0.2
+               // Fill opacity.
+               fillOpacity: 0.2,
+
+               // @option fillRule: String = 'evenodd'
+               // A string that defines [how the inside of a shape](https://developer.mozilla.org/docs/Web/SVG/Attribute/fill-rule) is determined.
+               fillRule: 'evenodd',
+
+               // className: '',
+
+               // Option inherited from "Interactive layer" abstract class
+               interactive: true
+       },
+
+       beforeAdd: function (map) {
+               // Renderer is set here because we need to call renderer.getEvents
+               // before this.getEvents.
+               this._renderer = map.getRenderer(this);
+       },
+
+       onAdd: function () {
+               this._renderer._initPath(this);
+               this._reset();
+               this._renderer._addPath(this);
+       },
+
+       onRemove: function () {
+               this._renderer._removePath(this);
+       },
+
+       // @method redraw(): this
+       // Redraws the layer. Sometimes useful after you changed the coordinates that the path uses.
+       redraw: function () {
+               if (this._map) {
+                       this._renderer._updatePath(this);
+               }
+               return this;
+       },
+
+       // @method setStyle(style: Path options): this
+       // Changes the appearance of a Path based on the options in the `Path options` object.
+       setStyle: function (style) {
+               L.setOptions(this, style);
+               if (this._renderer) {
+                       this._renderer._updateStyle(this);
+               }
+               return this;
+       },
+
+       // @method bringToFront(): this
+       // Brings the layer to the top of all path layers.
+       bringToFront: function () {
+               if (this._renderer) {
+                       this._renderer._bringToFront(this);
+               }
+               return this;
+       },
+
+       // @method bringToBack(): this
+       // Brings the layer to the bottom of all path layers.
+       bringToBack: function () {
+               if (this._renderer) {
+                       this._renderer._bringToBack(this);
+               }
+               return this;
+       },
+
+       getElement: function () {
+               return this._path;
+       },
+
+       _reset: function () {
+               // defined in children classes
+               this._project();
+               this._update();
+       },
+
+       _clickTolerance: function () {
+               // used when doing hit detection for Canvas layers
+               return (this.options.stroke ? this.options.weight / 2 : 0) + (L.Browser.touch ? 10 : 0);
        }
 });
 
 
+
 /*\r
- * L.GeoJSON turns any GeoJSON data into a Leaflet layer.\r
+ * @namespace LineUtil\r
+ *\r
+ * Various utility functions for polyine points processing, used by Leaflet internally to make polylines lightning-fast.\r
  */\r
 \r
-L.GeoJSON = L.FeatureGroup.extend({\r
-\r
-       initialize: function (geojson, options) {\r
-               L.setOptions(this, options);\r
-\r
-               this._layers = {};\r
-\r
-               if (geojson) {\r
-                       this.addData(geojson);\r
-               }\r
-       },\r
+L.LineUtil = {\r
 \r
-       addData: function (geojson) {\r
-               var features = L.Util.isArray(geojson) ? geojson : geojson.features,\r
-                   i, len, feature;\r
+       // Simplify polyline with vertex reduction and Douglas-Peucker simplification.\r
+       // Improves rendering performance dramatically by lessening the number of points to draw.\r
 \r
-               if (features) {\r
-                       for (i = 0, len = features.length; i < len; i++) {\r
-                               // Only add this if geometry or geometries are set and not null\r
-                               feature = features[i];\r
-                               if (feature.geometries || feature.geometry || feature.features || feature.coordinates) {\r
-                                       this.addData(features[i]);\r
-                               }\r
-                       }\r
-                       return this;\r
+       // @function simplify(points: Point[], tolerance: Number): Point[]\r
+       // Dramatically reduces the number of points in a polyline while retaining\r
+       // its shape and returns a new array of simplified points, using the\r
+       // [Douglas-Peucker algorithm](http://en.wikipedia.org/wiki/Douglas-Peucker_algorithm).\r
+       // Used for a huge performance boost when processing/displaying Leaflet polylines for\r
+       // each zoom level and also reducing visual noise. tolerance affects the amount of\r
+       // simplification (lesser value means higher quality but slower and with more points).\r
+       // Also released as a separated micro-library [Simplify.js](http://mourner.github.com/simplify-js/).\r
+       simplify: function (points, tolerance) {\r
+               if (!tolerance || !points.length) {\r
+                       return points.slice();\r
                }\r
 \r
-               var options = this.options;\r
-\r
-               if (options.filter && !options.filter(geojson)) { return; }\r
-\r
-               var layer = L.GeoJSON.geometryToLayer(geojson, options.pointToLayer, options.coordsToLatLng, options);\r
-               layer.feature = L.GeoJSON.asFeature(geojson);\r
+               var sqTolerance = tolerance * tolerance;\r
 \r
-               layer.defaultOptions = layer.options;\r
-               this.resetStyle(layer);\r
+               // stage 1: vertex reduction\r
+               points = this._reducePoints(points, sqTolerance);\r
 \r
-               if (options.onEachFeature) {\r
-                       options.onEachFeature(geojson, layer);\r
-               }\r
+               // stage 2: Douglas-Peucker simplification\r
+               points = this._simplifyDP(points, sqTolerance);\r
 \r
-               return this.addLayer(layer);\r
+               return points;\r
        },\r
 \r
-       resetStyle: function (layer) {\r
-               var style = this.options.style;\r
-               if (style) {\r
-                       // reset any custom styles\r
-                       L.Util.extend(layer.options, layer.defaultOptions);\r
-\r
-                       this._setLayerStyle(layer, style);\r
-               }\r
+       // @function pointToSegmentDistance(p: Point, p1: Point, p2: Point): Number\r
+       // Returns the distance between point `p` and segment `p1` to `p2`.\r
+       pointToSegmentDistance:  function (p, p1, p2) {\r
+               return Math.sqrt(this._sqClosestPointOnSegment(p, p1, p2, true));\r
        },\r
 \r
-       setStyle: function (style) {\r
-               this.eachLayer(function (layer) {\r
-                       this._setLayerStyle(layer, style);\r
-               }, this);\r
+       // @function closestPointOnSegment(p: Point, p1: Point, p2: Point): Number\r
+       // Returns the closest point from a point `p` on a segment `p1` to `p2`.\r
+       closestPointOnSegment: function (p, p1, p2) {\r
+               return this._sqClosestPointOnSegment(p, p1, p2);\r
        },\r
 \r
-       _setLayerStyle: function (layer, style) {\r
-               if (typeof style === 'function') {\r
-                       style = style(layer.feature);\r
-               }\r
-               if (layer.setStyle) {\r
-                       layer.setStyle(style);\r
-               }\r
-       }\r
-});\r
-\r
-L.extend(L.GeoJSON, {\r
-       geometryToLayer: function (geojson, pointToLayer, coordsToLatLng, vectorOptions) {\r
-               var geometry = geojson.type === 'Feature' ? geojson.geometry : geojson,\r
-                   coords = geometry.coordinates,\r
-                   layers = [],\r
-                   latlng, latlngs, i, len;\r
+       // Douglas-Peucker simplification, see http://en.wikipedia.org/wiki/Douglas-Peucker_algorithm\r
+       _simplifyDP: function (points, sqTolerance) {\r
 \r
-               coordsToLatLng = coordsToLatLng || this.coordsToLatLng;\r
+               var len = points.length,\r
+                   ArrayConstructor = typeof Uint8Array !== undefined + '' ? Uint8Array : Array,\r
+                   markers = new ArrayConstructor(len);\r
 \r
-               switch (geometry.type) {\r
-               case 'Point':\r
-                       latlng = coordsToLatLng(coords);\r
-                       return pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng);\r
+               markers[0] = markers[len - 1] = 1;\r
 \r
-               case 'MultiPoint':\r
-                       for (i = 0, len = coords.length; i < len; i++) {\r
-                               latlng = coordsToLatLng(coords[i]);\r
-                               layers.push(pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng));\r
-                       }\r
-                       return new L.FeatureGroup(layers);\r
+               this._simplifyDPStep(points, markers, sqTolerance, 0, len - 1);\r
 \r
-               case 'LineString':\r
-                       latlngs = this.coordsToLatLngs(coords, 0, coordsToLatLng);\r
-                       return new L.Polyline(latlngs, vectorOptions);\r
+               var i,\r
+                   newPoints = [];\r
 \r
-               case 'Polygon':\r
-                       if (coords.length === 2 && !coords[1].length) {\r
-                               throw new Error('Invalid GeoJSON object.');\r
+               for (i = 0; i < len; i++) {\r
+                       if (markers[i]) {\r
+                               newPoints.push(points[i]);\r
                        }\r
-                       latlngs = this.coordsToLatLngs(coords, 1, coordsToLatLng);\r
-                       return new L.Polygon(latlngs, vectorOptions);\r
+               }\r
 \r
-               case 'MultiLineString':\r
-                       latlngs = this.coordsToLatLngs(coords, 1, coordsToLatLng);\r
-                       return new L.MultiPolyline(latlngs, vectorOptions);\r
+               return newPoints;\r
+       },\r
 \r
-               case 'MultiPolygon':\r
-                       latlngs = this.coordsToLatLngs(coords, 2, coordsToLatLng);\r
-                       return new L.MultiPolygon(latlngs, vectorOptions);\r
+       _simplifyDPStep: function (points, markers, sqTolerance, first, last) {\r
 \r
-               case 'GeometryCollection':\r
-                       for (i = 0, len = geometry.geometries.length; i < len; i++) {\r
+               var maxSqDist = 0,\r
+                   index, i, sqDist;\r
 \r
-                               layers.push(this.geometryToLayer({\r
-                                       geometry: geometry.geometries[i],\r
-                                       type: 'Feature',\r
-                                       properties: geojson.properties\r
-                               }, pointToLayer, coordsToLatLng, vectorOptions));\r
-                       }\r
-                       return new L.FeatureGroup(layers);\r
+               for (i = first + 1; i <= last - 1; i++) {\r
+                       sqDist = this._sqClosestPointOnSegment(points[i], points[first], points[last], true);\r
 \r
-               default:\r
-                       throw new Error('Invalid GeoJSON object.');\r
+                       if (sqDist > maxSqDist) {\r
+                               index = i;\r
+                               maxSqDist = sqDist;\r
+                       }\r
                }\r
-       },\r
 \r
-       coordsToLatLng: function (coords) { // (Array[, Boolean]) -> LatLng\r
-               return new L.LatLng(coords[1], coords[0], coords[2]);\r
+               if (maxSqDist > sqTolerance) {\r
+                       markers[index] = 1;\r
+\r
+                       this._simplifyDPStep(points, markers, sqTolerance, first, index);\r
+                       this._simplifyDPStep(points, markers, sqTolerance, index, last);\r
+               }\r
        },\r
 \r
-       coordsToLatLngs: function (coords, levelsDeep, coordsToLatLng) { // (Array[, Number, Function]) -> Array\r
-               var latlng, i, len,\r
-                   latlngs = [];\r
+       // reduce points that are too close to each other to a single point\r
+       _reducePoints: function (points, sqTolerance) {\r
+               var reducedPoints = [points[0]];\r
 \r
-               for (i = 0, len = coords.length; i < len; i++) {\r
-                       latlng = levelsDeep ?\r
-                               this.coordsToLatLngs(coords[i], levelsDeep - 1, coordsToLatLng) :\r
-                               (coordsToLatLng || this.coordsToLatLng)(coords[i]);\r
-\r
-                       latlngs.push(latlng);\r
-               }\r
-\r
-               return latlngs;\r
-       },\r
-\r
-       latLngToCoords: function (latlng) {\r
-               var coords = [latlng.lng, latlng.lat];\r
-\r
-               if (latlng.alt !== undefined) {\r
-                       coords.push(latlng.alt);\r
+               for (var i = 1, prev = 0, len = points.length; i < len; i++) {\r
+                       if (this._sqDist(points[i], points[prev]) > sqTolerance) {\r
+                               reducedPoints.push(points[i]);\r
+                               prev = i;\r
+                       }\r
                }\r
-               return coords;\r
-       },\r
-\r
-       latLngsToCoords: function (latLngs) {\r
-               var coords = [];\r
-\r
-               for (var i = 0, len = latLngs.length; i < len; i++) {\r
-                       coords.push(L.GeoJSON.latLngToCoords(latLngs[i]));\r
+               if (prev < len - 1) {\r
+                       reducedPoints.push(points[len - 1]);\r
                }\r
-\r
-               return coords;\r
-       },\r
-\r
-       getFeature: function (layer, newGeometry) {\r
-               return layer.feature ? L.extend({}, layer.feature, {geometry: newGeometry}) : L.GeoJSON.asFeature(newGeometry);\r
+               return reducedPoints;\r
        },\r
 \r
-       asFeature: function (geoJSON) {\r
-               if (geoJSON.type === 'Feature') {\r
-                       return geoJSON;\r
-               }\r
-\r
-               return {\r
-                       type: 'Feature',\r
-                       properties: {},\r
-                       geometry: geoJSON\r
-               };\r
-       }\r
-});\r
-\r
-var PointToGeoJSON = {\r
-       toGeoJSON: function () {\r
-               return L.GeoJSON.getFeature(this, {\r
-                       type: 'Point',\r
-                       coordinates: L.GeoJSON.latLngToCoords(this.getLatLng())\r
-               });\r
-       }\r
-};\r
-\r
-L.Marker.include(PointToGeoJSON);\r
-L.Circle.include(PointToGeoJSON);\r
-L.CircleMarker.include(PointToGeoJSON);\r
-\r
-L.Polyline.include({\r
-       toGeoJSON: function () {\r
-               return L.GeoJSON.getFeature(this, {\r
-                       type: 'LineString',\r
-                       coordinates: L.GeoJSON.latLngsToCoords(this.getLatLngs())\r
-               });\r
-       }\r
-});\r
-\r
-L.Polygon.include({\r
-       toGeoJSON: function () {\r
-               var coords = [L.GeoJSON.latLngsToCoords(this.getLatLngs())],\r
-                   i, len, hole;\r
-\r
-               coords[0].push(coords[0][0]);\r
-\r
-               if (this._holes) {\r
-                       for (i = 0, len = this._holes.length; i < len; i++) {\r
-                               hole = L.GeoJSON.latLngsToCoords(this._holes[i]);\r
-                               hole.push(hole[0]);\r
-                               coords.push(hole);\r
-                       }\r
-               }\r
-\r
-               return L.GeoJSON.getFeature(this, {\r
-                       type: 'Polygon',\r
-                       coordinates: coords\r
-               });\r
-       }\r
-});\r
-\r
-(function () {\r
-       function multiToGeoJSON(type) {\r
-               return function () {\r
-                       var coords = [];\r
 \r
-                       this.eachLayer(function (layer) {\r
-                               coords.push(layer.toGeoJSON().geometry.coordinates);\r
-                       });\r
-\r
-                       return L.GeoJSON.getFeature(this, {\r
-                               type: type,\r
-                               coordinates: coords\r
-                       });\r
-               };\r
-       }\r
-\r
-       L.MultiPolyline.include({toGeoJSON: multiToGeoJSON('MultiLineString')});\r
-       L.MultiPolygon.include({toGeoJSON: multiToGeoJSON('MultiPolygon')});\r
+       // @function clipSegment(a: Point, b: Point, bounds: Bounds, useLastCode?: Boolean, round?: Boolean): Point[]|Boolean\r
+       // Clips the segment a to b by rectangular bounds with the\r
+       // [Cohen-Sutherland algorithm](https://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm)\r
+       // (modifying the segment points directly!). Used by Leaflet to only show polyline\r
+       // points that are on the screen or near, increasing performance.\r
+       clipSegment: function (a, b, bounds, useLastCode, round) {\r
+               var codeA = useLastCode ? this._lastCode : this._getBitCode(a, bounds),\r
+                   codeB = this._getBitCode(b, bounds),\r
 \r
-       L.LayerGroup.include({\r
-               toGeoJSON: function () {\r
+                   codeOut, p, newCode;\r
 \r
-                       var geometry = this.feature && this.feature.geometry,\r
-                               jsons = [],\r
-                               json;\r
+               // save 2nd code to avoid calculating it on the next segment\r
+               this._lastCode = codeB;\r
 \r
-                       if (geometry && geometry.type === 'MultiPoint') {\r
-                               return multiToGeoJSON('MultiPoint').call(this);\r
+               while (true) {\r
+                       // if a,b is inside the clip window (trivial accept)\r
+                       if (!(codeA | codeB)) {\r
+                               return [a, b];\r
                        }\r
 \r
-                       var isGeometryCollection = geometry && geometry.type === 'GeometryCollection';\r
-\r
-                       this.eachLayer(function (layer) {\r
-                               if (layer.toGeoJSON) {\r
-                                       json = layer.toGeoJSON();\r
-                                       jsons.push(isGeometryCollection ? json.geometry : L.GeoJSON.asFeature(json));\r
-                               }\r
-                       });\r
-\r
-                       if (isGeometryCollection) {\r
-                               return L.GeoJSON.getFeature(this, {\r
-                                       geometries: jsons,\r
-                                       type: 'GeometryCollection'\r
-                               });\r
+                       // if a,b is outside the clip window (trivial reject)\r
+                       if (codeA & codeB) {\r
+                               return false;\r
                        }\r
 \r
-                       return {\r
-                               type: 'FeatureCollection',\r
-                               features: jsons\r
-                       };\r
-               }\r
-       });\r
-}());\r
-\r
-L.geoJson = function (geojson, options) {\r
-       return new L.GeoJSON(geojson, options);\r
-};\r
-
-
-/*\r
- * L.DomEvent contains functions for working with DOM events.\r
- */\r
-\r
-L.DomEvent = {\r
-       /* inspired by John Resig, Dean Edwards and YUI addEvent implementations */\r
-       addListener: function (obj, type, fn, context) { // (HTMLElement, String, Function[, Object])\r
-\r
-               var id = L.stamp(fn),\r
-                   key = '_leaflet_' + type + id,\r
-                   handler, originalHandler, newType;\r
-\r
-               if (obj[key]) { return this; }\r
-\r
-               handler = function (e) {\r
-                       return fn.call(context || obj, e || L.DomEvent._getEvent());\r
-               };\r
-\r
-               if (L.Browser.pointer && type.indexOf('touch') === 0) {\r
-                       return this.addPointerListener(obj, type, handler, id);\r
-               }\r
-               if (L.Browser.touch && (type === 'dblclick') && this.addDoubleTapListener) {\r
-                       this.addDoubleTapListener(obj, handler, id);\r
-               }\r
-\r
-               if ('addEventListener' in obj) {\r
-\r
-                       if (type === 'mousewheel') {\r
-                               obj.addEventListener('DOMMouseScroll', handler, false);\r
-                               obj.addEventListener(type, handler, false);\r
-\r
-                       } else if ((type === 'mouseenter') || (type === 'mouseleave')) {\r
-\r
-                               originalHandler = handler;\r
-                               newType = (type === 'mouseenter' ? 'mouseover' : 'mouseout');\r
-\r
-                               handler = function (e) {\r
-                                       if (!L.DomEvent._checkMouse(obj, e)) { return; }\r
-                                       return originalHandler(e);\r
-                               };\r
-\r
-                               obj.addEventListener(newType, handler, false);\r
-\r
-                       } else if (type === 'click' && L.Browser.android) {\r
-                               originalHandler = handler;\r
-                               handler = function (e) {\r
-                                       return L.DomEvent._filterClick(e, originalHandler);\r
-                               };\r
+                       // other cases\r
+                       codeOut = codeA || codeB;\r
+                       p = this._getEdgeIntersection(a, b, codeOut, bounds, round);\r
+                       newCode = this._getBitCode(p, bounds);\r
 \r
-                               obj.addEventListener(type, handler, false);\r
+                       if (codeOut === codeA) {\r
+                               a = p;\r
+                               codeA = newCode;\r
                        } else {\r
-                               obj.addEventListener(type, handler, false);\r
+                               b = p;\r
+                               codeB = newCode;\r
                        }\r
-\r
-               } else if ('attachEvent' in obj) {\r
-                       obj.attachEvent('on' + type, handler);\r
                }\r
-\r
-               obj[key] = handler;\r
-\r
-               return this;\r
        },\r
 \r
-       removeListener: function (obj, type, fn) {  // (HTMLElement, String, Function)\r
-\r
-               var id = L.stamp(fn),\r
-                   key = '_leaflet_' + type + id,\r
-                   handler = obj[key];\r
-\r
-               if (!handler) { return this; }\r
-\r
-               if (L.Browser.pointer && type.indexOf('touch') === 0) {\r
-                       this.removePointerListener(obj, type, id);\r
-               } else if (L.Browser.touch && (type === 'dblclick') && this.removeDoubleTapListener) {\r
-                       this.removeDoubleTapListener(obj, id);\r
-\r
-               } else if ('removeEventListener' in obj) {\r
-\r
-                       if (type === 'mousewheel') {\r
-                               obj.removeEventListener('DOMMouseScroll', handler, false);\r
-                               obj.removeEventListener(type, handler, false);\r
-\r
-                       } else if ((type === 'mouseenter') || (type === 'mouseleave')) {\r
-                               obj.removeEventListener((type === 'mouseenter' ? 'mouseover' : 'mouseout'), handler, false);\r
-                       } else {\r
-                               obj.removeEventListener(type, handler, false);\r
-                       }\r
-               } else if ('detachEvent' in obj) {\r
-                       obj.detachEvent('on' + type, handler);\r
-               }\r
+       _getEdgeIntersection: function (a, b, code, bounds, round) {\r
+               var dx = b.x - a.x,\r
+                   dy = b.y - a.y,\r
+                   min = bounds.min,\r
+                   max = bounds.max,\r
+                   x, y;\r
 \r
-               obj[key] = null;\r
+               if (code & 8) { // top\r
+                       x = a.x + dx * (max.y - a.y) / dy;\r
+                       y = max.y;\r
 \r
-               return this;\r
-       },\r
+               } else if (code & 4) { // bottom\r
+                       x = a.x + dx * (min.y - a.y) / dy;\r
+                       y = min.y;\r
 \r
-       stopPropagation: function (e) {\r
+               } else if (code & 2) { // right\r
+                       x = max.x;\r
+                       y = a.y + dy * (max.x - a.x) / dx;\r
 \r
-               if (e.stopPropagation) {\r
-                       e.stopPropagation();\r
-               } else {\r
-                       e.cancelBubble = true;\r
+               } else if (code & 1) { // left\r
+                       x = min.x;\r
+                       y = a.y + dy * (min.x - a.x) / dx;\r
                }\r
-               L.DomEvent._skipped(e);\r
-\r
-               return this;\r
-       },\r
-\r
-       disableScrollPropagation: function (el) {\r
-               var stop = L.DomEvent.stopPropagation;\r
 \r
-               return L.DomEvent\r
-                       .on(el, 'mousewheel', stop)\r
-                       .on(el, 'MozMousePixelScroll', stop);\r
+               return new L.Point(x, y, round);\r
        },\r
 \r
-       disableClickPropagation: function (el) {\r
-               var stop = L.DomEvent.stopPropagation;\r
+       _getBitCode: function (p, bounds) {\r
+               var code = 0;\r
 \r
-               for (var i = L.Draggable.START.length - 1; i >= 0; i--) {\r
-                       L.DomEvent.on(el, L.Draggable.START[i], stop);\r
+               if (p.x < bounds.min.x) { // left\r
+                       code |= 1;\r
+               } else if (p.x > bounds.max.x) { // right\r
+                       code |= 2;\r
                }\r
 \r
-               return L.DomEvent\r
-                       .on(el, 'click', L.DomEvent._fakeStop)\r
-                       .on(el, 'dblclick', stop);\r
-       },\r
-\r
-       preventDefault: function (e) {\r
-\r
-               if (e.preventDefault) {\r
-                       e.preventDefault();\r
-               } else {\r
-                       e.returnValue = false;\r
+               if (p.y < bounds.min.y) { // bottom\r
+                       code |= 4;\r
+               } else if (p.y > bounds.max.y) { // top\r
+                       code |= 8;\r
                }\r
-               return this;\r
-       },\r
 \r
-       stop: function (e) {\r
-               return L.DomEvent\r
-                       .preventDefault(e)\r
-                       .stopPropagation(e);\r
+               return code;\r
        },\r
 \r
-       getMousePosition: function (e, container) {\r
-               if (!container) {\r
-                       return new L.Point(e.clientX, e.clientY);\r
-               }\r
-\r
-               var rect = container.getBoundingClientRect();\r
-\r
-               return new L.Point(\r
-                       e.clientX - rect.left - container.clientLeft,\r
-                       e.clientY - rect.top - container.clientTop);\r
+       // square distance (to avoid unnecessary Math.sqrt calls)\r
+       _sqDist: function (p1, p2) {\r
+               var dx = p2.x - p1.x,\r
+                   dy = p2.y - p1.y;\r
+               return dx * dx + dy * dy;\r
        },\r
 \r
-       getWheelDelta: function (e) {\r
+       // return closest point on segment or distance to that point\r
+       _sqClosestPointOnSegment: function (p, p1, p2, sqDist) {\r
+               var x = p1.x,\r
+                   y = p1.y,\r
+                   dx = p2.x - x,\r
+                   dy = p2.y - y,\r
+                   dot = dx * dx + dy * dy,\r
+                   t;\r
 \r
-               var delta = 0;\r
+               if (dot > 0) {\r
+                       t = ((p.x - x) * dx + (p.y - y) * dy) / dot;\r
 \r
-               if (e.wheelDelta) {\r
-                       delta = e.wheelDelta / 120;\r
-               }\r
-               if (e.detail) {\r
-                       delta = -e.detail / 3;\r
+                       if (t > 1) {\r
+                               x = p2.x;\r
+                               y = p2.y;\r
+                       } else if (t > 0) {\r
+                               x += dx * t;\r
+                               y += dy * t;\r
+                       }\r
                }\r
-               return delta;\r
-       },\r
-\r
-       _skipEvents: {},\r
-\r
-       _fakeStop: function (e) {\r
-               // fakes stopPropagation by setting a special event flag, checked/reset with L.DomEvent._skipped(e)\r
-               L.DomEvent._skipEvents[e.type] = true;\r
-       },\r
 \r
-       _skipped: function (e) {\r
-               var skipped = this._skipEvents[e.type];\r
-               // reset when checking, as it's only used in map container and propagates outside of the map\r
-               this._skipEvents[e.type] = false;\r
-               return skipped;\r
-       },\r
+               dx = p.x - x;\r
+               dy = p.y - y;\r
 \r
-       // check if element really left/entered the event target (for mouseenter/mouseleave)\r
-       _checkMouse: function (el, e) {\r
-\r
-               var related = e.relatedTarget;\r
-\r
-               if (!related) { return true; }\r
-\r
-               try {\r
-                       while (related && (related !== el)) {\r
-                               related = related.parentNode;\r
-                       }\r
-               } catch (err) {\r
-                       return false;\r
-               }\r
-               return (related !== el);\r
-       },\r
-\r
-       _getEvent: function () { // evil magic for IE\r
-               /*jshint noarg:false */\r
-               var e = window.event;\r
-               if (!e) {\r
-                       var caller = arguments.callee.caller;\r
-                       while (caller) {\r
-                               e = caller['arguments'][0];\r
-                               if (e && window.Event === e.constructor) {\r
-                                       break;\r
-                               }\r
-                               caller = caller.caller;\r
-                       }\r
-               }\r
-               return e;\r
-       },\r
-\r
-       // this is a horrible workaround for a bug in Android where a single touch triggers two click events\r
-       _filterClick: function (e, handler) {\r
-               var timeStamp = (e.timeStamp || e.originalEvent.timeStamp),\r
-                       elapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);\r
-\r
-               // are they closer together than 500ms yet more than 100ms?\r
-               // Android typically triggers them ~300ms apart while multiple listeners\r
-               // on the same event should be triggered far faster;\r
-               // or check if click is simulated on the element, and if it is, reject any non-simulated events\r
-\r
-               if ((elapsed && elapsed > 100 && elapsed < 500) || (e.target._simulatedClick && !e._simulated)) {\r
-                       L.DomEvent.stop(e);\r
-                       return;\r
-               }\r
-               L.DomEvent._lastClick = timeStamp;\r
-\r
-               return handler(e);\r
+               return sqDist ? dx * dx + dy * dy : new L.Point(x, y);\r
        }\r
 };\r
-\r
-L.DomEvent.on = L.DomEvent.addListener;\r
-L.DomEvent.off = L.DomEvent.removeListener;\r
-
 
-/*\r
- * L.Draggable allows you to add dragging capabilities to any element. Supports mobile devices too.\r
- */\r
-\r
-L.Draggable = L.Class.extend({\r
-       includes: L.Mixin.Events,\r
-\r
-       statics: {\r
-               START: L.Browser.touch ? ['touchstart', 'mousedown'] : ['mousedown'],\r
-               END: {\r
-                       mousedown: 'mouseup',\r
-                       touchstart: 'touchend',\r
-                       pointerdown: 'touchend',\r
-                       MSPointerDown: 'touchend'\r
-               },\r
-               MOVE: {\r
-                       mousedown: 'mousemove',\r
-                       touchstart: 'touchmove',\r
-                       pointerdown: 'touchmove',\r
-                       MSPointerDown: 'touchmove'\r
-               }\r
-       },\r
-\r
-       initialize: function (element, dragStartTarget) {\r
-               this._element = element;\r
-               this._dragStartTarget = dragStartTarget || element;\r
-       },\r
-\r
-       enable: function () {\r
-               if (this._enabled) { return; }\r
-\r
-               for (var i = L.Draggable.START.length - 1; i >= 0; i--) {\r
-                       L.DomEvent.on(this._dragStartTarget, L.Draggable.START[i], this._onDown, this);\r
-               }\r
-\r
-               this._enabled = true;\r
-       },\r
-\r
-       disable: function () {\r
-               if (!this._enabled) { return; }\r
-\r
-               for (var i = L.Draggable.START.length - 1; i >= 0; i--) {\r
-                       L.DomEvent.off(this._dragStartTarget, L.Draggable.START[i], this._onDown, this);\r
-               }\r
-\r
-               this._enabled = false;\r
-               this._moved = false;\r
-       },\r
-\r
-       _onDown: function (e) {\r
-               this._moved = false;\r
-\r
-               if (e.shiftKey || ((e.which !== 1) && (e.button !== 1) && !e.touches)) { return; }\r
-\r
-               L.DomEvent.stopPropagation(e);\r
-\r
-               if (L.Draggable._disabled) { return; }\r
-\r
-               L.DomUtil.disableImageDrag();\r
-               L.DomUtil.disableTextSelection();\r
-\r
-               if (this._moving) { return; }\r
-\r
-               var first = e.touches ? e.touches[0] : e;\r
-\r
-               this._startPoint = new L.Point(first.clientX, first.clientY);\r
-               this._startPos = this._newPos = L.DomUtil.getPosition(this._element);\r
-\r
-               L.DomEvent\r
-                   .on(document, L.Draggable.MOVE[e.type], this._onMove, this)\r
-                   .on(document, L.Draggable.END[e.type], this._onUp, this);\r
-       },\r
-\r
-       _onMove: function (e) {\r
-               if (e.touches && e.touches.length > 1) {\r
-                       this._moved = true;\r
-                       return;\r
-               }\r
-\r
-               var first = (e.touches && e.touches.length === 1 ? e.touches[0] : e),\r
-                   newPoint = new L.Point(first.clientX, first.clientY),\r
-                   offset = newPoint.subtract(this._startPoint);\r
-\r
-               if (!offset.x && !offset.y) { return; }\r
-               if (L.Browser.touch && Math.abs(offset.x) + Math.abs(offset.y) < 3) { return; }\r
-\r
-               L.DomEvent.preventDefault(e);\r
-\r
-               if (!this._moved) {\r
-                       this.fire('dragstart');\r
-\r
-                       this._moved = true;\r
-                       this._startPos = L.DomUtil.getPosition(this._element).subtract(offset);\r
-\r
-                       L.DomUtil.addClass(document.body, 'leaflet-dragging');\r
-                       this._lastTarget = e.target || e.srcElement;\r
-                       L.DomUtil.addClass(this._lastTarget, 'leaflet-drag-target');\r
-               }\r
-\r
-               this._newPos = this._startPos.add(offset);\r
-               this._moving = true;\r
-\r
-               L.Util.cancelAnimFrame(this._animRequest);\r
-               this._animRequest = L.Util.requestAnimFrame(this._updatePosition, this, true, this._dragStartTarget);\r
-       },\r
-\r
-       _updatePosition: function () {\r
-               this.fire('predrag');\r
-               L.DomUtil.setPosition(this._element, this._newPos);\r
-               this.fire('drag');\r
-       },\r
-\r
-       _onUp: function () {\r
-               L.DomUtil.removeClass(document.body, 'leaflet-dragging');\r
-\r
-               if (this._lastTarget) {\r
-                       L.DomUtil.removeClass(this._lastTarget, 'leaflet-drag-target');\r
-                       this._lastTarget = null;\r
-               }\r
-\r
-               for (var i in L.Draggable.MOVE) {\r
-                       L.DomEvent\r
-                           .off(document, L.Draggable.MOVE[i], this._onMove)\r
-                           .off(document, L.Draggable.END[i], this._onUp);\r
-               }\r
-\r
-               L.DomUtil.enableImageDrag();\r
-               L.DomUtil.enableTextSelection();\r
-\r
-               if (this._moved && this._moving) {\r
-                       // ensure drag is not fired after dragend\r
-                       L.Util.cancelAnimFrame(this._animRequest);\r
-\r
-                       this.fire('dragend', {\r
-                               distance: this._newPos.distanceTo(this._startPos)\r
-                       });\r
-               }\r
-\r
-               this._moving = false;\r
-       }\r
-});\r
 
 
 /*
-       L.Handler is a base class for handler classes that are used internally to inject
-       interaction features like dragging to classes like Map and Marker.
-*/
+ * @class Polyline
+ * @aka L.Polyline
+ * @inherits Path
+ *
+ * A class for drawing polyline overlays on a map. Extends `Path`.
+ *
+ * @example
+ *
+ * ```js
+ * // create a red polyline from an array of LatLng points
+ * var latlngs = [
+ *     [45.51, -122.68],
+ *     [37.77, -122.43],
+ *     [34.04, -118.2]
+ * ];
+ *
+ * var polyline = L.polyline(latlngs, {color: 'red'}).addTo(map);
+ *
+ * // zoom the map to the polyline
+ * map.fitBounds(polyline.getBounds());
+ * ```
+ *
+ * You can also pass a multi-dimensional array to represent a `MultiPolyline` shape:
+ *
+ * ```js
+ * // create a red polyline from an array of arrays of LatLng points
+ * var latlngs = [
+ *     [[45.51, -122.68],
+ *      [37.77, -122.43],
+ *      [34.04, -118.2]],
+ *     [[40.78, -73.91],
+ *      [41.83, -87.62],
+ *      [32.76, -96.72]]
+ * ];
+ * ```
+ */
 
-L.Handler = L.Class.extend({
-       initialize: function (map) {
-               this._map = map;
+L.Polyline = L.Path.extend({
+
+       // @section
+       // @aka Polyline options
+       options: {
+               // @option smoothFactor: Number = 1.0
+               // How much to simplify the polyline on each zoom level. More means
+               // better performance and smoother look, and less means more accurate representation.
+               smoothFactor: 1.0,
+
+               // @option noClip: Boolean = false
+               // Disable polyline clipping.
+               noClip: false
        },
 
-       enable: function () {
-               if (this._enabled) { return; }
+       initialize: function (latlngs, options) {
+               L.setOptions(this, options);
+               this._setLatLngs(latlngs);
+       },
 
-               this._enabled = true;
-               this.addHooks();
+       // @method getLatLngs(): LatLng[]
+       // Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.
+       getLatLngs: function () {
+               return this._latlngs;
        },
 
-       disable: function () {
-               if (!this._enabled) { return; }
+       // @method setLatLngs(latlngs: LatLng[]): this
+       // Replaces all the points in the polyline with the given array of geographical points.
+       setLatLngs: function (latlngs) {
+               this._setLatLngs(latlngs);
+               return this.redraw();
+       },
 
-               this._enabled = false;
-               this.removeHooks();
+       // @method isEmpty(): Boolean
+       // Returns `true` if the Polyline has no LatLngs.
+       isEmpty: function () {
+               return !this._latlngs.length;
        },
 
-       enabled: function () {
-               return !!this._enabled;
-       }
-});
+       closestLayerPoint: function (p) {
+               var minDistance = Infinity,
+                   minPoint = null,
+                   closest = L.LineUtil._sqClosestPointOnSegment,
+                   p1, p2;
 
+               for (var j = 0, jLen = this._parts.length; j < jLen; j++) {
+                       var points = this._parts[j];
 
-/*
- * L.Handler.MapDrag is used to make the map draggable (with panning inertia), enabled by default.
- */
+                       for (var i = 1, len = points.length; i < len; i++) {
+                               p1 = points[i - 1];
+                               p2 = points[i];
 
-L.Map.mergeOptions({
-       dragging: true,
+                               var sqDist = closest(p, p1, p2, true);
 
-       inertia: !L.Browser.android23,
-       inertiaDeceleration: 3400, // px/s^2
-       inertiaMaxSpeed: Infinity, // px/s
-       inertiaThreshold: L.Browser.touch ? 32 : 18, // ms
-       easeLinearity: 0.25,
+                               if (sqDist < minDistance) {
+                                       minDistance = sqDist;
+                                       minPoint = closest(p, p1, p2);
+                               }
+                       }
+               }
+               if (minPoint) {
+                       minPoint.distance = Math.sqrt(minDistance);
+               }
+               return minPoint;
+       },
 
-       // TODO refactor, move to CRS
-       worldCopyJump: false
-});
+       // @method getCenter(): LatLng
+       // Returns the center ([centroid](http://en.wikipedia.org/wiki/Centroid)) of the polyline.
+       getCenter: function () {
+               // throws error when not yet added to map as this center calculation requires projected coordinates
+               if (!this._map) {
+                       throw new Error('Must add layer to map before using getCenter()');
+               }
 
-L.Map.Drag = L.Handler.extend({
-       addHooks: function () {
-               if (!this._draggable) {
-                       var map = this._map;
+               var i, halfDist, segDist, dist, p1, p2, ratio,
+                   points = this._rings[0],
+                   len = points.length;
 
-                       this._draggable = new L.Draggable(map._mapPane, map._container);
+               if (!len) { return null; }
 
-                       this._draggable.on({
-                               'dragstart': this._onDragStart,
-                               'drag': this._onDrag,
-                               'dragend': this._onDragEnd
-                       }, this);
+               // polyline centroid algorithm; only uses the first ring if there are multiple
 
-                       if (map.options.worldCopyJump) {
-                               this._draggable.on('predrag', this._onPreDrag, this);
-                               map.on('viewreset', this._onViewReset, this);
+               for (i = 0, halfDist = 0; i < len - 1; i++) {
+                       halfDist += points[i].distanceTo(points[i + 1]) / 2;
+               }
 
-                               map.whenReady(this._onViewReset, this);
+               // The line is so small in the current view that all points are on the same pixel.
+               if (halfDist === 0) {
+                       return this._map.layerPointToLatLng(points[0]);
+               }
+
+               for (i = 0, dist = 0; i < len - 1; i++) {
+                       p1 = points[i];
+                       p2 = points[i + 1];
+                       segDist = p1.distanceTo(p2);
+                       dist += segDist;
+
+                       if (dist > halfDist) {
+                               ratio = (dist - halfDist) / segDist;
+                               return this._map.layerPointToLatLng([
+                                       p2.x - ratio * (p2.x - p1.x),
+                                       p2.y - ratio * (p2.y - p1.y)
+                               ]);
                        }
                }
-               this._draggable.enable();
        },
 
-       removeHooks: function () {
-               this._draggable.disable();
+       // @method getBounds(): LatLngBounds
+       // Returns the `LatLngBounds` of the path.
+       getBounds: function () {
+               return this._bounds;
        },
 
-       moved: function () {
-               return this._draggable && this._draggable._moved;
+       // @method addLatLng(latlng: LatLng, latlngs? LatLng[]): this
+       // Adds a given point to the polyline. By default, adds to the first ring of
+       // the polyline in case of a multi-polyline, but can be overridden by passing
+       // a specific ring as a LatLng array (that you can earlier access with [`getLatLngs`](#polyline-getlatlngs)).
+       addLatLng: function (latlng, latlngs) {
+               latlngs = latlngs || this._defaultShape();
+               latlng = L.latLng(latlng);
+               latlngs.push(latlng);
+               this._bounds.extend(latlng);
+               return this.redraw();
        },
 
-       _onDragStart: function () {
-               var map = this._map;
-
-               if (map._panAnim) {
-                       map._panAnim.stop();
-               }
-
-               map
-                   .fire('movestart')
-                   .fire('dragstart');
-
-               if (map.options.inertia) {
-                       this._positions = [];
-                       this._times = [];
-               }
+       _setLatLngs: function (latlngs) {
+               this._bounds = new L.LatLngBounds();
+               this._latlngs = this._convertLatLngs(latlngs);
        },
 
-       _onDrag: function () {
-               if (this._map.options.inertia) {
-                       var time = this._lastTime = +new Date(),
-                           pos = this._lastPos = this._draggable._newPos;
+       _defaultShape: function () {
+               return L.Polyline._flat(this._latlngs) ? this._latlngs : this._latlngs[0];
+       },
 
-                       this._positions.push(pos);
-                       this._times.push(time);
+       // recursively convert latlngs input into actual LatLng instances; calculate bounds along the way
+       _convertLatLngs: function (latlngs) {
+               var result = [],
+                   flat = L.Polyline._flat(latlngs);
 
-                       if (time - this._times[0] > 200) {
-                               this._positions.shift();
-                               this._times.shift();
+               for (var i = 0, len = latlngs.length; i < len; i++) {
+                       if (flat) {
+                               result[i] = L.latLng(latlngs[i]);
+                               this._bounds.extend(result[i]);
+                       } else {
+                               result[i] = this._convertLatLngs(latlngs[i]);
                        }
                }
 
-               this._map
-                   .fire('move')
-                   .fire('drag');
+               return result;
        },
 
-       _onViewReset: function () {
-               // TODO fix hardcoded Earth values
-               var pxCenter = this._map.getSize()._divideBy(2),
-                   pxWorldCenter = this._map.latLngToLayerPoint([0, 0]);
+       _project: function () {
+               var pxBounds = new L.Bounds();
+               this._rings = [];
+               this._projectLatlngs(this._latlngs, this._rings, pxBounds);
 
-               this._initialWorldOffset = pxWorldCenter.subtract(pxCenter).x;
-               this._worldWidth = this._map.project([0, 180]).x;
-       },
+               var w = this._clickTolerance(),
+                   p = new L.Point(w, w);
 
-       _onPreDrag: function () {
-               // TODO refactor to be able to adjust map pane position after zoom
-               var worldWidth = this._worldWidth,
-                   halfWidth = Math.round(worldWidth / 2),
-                   dx = this._initialWorldOffset,
-                   x = this._draggable._newPos.x,
-                   newX1 = (x - halfWidth + dx) % worldWidth + halfWidth - dx,
-                   newX2 = (x + halfWidth + dx) % worldWidth - halfWidth - dx,
-                   newX = Math.abs(newX1 + dx) < Math.abs(newX2 + dx) ? newX1 : newX2;
+               if (this._bounds.isValid() && pxBounds.isValid()) {
+                       pxBounds.min._subtract(p);
+                       pxBounds.max._add(p);
+                       this._pxBounds = pxBounds;
+               }
+       },
 
-               this._draggable._newPos.x = newX;
+       // recursively turns latlngs into a set of rings with projected coordinates
+       _projectLatlngs: function (latlngs, result, projectedBounds) {
+               var flat = latlngs[0] instanceof L.LatLng,
+                   len = latlngs.length,
+                   i, ring;
+
+               if (flat) {
+                       ring = [];
+                       for (i = 0; i < len; i++) {
+                               ring[i] = this._map.latLngToLayerPoint(latlngs[i]);
+                               projectedBounds.extend(ring[i]);
+                       }
+                       result.push(ring);
+               } else {
+                       for (i = 0; i < len; i++) {
+                               this._projectLatlngs(latlngs[i], result, projectedBounds);
+                       }
+               }
        },
 
-       _onDragEnd: function (e) {
-               var map = this._map,
-                   options = map.options,
-                   delay = +new Date() - this._lastTime,
+       // clip polyline by renderer bounds so that we have less to render for performance
+       _clipPoints: function () {
+               var bounds = this._renderer._bounds;
 
-                   noInertia = !options.inertia || delay > options.inertiaThreshold || !this._positions[0];
+               this._parts = [];
+               if (!this._pxBounds || !this._pxBounds.intersects(bounds)) {
+                       return;
+               }
 
-               map.fire('dragend', e);
-
-               if (noInertia) {
-                       map.fire('moveend');
-
-               } else {
-
-                       var direction = this._lastPos.subtract(this._positions[0]),
-                           duration = (this._lastTime + delay - this._times[0]) / 1000,
-                           ease = options.easeLinearity,
+               if (this.options.noClip) {
+                       this._parts = this._rings;
+                       return;
+               }
 
-                           speedVector = direction.multiplyBy(ease / duration),
-                           speed = speedVector.distanceTo([0, 0]),
+               var parts = this._parts,
+                   i, j, k, len, len2, segment, points;
 
-                           limitedSpeed = Math.min(options.inertiaMaxSpeed, speed),
-                           limitedSpeedVector = speedVector.multiplyBy(limitedSpeed / speed),
+               for (i = 0, k = 0, len = this._rings.length; i < len; i++) {
+                       points = this._rings[i];
 
-                           decelerationDuration = limitedSpeed / (options.inertiaDeceleration * ease),
-                           offset = limitedSpeedVector.multiplyBy(-decelerationDuration / 2).round();
+                       for (j = 0, len2 = points.length; j < len2 - 1; j++) {
+                               segment = L.LineUtil.clipSegment(points[j], points[j + 1], bounds, j, true);
 
-                       if (!offset.x || !offset.y) {
-                               map.fire('moveend');
+                               if (!segment) { continue; }
 
-                       } else {
-                               offset = map._limitOffset(offset, map.options.maxBounds);
+                               parts[k] = parts[k] || [];
+                               parts[k].push(segment[0]);
 
-                               L.Util.requestAnimFrame(function () {
-                                       map.panBy(offset, {
-                                               duration: decelerationDuration,
-                                               easeLinearity: ease,
-                                               noMoveStart: true
-                                       });
-                               });
+                               // if segment goes out of screen, or it's the last one, it's the end of the line part
+                               if ((segment[1] !== points[j + 1]) || (j === len2 - 2)) {
+                                       parts[k].push(segment[1]);
+                                       k++;
+                               }
                        }
                }
-       }
-});
-
-L.Map.addInitHook('addHandler', 'dragging', L.Map.Drag);
-
-
-/*
- * L.Handler.DoubleClickZoom is used to handle double-click zoom on the map, enabled by default.
- */
-
-L.Map.mergeOptions({
-       doubleClickZoom: true
-});
-
-L.Map.DoubleClickZoom = L.Handler.extend({
-       addHooks: function () {
-               this._map.on('dblclick', this._onDoubleClick, this);
-       },
-
-       removeHooks: function () {
-               this._map.off('dblclick', this._onDoubleClick, this);
        },
 
-       _onDoubleClick: function (e) {
-               var map = this._map,
-                   zoom = map.getZoom() + (e.originalEvent.shiftKey ? -1 : 1);
+       // simplify each clipped part of the polyline for performance
+       _simplifyPoints: function () {
+               var parts = this._parts,
+                   tolerance = this.options.smoothFactor;
 
-               if (map.options.doubleClickZoom === 'center') {
-                       map.setZoom(zoom);
-               } else {
-                       map.setZoomAround(e.containerPoint, zoom);
+               for (var i = 0, len = parts.length; i < len; i++) {
+                       parts[i] = L.LineUtil.simplify(parts[i], tolerance);
                }
-       }
-});
-
-L.Map.addInitHook('addHandler', 'doubleClickZoom', L.Map.DoubleClickZoom);
-
-
-/*
- * L.Handler.ScrollWheelZoom is used by L.Map to enable mouse scroll wheel zoom on the map.
- */
-
-L.Map.mergeOptions({
-       scrollWheelZoom: true
-});
-
-L.Map.ScrollWheelZoom = L.Handler.extend({
-       addHooks: function () {
-               L.DomEvent.on(this._map._container, 'mousewheel', this._onWheelScroll, this);
-               L.DomEvent.on(this._map._container, 'MozMousePixelScroll', L.DomEvent.preventDefault);
-               this._delta = 0;
-       },
-
-       removeHooks: function () {
-               L.DomEvent.off(this._map._container, 'mousewheel', this._onWheelScroll);
-               L.DomEvent.off(this._map._container, 'MozMousePixelScroll', L.DomEvent.preventDefault);
        },
 
-       _onWheelScroll: function (e) {
-               var delta = L.DomEvent.getWheelDelta(e);
-
-               this._delta += delta;
-               this._lastMousePos = this._map.mouseEventToContainerPoint(e);
-
-               if (!this._startTime) {
-                       this._startTime = +new Date();
-               }
-
-               var left = Math.max(40 - (+new Date() - this._startTime), 0);
-
-               clearTimeout(this._timer);
-               this._timer = setTimeout(L.bind(this._performZoom, this), left);
+       _update: function () {
+               if (!this._map) { return; }
 
-               L.DomEvent.preventDefault(e);
-               L.DomEvent.stopPropagation(e);
+               this._clipPoints();
+               this._simplifyPoints();
+               this._updatePath();
        },
 
-       _performZoom: function () {
-               var map = this._map,
-                   delta = this._delta,
-                   zoom = map.getZoom();
-
-               delta = delta > 0 ? Math.ceil(delta) : Math.floor(delta);
-               delta = Math.max(Math.min(delta, 4), -4);
-               delta = map._limitZoom(zoom + delta) - zoom;
-
-               this._delta = 0;
-               this._startTime = null;
-
-               if (!delta) { return; }
-
-               if (map.options.scrollWheelZoom === 'center') {
-                       map.setZoom(zoom + delta);
-               } else {
-                       map.setZoomAround(this._lastMousePos, zoom + delta);
-               }
+       _updatePath: function () {
+               this._renderer._updatePoly(this);
        }
 });
 
-L.Map.addInitHook('addHandler', 'scrollWheelZoom', L.Map.ScrollWheelZoom);
+// @factory L.polyline(latlngs: LatLng[], options?: Polyline options)
+// Instantiates a polyline object given an array of geographical points and
+// optionally an options object. You can create a `Polyline` object with
+// multiple separate lines (`MultiPolyline`) by passing an array of arrays
+// of geographic points.
+L.polyline = function (latlngs, options) {
+       return new L.Polyline(latlngs, options);
+};
+
+L.Polyline._flat = function (latlngs) {
+       // true if it's a flat array of latlngs; false if nested
+       return !L.Util.isArray(latlngs[0]) || (typeof latlngs[0][0] !== 'object' && typeof latlngs[0][0] !== 'undefined');
+};
+
 
 
 /*\r
- * Extends the event handling code with double tap support for mobile browsers.\r
+ * @namespace PolyUtil\r
+ * Various utility functions for polygon geometries.\r
  */\r
 \r
-L.extend(L.DomEvent, {\r
-\r
-       _touchstart: L.Browser.msPointer ? 'MSPointerDown' : L.Browser.pointer ? 'pointerdown' : 'touchstart',\r
-       _touchend: L.Browser.msPointer ? 'MSPointerUp' : L.Browser.pointer ? 'pointerup' : 'touchend',\r
-\r
-       // inspired by Zepto touch code by Thomas Fuchs\r
-       addDoubleTapListener: function (obj, handler, id) {\r
-               var last,\r
-                   doubleTap = false,\r
-                   delay = 250,\r
-                   touch,\r
-                   pre = '_leaflet_',\r
-                   touchstart = this._touchstart,\r
-                   touchend = this._touchend,\r
-                   trackedTouches = [];\r
+L.PolyUtil = {};\r
 \r
-               function onTouchStart(e) {\r
-                       var count;\r
+/* @function clipPolygon(points: Point[], bounds: Bounds, round?: Boolean): Point[]\r
+ * Clips the polygon geometry defined by the given `points` by the given bounds (using the [Sutherland-Hodgeman algorithm](https://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm)).\r
+ * Used by Leaflet to only show polygon points that are on the screen or near, increasing\r
+ * performance. Note that polygon points needs different algorithm for clipping\r
+ * than polyline, so there's a seperate method for it.\r
+ */\r
+L.PolyUtil.clipPolygon = function (points, bounds, round) {\r
+       var clippedPoints,\r
+           edges = [1, 4, 2, 8],\r
+           i, j, k,\r
+           a, b,\r
+           len, edge, p,\r
+           lu = L.LineUtil;\r
 \r
-                       if (L.Browser.pointer) {\r
-                               trackedTouches.push(e.pointerId);\r
-                               count = trackedTouches.length;\r
-                       } else {\r
-                               count = e.touches.length;\r
-                       }\r
-                       if (count > 1) {\r
-                               return;\r
-                       }\r
+       for (i = 0, len = points.length; i < len; i++) {\r
+               points[i]._code = lu._getBitCode(points[i], bounds);\r
+       }\r
 \r
-                       var now = Date.now(),\r
-                               delta = now - (last || now);\r
+       // for each edge (left, bottom, right, top)\r
+       for (k = 0; k < 4; k++) {\r
+               edge = edges[k];\r
+               clippedPoints = [];\r
 \r
-                       touch = e.touches ? e.touches[0] : e;\r
-                       doubleTap = (delta > 0 && delta <= delay);\r
-                       last = now;\r
-               }\r
+               for (i = 0, len = points.length, j = len - 1; i < len; j = i++) {\r
+                       a = points[i];\r
+                       b = points[j];\r
 \r
-               function onTouchEnd(e) {\r
-                       if (L.Browser.pointer) {\r
-                               var idx = trackedTouches.indexOf(e.pointerId);\r
-                               if (idx === -1) {\r
-                                       return;\r
+                       // if a is inside the clip window\r
+                       if (!(a._code & edge)) {\r
+                               // if b is outside the clip window (a->b goes out of screen)\r
+                               if (b._code & edge) {\r
+                                       p = lu._getEdgeIntersection(b, a, edge, bounds, round);\r
+                                       p._code = lu._getBitCode(p, bounds);\r
+                                       clippedPoints.push(p);\r
                                }\r
-                               trackedTouches.splice(idx, 1);\r
-                       }\r
-\r
-                       if (doubleTap) {\r
-                               if (L.Browser.pointer) {\r
-                                       // work around .type being readonly with MSPointer* events\r
-                                       var newTouch = { },\r
-                                               prop;\r
+                               clippedPoints.push(a);\r
 \r
-                                       // jshint forin:false\r
-                                       for (var i in touch) {\r
-                                               prop = touch[i];\r
-                                               if (typeof prop === 'function') {\r
-                                                       newTouch[i] = prop.bind(touch);\r
-                                               } else {\r
-                                                       newTouch[i] = prop;\r
-                                               }\r
-                                       }\r
-                                       touch = newTouch;\r
-                               }\r
-                               touch.type = 'dblclick';\r
-                               handler(touch);\r
-                               last = null;\r
+                       // else if b is inside the clip window (a->b enters the screen)\r
+                       } else if (!(b._code & edge)) {\r
+                               p = lu._getEdgeIntersection(b, a, edge, bounds, round);\r
+                               p._code = lu._getBitCode(p, bounds);\r
+                               clippedPoints.push(p);\r
                        }\r
                }\r
-               obj[pre + touchstart + id] = onTouchStart;\r
-               obj[pre + touchend + id] = onTouchEnd;\r
-\r
-               // on pointer we need to listen on the document, otherwise a drag starting on the map and moving off screen\r
-               // will not come through to us, so we will lose track of how many touches are ongoing\r
-               var endElement = L.Browser.pointer ? document.documentElement : obj;\r
-\r
-               obj.addEventListener(touchstart, onTouchStart, false);\r
-               endElement.addEventListener(touchend, onTouchEnd, false);\r
-\r
-               if (L.Browser.pointer) {\r
-                       endElement.addEventListener(L.DomEvent.POINTER_CANCEL, onTouchEnd, false);\r
-               }\r
-\r
-               return this;\r
-       },\r
-\r
-       removeDoubleTapListener: function (obj, id) {\r
-               var pre = '_leaflet_';\r
-\r
-               obj.removeEventListener(this._touchstart, obj[pre + this._touchstart + id], false);\r
-               (L.Browser.pointer ? document.documentElement : obj).removeEventListener(\r
-                       this._touchend, obj[pre + this._touchend + id], false);\r
-\r
-               if (L.Browser.pointer) {\r
-                       document.documentElement.removeEventListener(L.DomEvent.POINTER_CANCEL, obj[pre + this._touchend + id],\r
-                               false);\r
-               }\r
-\r
-               return this;\r
+               points = clippedPoints;\r
        }\r
-});\r
+\r
+       return points;\r
+};\r
+
 
 
 /*
- * Extends L.DomEvent to provide touch support for Internet Explorer and Windows-based devices.
+ * @class Polygon
+ * @aka L.Polygon
+ * @inherits Polyline
+ *
+ * A class for drawing polygon overlays on a map. Extends `Polyline`.
+ *
+ * Note that points you pass when creating a polygon shouldn't have an additional last point equal to the first one — it's better to filter out such points.
+ *
+ *
+ * @example
+ *
+ * ```js
+ * // create a red polygon from an array of LatLng points
+ * var latlngs = [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]];
+ *
+ * var polygon = L.polygon(latlngs, {color: 'red'}).addTo(map);
+ *
+ * // zoom the map to the polygon
+ * map.fitBounds(polygon.getBounds());
+ * ```
+ *
+ * You can also pass an array of arrays of latlngs, with the first array representing the outer shape and the other arrays representing holes in the outer shape:
+ *
+ * ```js
+ * var latlngs = [
+ *   [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]], // outer ring
+ *   [[37.29, -108.58],[40.71, -108.58],[40.71, -102.50],[37.29, -102.50]] // hole
+ * ];
+ * ```
+ *
+ * Additionally, you can pass a multi-dimensional array to represent a MultiPolygon shape.
+ *
+ * ```js
+ * var latlngs = [
+ *   [ // first polygon
+ *     [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]], // outer ring
+ *     [[37.29, -108.58],[40.71, -108.58],[40.71, -102.50],[37.29, -102.50]] // hole
+ *   ],
+ *   [ // second polygon
+ *     [[41, -111.03],[45, -111.04],[45, -104.05],[41, -104.05]]
+ *   ]
+ * ];
+ * ```
  */
 
-L.extend(L.DomEvent, {
-
-       //static
-       POINTER_DOWN: L.Browser.msPointer ? 'MSPointerDown' : 'pointerdown',
-       POINTER_MOVE: L.Browser.msPointer ? 'MSPointerMove' : 'pointermove',
-       POINTER_UP: L.Browser.msPointer ? 'MSPointerUp' : 'pointerup',
-       POINTER_CANCEL: L.Browser.msPointer ? 'MSPointerCancel' : 'pointercancel',
-
-       _pointers: [],
-       _pointerDocumentListener: false,
+L.Polygon = L.Polyline.extend({
 
-       // Provides a touch events wrapper for (ms)pointer events.
-       // Based on changes by veproza https://github.com/CloudMade/Leaflet/pull/1019
-       //ref http://www.w3.org/TR/pointerevents/ https://www.w3.org/Bugs/Public/show_bug.cgi?id=22890
+       options: {
+               fill: true
+       },
 
-       addPointerListener: function (obj, type, handler, id) {
+       isEmpty: function () {
+               return !this._latlngs.length || !this._latlngs[0].length;
+       },
 
-               switch (type) {
-               case 'touchstart':
-                       return this.addPointerListenerStart(obj, type, handler, id);
-               case 'touchend':
-                       return this.addPointerListenerEnd(obj, type, handler, id);
-               case 'touchmove':
-                       return this.addPointerListenerMove(obj, type, handler, id);
-               default:
-                       throw 'Unknown touch event type';
+       getCenter: function () {
+               // throws error when not yet added to map as this center calculation requires projected coordinates
+               if (!this._map) {
+                       throw new Error('Must add layer to map before using getCenter()');
                }
-       },
 
-       addPointerListenerStart: function (obj, type, handler, id) {
-               var pre = '_leaflet_',
-                   pointers = this._pointers;
+               var i, j, p1, p2, f, area, x, y, center,
+                   points = this._rings[0],
+                   len = points.length;
 
-               var cb = function (e) {
-                       if (e.pointerType !== 'mouse' && e.pointerType !== e.MSPOINTER_TYPE_MOUSE) {
-                               L.DomEvent.preventDefault(e);
-                       }
+               if (!len) { return null; }
 
-                       var alreadyInArray = false;
-                       for (var i = 0; i < pointers.length; i++) {
-                               if (pointers[i].pointerId === e.pointerId) {
-                                       alreadyInArray = true;
-                                       break;
-                               }
-                       }
-                       if (!alreadyInArray) {
-                               pointers.push(e);
-                       }
+               // polygon centroid algorithm; only uses the first ring if there are multiple
 
-                       e.touches = pointers.slice();
-                       e.changedTouches = [e];
+               area = x = y = 0;
 
-                       handler(e);
-               };
+               for (i = 0, j = len - 1; i < len; j = i++) {
+                       p1 = points[i];
+                       p2 = points[j];
 
-               obj[pre + 'touchstart' + id] = cb;
-               obj.addEventListener(this.POINTER_DOWN, cb, false);
-
-               // need to also listen for end events to keep the _pointers list accurate
-               // this needs to be on the body and never go away
-               if (!this._pointerDocumentListener) {
-                       var internalCb = function (e) {
-                               for (var i = 0; i < pointers.length; i++) {
-                                       if (pointers[i].pointerId === e.pointerId) {
-                                               pointers.splice(i, 1);
-                                               break;
-                                       }
-                               }
-                       };
-                       //We listen on the documentElement as any drags that end by moving the touch off the screen get fired there
-                       document.documentElement.addEventListener(this.POINTER_UP, internalCb, false);
-                       document.documentElement.addEventListener(this.POINTER_CANCEL, internalCb, false);
+                       f = p1.y * p2.x - p2.y * p1.x;
+                       x += (p1.x + p2.x) * f;
+                       y += (p1.y + p2.y) * f;
+                       area += f * 3;
+               }
 
-                       this._pointerDocumentListener = true;
+               if (area === 0) {
+                       // Polygon is so small that all points are on same pixel.
+                       center = points[0];
+               } else {
+                       center = [x / area, y / area];
                }
+               return this._map.layerPointToLatLng(center);
+       },
 
-               return this;
+       _convertLatLngs: function (latlngs) {
+               var result = L.Polyline.prototype._convertLatLngs.call(this, latlngs),
+                   len = result.length;
+
+               // remove last point if it equals first one
+               if (len >= 2 && result[0] instanceof L.LatLng && result[0].equals(result[len - 1])) {
+                       result.pop();
+               }
+               return result;
        },
 
-       addPointerListenerMove: function (obj, type, handler, id) {
-               var pre = '_leaflet_',
-                   touches = this._pointers;
+       _setLatLngs: function (latlngs) {
+               L.Polyline.prototype._setLatLngs.call(this, latlngs);
+               if (L.Polyline._flat(this._latlngs)) {
+                       this._latlngs = [this._latlngs];
+               }
+       },
 
-               function cb(e) {
+       _defaultShape: function () {
+               return L.Polyline._flat(this._latlngs[0]) ? this._latlngs[0] : this._latlngs[0][0];
+       },
 
-                       // don't fire touch moves when mouse isn't down
-                       if ((e.pointerType === e.MSPOINTER_TYPE_MOUSE || e.pointerType === 'mouse') && e.buttons === 0) { return; }
+       _clipPoints: function () {
+               // polygons need a different clipping algorithm so we redefine that
 
-                       for (var i = 0; i < touches.length; i++) {
-                               if (touches[i].pointerId === e.pointerId) {
-                                       touches[i] = e;
-                                       break;
-                               }
-                       }
+               var bounds = this._renderer._bounds,
+                   w = this.options.weight,
+                   p = new L.Point(w, w);
 
-                       e.touches = touches.slice();
-                       e.changedTouches = [e];
+               // increase clip padding by stroke width to avoid stroke on clip edges
+               bounds = new L.Bounds(bounds.min.subtract(p), bounds.max.add(p));
 
-                       handler(e);
+               this._parts = [];
+               if (!this._pxBounds || !this._pxBounds.intersects(bounds)) {
+                       return;
                }
 
-               obj[pre + 'touchmove' + id] = cb;
-               obj.addEventListener(this.POINTER_MOVE, cb, false);
+               if (this.options.noClip) {
+                       this._parts = this._rings;
+                       return;
+               }
 
-               return this;
+               for (var i = 0, len = this._rings.length, clipped; i < len; i++) {
+                       clipped = L.PolyUtil.clipPolygon(this._rings[i], bounds, true);
+                       if (clipped.length) {
+                               this._parts.push(clipped);
+                       }
+               }
        },
 
-       addPointerListenerEnd: function (obj, type, handler, id) {
-               var pre = '_leaflet_',
-                   touches = this._pointers;
+       _updatePath: function () {
+               this._renderer._updatePoly(this, true);
+       }
+});
 
-               var cb = function (e) {
-                       for (var i = 0; i < touches.length; i++) {
-                               if (touches[i].pointerId === e.pointerId) {
-                                       touches.splice(i, 1);
-                                       break;
-                               }
-                       }
 
-                       e.touches = touches.slice();
-                       e.changedTouches = [e];
+// @factory L.polygon(latlngs: LatLng[], options?: Polyline options)
+L.polygon = function (latlngs, options) {
+       return new L.Polygon(latlngs, options);
+};
 
-                       handler(e);
-               };
 
-               obj[pre + 'touchend' + id] = cb;
-               obj.addEventListener(this.POINTER_UP, cb, false);
-               obj.addEventListener(this.POINTER_CANCEL, cb, false);
 
-               return this;
+/*
+ * L.Rectangle extends Polygon and creates a rectangle when passed a LatLngBounds object.
+ */
+
+/*
+ * @class Rectangle
+ * @aka L.Retangle
+ * @inherits Polygon
+ *
+ * A class for drawing rectangle overlays on a map. Extends `Polygon`.
+ *
+ * @example
+ *
+ * ```js
+ * // define rectangle geographical bounds
+ * var bounds = [[54.559322, -5.767822], [56.1210604, -3.021240]];
+ *
+ * // create an orange rectangle
+ * L.rectangle(bounds, {color: "#ff7800", weight: 1}).addTo(map);
+ *
+ * // zoom the map to the rectangle bounds
+ * map.fitBounds(bounds);
+ * ```
+ *
+ */
+
+
+L.Rectangle = L.Polygon.extend({
+       initialize: function (latLngBounds, options) {
+               L.Polygon.prototype.initialize.call(this, this._boundsToLatLngs(latLngBounds), options);
        },
 
-       removePointerListener: function (obj, type, id) {
-               var pre = '_leaflet_',
-                   cb = obj[pre + type + id];
-
-               switch (type) {
-               case 'touchstart':
-                       obj.removeEventListener(this.POINTER_DOWN, cb, false);
-                       break;
-               case 'touchmove':
-                       obj.removeEventListener(this.POINTER_MOVE, cb, false);
-                       break;
-               case 'touchend':
-                       obj.removeEventListener(this.POINTER_UP, cb, false);
-                       obj.removeEventListener(this.POINTER_CANCEL, cb, false);
-                       break;
-               }
+       // @method setBounds(latLngBounds: LatLngBounds): this
+       // Redraws the rectangle with the passed bounds.
+       setBounds: function (latLngBounds) {
+               return this.setLatLngs(this._boundsToLatLngs(latLngBounds));
+       },
 
-               return this;
+       _boundsToLatLngs: function (latLngBounds) {
+               latLngBounds = L.latLngBounds(latLngBounds);
+               return [
+                       latLngBounds.getSouthWest(),
+                       latLngBounds.getNorthWest(),
+                       latLngBounds.getNorthEast(),
+                       latLngBounds.getSouthEast()
+               ];
        }
 });
 
 
-/*
- * L.Handler.TouchZoom is used by L.Map to add pinch zoom on supported mobile browsers.
- */
+// @factory L.rectangle(latLngBounds: LatLngBounds, options?: Polyline options)
+L.rectangle = function (latLngBounds, options) {
+       return new L.Rectangle(latLngBounds, options);
+};
 
-L.Map.mergeOptions({
-       touchZoom: L.Browser.touch && !L.Browser.android23,
-       bounceAtZoomLimits: true
-});
 
-L.Map.TouchZoom = L.Handler.extend({
-       addHooks: function () {
-               L.DomEvent.on(this._map._container, 'touchstart', this._onTouchStart, this);
-       },
 
-       removeHooks: function () {
-               L.DomEvent.off(this._map._container, 'touchstart', this._onTouchStart, this);
+/*
+ * @class CircleMarker
+ * @aka L.CircleMarker
+ * @inherits Path
+ *
+ * A circle of a fixed size with radius specified in pixels. Extends `Path`.
+ */
+
+L.CircleMarker = L.Path.extend({
+
+       // @section
+       // @aka CircleMarker options
+       options: {
+               fill: true,
+
+               // @option radius: Number = 10
+               // Radius of the circle marker, in pixels
+               radius: 10
        },
 
-       _onTouchStart: function (e) {
-               var map = this._map;
+       initialize: function (latlng, options) {
+               L.setOptions(this, options);
+               this._latlng = L.latLng(latlng);
+               this._radius = this.options.radius;
+       },
 
-               if (!e.touches || e.touches.length !== 2 || map._animatingZoom || this._zooming) { return; }
+       // @method setLatLng(latLng: LatLng): this
+       // Sets the position of a circle marker to a new location.
+       setLatLng: function (latlng) {
+               this._latlng = L.latLng(latlng);
+               this.redraw();
+               return this.fire('move', {latlng: this._latlng});
+       },
 
-               var p1 = map.mouseEventToLayerPoint(e.touches[0]),
-                   p2 = map.mouseEventToLayerPoint(e.touches[1]),
-                   viewCenter = map._getCenterLayerPoint();
+       // @method getLatLng(): LatLng
+       // Returns the current geographical position of the circle marker
+       getLatLng: function () {
+               return this._latlng;
+       },
 
-               this._startCenter = p1.add(p2)._divideBy(2);
-               this._startDist = p1.distanceTo(p2);
+       // @method setRadius(radius: Number): this
+       // Sets the radius of a circle marker. Units are in pixels.
+       setRadius: function (radius) {
+               this.options.radius = this._radius = radius;
+               return this.redraw();
+       },
 
-               this._moved = false;
-               this._zooming = true;
+       // @method getRadius(): Number
+       // Returns the current radius of the circle
+       getRadius: function () {
+               return this._radius;
+       },
 
-               this._centerOffset = viewCenter.subtract(this._startCenter);
+       setStyle : function (options) {
+               var radius = options && options.radius || this._radius;
+               L.Path.prototype.setStyle.call(this, options);
+               this.setRadius(radius);
+               return this;
+       },
 
-               if (map._panAnim) {
-                       map._panAnim.stop();
-               }
+       _project: function () {
+               this._point = this._map.latLngToLayerPoint(this._latlng);
+               this._updateBounds();
+       },
 
-               L.DomEvent
-                   .on(document, 'touchmove', this._onTouchMove, this)
-                   .on(document, 'touchend', this._onTouchEnd, this);
+       _updateBounds: function () {
+               var r = this._radius,
+                   r2 = this._radiusY || r,
+                   w = this._clickTolerance(),
+                   p = [r + w, r2 + w];
+               this._pxBounds = new L.Bounds(this._point.subtract(p), this._point.add(p));
+       },
 
-               L.DomEvent.preventDefault(e);
+       _update: function () {
+               if (this._map) {
+                       this._updatePath();
+               }
        },
 
-       _onTouchMove: function (e) {
-               var map = this._map;
+       _updatePath: function () {
+               this._renderer._updateCircle(this);
+       },
 
-               if (!e.touches || e.touches.length !== 2 || !this._zooming) { return; }
+       _empty: function () {
+               return this._radius && !this._renderer._bounds.intersects(this._pxBounds);
+       }
+});
 
-               var p1 = map.mouseEventToLayerPoint(e.touches[0]),
-                   p2 = map.mouseEventToLayerPoint(e.touches[1]);
 
-               this._scale = p1.distanceTo(p2) / this._startDist;
-               this._delta = p1._add(p2)._divideBy(2)._subtract(this._startCenter);
+// @factory L.circleMarker(latlng: LatLng, options?: CircleMarker options)
+// Instantiates a circle marker object given a geographical point, and an optional options object.
+L.circleMarker = function (latlng, options) {
+       return new L.CircleMarker(latlng, options);
+};
 
-               if (this._scale === 1) { return; }
 
-               if (!map.options.bounceAtZoomLimits) {
-                       if ((map.getZoom() === map.getMinZoom() && this._scale < 1) ||
-                           (map.getZoom() === map.getMaxZoom() && this._scale > 1)) { return; }
-               }
 
-               if (!this._moved) {
-                       L.DomUtil.addClass(map._mapPane, 'leaflet-touching');
+/*
+ * @class Circle
+ * @aka L.Circle
+ * @inherits CircleMarker
+ *
+ * A class for drawing circle overlays on a map. Extends `CircleMarker`.
+ *
+ * It's an approximation and starts to diverge from a real circle closer to poles (due to projection distortion).
+ *
+ * @example
+ *
+ * ```js
+ * L.circle([50.5, 30.5], {radius: 200}).addTo(map);
+ * ```
+ */
 
-                       map
-                           .fire('movestart')
-                           .fire('zoomstart');
+L.Circle = L.CircleMarker.extend({
 
-                       this._moved = true;
+       initialize: function (latlng, options, legacyOptions) {
+               if (typeof options === 'number') {
+                       // Backwards compatibility with 0.7.x factory (latlng, radius, options?)
+                       options = L.extend({}, legacyOptions, {radius: options});
                }
+               L.setOptions(this, options);
+               this._latlng = L.latLng(latlng);
 
-               L.Util.cancelAnimFrame(this._animRequest);
-               this._animRequest = L.Util.requestAnimFrame(
-                       this._updateOnMove, this, true, this._map._container);
+               if (isNaN(this.options.radius)) { throw new Error('Circle radius cannot be NaN'); }
 
-               L.DomEvent.preventDefault(e);
+               // @section
+               // @aka Circle options
+               // @option radius: Number; Radius of the circle, in meters.
+               this._mRadius = this.options.radius;
        },
 
-       _updateOnMove: function () {
-               var map = this._map,
-                   origin = this._getScaleOrigin(),
-                   center = map.layerPointToLatLng(origin),
-                   zoom = map.getScaleZoom(this._scale);
+       // @method setRadius(radius: Number): this
+       // Sets the radius of a circle. Units are in meters.
+       setRadius: function (radius) {
+               this._mRadius = radius;
+               return this.redraw();
+       },
 
-               map._animateZoom(center, zoom, this._startCenter, this._scale, this._delta, false, true);
+       // @method getRadius(): Number
+       // Returns the current radius of a circle. Units are in meters.
+       getRadius: function () {
+               return this._mRadius;
        },
 
-       _onTouchEnd: function () {
-               if (!this._moved || !this._zooming) {
-                       this._zooming = false;
-                       return;
-               }
+       // @method getBounds(): LatLngBounds
+       // Returns the `LatLngBounds` of the path.
+       getBounds: function () {
+               var half = [this._radius, this._radiusY || this._radius];
 
-               var map = this._map;
+               return new L.LatLngBounds(
+                       this._map.layerPointToLatLng(this._point.subtract(half)),
+                       this._map.layerPointToLatLng(this._point.add(half)));
+       },
 
-               this._zooming = false;
-               L.DomUtil.removeClass(map._mapPane, 'leaflet-touching');
-               L.Util.cancelAnimFrame(this._animRequest);
+       setStyle: L.Path.prototype.setStyle,
 
-               L.DomEvent
-                   .off(document, 'touchmove', this._onTouchMove)
-                   .off(document, 'touchend', this._onTouchEnd);
+       _project: function () {
 
-               var origin = this._getScaleOrigin(),
-                   center = map.layerPointToLatLng(origin),
+               var lng = this._latlng.lng,
+                   lat = this._latlng.lat,
+                   map = this._map,
+                   crs = map.options.crs;
 
-                   oldZoom = map.getZoom(),
-                   floatZoomDelta = map.getScaleZoom(this._scale) - oldZoom,
-                   roundZoomDelta = (floatZoomDelta > 0 ?
-                           Math.ceil(floatZoomDelta) : Math.floor(floatZoomDelta)),
+               if (crs.distance === L.CRS.Earth.distance) {
+                       var d = Math.PI / 180,
+                           latR = (this._mRadius / L.CRS.Earth.R) / d,
+                           top = map.project([lat + latR, lng]),
+                           bottom = map.project([lat - latR, lng]),
+                           p = top.add(bottom).divideBy(2),
+                           lat2 = map.unproject(p).lat,
+                           lngR = Math.acos((Math.cos(latR * d) - Math.sin(lat * d) * Math.sin(lat2 * d)) /
+                                   (Math.cos(lat * d) * Math.cos(lat2 * d))) / d;
+
+                       if (isNaN(lngR) || lngR === 0) {
+                               lngR = latR / Math.cos(Math.PI / 180 * lat); // Fallback for edge case, #2425
+                       }
 
-                   zoom = map._limitZoom(oldZoom + roundZoomDelta),
-                   scale = map.getZoomScale(zoom) / this._scale;
+                       this._point = p.subtract(map.getPixelOrigin());
+                       this._radius = isNaN(lngR) ? 0 : Math.max(Math.round(p.x - map.project([lat2, lng - lngR]).x), 1);
+                       this._radiusY = Math.max(Math.round(p.y - top.y), 1);
 
-               map._animateZoom(center, zoom, origin, scale);
-       },
+               } else {
+                       var latlng2 = crs.unproject(crs.project(this._latlng).subtract([this._mRadius, 0]));
+
+                       this._point = map.latLngToLayerPoint(this._latlng);
+                       this._radius = this._point.x - map.latLngToLayerPoint(latlng2).x;
+               }
 
-       _getScaleOrigin: function () {
-               var centerOffset = this._centerOffset.subtract(this._delta).divideBy(this._scale);
-               return this._startCenter.add(centerOffset);
+               this._updateBounds();
        }
 });
 
-L.Map.addInitHook('addHandler', 'touchZoom', L.Map.TouchZoom);
+// @factory L.circle(latlng: LatLng, options?: Circle options)
+// Instantiates a circle object given a geographical point, and an options object
+// which contains the circle radius.
+// @alternative
+// @factory L.circle(latlng: LatLng, radius: Number, options?: Circle options)
+// Obsolete way of instantiating a circle, for compatibility with 0.7.x code.
+// Do not use in new applications or plugins.
+L.circle = function (latlng, options, legacyOptions) {
+       return new L.Circle(latlng, options, legacyOptions);
+};
+
 
 
 /*
- * L.Map.Tap is used to enable mobile hacks like quick taps and long hold.
+ * @class SVG
+ * @inherits Renderer
+ * @aka L.SVG
+ *
+ * Allows vector layers to be displayed with [SVG](https://developer.mozilla.org/docs/Web/SVG).
+ * Inherits `Renderer`.
+ *
+ * Due to [technical limitations](http://caniuse.com/#search=svg), SVG is not
+ * available in all web browsers, notably Android 2.x and 3.x.
+ *
+ * Although SVG is not available on IE7 and IE8, these browsers support
+ * [VML](https://en.wikipedia.org/wiki/Vector_Markup_Language)
+ * (a now deprecated technology), and the SVG renderer will fall back to VML in
+ * this case.
+ *
+ * @example
+ *
+ * Use SVG by default for all paths in the map:
+ *
+ * ```js
+ * var map = L.map('map', {
+ *     renderer: L.svg()
+ * });
+ * ```
+ *
+ * Use a SVG renderer with extra padding for specific vector geometries:
+ *
+ * ```js
+ * var map = L.map('map');
+ * var myRenderer = L.svg({ padding: 0.5 });
+ * var line = L.polyline( coordinates, { renderer: myRenderer } );
+ * var circle = L.circle( center, { renderer: myRenderer } );
+ * ```
  */
 
-L.Map.mergeOptions({
-       tap: true,
-       tapTolerance: 15
-});
+L.SVG = L.Renderer.extend({
 
-L.Map.Tap = L.Handler.extend({
-       addHooks: function () {
-               L.DomEvent.on(this._map._container, 'touchstart', this._onDown, this);
+       getEvents: function () {
+               var events = L.Renderer.prototype.getEvents.call(this);
+               events.zoomstart = this._onZoomStart;
+               return events;
        },
 
-       removeHooks: function () {
-               L.DomEvent.off(this._map._container, 'touchstart', this._onDown, this);
+       _initContainer: function () {
+               this._container = L.SVG.create('svg');
+
+               // makes it possible to click through svg root; we'll reset it back in individual paths
+               this._container.setAttribute('pointer-events', 'none');
+
+               this._rootGroup = L.SVG.create('g');
+               this._container.appendChild(this._rootGroup);
        },
 
-       _onDown: function (e) {
-               if (!e.touches) { return; }
+       _onZoomStart: function () {
+               // Drag-then-pinch interactions might mess up the center and zoom.
+               // In this case, the easiest way to prevent this is re-do the renderer
+               //   bounds and padding when the zooming starts.
+               this._update();
+       },
 
-               L.DomEvent.preventDefault(e);
+       _update: function () {
+               if (this._map._animatingZoom && this._bounds) { return; }
 
-               this._fireClick = true;
+               L.Renderer.prototype._update.call(this);
 
-               // don't simulate click or track longpress if more than 1 touch
-               if (e.touches.length > 1) {
-                       this._fireClick = false;
-                       clearTimeout(this._holdTimeout);
-                       return;
+               var b = this._bounds,
+                   size = b.getSize(),
+                   container = this._container;
+
+               // set size of svg-container if changed
+               if (!this._svgSize || !this._svgSize.equals(size)) {
+                       this._svgSize = size;
+                       container.setAttribute('width', size.x);
+                       container.setAttribute('height', size.y);
                }
 
-               var first = e.touches[0],
-                   el = first.target;
+               // movement: update container viewBox so that we don't have to change coordinates of individual layers
+               L.DomUtil.setPosition(container, b.min);
+               container.setAttribute('viewBox', [b.min.x, b.min.y, size.x, size.y].join(' '));
 
-               this._startPos = this._newPos = new L.Point(first.clientX, first.clientY);
+               this.fire('update');
+       },
 
-               // if touching a link, highlight it
-               if (el.tagName && el.tagName.toLowerCase() === 'a') {
-                       L.DomUtil.addClass(el, 'leaflet-active');
+       // methods below are called by vector layers implementations
+
+       _initPath: function (layer) {
+               var path = layer._path = L.SVG.create('path');
+
+               // @namespace Path
+               // @option className: String = null
+               // Custom class name set on an element. Only for SVG renderer.
+               if (layer.options.className) {
+                       L.DomUtil.addClass(path, layer.options.className);
                }
 
-               // simulate long hold but setting a timeout
-               this._holdTimeout = setTimeout(L.bind(function () {
-                       if (this._isTapValid()) {
-                               this._fireClick = false;
-                               this._onUp();
-                               this._simulateEvent('contextmenu', first);
-                       }
-               }, this), 1000);
+               if (layer.options.interactive) {
+                       L.DomUtil.addClass(path, 'leaflet-interactive');
+               }
 
-               L.DomEvent
-                       .on(document, 'touchmove', this._onMove, this)
-                       .on(document, 'touchend', this._onUp, this);
+               this._updateStyle(layer);
+               this._layers[L.stamp(layer)] = layer;
        },
 
-       _onUp: function (e) {
-               clearTimeout(this._holdTimeout);
+       _addPath: function (layer) {
+               this._rootGroup.appendChild(layer._path);
+               layer.addInteractiveTarget(layer._path);
+       },
 
-               L.DomEvent
-                       .off(document, 'touchmove', this._onMove, this)
-                       .off(document, 'touchend', this._onUp, this);
+       _removePath: function (layer) {
+               L.DomUtil.remove(layer._path);
+               layer.removeInteractiveTarget(layer._path);
+               delete this._layers[L.stamp(layer)];
+       },
 
-               if (this._fireClick && e && e.changedTouches) {
+       _updatePath: function (layer) {
+               layer._project();
+               layer._update();
+       },
 
-                       var first = e.changedTouches[0],
-                           el = first.target;
+       _updateStyle: function (layer) {
+               var path = layer._path,
+                   options = layer.options;
 
-                       if (el && el.tagName && el.tagName.toLowerCase() === 'a') {
-                               L.DomUtil.removeClass(el, 'leaflet-active');
+               if (!path) { return; }
+
+               if (options.stroke) {
+                       path.setAttribute('stroke', options.color);
+                       path.setAttribute('stroke-opacity', options.opacity);
+                       path.setAttribute('stroke-width', options.weight);
+                       path.setAttribute('stroke-linecap', options.lineCap);
+                       path.setAttribute('stroke-linejoin', options.lineJoin);
+
+                       if (options.dashArray) {
+                               path.setAttribute('stroke-dasharray', options.dashArray);
+                       } else {
+                               path.removeAttribute('stroke-dasharray');
                        }
 
-                       // simulate click if the touch didn't move too much
-                       if (this._isTapValid()) {
-                               this._simulateEvent('click', first);
+                       if (options.dashOffset) {
+                               path.setAttribute('stroke-dashoffset', options.dashOffset);
+                       } else {
+                               path.removeAttribute('stroke-dashoffset');
                        }
+               } else {
+                       path.setAttribute('stroke', 'none');
+               }
+
+               if (options.fill) {
+                       path.setAttribute('fill', options.fillColor || options.color);
+                       path.setAttribute('fill-opacity', options.fillOpacity);
+                       path.setAttribute('fill-rule', options.fillRule || 'evenodd');
+               } else {
+                       path.setAttribute('fill', 'none');
                }
        },
 
-       _isTapValid: function () {
-               return this._newPos.distanceTo(this._startPos) <= this._map.options.tapTolerance;
+       _updatePoly: function (layer, closed) {
+               this._setPath(layer, L.SVG.pointsToPath(layer._parts, closed));
        },
 
-       _onMove: function (e) {
-               var first = e.touches[0];
-               this._newPos = new L.Point(first.clientX, first.clientY);
+       _updateCircle: function (layer) {
+               var p = layer._point,
+                   r = layer._radius,
+                   r2 = layer._radiusY || r,
+                   arc = 'a' + r + ',' + r2 + ' 0 1,0 ';
+
+               // drawing a circle with two half-arcs
+               var d = layer._empty() ? 'M0 0' :
+                               'M' + (p.x - r) + ',' + p.y +
+                               arc + (r * 2) + ',0 ' +
+                               arc + (-r * 2) + ',0 ';
+
+               this._setPath(layer, d);
        },
 
-       _simulateEvent: function (type, e) {
-               var simulatedEvent = document.createEvent('MouseEvents');
+       _setPath: function (layer, path) {
+               layer._path.setAttribute('d', path);
+       },
 
-               simulatedEvent._simulated = true;
-               e.target._simulatedClick = true;
+       // SVG does not have the concept of zIndex so we resort to changing the DOM order of elements
+       _bringToFront: function (layer) {
+               L.DomUtil.toFront(layer._path);
+       },
 
-               simulatedEvent.initMouseEvent(
-                       type, true, true, window, 1,
-                       e.screenX, e.screenY,
-                       e.clientX, e.clientY,
-                       false, false, false, false, 0, null);
+       _bringToBack: function (layer) {
+               L.DomUtil.toBack(layer._path);
+       }
+});
 
-               e.target.dispatchEvent(simulatedEvent);
+
+// @namespace SVG; @section
+// There are several static functions which can be called without instantiating L.SVG:
+L.extend(L.SVG, {
+       // @function create(name: String): SVGElement
+       // Returns a instance of [SVGElement](https://developer.mozilla.org/docs/Web/API/SVGElement),
+       // corresponding to the class name passed. For example, using 'line' will return
+       // an instance of [SVGLineElement](https://developer.mozilla.org/docs/Web/API/SVGLineElement).
+       create: function (name) {
+               return document.createElementNS('http://www.w3.org/2000/svg', name);
+       },
+
+       // @function pointsToPath(rings: Point[], closed: Boolean): String
+       // Generates a SVG path string for multiple rings, with each ring turning
+       // into "M..L..L.." instructions
+       pointsToPath: function (rings, closed) {
+               var str = '',
+                   i, j, len, len2, points, p;
+
+               for (i = 0, len = rings.length; i < len; i++) {
+                       points = rings[i];
+
+                       for (j = 0, len2 = points.length; j < len2; j++) {
+                               p = points[j];
+                               str += (j ? 'L' : 'M') + p.x + ' ' + p.y;
+                       }
+
+                       // closes the ring for polygons; "x" is VML syntax
+                       str += closed ? (L.Browser.svg ? 'z' : 'x') : '';
+               }
+
+               // SVG complains about empty path strings
+               return str || 'M0 0';
        }
 });
 
-if (L.Browser.touch && !L.Browser.pointer) {
-       L.Map.addInitHook('addHandler', 'tap', L.Map.Tap);
-}
+// @namespace Browser; @property svg: Boolean
+// `true` when the browser supports [SVG](https://developer.mozilla.org/docs/Web/SVG).
+L.Browser.svg = !!(document.createElementNS && L.SVG.create('svg').createSVGRect);
+
+
+// @namespace SVG
+// @factory L.svg(options?: Renderer options)
+// Creates a SVG renderer with the given options.
+L.svg = function (options) {
+       return L.Browser.svg || L.Browser.vml ? new L.SVG(options) : null;
+};
+
 
 
 /*
- * L.Handler.ShiftDragZoom is used to add shift-drag zoom interaction to the map
-  * (zoom to a selected bounding box), enabled by default.
+ * Thanks to Dmitry Baranovsky and his Raphael library for inspiration!
  */
 
-L.Map.mergeOptions({
-       boxZoom: true
-});
+/*
+ * @class SVG
+ *
+ * Although SVG is not available on IE7 and IE8, these browsers support [VML](https://en.wikipedia.org/wiki/Vector_Markup_Language), and the SVG renderer will fall back to VML in this case.
+ *
+ * VML was deprecated in 2012, which means VML functionality exists only for backwards compatibility
+ * with old versions of Internet Explorer.
+ */
 
-L.Map.BoxZoom = L.Handler.extend({
-       initialize: function (map) {
-               this._map = map;
-               this._container = map._container;
-               this._pane = map._panes.overlayPane;
-               this._moved = false;
-       },
+// @namespace Browser; @property vml: Boolean
+// `true` if the browser supports [VML](https://en.wikipedia.org/wiki/Vector_Markup_Language).
+L.Browser.vml = !L.Browser.svg && (function () {
+       try {
+               var div = document.createElement('div');
+               div.innerHTML = '<v:shape adj="1"/>';
 
-       addHooks: function () {
-               L.DomEvent.on(this._container, 'mousedown', this._onMouseDown, this);
-       },
+               var shape = div.firstChild;
+               shape.style.behavior = 'url(#default#VML)';
 
-       removeHooks: function () {
-               L.DomEvent.off(this._container, 'mousedown', this._onMouseDown);
-               this._moved = false;
+               return shape && (typeof shape.adj === 'object');
+
+       } catch (e) {
+               return false;
+       }
+}());
+
+// redefine some SVG methods to handle VML syntax which is similar but with some differences
+L.SVG.include(!L.Browser.vml ? {} : {
+
+       _initContainer: function () {
+               this._container = L.DomUtil.create('div', 'leaflet-vml-container');
        },
 
-       moved: function () {
-               return this._moved;
+       _update: function () {
+               if (this._map._animatingZoom) { return; }
+               L.Renderer.prototype._update.call(this);
+               this.fire('update');
        },
 
-       _onMouseDown: function (e) {
-               this._moved = false;
+       _initPath: function (layer) {
+               var container = layer._container = L.SVG.create('shape');
 
-               if (!e.shiftKey || ((e.which !== 1) && (e.button !== 1))) { return false; }
+               L.DomUtil.addClass(container, 'leaflet-vml-shape ' + (this.options.className || ''));
 
-               L.DomUtil.disableTextSelection();
-               L.DomUtil.disableImageDrag();
+               container.coordsize = '1 1';
 
-               this._startLayerPoint = this._map.mouseEventToLayerPoint(e);
+               layer._path = L.SVG.create('path');
+               container.appendChild(layer._path);
 
-               L.DomEvent
-                   .on(document, 'mousemove', this._onMouseMove, this)
-                   .on(document, 'mouseup', this._onMouseUp, this)
-                   .on(document, 'keydown', this._onKeyDown, this);
+               this._updateStyle(layer);
+               this._layers[L.stamp(layer)] = layer;
        },
 
-       _onMouseMove: function (e) {
-               if (!this._moved) {
-                       this._box = L.DomUtil.create('div', 'leaflet-zoom-box', this._pane);
-                       L.DomUtil.setPosition(this._box, this._startLayerPoint);
+       _addPath: function (layer) {
+               var container = layer._container;
+               this._container.appendChild(container);
 
-                       //TODO refactor: move cursor to styles
-                       this._container.style.cursor = 'crosshair';
-                       this._map.fire('boxzoomstart');
+               if (layer.options.interactive) {
+                       layer.addInteractiveTarget(container);
                }
+       },
 
-               var startPoint = this._startLayerPoint,
-                   box = this._box,
-
-                   layerPoint = this._map.mouseEventToLayerPoint(e),
-                   offset = layerPoint.subtract(startPoint),
-
-                   newPos = new L.Point(
-                       Math.min(layerPoint.x, startPoint.x),
-                       Math.min(layerPoint.y, startPoint.y));
+       _removePath: function (layer) {
+               var container = layer._container;
+               L.DomUtil.remove(container);
+               layer.removeInteractiveTarget(container);
+               delete this._layers[L.stamp(layer)];
+       },
 
-               L.DomUtil.setPosition(box, newPos);
+       _updateStyle: function (layer) {
+               var stroke = layer._stroke,
+                   fill = layer._fill,
+                   options = layer.options,
+                   container = layer._container;
 
-               this._moved = true;
+               container.stroked = !!options.stroke;
+               container.filled = !!options.fill;
 
-               // TODO refactor: remove hardcoded 4 pixels
-               box.style.width  = (Math.max(0, Math.abs(offset.x) - 4)) + 'px';
-               box.style.height = (Math.max(0, Math.abs(offset.y) - 4)) + 'px';
-       },
+               if (options.stroke) {
+                       if (!stroke) {
+                               stroke = layer._stroke = L.SVG.create('stroke');
+                       }
+                       container.appendChild(stroke);
+                       stroke.weight = options.weight + 'px';
+                       stroke.color = options.color;
+                       stroke.opacity = options.opacity;
+
+                       if (options.dashArray) {
+                               stroke.dashStyle = L.Util.isArray(options.dashArray) ?
+                                   options.dashArray.join(' ') :
+                                   options.dashArray.replace(/( *, *)/g, ' ');
+                       } else {
+                               stroke.dashStyle = '';
+                       }
+                       stroke.endcap = options.lineCap.replace('butt', 'flat');
+                       stroke.joinstyle = options.lineJoin;
 
-       _finish: function () {
-               if (this._moved) {
-                       this._pane.removeChild(this._box);
-                       this._container.style.cursor = '';
+               } else if (stroke) {
+                       container.removeChild(stroke);
+                       layer._stroke = null;
                }
 
-               L.DomUtil.enableTextSelection();
-               L.DomUtil.enableImageDrag();
+               if (options.fill) {
+                       if (!fill) {
+                               fill = layer._fill = L.SVG.create('fill');
+                       }
+                       container.appendChild(fill);
+                       fill.color = options.fillColor || options.color;
+                       fill.opacity = options.fillOpacity;
 
-               L.DomEvent
-                   .off(document, 'mousemove', this._onMouseMove)
-                   .off(document, 'mouseup', this._onMouseUp)
-                   .off(document, 'keydown', this._onKeyDown);
+               } else if (fill) {
+                       container.removeChild(fill);
+                       layer._fill = null;
+               }
        },
 
-       _onMouseUp: function (e) {
-
-               this._finish();
-
-               var map = this._map,
-                   layerPoint = map.mouseEventToLayerPoint(e);
-
-               if (this._startLayerPoint.equals(layerPoint)) { return; }
+       _updateCircle: function (layer) {
+               var p = layer._point.round(),
+                   r = Math.round(layer._radius),
+                   r2 = Math.round(layer._radiusY || r);
 
-               var bounds = new L.LatLngBounds(
-                       map.layerPointToLatLng(this._startLayerPoint),
-                       map.layerPointToLatLng(layerPoint));
+               this._setPath(layer, layer._empty() ? 'M0 0' :
+                               'AL ' + p.x + ',' + p.y + ' ' + r + ',' + r2 + ' 0,' + (65535 * 360));
+       },
 
-               map.fitBounds(bounds);
+       _setPath: function (layer, path) {
+               layer._path.v = path;
+       },
 
-               map.fire('boxzoomend', {
-                       boxZoomBounds: bounds
-               });
+       _bringToFront: function (layer) {
+               L.DomUtil.toFront(layer._container);
        },
 
-       _onKeyDown: function (e) {
-               if (e.keyCode === 27) {
-                       this._finish();
-               }
+       _bringToBack: function (layer) {
+               L.DomUtil.toBack(layer._container);
        }
 });
 
-L.Map.addInitHook('addHandler', 'boxZoom', L.Map.BoxZoom);
+if (L.Browser.vml) {
+       L.SVG.create = (function () {
+               try {
+                       document.namespaces.add('lvml', 'urn:schemas-microsoft-com:vml');
+                       return function (name) {
+                               return document.createElement('<lvml:' + name + ' class="lvml">');
+                       };
+               } catch (e) {
+                       return function (name) {
+                               return document.createElement('<' + name + ' xmlns="urn:schemas-microsoft.com:vml" class="lvml">');
+                       };
+               }
+       })();
+}
+
 
 
 /*
- * L.Map.Keyboard is handling keyboard interaction with the map, enabled by default.
+ * @class Canvas
+ * @inherits Renderer
+ * @aka L.Canvas
+ *
+ * Allows vector layers to be displayed with [`<canvas>`](https://developer.mozilla.org/docs/Web/API/Canvas_API).
+ * Inherits `Renderer`.
+ *
+ * Due to [technical limitations](http://caniuse.com/#search=canvas), Canvas is not
+ * available in all web browsers, notably IE8, and overlapping geometries might
+ * not display properly in some edge cases.
+ *
+ * @example
+ *
+ * Use Canvas by default for all paths in the map:
+ *
+ * ```js
+ * var map = L.map('map', {
+ *     renderer: L.canvas()
+ * });
+ * ```
+ *
+ * Use a Canvas renderer with extra padding for specific vector geometries:
+ *
+ * ```js
+ * var map = L.map('map');
+ * var myRenderer = L.canvas({ padding: 0.5 });
+ * var line = L.polyline( coordinates, { renderer: myRenderer } );
+ * var circle = L.circle( center, { renderer: myRenderer } );
+ * ```
  */
 
-L.Map.mergeOptions({
-       keyboard: true,
-       keyboardPanOffset: 80,
-       keyboardZoomOffset: 1
-});
+L.Canvas = L.Renderer.extend({
+       getEvents: function () {
+               var events = L.Renderer.prototype.getEvents.call(this);
+               events.viewprereset = this._onViewPreReset;
+               return events;
+       },
 
-L.Map.Keyboard = L.Handler.extend({
+       _onViewPreReset: function () {
+               // Set a flag so that a viewprereset+moveend+viewreset only updates&redraws once
+               this._postponeUpdatePaths = true;
+       },
 
-       keyCodes: {
-               left:    [37],
-               right:   [39],
-               down:    [40],
-               up:      [38],
-               zoomIn:  [187, 107, 61, 171],
-               zoomOut: [189, 109, 173]
+       onAdd: function () {
+               L.Renderer.prototype.onAdd.call(this);
+
+               // Redraw vectors since canvas is cleared upon removal,
+               // in case of removing the renderer itself from the map.
+               this._draw();
        },
 
-       initialize: function (map) {
-               this._map = map;
+       _initContainer: function () {
+               var container = this._container = document.createElement('canvas');
+
+               L.DomEvent
+                       .on(container, 'mousemove', L.Util.throttle(this._onMouseMove, 32, this), this)
+                       .on(container, 'click dblclick mousedown mouseup contextmenu', this._onClick, this)
+                       .on(container, 'mouseout', this._handleMouseOut, this);
 
-               this._setPanOffset(map.options.keyboardPanOffset);
-               this._setZoomOffset(map.options.keyboardZoomOffset);
+               this._ctx = container.getContext('2d');
        },
 
-       addHooks: function () {
-               var container = this._map._container;
+       _updatePaths: function () {
+               if (this._postponeUpdatePaths) { return; }
 
-               // make the container focusable by tabbing
-               if (container.tabIndex === -1) {
-                       container.tabIndex = '0';
+               var layer;
+               this._redrawBounds = null;
+               for (var id in this._layers) {
+                       layer = this._layers[id];
+                       layer._update();
                }
+               this._redraw();
+       },
 
-               L.DomEvent
-                   .on(container, 'focus', this._onFocus, this)
-                   .on(container, 'blur', this._onBlur, this)
-                   .on(container, 'mousedown', this._onMouseDown, this);
+       _update: function () {
+               if (this._map._animatingZoom && this._bounds) { return; }
 
-               this._map
-                   .on('focus', this._addHooks, this)
-                   .on('blur', this._removeHooks, this);
-       },
+               this._drawnLayers = {};
 
-       removeHooks: function () {
-               this._removeHooks();
+               L.Renderer.prototype._update.call(this);
 
-               var container = this._map._container;
+               var b = this._bounds,
+                   container = this._container,
+                   size = b.getSize(),
+                   m = L.Browser.retina ? 2 : 1;
 
-               L.DomEvent
-                   .off(container, 'focus', this._onFocus, this)
-                   .off(container, 'blur', this._onBlur, this)
-                   .off(container, 'mousedown', this._onMouseDown, this);
+               L.DomUtil.setPosition(container, b.min);
 
-               this._map
-                   .off('focus', this._addHooks, this)
-                   .off('blur', this._removeHooks, this);
-       },
+               // set canvas size (also clearing it); use double size on retina
+               container.width = m * size.x;
+               container.height = m * size.y;
+               container.style.width = size.x + 'px';
+               container.style.height = size.y + 'px';
 
-       _onMouseDown: function () {
-               if (this._focused) { return; }
+               if (L.Browser.retina) {
+                       this._ctx.scale(2, 2);
+               }
 
-               var body = document.body,
-                   docEl = document.documentElement,
-                   top = body.scrollTop || docEl.scrollTop,
-                   left = body.scrollLeft || docEl.scrollLeft;
+               // translate so we use the same path coordinates after canvas element moves
+               this._ctx.translate(-b.min.x, -b.min.y);
 
-               this._map._container.focus();
+               // Tell paths to redraw themselves
+               this.fire('update');
+       },
 
-               window.scrollTo(left, top);
+       _reset: function () {
+               L.Renderer.prototype._reset.call(this);
+
+               if (this._postponeUpdatePaths) {
+                       this._postponeUpdatePaths = false;
+                       this._updatePaths();
+               }
        },
 
-       _onFocus: function () {
-               this._focused = true;
-               this._map.fire('focus');
+       _initPath: function (layer) {
+               this._updateDashArray(layer);
+               this._layers[L.stamp(layer)] = layer;
+
+               var order = layer._order = {
+                       layer: layer,
+                       prev: this._drawLast,
+                       next: null
+               };
+               if (this._drawLast) { this._drawLast.next = order; }
+               this._drawLast = order;
+               this._drawFirst = this._drawFirst || this._drawLast;
        },
 
-       _onBlur: function () {
-               this._focused = false;
-               this._map.fire('blur');
+       _addPath: function (layer) {
+               this._requestRedraw(layer);
        },
 
-       _setPanOffset: function (pan) {
-               var keys = this._panKeys = {},
-                   codes = this.keyCodes,
-                   i, len;
+       _removePath: function (layer) {
+               var order = layer._order;
+               var next = order.next;
+               var prev = order.prev;
 
-               for (i = 0, len = codes.left.length; i < len; i++) {
-                       keys[codes.left[i]] = [-1 * pan, 0];
-               }
-               for (i = 0, len = codes.right.length; i < len; i++) {
-                       keys[codes.right[i]] = [pan, 0];
-               }
-               for (i = 0, len = codes.down.length; i < len; i++) {
-                       keys[codes.down[i]] = [0, pan];
+               if (next) {
+                       next.prev = prev;
+               } else {
+                       this._drawLast = prev;
                }
-               for (i = 0, len = codes.up.length; i < len; i++) {
-                       keys[codes.up[i]] = [0, -1 * pan];
+               if (prev) {
+                       prev.next = next;
+               } else {
+                       this._drawFirst = next;
                }
+
+               delete layer._order;
+
+               delete this._layers[L.stamp(layer)];
+
+               this._requestRedraw(layer);
        },
 
-       _setZoomOffset: function (zoom) {
-               var keys = this._zoomKeys = {},
-                   codes = this.keyCodes,
-                   i, len;
+       _updatePath: function (layer) {
+               // Redraw the union of the layer's old pixel
+               // bounds and the new pixel bounds.
+               this._extendRedrawBounds(layer);
+               layer._project();
+               layer._update();
+               // The redraw will extend the redraw bounds
+               // with the new pixel bounds.
+               this._requestRedraw(layer);
+       },
 
-               for (i = 0, len = codes.zoomIn.length; i < len; i++) {
-                       keys[codes.zoomIn[i]] = zoom;
+       _updateStyle: function (layer) {
+               this._updateDashArray(layer);
+               this._requestRedraw(layer);
+       },
+
+       _updateDashArray: function (layer) {
+               if (layer.options.dashArray) {
+                       var parts = layer.options.dashArray.split(','),
+                           dashArray = [],
+                           i;
+                       for (i = 0; i < parts.length; i++) {
+                               dashArray.push(Number(parts[i]));
+                       }
+                       layer.options._dashArray = dashArray;
                }
-               for (i = 0, len = codes.zoomOut.length; i < len; i++) {
-                       keys[codes.zoomOut[i]] = -zoom;
+       },
+
+       _requestRedraw: function (layer) {
+               if (!this._map) { return; }
+
+               this._extendRedrawBounds(layer);
+               this._redrawRequest = this._redrawRequest || L.Util.requestAnimFrame(this._redraw, this);
+       },
+
+       _extendRedrawBounds: function (layer) {
+               var padding = (layer.options.weight || 0) + 1;
+               this._redrawBounds = this._redrawBounds || new L.Bounds();
+               this._redrawBounds.extend(layer._pxBounds.min.subtract([padding, padding]));
+               this._redrawBounds.extend(layer._pxBounds.max.add([padding, padding]));
+       },
+
+       _redraw: function () {
+               this._redrawRequest = null;
+
+               if (this._redrawBounds) {
+                       this._redrawBounds.min._floor();
+                       this._redrawBounds.max._ceil();
                }
+
+               this._clear(); // clear layers in redraw bounds
+               this._draw(); // draw layers
+
+               this._redrawBounds = null;
        },
 
-       _addHooks: function () {
-               L.DomEvent.on(document, 'keydown', this._onKeyDown, this);
+       _clear: function () {
+               var bounds = this._redrawBounds;
+               if (bounds) {
+                       var size = bounds.getSize();
+                       this._ctx.clearRect(bounds.min.x, bounds.min.y, size.x, size.y);
+               } else {
+                       this._ctx.clearRect(0, 0, this._container.width, this._container.height);
+               }
        },
 
-       _removeHooks: function () {
-               L.DomEvent.off(document, 'keydown', this._onKeyDown, this);
+       _draw: function () {
+               var layer, bounds = this._redrawBounds;
+               this._ctx.save();
+               if (bounds) {
+                       var size = bounds.getSize();
+                       this._ctx.beginPath();
+                       this._ctx.rect(bounds.min.x, bounds.min.y, size.x, size.y);
+                       this._ctx.clip();
+               }
+
+               this._drawing = true;
+
+               for (var order = this._drawFirst; order; order = order.next) {
+                       layer = order.layer;
+                       if (!bounds || (layer._pxBounds && layer._pxBounds.intersects(bounds))) {
+                               layer._updatePath();
+                       }
+               }
+
+               this._drawing = false;
+
+               this._ctx.restore();  // Restore state before clipping.
        },
 
-       _onKeyDown: function (e) {
-               var key = e.keyCode,
-                   map = this._map;
+       _updatePoly: function (layer, closed) {
+               if (!this._drawing) { return; }
 
-               if (key in this._panKeys) {
+               var i, j, len2, p,
+                   parts = layer._parts,
+                   len = parts.length,
+                   ctx = this._ctx;
 
-                       if (map._panAnim && map._panAnim._inProgress) { return; }
+               if (!len) { return; }
 
-                       map.panBy(this._panKeys[key]);
+               this._drawnLayers[layer._leaflet_id] = layer;
 
-                       if (map.options.maxBounds) {
-                               map.panInsideBounds(map.options.maxBounds);
+               ctx.beginPath();
+
+               if (ctx.setLineDash) {
+                       ctx.setLineDash(layer.options && layer.options._dashArray || []);
+               }
+
+               for (i = 0; i < len; i++) {
+                       for (j = 0, len2 = parts[i].length; j < len2; j++) {
+                               p = parts[i][j];
+                               ctx[j ? 'lineTo' : 'moveTo'](p.x, p.y);
                        }
+                       if (closed) {
+                               ctx.closePath();
+                       }
+               }
 
-               } else if (key in this._zoomKeys) {
-                       map.setZoom(map.getZoom() + this._zoomKeys[key]);
+               this._fillStroke(ctx, layer);
 
-               } else {
-                       return;
+               // TODO optimization: 1 fill/stroke for all features with equal style instead of 1 for each feature
+       },
+
+       _updateCircle: function (layer) {
+
+               if (!this._drawing || layer._empty()) { return; }
+
+               var p = layer._point,
+                   ctx = this._ctx,
+                   r = layer._radius,
+                   s = (layer._radiusY || r) / r;
+
+               this._drawnLayers[layer._leaflet_id] = layer;
+
+               if (s !== 1) {
+                       ctx.save();
+                       ctx.scale(1, s);
                }
 
-               L.DomEvent.stop(e);
-       }
-});
+               ctx.beginPath();
+               ctx.arc(p.x, p.y / s, r, 0, Math.PI * 2, false);
 
-L.Map.addInitHook('addHandler', 'keyboard', L.Map.Keyboard);
+               if (s !== 1) {
+                       ctx.restore();
+               }
 
+               this._fillStroke(ctx, layer);
+       },
 
-/*
- * L.Handler.MarkerDrag is used internally by L.Marker to make the markers draggable.
- */
+       _fillStroke: function (ctx, layer) {
+               var options = layer.options;
 
-L.Handler.MarkerDrag = L.Handler.extend({
-       initialize: function (marker) {
-               this._marker = marker;
+               if (options.fill) {
+                       ctx.globalAlpha = options.fillOpacity;
+                       ctx.fillStyle = options.fillColor || options.color;
+                       ctx.fill(options.fillRule || 'evenodd');
+               }
+
+               if (options.stroke && options.weight !== 0) {
+                       ctx.globalAlpha = options.opacity;
+                       ctx.lineWidth = options.weight;
+                       ctx.strokeStyle = options.color;
+                       ctx.lineCap = options.lineCap;
+                       ctx.lineJoin = options.lineJoin;
+                       ctx.stroke();
+               }
        },
 
-       addHooks: function () {
-               var icon = this._marker._icon;
-               if (!this._draggable) {
-                       this._draggable = new L.Draggable(icon, icon);
+       // Canvas obviously doesn't have mouse events for individual drawn objects,
+       // so we emulate that by calculating what's under the mouse on mousemove/click manually
+
+       _onClick: function (e) {
+               var point = this._map.mouseEventToLayerPoint(e), layer, clickedLayer;
+
+               for (var order = this._drawFirst; order; order = order.next) {
+                       layer = order.layer;
+                       if (layer.options.interactive && layer._containsPoint(point) && !this._map._draggableMoved(layer)) {
+                               clickedLayer = layer;
+                       }
                }
+               if (clickedLayer)  {
+                       L.DomEvent._fakeStop(e);
+                       this._fireEvent([clickedLayer], e);
+               }
+       },
 
-               this._draggable
-                       .on('dragstart', this._onDragStart, this)
-                       .on('drag', this._onDrag, this)
-                       .on('dragend', this._onDragEnd, this);
-               this._draggable.enable();
-               L.DomUtil.addClass(this._marker._icon, 'leaflet-marker-draggable');
+       _onMouseMove: function (e) {
+               if (!this._map || this._map.dragging.moving() || this._map._animatingZoom) { return; }
+
+               var point = this._map.mouseEventToLayerPoint(e);
+               this._handleMouseHover(e, point);
        },
 
-       removeHooks: function () {
-               this._draggable
-                       .off('dragstart', this._onDragStart, this)
-                       .off('drag', this._onDrag, this)
-                       .off('dragend', this._onDragEnd, this);
 
-               this._draggable.disable();
-               L.DomUtil.removeClass(this._marker._icon, 'leaflet-marker-draggable');
+       _handleMouseOut: function (e) {
+               var layer = this._hoveredLayer;
+               if (layer) {
+                       // if we're leaving the layer, fire mouseout
+                       L.DomUtil.removeClass(this._container, 'leaflet-interactive');
+                       this._fireEvent([layer], e, 'mouseout');
+                       this._hoveredLayer = null;
+               }
        },
 
-       moved: function () {
-               return this._draggable && this._draggable._moved;
+       _handleMouseHover: function (e, point) {
+               var layer, candidateHoveredLayer;
+
+               for (var order = this._drawFirst; order; order = order.next) {
+                       layer = order.layer;
+                       if (layer.options.interactive && layer._containsPoint(point)) {
+                               candidateHoveredLayer = layer;
+                       }
+               }
+
+               if (candidateHoveredLayer !== this._hoveredLayer) {
+                       this._handleMouseOut(e);
+
+                       if (candidateHoveredLayer) {
+                               L.DomUtil.addClass(this._container, 'leaflet-interactive'); // change cursor
+                               this._fireEvent([candidateHoveredLayer], e, 'mouseover');
+                               this._hoveredLayer = candidateHoveredLayer;
+                       }
+               }
+
+               if (this._hoveredLayer) {
+                       this._fireEvent([this._hoveredLayer], e);
+               }
        },
 
-       _onDragStart: function () {
-               this._marker
-                   .closePopup()
-                   .fire('movestart')
-                   .fire('dragstart');
+       _fireEvent: function (layers, e, type) {
+               this._map._fireDOMEvent(e, type || e.type, layers);
        },
 
-       _onDrag: function () {
-               var marker = this._marker,
-                   shadow = marker._shadow,
-                   iconPos = L.DomUtil.getPosition(marker._icon),
-                   latlng = marker._map.layerPointToLatLng(iconPos);
+       _bringToFront: function (layer) {
+               var order = layer._order;
+               var next = order.next;
+               var prev = order.prev;
 
-               // update shadow position
-               if (shadow) {
-                       L.DomUtil.setPosition(shadow, iconPos);
+               if (next) {
+                       next.prev = prev;
+               } else {
+                       // Already last
+                       return;
+               }
+               if (prev) {
+                       prev.next = next;
+               } else if (next) {
+                       // Update first entry unless this is the
+                       // signle entry
+                       this._drawFirst = next;
                }
 
-               marker._latlng = latlng;
+               order.prev = this._drawLast;
+               this._drawLast.next = order;
 
-               marker
-                   .fire('move', {latlng: latlng})
-                   .fire('drag');
+               order.next = null;
+               this._drawLast = order;
+
+               this._requestRedraw(layer);
        },
 
-       _onDragEnd: function (e) {
-               this._marker
-                   .fire('moveend')
-                   .fire('dragend', e);
+       _bringToBack: function (layer) {
+               var order = layer._order;
+               var next = order.next;
+               var prev = order.prev;
+
+               if (prev) {
+                       prev.next = next;
+               } else {
+                       // Already first
+                       return;
+               }
+               if (next) {
+                       next.prev = prev;
+               } else if (prev) {
+                       // Update last entry unless this is the
+                       // signle entry
+                       this._drawLast = prev;
+               }
+
+               order.prev = null;
+
+               order.next = this._drawFirst;
+               this._drawFirst.prev = order;
+               this._drawFirst = order;
+
+               this._requestRedraw(layer);
        }
 });
 
+// @namespace Browser; @property canvas: Boolean
+// `true` when the browser supports [`<canvas>`](https://developer.mozilla.org/docs/Web/API/Canvas_API).
+L.Browser.canvas = (function () {
+       return !!document.createElement('canvas').getContext;
+}());
+
+// @namespace Canvas
+// @factory L.canvas(options?: Renderer options)
+// Creates a Canvas renderer with the given options.
+L.canvas = function (options) {
+       return L.Browser.canvas ? new L.Canvas(options) : null;
+};
+
+L.Polyline.prototype._containsPoint = function (p, closed) {
+       var i, j, k, len, len2, part,
+           w = this._clickTolerance();
+
+       if (!this._pxBounds.contains(p)) { return false; }
+
+       // hit detection for polylines
+       for (i = 0, len = this._parts.length; i < len; i++) {
+               part = this._parts[i];
+
+               for (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) {
+                       if (!closed && (j === 0)) { continue; }
+
+                       if (L.LineUtil.pointToSegmentDistance(p, part[k], part[j]) <= w) {
+                               return true;
+                       }
+               }
+       }
+       return false;
+};
+
+L.Polygon.prototype._containsPoint = function (p) {
+       var inside = false,
+           part, p1, p2, i, j, k, len, len2;
+
+       if (!this._pxBounds.contains(p)) { return false; }
+
+       // ray casting algorithm for detecting if point is in polygon
+       for (i = 0, len = this._parts.length; i < len; i++) {
+               part = this._parts[i];
+
+               for (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) {
+                       p1 = part[j];
+                       p2 = part[k];
+
+                       if (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) {
+                               inside = !inside;
+                       }
+               }
+       }
+
+       // also check if it's on polygon stroke
+       return inside || L.Polyline.prototype._containsPoint.call(this, p, true);
+};
+
+L.CircleMarker.prototype._containsPoint = function (p) {
+       return p.distanceTo(this._point) <= this._radius + this._clickTolerance();
+};
+
+
 
 /*\r
- * L.Control is a base class for implementing map controls. Handles positioning.\r
- * All other controls extend from this class.\r
+ * @class GeoJSON\r
+ * @aka L.GeoJSON\r
+ * @inherits FeatureGroup\r
+ *\r
+ * Represents a GeoJSON object or an array of GeoJSON objects. Allows you to parse\r
+ * GeoJSON data and display it on the map. Extends `FeatureGroup`.\r
+ *\r
+ * @example\r
+ *\r
+ * ```js\r
+ * L.geoJSON(data, {\r
+ *     style: function (feature) {\r
+ *             return {color: feature.properties.color};\r
+ *     }\r
+ * }).bindPopup(function (layer) {\r
+ *     return layer.feature.properties.description;\r
+ * }).addTo(map);\r
+ * ```\r
  */\r
 \r
-L.Control = L.Class.extend({\r
-       options: {\r
-               position: 'topright'\r
-       },\r
+L.GeoJSON = L.FeatureGroup.extend({\r
 \r
-       initialize: function (options) {\r
+       /* @section\r
+        * @aka GeoJSON options\r
+        *\r
+        * @option pointToLayer: Function = *\r
+        * A `Function` defining how GeoJSON points spawn Leaflet layers. It is internally\r
+        * called when data is added, passing the GeoJSON point feature and its `LatLng`.\r
+        * The default is to spawn a default `Marker`:\r
+        * ```js\r
+        * function(geoJsonPoint, latlng) {\r
+        *      return L.marker(latlng);\r
+        * }\r
+        * ```\r
+        *\r
+        * @option style: Function = *\r
+        * A `Function` defining the `Path options` for styling GeoJSON lines and polygons,\r
+        * called internally when data is added.\r
+        * The default value is to not override any defaults:\r
+        * ```js\r
+        * function (geoJsonFeature) {\r
+        *      return {}\r
+        * }\r
+        * ```\r
+        *\r
+        * @option onEachFeature: Function = *\r
+        * A `Function` that will be called once for each created `Feature`, after it has\r
+        * been created and styled. Useful for attaching events and popups to features.\r
+        * The default is to do nothing with the newly created layers:\r
+        * ```js\r
+        * function (feature, layer) {}\r
+        * ```\r
+        *\r
+        * @option filter: Function = *\r
+        * A `Function` that will be used to decide whether to include a feature or not.\r
+        * The default is to include all features:\r
+        * ```js\r
+        * function (geoJsonFeature) {\r
+        *      return true;\r
+        * }\r
+        * ```\r
+        * Note: dynamically changing the `filter` option will have effect only on newly\r
+        * added data. It will _not_ re-evaluate already included features.\r
+        *\r
+        * @option coordsToLatLng: Function = *\r
+        * A `Function` that will be used for converting GeoJSON coordinates to `LatLng`s.\r
+        * The default is the `coordsToLatLng` static method.\r
+        */\r
+\r
+       initialize: function (geojson, options) {\r
                L.setOptions(this, options);\r
-       },\r
 \r
-       getPosition: function () {\r
-               return this.options.position;\r
+               this._layers = {};\r
+\r
+               if (geojson) {\r
+                       this.addData(geojson);\r
+               }\r
        },\r
 \r
-       setPosition: function (position) {\r
-               var map = this._map;\r
+       // @method addData( <GeoJSON> data ): this\r
+       // Adds a GeoJSON object to the layer.\r
+       addData: function (geojson) {\r
+               var features = L.Util.isArray(geojson) ? geojson : geojson.features,\r
+                   i, len, feature;\r
 \r
-               if (map) {\r
-                       map.removeControl(this);\r
+               if (features) {\r
+                       for (i = 0, len = features.length; i < len; i++) {\r
+                               // only add this if geometry or geometries are set and not null\r
+                               feature = features[i];\r
+                               if (feature.geometries || feature.geometry || feature.features || feature.coordinates) {\r
+                                       this.addData(feature);\r
+                               }\r
+                       }\r
+                       return this;\r
                }\r
 \r
-               this.options.position = position;\r
+               var options = this.options;\r
 \r
-               if (map) {\r
-                       map.addControl(this);\r
+               if (options.filter && !options.filter(geojson)) { return this; }\r
+\r
+               var layer = L.GeoJSON.geometryToLayer(geojson, options);\r
+               if (!layer) {\r
+                       return this;\r
                }\r
+               layer.feature = L.GeoJSON.asFeature(geojson);\r
 \r
-               return this;\r
-       },\r
+               layer.defaultOptions = layer.options;\r
+               this.resetStyle(layer);\r
 \r
-       getContainer: function () {\r
-               return this._container;\r
-       },\r
+               if (options.onEachFeature) {\r
+                       options.onEachFeature(geojson, layer);\r
+               }\r
 \r
-       addTo: function (map) {\r
-               this._map = map;\r
+               return this.addLayer(layer);\r
+       },\r
 \r
-               var container = this._container = this.onAdd(map),\r
-                   pos = this.getPosition(),\r
-                   corner = map._controlCorners[pos];\r
+       // @method resetStyle( <Path> layer ): this\r
+       // Resets the given vector layer's style to the original GeoJSON style, useful for resetting style after hover events.\r
+       resetStyle: function (layer) {\r
+               // reset any custom styles\r
+               layer.options = L.Util.extend({}, layer.defaultOptions);\r
+               this._setLayerStyle(layer, this.options.style);\r
+               return this;\r
+       },\r
 \r
-               L.DomUtil.addClass(container, 'leaflet-control');\r
+       // @method setStyle( <Function> style ): this\r
+       // Changes styles of GeoJSON vector layers with the given style function.\r
+       setStyle: function (style) {\r
+               return this.eachLayer(function (layer) {\r
+                       this._setLayerStyle(layer, style);\r
+               }, this);\r
+       },\r
 \r
-               if (pos.indexOf('bottom') !== -1) {\r
-                       corner.insertBefore(container, corner.firstChild);\r
-               } else {\r
-                       corner.appendChild(container);\r
+       _setLayerStyle: function (layer, style) {\r
+               if (typeof style === 'function') {\r
+                       style = style(layer.feature);\r
                }\r
+               if (layer.setStyle) {\r
+                       layer.setStyle(style);\r
+               }\r
+       }\r
+});\r
 \r
-               return this;\r
-       },\r
-\r
-       removeFrom: function (map) {\r
-               var pos = this.getPosition(),\r
-                   corner = map._controlCorners[pos];\r
+// @section\r
+// There are several static functions which can be called without instantiating L.GeoJSON:\r
+L.extend(L.GeoJSON, {\r
+       // @function geometryToLayer(featureData: Object, options?: GeoJSON options): Layer\r
+       // Creates a `Layer` from a given GeoJSON feature. Can use a custom\r
+       // [`pointToLayer`](#geojson-pointtolayer) and/or [`coordsToLatLng`](#geojson-coordstolatlng)\r
+       // functions if provided as options.\r
+       geometryToLayer: function (geojson, options) {\r
 \r
-               corner.removeChild(this._container);\r
-               this._map = null;\r
+               var geometry = geojson.type === 'Feature' ? geojson.geometry : geojson,\r
+                   coords = geometry ? geometry.coordinates : null,\r
+                   layers = [],\r
+                   pointToLayer = options && options.pointToLayer,\r
+                   coordsToLatLng = options && options.coordsToLatLng || this.coordsToLatLng,\r
+                   latlng, latlngs, i, len;\r
 \r
-               if (this.onRemove) {\r
-                       this.onRemove(map);\r
+               if (!coords && !geometry) {\r
+                       return null;\r
                }\r
 \r
-               return this;\r
-       },\r
+               switch (geometry.type) {\r
+               case 'Point':\r
+                       latlng = coordsToLatLng(coords);\r
+                       return pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng);\r
 \r
-       _refocusOnMap: function () {\r
-               if (this._map) {\r
-                       this._map.getContainer().focus();\r
+               case 'MultiPoint':\r
+                       for (i = 0, len = coords.length; i < len; i++) {\r
+                               latlng = coordsToLatLng(coords[i]);\r
+                               layers.push(pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng));\r
+                       }\r
+                       return new L.FeatureGroup(layers);\r
+\r
+               case 'LineString':\r
+               case 'MultiLineString':\r
+                       latlngs = this.coordsToLatLngs(coords, geometry.type === 'LineString' ? 0 : 1, coordsToLatLng);\r
+                       return new L.Polyline(latlngs, options);\r
+\r
+               case 'Polygon':\r
+               case 'MultiPolygon':\r
+                       latlngs = this.coordsToLatLngs(coords, geometry.type === 'Polygon' ? 1 : 2, coordsToLatLng);\r
+                       return new L.Polygon(latlngs, options);\r
+\r
+               case 'GeometryCollection':\r
+                       for (i = 0, len = geometry.geometries.length; i < len; i++) {\r
+                               var layer = this.geometryToLayer({\r
+                                       geometry: geometry.geometries[i],\r
+                                       type: 'Feature',\r
+                                       properties: geojson.properties\r
+                               }, options);\r
+\r
+                               if (layer) {\r
+                                       layers.push(layer);\r
+                               }\r
+                       }\r
+                       return new L.FeatureGroup(layers);\r
+\r
+               default:\r
+                       throw new Error('Invalid GeoJSON object.');\r
                }\r
-       }\r
-});\r
+       },\r
 \r
-L.control = function (options) {\r
-       return new L.Control(options);\r
-};\r
+       // @function coordsToLatLng(coords: Array): LatLng\r
+       // Creates a `LatLng` object from an array of 2 numbers (longitude, latitude)\r
+       // or 3 numbers (longitude, latitude, altitude) used in GeoJSON for points.\r
+       coordsToLatLng: function (coords) {\r
+               return new L.LatLng(coords[1], coords[0], coords[2]);\r
+       },\r
+\r
+       // @function coordsToLatLngs(coords: Array, levelsDeep?: Number, coordsToLatLng?: Function): Array\r
+       // Creates a multidimensional array of `LatLng`s from a GeoJSON coordinates array.\r
+       // `levelsDeep` specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default).\r
+       // Can use a custom [`coordsToLatLng`](#geojson-coordstolatlng) function.\r
+       coordsToLatLngs: function (coords, levelsDeep, coordsToLatLng) {\r
+               var latlngs = [];\r
 \r
+               for (var i = 0, len = coords.length, latlng; i < len; i++) {\r
+                       latlng = levelsDeep ?\r
+                               this.coordsToLatLngs(coords[i], levelsDeep - 1, coordsToLatLng) :\r
+                               (coordsToLatLng || this.coordsToLatLng)(coords[i]);\r
 \r
-// adds control-related methods to L.Map\r
+                       latlngs.push(latlng);\r
+               }\r
 \r
-L.Map.include({\r
-       addControl: function (control) {\r
-               control.addTo(this);\r
-               return this;\r
+               return latlngs;\r
        },\r
 \r
-       removeControl: function (control) {\r
-               control.removeFrom(this);\r
-               return this;\r
+       // @function latLngToCoords(latlng: LatLng): Array\r
+       // Reverse of [`coordsToLatLng`](#geojson-coordstolatlng)\r
+       latLngToCoords: function (latlng) {\r
+               return latlng.alt !== undefined ?\r
+                               [latlng.lng, latlng.lat, latlng.alt] :\r
+                               [latlng.lng, latlng.lat];\r
        },\r
 \r
-       _initControlPos: function () {\r
-               var corners = this._controlCorners = {},\r
-                   l = 'leaflet-',\r
-                   container = this._controlContainer =\r
-                           L.DomUtil.create('div', l + 'control-container', this._container);\r
+       // @function latLngsToCoords(latlngs: Array, levelsDeep?: Number, closed?: Boolean): Array\r
+       // Reverse of [`coordsToLatLngs`](#geojson-coordstolatlngs)\r
+       // `closed` determines whether the first point should be appended to the end of the array to close the feature, only used when `levelsDeep` is 0. False by default.\r
+       latLngsToCoords: function (latlngs, levelsDeep, closed) {\r
+               var coords = [];\r
 \r
-               function createCorner(vSide, hSide) {\r
-                       var className = l + vSide + ' ' + l + hSide;\r
+               for (var i = 0, len = latlngs.length; i < len; i++) {\r
+                       coords.push(levelsDeep ?\r
+                               L.GeoJSON.latLngsToCoords(latlngs[i], levelsDeep - 1, closed) :\r
+                               L.GeoJSON.latLngToCoords(latlngs[i]));\r
+               }\r
 \r
-                       corners[vSide + hSide] = L.DomUtil.create('div', className, container);\r
+               if (!levelsDeep && closed) {\r
+                       coords.push(coords[0]);\r
                }\r
 \r
-               createCorner('top', 'left');\r
-               createCorner('top', 'right');\r
-               createCorner('bottom', 'left');\r
-               createCorner('bottom', 'right');\r
+               return coords;\r
        },\r
 \r
-       _clearControlPos: function () {\r
-               this._container.removeChild(this._controlContainer);\r
+       getFeature: function (layer, newGeometry) {\r
+               return layer.feature ?\r
+                               L.extend({}, layer.feature, {geometry: newGeometry}) :\r
+                               L.GeoJSON.asFeature(newGeometry);\r
+       },\r
+\r
+       // @function asFeature(geojson: Object): Object\r
+       // Normalize GeoJSON geometries/features into GeoJSON features.\r
+       asFeature: function (geojson) {\r
+               if (geojson.type === 'Feature' || geojson.type === 'FeatureCollection') {\r
+                       return geojson;\r
+               }\r
+\r
+               return {\r
+                       type: 'Feature',\r
+                       properties: {},\r
+                       geometry: geojson\r
+               };\r
        }\r
 });\r
-
-
-/*\r
- * L.Control.Zoom is used for the default zoom buttons on the map.\r
- */\r
 \r
-L.Control.Zoom = L.Control.extend({\r
-       options: {\r
-               position: 'topleft',\r
-               zoomInText: '+',\r
-               zoomInTitle: 'Zoom in',\r
-               zoomOutText: '-',\r
-               zoomOutTitle: 'Zoom out'\r
-       },\r
+var PointToGeoJSON = {\r
+       toGeoJSON: function () {\r
+               return L.GeoJSON.getFeature(this, {\r
+                       type: 'Point',\r
+                       coordinates: L.GeoJSON.latLngToCoords(this.getLatLng())\r
+               });\r
+       }\r
+};\r
 \r
-       onAdd: function (map) {\r
-               var zoomName = 'leaflet-control-zoom',\r
-                   container = L.DomUtil.create('div', zoomName + ' leaflet-bar');\r
+// @namespace Marker\r
+// @method toGeoJSON(): Object\r
+// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the marker (as a GeoJSON `Point` Feature).\r
+L.Marker.include(PointToGeoJSON);\r
 \r
-               this._map = map;\r
+// @namespace CircleMarker\r
+// @method toGeoJSON(): Object\r
+// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the circle marker (as a GeoJSON `Point` Feature).\r
+L.Circle.include(PointToGeoJSON);\r
+L.CircleMarker.include(PointToGeoJSON);\r
 \r
-               this._zoomInButton  = this._createButton(\r
-                       this.options.zoomInText, this.options.zoomInTitle,\r
-                       zoomName + '-in',  container, this._zoomIn,  this);\r
-               this._zoomOutButton = this._createButton(\r
-                       this.options.zoomOutText, this.options.zoomOutTitle,\r
-                       zoomName + '-out', container, this._zoomOut, this);\r
 \r
-               this._updateDisabled();\r
-               map.on('zoomend zoomlevelschange', this._updateDisabled, this);\r
+// @namespace Polyline\r
+// @method toGeoJSON(): Object\r
+// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the polyline (as a GeoJSON `LineString` or `MultiLineString` Feature).\r
+L.Polyline.prototype.toGeoJSON = function () {\r
+       var multi = !L.Polyline._flat(this._latlngs);\r
 \r
-               return container;\r
-       },\r
+       var coords = L.GeoJSON.latLngsToCoords(this._latlngs, multi ? 1 : 0);\r
 \r
-       onRemove: function (map) {\r
-               map.off('zoomend zoomlevelschange', this._updateDisabled, this);\r
-       },\r
+       return L.GeoJSON.getFeature(this, {\r
+               type: (multi ? 'Multi' : '') + 'LineString',\r
+               coordinates: coords\r
+       });\r
+};\r
 \r
-       _zoomIn: function (e) {\r
-               this._map.zoomIn(e.shiftKey ? 3 : 1);\r
-       },\r
+// @namespace Polygon\r
+// @method toGeoJSON(): Object\r
+// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the polygon (as a GeoJSON `Polygon` or `MultiPolygon` Feature).\r
+L.Polygon.prototype.toGeoJSON = function () {\r
+       var holes = !L.Polyline._flat(this._latlngs),\r
+           multi = holes && !L.Polyline._flat(this._latlngs[0]);\r
 \r
-       _zoomOut: function (e) {\r
-               this._map.zoomOut(e.shiftKey ? 3 : 1);\r
-       },\r
+       var coords = L.GeoJSON.latLngsToCoords(this._latlngs, multi ? 2 : holes ? 1 : 0, true);\r
 \r
-       _createButton: function (html, title, className, container, fn, context) {\r
-               var link = L.DomUtil.create('a', className, container);\r
-               link.innerHTML = html;\r
-               link.href = '#';\r
-               link.title = title;\r
+       if (!holes) {\r
+               coords = [coords];\r
+       }\r
 \r
-               var stop = L.DomEvent.stopPropagation;\r
+       return L.GeoJSON.getFeature(this, {\r
+               type: (multi ? 'Multi' : '') + 'Polygon',\r
+               coordinates: coords\r
+       });\r
+};\r
 \r
-               L.DomEvent\r
-                   .on(link, 'click', stop)\r
-                   .on(link, 'mousedown', stop)\r
-                   .on(link, 'dblclick', stop)\r
-                   .on(link, 'click', L.DomEvent.preventDefault)\r
-                   .on(link, 'click', fn, context)\r
-                   .on(link, 'click', this._refocusOnMap, context);\r
 \r
-               return link;\r
+// @namespace LayerGroup\r
+L.LayerGroup.include({\r
+       toMultiPoint: function () {\r
+               var coords = [];\r
+\r
+               this.eachLayer(function (layer) {\r
+                       coords.push(layer.toGeoJSON().geometry.coordinates);\r
+               });\r
+\r
+               return L.GeoJSON.getFeature(this, {\r
+                       type: 'MultiPoint',\r
+                       coordinates: coords\r
+               });\r
        },\r
 \r
-       _updateDisabled: function () {\r
-               var map = this._map,\r
-                       className = 'leaflet-disabled';\r
+       // @method toGeoJSON(): Object\r
+       // Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the layer group (as a GeoJSON `GeometryCollection`).\r
+       toGeoJSON: function () {\r
 \r
-               L.DomUtil.removeClass(this._zoomInButton, className);\r
-               L.DomUtil.removeClass(this._zoomOutButton, className);\r
+               var type = this.feature && this.feature.geometry && this.feature.geometry.type;\r
 \r
-               if (map._zoom === map.getMinZoom()) {\r
-                       L.DomUtil.addClass(this._zoomOutButton, className);\r
-               }\r
-               if (map._zoom === map.getMaxZoom()) {\r
-                       L.DomUtil.addClass(this._zoomInButton, className);\r
+               if (type === 'MultiPoint') {\r
+                       return this.toMultiPoint();\r
                }\r
-       }\r
-});\r
 \r
-L.Map.mergeOptions({\r
-       zoomControl: true\r
-});\r
+               var isGeometryCollection = type === 'GeometryCollection',\r
+                   jsons = [];\r
 \r
-L.Map.addInitHook(function () {\r
-       if (this.options.zoomControl) {\r
-               this.zoomControl = new L.Control.Zoom();\r
-               this.addControl(this.zoomControl);\r
+               this.eachLayer(function (layer) {\r
+                       if (layer.toGeoJSON) {\r
+                               var json = layer.toGeoJSON();\r
+                               jsons.push(isGeometryCollection ? json.geometry : L.GeoJSON.asFeature(json));\r
+                       }\r
+               });\r
+\r
+               if (isGeometryCollection) {\r
+                       return L.GeoJSON.getFeature(this, {\r
+                               geometries: jsons,\r
+                               type: 'GeometryCollection'\r
+                       });\r
+               }\r
+\r
+               return {\r
+                       type: 'FeatureCollection',\r
+                       features: jsons\r
+               };\r
        }\r
 });\r
 \r
-L.control.zoom = function (options) {\r
-       return new L.Control.Zoom(options);\r
+// @namespace GeoJSON\r
+// @factory L.geoJSON(geojson?: Object, options?: GeoJSON options)\r
+// Creates a GeoJSON layer. Optionally accepts an object in\r
+// [GeoJSON format](http://geojson.org/geojson-spec.html) to display on the map\r
+// (you can alternatively add it later with `addData` method) and an `options` object.\r
+L.geoJSON = function (geojson, options) {\r
+       return new L.GeoJSON(geojson, options);\r
 };\r
-\r
+// Backward compatibility.\r
+L.geoJson = L.geoJSON;\r
+
 
 
 /*\r
- * L.Control.Attribution is used for displaying attribution on the map (added by default).\r
+ * @class Draggable\r
+ * @aka L.Draggable\r
+ * @inherits Evented\r
+ *\r
+ * A class for making DOM elements draggable (including touch support).\r
+ * Used internally for map and marker dragging. Only works for elements\r
+ * that were positioned with [`L.DomUtil.setPosition`](#domutil-setposition).\r
+ *\r
+ * @example\r
+ * ```js\r
+ * var draggable = new L.Draggable(elementToDrag);\r
+ * draggable.enable();\r
+ * ```\r
  */\r
 \r
-L.Control.Attribution = L.Control.extend({\r
+L.Draggable = L.Evented.extend({\r
+\r
        options: {\r
-               position: 'bottomright',\r
-               prefix: '<a href="http://leafletjs.com" title="A JS library for interactive maps">Leaflet</a>'\r
+               // @option clickTolerance: Number = 3\r
+               // The max number of pixels a user can shift the mouse pointer during a click\r
+               // for it to be considered a valid click (as opposed to a mouse drag).\r
+               clickTolerance: 3\r
        },\r
 \r
-       initialize: function (options) {\r
-               L.setOptions(this, options);\r
-\r
-               this._attributions = {};\r
+       statics: {\r
+               START: L.Browser.touch ? ['touchstart', 'mousedown'] : ['mousedown'],\r
+               END: {\r
+                       mousedown: 'mouseup',\r
+                       touchstart: 'touchend',\r
+                       pointerdown: 'touchend',\r
+                       MSPointerDown: 'touchend'\r
+               },\r
+               MOVE: {\r
+                       mousedown: 'mousemove',\r
+                       touchstart: 'touchmove',\r
+                       pointerdown: 'touchmove',\r
+                       MSPointerDown: 'touchmove'\r
+               }\r
        },\r
 \r
-       onAdd: function (map) {\r
-               this._container = L.DomUtil.create('div', 'leaflet-control-attribution');\r
-               L.DomEvent.disableClickPropagation(this._container);\r
+       // @constructor L.Draggable(el: HTMLElement, dragHandle?: HTMLElement, preventOutline: Boolean)\r
+       // Creates a `Draggable` object for moving `el` when you start dragging the `dragHandle` element (equals `el` itself by default).\r
+       initialize: function (element, dragStartTarget, preventOutline) {\r
+               this._element = element;\r
+               this._dragStartTarget = dragStartTarget || element;\r
+               this._preventOutline = preventOutline;\r
+       },\r
 \r
-               for (var i in map._layers) {\r
-                       if (map._layers[i].getAttribution) {\r
-                               this.addAttribution(map._layers[i].getAttribution());\r
-                       }\r
-               }\r
-               \r
-               map\r
-                   .on('layeradd', this._onLayerAdd, this)\r
-                   .on('layerremove', this._onLayerRemove, this);\r
+       // @method enable()\r
+       // Enables the dragging ability\r
+       enable: function () {\r
+               if (this._enabled) { return; }\r
 \r
-               this._update();\r
+               L.DomEvent.on(this._dragStartTarget, L.Draggable.START.join(' '), this._onDown, this);\r
 \r
-               return this._container;\r
+               this._enabled = true;\r
        },\r
 \r
-       onRemove: function (map) {\r
-               map\r
-                   .off('layeradd', this._onLayerAdd)\r
-                   .off('layerremove', this._onLayerRemove);\r
+       // @method disable()\r
+       // Disables the dragging ability\r
+       disable: function () {\r
+               if (!this._enabled) { return; }\r
 \r
-       },\r
+               // If we're currently dragging this draggable,\r
+               // disabling it counts as first ending the drag.\r
+               if (L.Draggable._dragging === this) {\r
+                       this.finishDrag();\r
+               }\r
 \r
-       setPrefix: function (prefix) {\r
-               this.options.prefix = prefix;\r
-               this._update();\r
-               return this;\r
+               L.DomEvent.off(this._dragStartTarget, L.Draggable.START.join(' '), this._onDown, this);\r
+\r
+               this._enabled = false;\r
+               this._moved = false;\r
        },\r
 \r
-       addAttribution: function (text) {\r
-               if (!text) { return; }\r
+       _onDown: function (e) {\r
+               // Ignore simulated events, since we handle both touch and\r
+               // mouse explicitly; otherwise we risk getting duplicates of\r
+               // touch events, see #4315.\r
+               // Also ignore the event if disabled; this happens in IE11\r
+               // under some circumstances, see #3666.\r
+               if (e._simulated || !this._enabled) { return; }\r
 \r
-               if (!this._attributions[text]) {\r
-                       this._attributions[text] = 0;\r
+               this._moved = false;\r
+\r
+               if (L.DomUtil.hasClass(this._element, 'leaflet-zoom-anim')) { return; }\r
+\r
+               if (L.Draggable._dragging || e.shiftKey || ((e.which !== 1) && (e.button !== 1) && !e.touches)) { return; }\r
+               L.Draggable._dragging = this;  // Prevent dragging multiple objects at once.\r
+\r
+               if (this._preventOutline) {\r
+                       L.DomUtil.preventOutline(this._element);\r
                }\r
-               this._attributions[text]++;\r
 \r
-               this._update();\r
+               L.DomUtil.disableImageDrag();\r
+               L.DomUtil.disableTextSelection();\r
 \r
-               return this;\r
+               if (this._moving) { return; }\r
+\r
+               // @event down: Event\r
+               // Fired when a drag is about to start.\r
+               this.fire('down');\r
+\r
+               var first = e.touches ? e.touches[0] : e;\r
+\r
+               this._startPoint = new L.Point(first.clientX, first.clientY);\r
+\r
+               L.DomEvent\r
+                       .on(document, L.Draggable.MOVE[e.type], this._onMove, this)\r
+                       .on(document, L.Draggable.END[e.type], this._onUp, this);\r
        },\r
 \r
-       removeAttribution: function (text) {\r
-               if (!text) { return; }\r
+       _onMove: function (e) {\r
+               // Ignore simulated events, since we handle both touch and\r
+               // mouse explicitly; otherwise we risk getting duplicates of\r
+               // touch events, see #4315.\r
+               // Also ignore the event if disabled; this happens in IE11\r
+               // under some circumstances, see #3666.\r
+               if (e._simulated || !this._enabled) { return; }\r
 \r
-               if (this._attributions[text]) {\r
-                       this._attributions[text]--;\r
-                       this._update();\r
+               if (e.touches && e.touches.length > 1) {\r
+                       this._moved = true;\r
+                       return;\r
                }\r
 \r
-               return this;\r
-       },\r
+               var first = (e.touches && e.touches.length === 1 ? e.touches[0] : e),\r
+                   newPoint = new L.Point(first.clientX, first.clientY),\r
+                   offset = newPoint.subtract(this._startPoint);\r
 \r
-       _update: function () {\r
-               if (!this._map) { return; }\r
+               if (!offset.x && !offset.y) { return; }\r
+               if (Math.abs(offset.x) + Math.abs(offset.y) < this.options.clickTolerance) { return; }\r
 \r
-               var attribs = [];\r
+               L.DomEvent.preventDefault(e);\r
 \r
-               for (var i in this._attributions) {\r
-                       if (this._attributions[i]) {\r
-                               attribs.push(i);\r
+               if (!this._moved) {\r
+                       // @event dragstart: Event\r
+                       // Fired when a drag starts\r
+                       this.fire('dragstart');\r
+\r
+                       this._moved = true;\r
+                       this._startPos = L.DomUtil.getPosition(this._element).subtract(offset);\r
+\r
+                       L.DomUtil.addClass(document.body, 'leaflet-dragging');\r
+\r
+                       this._lastTarget = e.target || e.srcElement;\r
+                       // IE and Edge do not give the <use> element, so fetch it\r
+                       // if necessary\r
+                       if ((window.SVGElementInstance) && (this._lastTarget instanceof SVGElementInstance)) {\r
+                               this._lastTarget = this._lastTarget.correspondingUseElement;\r
                        }\r
+                       L.DomUtil.addClass(this._lastTarget, 'leaflet-drag-target');\r
                }\r
 \r
-               var prefixAndAttribs = [];\r
+               this._newPos = this._startPos.add(offset);\r
+               this._moving = true;\r
 \r
-               if (this.options.prefix) {\r
-                       prefixAndAttribs.push(this.options.prefix);\r
-               }\r
-               if (attribs.length) {\r
-                       prefixAndAttribs.push(attribs.join(', '));\r
-               }\r
+               L.Util.cancelAnimFrame(this._animRequest);\r
+               this._lastEvent = e;\r
+               this._animRequest = L.Util.requestAnimFrame(this._updatePosition, this, true);\r
+       },\r
 \r
-               this._container.innerHTML = prefixAndAttribs.join(' | ');\r
+       _updatePosition: function () {\r
+               var e = {originalEvent: this._lastEvent};\r
+\r
+               // @event predrag: Event\r
+               // Fired continuously during dragging *before* each corresponding\r
+               // update of the element's position.\r
+               this.fire('predrag', e);\r
+               L.DomUtil.setPosition(this._element, this._newPos);\r
+\r
+               // @event drag: Event\r
+               // Fired continuously during dragging.\r
+               this.fire('drag', e);\r
        },\r
 \r
-       _onLayerAdd: function (e) {\r
-               if (e.layer.getAttribution) {\r
-                       this.addAttribution(e.layer.getAttribution());\r
-               }\r
+       _onUp: function (e) {\r
+               // Ignore simulated events, since we handle both touch and\r
+               // mouse explicitly; otherwise we risk getting duplicates of\r
+               // touch events, see #4315.\r
+               // Also ignore the event if disabled; this happens in IE11\r
+               // under some circumstances, see #3666.\r
+               if (e._simulated || !this._enabled) { return; }\r
+               this.finishDrag();\r
        },\r
 \r
-       _onLayerRemove: function (e) {\r
-               if (e.layer.getAttribution) {\r
-                       this.removeAttribution(e.layer.getAttribution());\r
+       finishDrag: function () {\r
+               L.DomUtil.removeClass(document.body, 'leaflet-dragging');\r
+\r
+               if (this._lastTarget) {\r
+                       L.DomUtil.removeClass(this._lastTarget, 'leaflet-drag-target');\r
+                       this._lastTarget = null;\r
                }\r
-       }\r
-});\r
 \r
-L.Map.mergeOptions({\r
-       attributionControl: true\r
-});\r
+               for (var i in L.Draggable.MOVE) {\r
+                       L.DomEvent\r
+                               .off(document, L.Draggable.MOVE[i], this._onMove, this)\r
+                               .off(document, L.Draggable.END[i], this._onUp, this);\r
+               }\r
 \r
-L.Map.addInitHook(function () {\r
-       if (this.options.attributionControl) {\r
-               this.attributionControl = (new L.Control.Attribution()).addTo(this);\r
+               L.DomUtil.enableImageDrag();\r
+               L.DomUtil.enableTextSelection();\r
+\r
+               if (this._moved && this._moving) {\r
+                       // ensure drag is not fired after dragend\r
+                       L.Util.cancelAnimFrame(this._animRequest);\r
+\r
+                       // @event dragend: DragEndEvent\r
+                       // Fired when the drag ends.\r
+                       this.fire('dragend', {\r
+                               distance: this._newPos.distanceTo(this._startPos)\r
+                       });\r
+               }\r
+\r
+               this._moving = false;\r
+               L.Draggable._dragging = false;\r
        }\r
-});\r
 \r
-L.control.attribution = function (options) {\r
-       return new L.Control.Attribution(options);\r
-};\r
+});\r
+
+
+
+/*
+       L.Handler is a base class for handler classes that are used internally to inject
+       interaction features like dragging to classes like Map and Marker.
+*/
+
+// @class Handler
+// @aka L.Handler
+// Abstract class for map interaction handlers
+
+L.Handler = L.Class.extend({
+       initialize: function (map) {
+               this._map = map;
+       },
+
+       // @method enable(): this
+       // Enables the handler
+       enable: function () {
+               if (this._enabled) { return this; }
+
+               this._enabled = true;
+               this.addHooks();
+               return this;
+       },
+
+       // @method disable(): this
+       // Disables the handler
+       disable: function () {
+               if (!this._enabled) { return this; }
+
+               this._enabled = false;
+               this.removeHooks();
+               return this;
+       },
+
+       // @method enabled(): Boolean
+       // Returns `true` if the handler is enabled
+       enabled: function () {
+               return !!this._enabled;
+       }
+
+       // @section Extension methods
+       // Classes inheriting from `Handler` must implement the two following methods:
+       // @method addHooks()
+       // Called when the handler is enabled, should add event hooks.
+       // @method removeHooks()
+       // Called when the handler is disabled, should remove the event hooks added previously.
+});
+
+
+
+/*
+ * L.Handler.MapDrag is used to make the map draggable (with panning inertia), enabled by default.
+ */
+
+// @namespace Map
+// @section Interaction Options
+L.Map.mergeOptions({
+       // @option dragging: Boolean = true
+       // Whether the map be draggable with mouse/touch or not.
+       dragging: true,
+
+       // @section Panning Inertia Options
+       // @option inertia: Boolean = *
+       // If enabled, panning of the map will have an inertia effect where
+       // the map builds momentum while dragging and continues moving in
+       // the same direction for some time. Feels especially nice on touch
+       // devices. Enabled by default unless running on old Android devices.
+       inertia: !L.Browser.android23,
+
+       // @option inertiaDeceleration: Number = 3000
+       // The rate with which the inertial movement slows down, in pixels/second².
+       inertiaDeceleration: 3400, // px/s^2
+
+       // @option inertiaMaxSpeed: Number = Infinity
+       // Max speed of the inertial movement, in pixels/second.
+       inertiaMaxSpeed: Infinity, // px/s
+
+       // @option easeLinearity: Number = 0.2
+       easeLinearity: 0.2,
+
+       // TODO refactor, move to CRS
+       // @option worldCopyJump: Boolean = false
+       // With this option enabled, the map tracks when you pan to another "copy"
+       // of the world and seamlessly jumps to the original one so that all overlays
+       // like markers and vector layers are still visible.
+       worldCopyJump: false,
+
+       // @option maxBoundsViscosity: Number = 0.0
+       // If `maxBounds` is set, this option will control how solid the bounds
+       // are when dragging the map around. The default value of `0.0` allows the
+       // user to drag outside the bounds at normal speed, higher values will
+       // slow down map dragging outside bounds, and `1.0` makes the bounds fully
+       // solid, preventing the user from dragging outside the bounds.
+       maxBoundsViscosity: 0.0
+});
+
+L.Map.Drag = L.Handler.extend({
+       addHooks: function () {
+               if (!this._draggable) {
+                       var map = this._map;
+
+                       this._draggable = new L.Draggable(map._mapPane, map._container);
+
+                       this._draggable.on({
+                               down: this._onDown,
+                               dragstart: this._onDragStart,
+                               drag: this._onDrag,
+                               dragend: this._onDragEnd
+                       }, this);
+
+                       this._draggable.on('predrag', this._onPreDragLimit, this);
+                       if (map.options.worldCopyJump) {
+                               this._draggable.on('predrag', this._onPreDragWrap, this);
+                               map.on('zoomend', this._onZoomEnd, this);
+
+                               map.whenReady(this._onZoomEnd, this);
+                       }
+               }
+               L.DomUtil.addClass(this._map._container, 'leaflet-grab leaflet-touch-drag');
+               this._draggable.enable();
+               this._positions = [];
+               this._times = [];
+       },
+
+       removeHooks: function () {
+               L.DomUtil.removeClass(this._map._container, 'leaflet-grab');
+               L.DomUtil.removeClass(this._map._container, 'leaflet-touch-drag');
+               this._draggable.disable();
+       },
+
+       moved: function () {
+               return this._draggable && this._draggable._moved;
+       },
+
+       moving: function () {
+               return this._draggable && this._draggable._moving;
+       },
+
+       _onDown: function () {
+               this._map._stop();
+       },
+
+       _onDragStart: function () {
+               var map = this._map;
+
+               if (this._map.options.maxBounds && this._map.options.maxBoundsViscosity) {
+                       var bounds = L.latLngBounds(this._map.options.maxBounds);
+
+                       this._offsetLimit = L.bounds(
+                               this._map.latLngToContainerPoint(bounds.getNorthWest()).multiplyBy(-1),
+                               this._map.latLngToContainerPoint(bounds.getSouthEast()).multiplyBy(-1)
+                                       .add(this._map.getSize()));
+
+                       this._viscosity = Math.min(1.0, Math.max(0.0, this._map.options.maxBoundsViscosity));
+               } else {
+                       this._offsetLimit = null;
+               }
+
+               map
+                   .fire('movestart')
+                   .fire('dragstart');
+
+               if (map.options.inertia) {
+                       this._positions = [];
+                       this._times = [];
+               }
+       },
+
+       _onDrag: function (e) {
+               if (this._map.options.inertia) {
+                       var time = this._lastTime = +new Date(),
+                           pos = this._lastPos = this._draggable._absPos || this._draggable._newPos;
+
+                       this._positions.push(pos);
+                       this._times.push(time);
+
+                       if (time - this._times[0] > 50) {
+                               this._positions.shift();
+                               this._times.shift();
+                       }
+               }
+
+               this._map
+                   .fire('move', e)
+                   .fire('drag', e);
+       },
+
+       _onZoomEnd: function () {
+               var pxCenter = this._map.getSize().divideBy(2),
+                   pxWorldCenter = this._map.latLngToLayerPoint([0, 0]);
+
+               this._initialWorldOffset = pxWorldCenter.subtract(pxCenter).x;
+               this._worldWidth = this._map.getPixelWorldBounds().getSize().x;
+       },
+
+       _viscousLimit: function (value, threshold) {
+               return value - (value - threshold) * this._viscosity;
+       },
+
+       _onPreDragLimit: function () {
+               if (!this._viscosity || !this._offsetLimit) { return; }
+
+               var offset = this._draggable._newPos.subtract(this._draggable._startPos);
+
+               var limit = this._offsetLimit;
+               if (offset.x < limit.min.x) { offset.x = this._viscousLimit(offset.x, limit.min.x); }
+               if (offset.y < limit.min.y) { offset.y = this._viscousLimit(offset.y, limit.min.y); }
+               if (offset.x > limit.max.x) { offset.x = this._viscousLimit(offset.x, limit.max.x); }
+               if (offset.y > limit.max.y) { offset.y = this._viscousLimit(offset.y, limit.max.y); }
+
+               this._draggable._newPos = this._draggable._startPos.add(offset);
+       },
+
+       _onPreDragWrap: function () {
+               // TODO refactor to be able to adjust map pane position after zoom
+               var worldWidth = this._worldWidth,
+                   halfWidth = Math.round(worldWidth / 2),
+                   dx = this._initialWorldOffset,
+                   x = this._draggable._newPos.x,
+                   newX1 = (x - halfWidth + dx) % worldWidth + halfWidth - dx,
+                   newX2 = (x + halfWidth + dx) % worldWidth - halfWidth - dx,
+                   newX = Math.abs(newX1 + dx) < Math.abs(newX2 + dx) ? newX1 : newX2;
+
+               this._draggable._absPos = this._draggable._newPos.clone();
+               this._draggable._newPos.x = newX;
+       },
+
+       _onDragEnd: function (e) {
+               var map = this._map,
+                   options = map.options,
+
+                   noInertia = !options.inertia || this._times.length < 2;
+
+               map.fire('dragend', e);
+
+               if (noInertia) {
+                       map.fire('moveend');
+
+               } else {
+
+                       var direction = this._lastPos.subtract(this._positions[0]),
+                           duration = (this._lastTime - this._times[0]) / 1000,
+                           ease = options.easeLinearity,
+
+                           speedVector = direction.multiplyBy(ease / duration),
+                           speed = speedVector.distanceTo([0, 0]),
+
+                           limitedSpeed = Math.min(options.inertiaMaxSpeed, speed),
+                           limitedSpeedVector = speedVector.multiplyBy(limitedSpeed / speed),
+
+                           decelerationDuration = limitedSpeed / (options.inertiaDeceleration * ease),
+                           offset = limitedSpeedVector.multiplyBy(-decelerationDuration / 2).round();
+
+                       if (!offset.x && !offset.y) {
+                               map.fire('moveend');
+
+                       } else {
+                               offset = map._limitOffset(offset, map.options.maxBounds);
+
+                               L.Util.requestAnimFrame(function () {
+                                       map.panBy(offset, {
+                                               duration: decelerationDuration,
+                                               easeLinearity: ease,
+                                               noMoveStart: true,
+                                               animate: true
+                                       });
+                               });
+                       }
+               }
+       }
+});
+
+// @section Handlers
+// @property dragging: Handler
+// Map dragging handler (by both mouse and touch).
+L.Map.addInitHook('addHandler', 'dragging', L.Map.Drag);
+
+
+
+/*
+ * L.Handler.DoubleClickZoom is used to handle double-click zoom on the map, enabled by default.
+ */
+
+// @namespace Map
+// @section Interaction Options
+
+L.Map.mergeOptions({
+       // @option doubleClickZoom: Boolean|String = true
+       // Whether the map can be zoomed in by double clicking on it and
+       // zoomed out by double clicking while holding shift. If passed
+       // `'center'`, double-click zoom will zoom to the center of the
+       //  view regardless of where the mouse was.
+       doubleClickZoom: true
+});
+
+L.Map.DoubleClickZoom = L.Handler.extend({
+       addHooks: function () {
+               this._map.on('dblclick', this._onDoubleClick, this);
+       },
+
+       removeHooks: function () {
+               this._map.off('dblclick', this._onDoubleClick, this);
+       },
+
+       _onDoubleClick: function (e) {
+               var map = this._map,
+                   oldZoom = map.getZoom(),
+                   delta = map.options.zoomDelta,
+                   zoom = e.originalEvent.shiftKey ? oldZoom - delta : oldZoom + delta;
+
+               if (map.options.doubleClickZoom === 'center') {
+                       map.setZoom(zoom);
+               } else {
+                       map.setZoomAround(e.containerPoint, zoom);
+               }
+       }
+});
+
+// @section Handlers
+//
+// Map properties include interaction handlers that allow you to control
+// interaction behavior in runtime, enabling or disabling certain features such
+// as dragging or touch zoom (see `Handler` methods). For example:
+//
+// ```js
+// map.doubleClickZoom.disable();
+// ```
+//
+// @property doubleClickZoom: Handler
+// Double click zoom handler.
+L.Map.addInitHook('addHandler', 'doubleClickZoom', L.Map.DoubleClickZoom);
+
+
+
+/*
+ * L.Handler.ScrollWheelZoom is used by L.Map to enable mouse scroll wheel zoom on the map.
+ */
+
+// @namespace Map
+// @section Interaction Options
+L.Map.mergeOptions({
+       // @section Mousewheel options
+       // @option scrollWheelZoom: Boolean|String = true
+       // Whether the map can be zoomed by using the mouse wheel. If passed `'center'`,
+       // it will zoom to the center of the view regardless of where the mouse was.
+       scrollWheelZoom: true,
+
+       // @option wheelDebounceTime: Number = 40
+       // Limits the rate at which a wheel can fire (in milliseconds). By default
+       // user can't zoom via wheel more often than once per 40 ms.
+       wheelDebounceTime: 40,
+
+       // @option wheelPxPerZoomLevel: Number = 60
+       // How many scroll pixels (as reported by [L.DomEvent.getWheelDelta](#domevent-getwheeldelta))
+       // mean a change of one full zoom level. Smaller values will make wheel-zooming
+       // faster (and vice versa).
+       wheelPxPerZoomLevel: 60
+});
+
+L.Map.ScrollWheelZoom = L.Handler.extend({
+       addHooks: function () {
+               L.DomEvent.on(this._map._container, 'mousewheel', this._onWheelScroll, this);
+
+               this._delta = 0;
+       },
+
+       removeHooks: function () {
+               L.DomEvent.off(this._map._container, 'mousewheel', this._onWheelScroll, this);
+       },
+
+       _onWheelScroll: function (e) {
+               var delta = L.DomEvent.getWheelDelta(e);
+
+               var debounce = this._map.options.wheelDebounceTime;
+
+               this._delta += delta;
+               this._lastMousePos = this._map.mouseEventToContainerPoint(e);
+
+               if (!this._startTime) {
+                       this._startTime = +new Date();
+               }
+
+               var left = Math.max(debounce - (+new Date() - this._startTime), 0);
+
+               clearTimeout(this._timer);
+               this._timer = setTimeout(L.bind(this._performZoom, this), left);
+
+               L.DomEvent.stop(e);
+       },
+
+       _performZoom: function () {
+               var map = this._map,
+                   zoom = map.getZoom(),
+                   snap = this._map.options.zoomSnap || 0;
+
+               map._stop(); // stop panning and fly animations if any
+
+               // map the delta with a sigmoid function to -4..4 range leaning on -1..1
+               var d2 = this._delta / (this._map.options.wheelPxPerZoomLevel * 4),
+                   d3 = 4 * Math.log(2 / (1 + Math.exp(-Math.abs(d2)))) / Math.LN2,
+                   d4 = snap ? Math.ceil(d3 / snap) * snap : d3,
+                   delta = map._limitZoom(zoom + (this._delta > 0 ? d4 : -d4)) - zoom;
+
+               this._delta = 0;
+               this._startTime = null;
+
+               if (!delta) { return; }
+
+               if (map.options.scrollWheelZoom === 'center') {
+                       map.setZoom(zoom + delta);
+               } else {
+                       map.setZoomAround(this._lastMousePos, zoom + delta);
+               }
+       }
+});
+
+// @section Handlers
+// @property scrollWheelZoom: Handler
+// Scroll wheel zoom handler.
+L.Map.addInitHook('addHandler', 'scrollWheelZoom', L.Map.ScrollWheelZoom);
+
+
+
+/*\r
+ * Extends the event handling code with double tap support for mobile browsers.\r
+ */\r
+\r
+L.extend(L.DomEvent, {\r
+\r
+       _touchstart: L.Browser.msPointer ? 'MSPointerDown' : L.Browser.pointer ? 'pointerdown' : 'touchstart',\r
+       _touchend: L.Browser.msPointer ? 'MSPointerUp' : L.Browser.pointer ? 'pointerup' : 'touchend',\r
+\r
+       // inspired by Zepto touch code by Thomas Fuchs\r
+       addDoubleTapListener: function (obj, handler, id) {\r
+               var last, touch,\r
+                   doubleTap = false,\r
+                   delay = 250;\r
+\r
+               function onTouchStart(e) {\r
+                       var count;\r
+\r
+                       if (L.Browser.pointer) {\r
+                               if ((!L.Browser.edge) || e.pointerType === 'mouse') { return; }\r
+                               count = L.DomEvent._pointersCount;\r
+                       } else {\r
+                               count = e.touches.length;\r
+                       }\r
+\r
+                       if (count > 1) { return; }\r
+\r
+                       var now = Date.now(),\r
+                           delta = now - (last || now);\r
+\r
+                       touch = e.touches ? e.touches[0] : e;\r
+                       doubleTap = (delta > 0 && delta <= delay);\r
+                       last = now;\r
+               }\r
+\r
+               function onTouchEnd(e) {\r
+                       if (doubleTap && !touch.cancelBubble) {\r
+                               if (L.Browser.pointer) {\r
+                                       if ((!L.Browser.edge) || e.pointerType === 'mouse') { return; }\r
+\r
+                                       // work around .type being readonly with MSPointer* events\r
+                                       var newTouch = {},\r
+                                           prop, i;\r
+\r
+                                       for (i in touch) {\r
+                                               prop = touch[i];\r
+                                               newTouch[i] = prop && prop.bind ? prop.bind(touch) : prop;\r
+                                       }\r
+                                       touch = newTouch;\r
+                               }\r
+                               touch.type = 'dblclick';\r
+                               handler(touch);\r
+                               last = null;\r
+                       }\r
+               }\r
+\r
+               var pre = '_leaflet_',\r
+                   touchstart = this._touchstart,\r
+                   touchend = this._touchend;\r
+\r
+               obj[pre + touchstart + id] = onTouchStart;\r
+               obj[pre + touchend + id] = onTouchEnd;\r
+               obj[pre + 'dblclick' + id] = handler;\r
+\r
+               obj.addEventListener(touchstart, onTouchStart, false);\r
+               obj.addEventListener(touchend, onTouchEnd, false);\r
+\r
+               // On some platforms (notably, chrome<55 on win10 + touchscreen + mouse),\r
+               // the browser doesn't fire touchend/pointerup events but does fire\r
+               // native dblclicks. See #4127.\r
+               // Edge 14 also fires native dblclicks, but only for pointerType mouse, see #5180.\r
+               obj.addEventListener('dblclick', handler, false);\r
+\r
+               return this;\r
+       },\r
+\r
+       removeDoubleTapListener: function (obj, id) {\r
+               var pre = '_leaflet_',\r
+                   touchstart = obj[pre + this._touchstart + id],\r
+                   touchend = obj[pre + this._touchend + id],\r
+                   dblclick = obj[pre + 'dblclick' + id];\r
+\r
+               obj.removeEventListener(this._touchstart, touchstart, false);\r
+               obj.removeEventListener(this._touchend, touchend, false);\r
+               if (!L.Browser.edge) {\r
+                       obj.removeEventListener('dblclick', dblclick, false);\r
+               }\r
+\r
+               return this;\r
+       }\r
+});\r
+
+
+
+/*
+ * Extends L.DomEvent to provide touch support for Internet Explorer and Windows-based devices.
+ */
+
+L.extend(L.DomEvent, {
+
+       POINTER_DOWN:   L.Browser.msPointer ? 'MSPointerDown'   : 'pointerdown',
+       POINTER_MOVE:   L.Browser.msPointer ? 'MSPointerMove'   : 'pointermove',
+       POINTER_UP:     L.Browser.msPointer ? 'MSPointerUp'     : 'pointerup',
+       POINTER_CANCEL: L.Browser.msPointer ? 'MSPointerCancel' : 'pointercancel',
+       TAG_WHITE_LIST: ['INPUT', 'SELECT', 'OPTION'],
+
+       _pointers: {},
+       _pointersCount: 0,
+
+       // Provides a touch events wrapper for (ms)pointer events.
+       // ref http://www.w3.org/TR/pointerevents/ https://www.w3.org/Bugs/Public/show_bug.cgi?id=22890
+
+       addPointerListener: function (obj, type, handler, id) {
+
+               if (type === 'touchstart') {
+                       this._addPointerStart(obj, handler, id);
+
+               } else if (type === 'touchmove') {
+                       this._addPointerMove(obj, handler, id);
+
+               } else if (type === 'touchend') {
+                       this._addPointerEnd(obj, handler, id);
+               }
+
+               return this;
+       },
+
+       removePointerListener: function (obj, type, id) {
+               var handler = obj['_leaflet_' + type + id];
+
+               if (type === 'touchstart') {
+                       obj.removeEventListener(this.POINTER_DOWN, handler, false);
+
+               } else if (type === 'touchmove') {
+                       obj.removeEventListener(this.POINTER_MOVE, handler, false);
+
+               } else if (type === 'touchend') {
+                       obj.removeEventListener(this.POINTER_UP, handler, false);
+                       obj.removeEventListener(this.POINTER_CANCEL, handler, false);
+               }
+
+               return this;
+       },
+
+       _addPointerStart: function (obj, handler, id) {
+               var onDown = L.bind(function (e) {
+                       if (e.pointerType !== 'mouse' && e.MSPOINTER_TYPE_MOUSE && e.pointerType !== e.MSPOINTER_TYPE_MOUSE) {
+                               // In IE11, some touch events needs to fire for form controls, or
+                               // the controls will stop working. We keep a whitelist of tag names that
+                               // need these events. For other target tags, we prevent default on the event.
+                               if (this.TAG_WHITE_LIST.indexOf(e.target.tagName) < 0) {
+                                       L.DomEvent.preventDefault(e);
+                               } else {
+                                       return;
+                               }
+                       }
+
+                       this._handlePointer(e, handler);
+               }, this);
+
+               obj['_leaflet_touchstart' + id] = onDown;
+               obj.addEventListener(this.POINTER_DOWN, onDown, false);
+
+               // need to keep track of what pointers and how many are active to provide e.touches emulation
+               if (!this._pointerDocListener) {
+                       var pointerUp = L.bind(this._globalPointerUp, this);
+
+                       // we listen documentElement as any drags that end by moving the touch off the screen get fired there
+                       document.documentElement.addEventListener(this.POINTER_DOWN, L.bind(this._globalPointerDown, this), true);
+                       document.documentElement.addEventListener(this.POINTER_MOVE, L.bind(this._globalPointerMove, this), true);
+                       document.documentElement.addEventListener(this.POINTER_UP, pointerUp, true);
+                       document.documentElement.addEventListener(this.POINTER_CANCEL, pointerUp, true);
+
+                       this._pointerDocListener = true;
+               }
+       },
+
+       _globalPointerDown: function (e) {
+               this._pointers[e.pointerId] = e;
+               this._pointersCount++;
+       },
+
+       _globalPointerMove: function (e) {
+               if (this._pointers[e.pointerId]) {
+                       this._pointers[e.pointerId] = e;
+               }
+       },
+
+       _globalPointerUp: function (e) {
+               delete this._pointers[e.pointerId];
+               this._pointersCount--;
+       },
+
+       _handlePointer: function (e, handler) {
+               e.touches = [];
+               for (var i in this._pointers) {
+                       e.touches.push(this._pointers[i]);
+               }
+               e.changedTouches = [e];
+
+               handler(e);
+       },
+
+       _addPointerMove: function (obj, handler, id) {
+               var onMove = L.bind(function (e) {
+                       // don't fire touch moves when mouse isn't down
+                       if ((e.pointerType === e.MSPOINTER_TYPE_MOUSE || e.pointerType === 'mouse') && e.buttons === 0) { return; }
+
+                       this._handlePointer(e, handler);
+               }, this);
+
+               obj['_leaflet_touchmove' + id] = onMove;
+               obj.addEventListener(this.POINTER_MOVE, onMove, false);
+       },
+
+       _addPointerEnd: function (obj, handler, id) {
+               var onUp = L.bind(function (e) {
+                       this._handlePointer(e, handler);
+               }, this);
+
+               obj['_leaflet_touchend' + id] = onUp;
+               obj.addEventListener(this.POINTER_UP, onUp, false);
+               obj.addEventListener(this.POINTER_CANCEL, onUp, false);
+       }
+});
+
+
+
+/*
+ * L.Handler.TouchZoom is used by L.Map to add pinch zoom on supported mobile browsers.
+ */
+
+// @namespace Map
+// @section Interaction Options
+L.Map.mergeOptions({
+       // @section Touch interaction options
+       // @option touchZoom: Boolean|String = *
+       // Whether the map can be zoomed by touch-dragging with two fingers. If
+       // passed `'center'`, it will zoom to the center of the view regardless of
+       // where the touch events (fingers) were. Enabled for touch-capable web
+       // browsers except for old Androids.
+       touchZoom: L.Browser.touch && !L.Browser.android23,
+
+       // @option bounceAtZoomLimits: Boolean = true
+       // Set it to false if you don't want the map to zoom beyond min/max zoom
+       // and then bounce back when pinch-zooming.
+       bounceAtZoomLimits: true
+});
+
+L.Map.TouchZoom = L.Handler.extend({
+       addHooks: function () {
+               L.DomUtil.addClass(this._map._container, 'leaflet-touch-zoom');
+               L.DomEvent.on(this._map._container, 'touchstart', this._onTouchStart, this);
+       },
+
+       removeHooks: function () {
+               L.DomUtil.removeClass(this._map._container, 'leaflet-touch-zoom');
+               L.DomEvent.off(this._map._container, 'touchstart', this._onTouchStart, this);
+       },
+
+       _onTouchStart: function (e) {
+               var map = this._map;
+               if (!e.touches || e.touches.length !== 2 || map._animatingZoom || this._zooming) { return; }
+
+               var p1 = map.mouseEventToContainerPoint(e.touches[0]),
+                   p2 = map.mouseEventToContainerPoint(e.touches[1]);
+
+               this._centerPoint = map.getSize()._divideBy(2);
+               this._startLatLng = map.containerPointToLatLng(this._centerPoint);
+               if (map.options.touchZoom !== 'center') {
+                       this._pinchStartLatLng = map.containerPointToLatLng(p1.add(p2)._divideBy(2));
+               }
+
+               this._startDist = p1.distanceTo(p2);
+               this._startZoom = map.getZoom();
+
+               this._moved = false;
+               this._zooming = true;
+
+               map._stop();
+
+               L.DomEvent
+                   .on(document, 'touchmove', this._onTouchMove, this)
+                   .on(document, 'touchend', this._onTouchEnd, this);
+
+               L.DomEvent.preventDefault(e);
+       },
+
+       _onTouchMove: function (e) {
+               if (!e.touches || e.touches.length !== 2 || !this._zooming) { return; }
+
+               var map = this._map,
+                   p1 = map.mouseEventToContainerPoint(e.touches[0]),
+                   p2 = map.mouseEventToContainerPoint(e.touches[1]),
+                   scale = p1.distanceTo(p2) / this._startDist;
+
+
+               this._zoom = map.getScaleZoom(scale, this._startZoom);
+
+               if (!map.options.bounceAtZoomLimits && (
+                       (this._zoom < map.getMinZoom() && scale < 1) ||
+                       (this._zoom > map.getMaxZoom() && scale > 1))) {
+                       this._zoom = map._limitZoom(this._zoom);
+               }
+
+               if (map.options.touchZoom === 'center') {
+                       this._center = this._startLatLng;
+                       if (scale === 1) { return; }
+               } else {
+                       // Get delta from pinch to center, so centerLatLng is delta applied to initial pinchLatLng
+                       var delta = p1._add(p2)._divideBy(2)._subtract(this._centerPoint);
+                       if (scale === 1 && delta.x === 0 && delta.y === 0) { return; }
+                       this._center = map.unproject(map.project(this._pinchStartLatLng, this._zoom).subtract(delta), this._zoom);
+               }
+
+               if (!this._moved) {
+                       map._moveStart(true);
+                       this._moved = true;
+               }
+
+               L.Util.cancelAnimFrame(this._animRequest);
+
+               var moveFn = L.bind(map._move, map, this._center, this._zoom, {pinch: true, round: false});
+               this._animRequest = L.Util.requestAnimFrame(moveFn, this, true);
+
+               L.DomEvent.preventDefault(e);
+       },
+
+       _onTouchEnd: function () {
+               if (!this._moved || !this._zooming) {
+                       this._zooming = false;
+                       return;
+               }
+
+               this._zooming = false;
+               L.Util.cancelAnimFrame(this._animRequest);
+
+               L.DomEvent
+                   .off(document, 'touchmove', this._onTouchMove)
+                   .off(document, 'touchend', this._onTouchEnd);
+
+               // Pinch updates GridLayers' levels only when zoomSnap is off, so zoomSnap becomes noUpdate.
+               if (this._map.options.zoomAnimation) {
+                       this._map._animateZoom(this._center, this._map._limitZoom(this._zoom), true, this._map.options.zoomSnap);
+               } else {
+                       this._map._resetView(this._center, this._map._limitZoom(this._zoom));
+               }
+       }
+});
+
+// @section Handlers
+// @property touchZoom: Handler
+// Touch zoom handler.
+L.Map.addInitHook('addHandler', 'touchZoom', L.Map.TouchZoom);
+
+
+
+/*
+ * L.Map.Tap is used to enable mobile hacks like quick taps and long hold.
+ */
+
+// @namespace Map
+// @section Interaction Options
+L.Map.mergeOptions({
+       // @section Touch interaction options
+       // @option tap: Boolean = true
+       // Enables mobile hacks for supporting instant taps (fixing 200ms click
+       // delay on iOS/Android) and touch holds (fired as `contextmenu` events).
+       tap: true,
+
+       // @option tapTolerance: Number = 15
+       // The max number of pixels a user can shift his finger during touch
+       // for it to be considered a valid tap.
+       tapTolerance: 15
+});
+
+L.Map.Tap = L.Handler.extend({
+       addHooks: function () {
+               L.DomEvent.on(this._map._container, 'touchstart', this._onDown, this);
+       },
+
+       removeHooks: function () {
+               L.DomEvent.off(this._map._container, 'touchstart', this._onDown, this);
+       },
+
+       _onDown: function (e) {
+               if (!e.touches) { return; }
+
+               L.DomEvent.preventDefault(e);
+
+               this._fireClick = true;
+
+               // don't simulate click or track longpress if more than 1 touch
+               if (e.touches.length > 1) {
+                       this._fireClick = false;
+                       clearTimeout(this._holdTimeout);
+                       return;
+               }
+
+               var first = e.touches[0],
+                   el = first.target;
+
+               this._startPos = this._newPos = new L.Point(first.clientX, first.clientY);
+
+               // if touching a link, highlight it
+               if (el.tagName && el.tagName.toLowerCase() === 'a') {
+                       L.DomUtil.addClass(el, 'leaflet-active');
+               }
+
+               // simulate long hold but setting a timeout
+               this._holdTimeout = setTimeout(L.bind(function () {
+                       if (this._isTapValid()) {
+                               this._fireClick = false;
+                               this._onUp();
+                               this._simulateEvent('contextmenu', first);
+                       }
+               }, this), 1000);
+
+               this._simulateEvent('mousedown', first);
+
+               L.DomEvent.on(document, {
+                       touchmove: this._onMove,
+                       touchend: this._onUp
+               }, this);
+       },
+
+       _onUp: function (e) {
+               clearTimeout(this._holdTimeout);
+
+               L.DomEvent.off(document, {
+                       touchmove: this._onMove,
+                       touchend: this._onUp
+               }, this);
+
+               if (this._fireClick && e && e.changedTouches) {
+
+                       var first = e.changedTouches[0],
+                           el = first.target;
+
+                       if (el && el.tagName && el.tagName.toLowerCase() === 'a') {
+                               L.DomUtil.removeClass(el, 'leaflet-active');
+                       }
+
+                       this._simulateEvent('mouseup', first);
+
+                       // simulate click if the touch didn't move too much
+                       if (this._isTapValid()) {
+                               this._simulateEvent('click', first);
+                       }
+               }
+       },
+
+       _isTapValid: function () {
+               return this._newPos.distanceTo(this._startPos) <= this._map.options.tapTolerance;
+       },
+
+       _onMove: function (e) {
+               var first = e.touches[0];
+               this._newPos = new L.Point(first.clientX, first.clientY);
+               this._simulateEvent('mousemove', first);
+       },
+
+       _simulateEvent: function (type, e) {
+               var simulatedEvent = document.createEvent('MouseEvents');
+
+               simulatedEvent._simulated = true;
+               e.target._simulatedClick = true;
+
+               simulatedEvent.initMouseEvent(
+                       type, true, true, window, 1,
+                       e.screenX, e.screenY,
+                       e.clientX, e.clientY,
+                       false, false, false, false, 0, null);
+
+               e.target.dispatchEvent(simulatedEvent);
+       }
+});
+
+// @section Handlers
+// @property tap: Handler
+// Mobile touch hacks (quick tap and touch hold) handler.
+if (L.Browser.touch && !L.Browser.pointer) {
+       L.Map.addInitHook('addHandler', 'tap', L.Map.Tap);
+}
+
+
+
+/*
+ * L.Handler.BoxZoom is used to add shift-drag zoom interaction to the map
+ * (zoom to a selected bounding box), enabled by default.
+ */
+
+// @namespace Map
+// @section Interaction Options
+L.Map.mergeOptions({
+       // @option boxZoom: Boolean = true
+       // Whether the map can be zoomed to a rectangular area specified by
+       // dragging the mouse while pressing the shift key.
+       boxZoom: true
+});
+
+L.Map.BoxZoom = L.Handler.extend({
+       initialize: function (map) {
+               this._map = map;
+               this._container = map._container;
+               this._pane = map._panes.overlayPane;
+       },
+
+       addHooks: function () {
+               L.DomEvent.on(this._container, 'mousedown', this._onMouseDown, this);
+       },
+
+       removeHooks: function () {
+               L.DomEvent.off(this._container, 'mousedown', this._onMouseDown, this);
+       },
+
+       moved: function () {
+               return this._moved;
+       },
+
+       _resetState: function () {
+               this._moved = false;
+       },
+
+       _onMouseDown: function (e) {
+               if (!e.shiftKey || ((e.which !== 1) && (e.button !== 1))) { return false; }
+
+               this._resetState();
+
+               L.DomUtil.disableTextSelection();
+               L.DomUtil.disableImageDrag();
+
+               this._startPoint = this._map.mouseEventToContainerPoint(e);
+
+               L.DomEvent.on(document, {
+                       contextmenu: L.DomEvent.stop,
+                       mousemove: this._onMouseMove,
+                       mouseup: this._onMouseUp,
+                       keydown: this._onKeyDown
+               }, this);
+       },
+
+       _onMouseMove: function (e) {
+               if (!this._moved) {
+                       this._moved = true;
+
+                       this._box = L.DomUtil.create('div', 'leaflet-zoom-box', this._container);
+                       L.DomUtil.addClass(this._container, 'leaflet-crosshair');
+
+                       this._map.fire('boxzoomstart');
+               }
+
+               this._point = this._map.mouseEventToContainerPoint(e);
+
+               var bounds = new L.Bounds(this._point, this._startPoint),
+                   size = bounds.getSize();
+
+               L.DomUtil.setPosition(this._box, bounds.min);
+
+               this._box.style.width  = size.x + 'px';
+               this._box.style.height = size.y + 'px';
+       },
+
+       _finish: function () {
+               if (this._moved) {
+                       L.DomUtil.remove(this._box);
+                       L.DomUtil.removeClass(this._container, 'leaflet-crosshair');
+               }
+
+               L.DomUtil.enableTextSelection();
+               L.DomUtil.enableImageDrag();
+
+               L.DomEvent.off(document, {
+                       contextmenu: L.DomEvent.stop,
+                       mousemove: this._onMouseMove,
+                       mouseup: this._onMouseUp,
+                       keydown: this._onKeyDown
+               }, this);
+       },
+
+       _onMouseUp: function (e) {
+               if ((e.which !== 1) && (e.button !== 1)) { return; }
+
+               this._finish();
+
+               if (!this._moved) { return; }
+               // Postpone to next JS tick so internal click event handling
+               // still see it as "moved".
+               setTimeout(L.bind(this._resetState, this), 0);
+
+               var bounds = new L.LatLngBounds(
+                       this._map.containerPointToLatLng(this._startPoint),
+                       this._map.containerPointToLatLng(this._point));
+
+               this._map
+                       .fitBounds(bounds)
+                       .fire('boxzoomend', {boxZoomBounds: bounds});
+       },
+
+       _onKeyDown: function (e) {
+               if (e.keyCode === 27) {
+                       this._finish();
+               }
+       }
+});
+
+// @section Handlers
+// @property boxZoom: Handler
+// Box (shift-drag with mouse) zoom handler.
+L.Map.addInitHook('addHandler', 'boxZoom', L.Map.BoxZoom);
+
 
 
 /*
- * L.Control.Scale is used for displaying metric/imperial scale on the map.
+ * L.Map.Keyboard is handling keyboard interaction with the map, enabled by default.
  */
 
-L.Control.Scale = L.Control.extend({
-       options: {
-               position: 'bottomleft',
-               maxWidth: 100,
-               metric: true,
-               imperial: true,
-               updateWhenIdle: false
+// @namespace Map
+// @section Keyboard Navigation Options
+L.Map.mergeOptions({
+       // @option keyboard: Boolean = true
+       // Makes the map focusable and allows users to navigate the map with keyboard
+       // arrows and `+`/`-` keys.
+       keyboard: true,
+
+       // @option keyboardPanDelta: Number = 80
+       // Amount of pixels to pan when pressing an arrow key.
+       keyboardPanDelta: 80
+});
+
+L.Map.Keyboard = L.Handler.extend({
+
+       keyCodes: {
+               left:    [37],
+               right:   [39],
+               down:    [40],
+               up:      [38],
+               zoomIn:  [187, 107, 61, 171],
+               zoomOut: [189, 109, 54, 173]
        },
 
-       onAdd: function (map) {
+       initialize: function (map) {
                this._map = map;
 
-               var className = 'leaflet-control-scale',
-                   container = L.DomUtil.create('div', className),
-                   options = this.options;
+               this._setPanDelta(map.options.keyboardPanDelta);
+               this._setZoomDelta(map.options.zoomDelta);
+       },
 
-               this._addScales(options, className, container);
+       addHooks: function () {
+               var container = this._map._container;
 
-               map.on(options.updateWhenIdle ? 'moveend' : 'move', this._update, this);
-               map.whenReady(this._update, this);
+               // make the container focusable by tabbing
+               if (container.tabIndex <= 0) {
+                       container.tabIndex = '0';
+               }
 
-               return container;
-       },
+               L.DomEvent.on(container, {
+                       focus: this._onFocus,
+                       blur: this._onBlur,
+                       mousedown: this._onMouseDown
+               }, this);
 
-       onRemove: function (map) {
-               map.off(this.options.updateWhenIdle ? 'moveend' : 'move', this._update, this);
+               this._map.on({
+                       focus: this._addHooks,
+                       blur: this._removeHooks
+               }, this);
        },
 
-       _addScales: function (options, className, container) {
-               if (options.metric) {
-                       this._mScale = L.DomUtil.create('div', className + '-line', container);
-               }
-               if (options.imperial) {
-                       this._iScale = L.DomUtil.create('div', className + '-line', container);
-               }
+       removeHooks: function () {
+               this._removeHooks();
+
+               L.DomEvent.off(this._map._container, {
+                       focus: this._onFocus,
+                       blur: this._onBlur,
+                       mousedown: this._onMouseDown
+               }, this);
+
+               this._map.off({
+                       focus: this._addHooks,
+                       blur: this._removeHooks
+               }, this);
        },
 
-       _update: function () {
-               var bounds = this._map.getBounds(),
-                   centerLat = bounds.getCenter().lat,
-                   halfWorldMeters = 6378137 * Math.PI * Math.cos(centerLat * Math.PI / 180),
-                   dist = halfWorldMeters * (bounds.getNorthEast().lng - bounds.getSouthWest().lng) / 180,
+       _onMouseDown: function () {
+               if (this._focused) { return; }
 
-                   size = this._map.getSize(),
-                   options = this.options,
-                   maxMeters = 0;
+               var body = document.body,
+                   docEl = document.documentElement,
+                   top = body.scrollTop || docEl.scrollTop,
+                   left = body.scrollLeft || docEl.scrollLeft;
 
-               if (size.x > 0) {
-                       maxMeters = dist * (options.maxWidth / size.x);
-               }
+               this._map._container.focus();
 
-               this._updateScales(options, maxMeters);
+               window.scrollTo(left, top);
        },
 
-       _updateScales: function (options, maxMeters) {
-               if (options.metric && maxMeters) {
-                       this._updateMetric(maxMeters);
+       _onFocus: function () {
+               this._focused = true;
+               this._map.fire('focus');
+       },
+
+       _onBlur: function () {
+               this._focused = false;
+               this._map.fire('blur');
+       },
+
+       _setPanDelta: function (panDelta) {
+               var keys = this._panKeys = {},
+                   codes = this.keyCodes,
+                   i, len;
+
+               for (i = 0, len = codes.left.length; i < len; i++) {
+                       keys[codes.left[i]] = [-1 * panDelta, 0];
+               }
+               for (i = 0, len = codes.right.length; i < len; i++) {
+                       keys[codes.right[i]] = [panDelta, 0];
+               }
+               for (i = 0, len = codes.down.length; i < len; i++) {
+                       keys[codes.down[i]] = [0, panDelta];
                }
+               for (i = 0, len = codes.up.length; i < len; i++) {
+                       keys[codes.up[i]] = [0, -1 * panDelta];
+               }
+       },
 
-               if (options.imperial && maxMeters) {
-                       this._updateImperial(maxMeters);
+       _setZoomDelta: function (zoomDelta) {
+               var keys = this._zoomKeys = {},
+                   codes = this.keyCodes,
+                   i, len;
+
+               for (i = 0, len = codes.zoomIn.length; i < len; i++) {
+                       keys[codes.zoomIn[i]] = zoomDelta;
+               }
+               for (i = 0, len = codes.zoomOut.length; i < len; i++) {
+                       keys[codes.zoomOut[i]] = -zoomDelta;
                }
        },
 
-       _updateMetric: function (maxMeters) {
-               var meters = this._getRoundNum(maxMeters);
+       _addHooks: function () {
+               L.DomEvent.on(document, 'keydown', this._onKeyDown, this);
+       },
 
-               this._mScale.style.width = this._getScaleWidth(meters / maxMeters) + 'px';
-               this._mScale.innerHTML = meters < 1000 ? meters + ' m' : (meters / 1000) + ' km';
+       _removeHooks: function () {
+               L.DomEvent.off(document, 'keydown', this._onKeyDown, this);
        },
 
-       _updateImperial: function (maxMeters) {
-               var maxFeet = maxMeters * 3.2808399,
-                   scale = this._iScale,
-                   maxMiles, miles, feet;
+       _onKeyDown: function (e) {
+               if (e.altKey || e.ctrlKey || e.metaKey) { return; }
 
-               if (maxFeet > 5280) {
-                       maxMiles = maxFeet / 5280;
-                       miles = this._getRoundNum(maxMiles);
+               var key = e.keyCode,
+                   map = this._map,
+                   offset;
+
+               if (key in this._panKeys) {
+
+                       if (map._panAnim && map._panAnim._inProgress) { return; }
+
+                       offset = this._panKeys[key];
+                       if (e.shiftKey) {
+                               offset = L.point(offset).multiplyBy(3);
+                       }
+
+                       map.panBy(offset);
 
-                       scale.style.width = this._getScaleWidth(miles / maxMiles) + 'px';
-                       scale.innerHTML = miles + ' mi';
+                       if (map.options.maxBounds) {
+                               map.panInsideBounds(map.options.maxBounds);
+                       }
+
+               } else if (key in this._zoomKeys) {
+                       map.setZoom(map.getZoom() + (e.shiftKey ? 3 : 1) * this._zoomKeys[key]);
+
+               } else if (key === 27) {
+                       map.closePopup();
 
                } else {
-                       feet = this._getRoundNum(maxFeet);
+                       return;
+               }
+
+               L.DomEvent.stop(e);
+       }
+});
+
+// @section Handlers
+// @section Handlers
+// @property keyboard: Handler
+// Keyboard navigation handler.
+L.Map.addInitHook('addHandler', 'keyboard', L.Map.Keyboard);
+
 
-                       scale.style.width = this._getScaleWidth(feet / maxFeet) + 'px';
-                       scale.innerHTML = feet + ' ft';
+
+/*
+ * L.Handler.MarkerDrag is used internally by L.Marker to make the markers draggable.
+ */
+
+
+/* @namespace Marker
+ * @section Interaction handlers
+ *
+ * Interaction handlers are properties of a marker instance that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging (see `Handler` methods). Example:
+ *
+ * ```js
+ * marker.dragging.disable();
+ * ```
+ *
+ * @property dragging: Handler
+ * Marker dragging handler (by both mouse and touch).
+ */
+
+L.Handler.MarkerDrag = L.Handler.extend({
+       initialize: function (marker) {
+               this._marker = marker;
+       },
+
+       addHooks: function () {
+               var icon = this._marker._icon;
+
+               if (!this._draggable) {
+                       this._draggable = new L.Draggable(icon, icon, true);
                }
+
+               this._draggable.on({
+                       dragstart: this._onDragStart,
+                       drag: this._onDrag,
+                       dragend: this._onDragEnd
+               }, this).enable();
+
+               L.DomUtil.addClass(icon, 'leaflet-marker-draggable');
        },
 
-       _getScaleWidth: function (ratio) {
-               return Math.round(this.options.maxWidth * ratio) - 10;
+       removeHooks: function () {
+               this._draggable.off({
+                       dragstart: this._onDragStart,
+                       drag: this._onDrag,
+                       dragend: this._onDragEnd
+               }, this).disable();
+
+               if (this._marker._icon) {
+                       L.DomUtil.removeClass(this._marker._icon, 'leaflet-marker-draggable');
+               }
        },
 
-       _getRoundNum: function (num) {
-               var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1),
-                   d = num / pow10;
+       moved: function () {
+               return this._draggable && this._draggable._moved;
+       },
+
+       _onDragStart: function () {
+               // @section Dragging events
+               // @event dragstart: Event
+               // Fired when the user starts dragging the marker.
 
-               d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
+               // @event movestart: Event
+               // Fired when the marker starts moving (because of dragging).
 
-               return pow10 * d;
+               this._oldLatLng = this._marker.getLatLng();
+               this._marker
+                   .closePopup()
+                   .fire('movestart')
+                   .fire('dragstart');
+       },
+
+       _onDrag: function (e) {
+               var marker = this._marker,
+                   shadow = marker._shadow,
+                   iconPos = L.DomUtil.getPosition(marker._icon),
+                   latlng = marker._map.layerPointToLatLng(iconPos);
+
+               // update shadow position
+               if (shadow) {
+                       L.DomUtil.setPosition(shadow, iconPos);
+               }
+
+               marker._latlng = latlng;
+               e.latlng = latlng;
+               e.oldLatLng = this._oldLatLng;
+
+               // @event drag: Event
+               // Fired repeatedly while the user drags the marker.
+               marker
+                   .fire('move', e)
+                   .fire('drag', e);
+       },
+
+       _onDragEnd: function (e) {
+               // @event dragend: DragEndEvent
+               // Fired when the user stops dragging the marker.
+
+               // @event moveend: Event
+               // Fired when the marker stops moving (because of dragging).
+               delete this._oldLatLng;
+               this._marker
+                   .fire('moveend')
+                   .fire('dragend', e);
        }
 });
 
-L.control.scale = function (options) {
-       return new L.Control.Scale(options);
-};
 
 
 /*\r
- * L.Control.Layers is a control to allow users to switch between different layers on the map.\r
+ * @class Control\r
+ * @aka L.Control\r
+ * @inherits Class\r
+ *\r
+ * L.Control is a base class for implementing map controls. Handles positioning.\r
+ * All other controls extend from this class.\r
+ */\r
+\r
+L.Control = L.Class.extend({\r
+       // @section\r
+       // @aka Control options\r
+       options: {\r
+               // @option position: String = 'topright'\r
+               // The position of the control (one of the map corners). Possible values are `'topleft'`,\r
+               // `'topright'`, `'bottomleft'` or `'bottomright'`\r
+               position: 'topright'\r
+       },\r
+\r
+       initialize: function (options) {\r
+               L.setOptions(this, options);\r
+       },\r
+\r
+       /* @section\r
+        * Classes extending L.Control will inherit the following methods:\r
+        *\r
+        * @method getPosition: string\r
+        * Returns the position of the control.\r
+        */\r
+       getPosition: function () {\r
+               return this.options.position;\r
+       },\r
+\r
+       // @method setPosition(position: string): this\r
+       // Sets the position of the control.\r
+       setPosition: function (position) {\r
+               var map = this._map;\r
+\r
+               if (map) {\r
+                       map.removeControl(this);\r
+               }\r
+\r
+               this.options.position = position;\r
+\r
+               if (map) {\r
+                       map.addControl(this);\r
+               }\r
+\r
+               return this;\r
+       },\r
+\r
+       // @method getContainer: HTMLElement\r
+       // Returns the HTMLElement that contains the control.\r
+       getContainer: function () {\r
+               return this._container;\r
+       },\r
+\r
+       // @method addTo(map: Map): this\r
+       // Adds the control to the given map.\r
+       addTo: function (map) {\r
+               this.remove();\r
+               this._map = map;\r
+\r
+               var container = this._container = this.onAdd(map),\r
+                   pos = this.getPosition(),\r
+                   corner = map._controlCorners[pos];\r
+\r
+               L.DomUtil.addClass(container, 'leaflet-control');\r
+\r
+               if (pos.indexOf('bottom') !== -1) {\r
+                       corner.insertBefore(container, corner.firstChild);\r
+               } else {\r
+                       corner.appendChild(container);\r
+               }\r
+\r
+               return this;\r
+       },\r
+\r
+       // @method remove: this\r
+       // Removes the control from the map it is currently active on.\r
+       remove: function () {\r
+               if (!this._map) {\r
+                       return this;\r
+               }\r
+\r
+               L.DomUtil.remove(this._container);\r
+\r
+               if (this.onRemove) {\r
+                       this.onRemove(this._map);\r
+               }\r
+\r
+               this._map = null;\r
+\r
+               return this;\r
+       },\r
+\r
+       _refocusOnMap: function (e) {\r
+               // if map exists and event is not a keyboard event\r
+               if (this._map && e && e.screenX > 0 && e.screenY > 0) {\r
+                       this._map.getContainer().focus();\r
+               }\r
+       }\r
+});\r
+\r
+L.control = function (options) {\r
+       return new L.Control(options);\r
+};\r
+\r
+/* @section Extension methods\r
+ * @uninheritable\r
+ *\r
+ * Every control should extend from `L.Control` and (re-)implement the following methods.\r
+ *\r
+ * @method onAdd(map: Map): HTMLElement\r
+ * Should return the container DOM element for the control and add listeners on relevant map events. Called on [`control.addTo(map)`](#control-addTo).\r
+ *\r
+ * @method onRemove(map: Map)\r
+ * Optional method. Should contain all clean up code that removes the listeners previously added in [`onAdd`](#control-onadd). Called on [`control.remove()`](#control-remove).\r
+ */\r
+\r
+/* @namespace Map\r
+ * @section Methods for Layers and Controls\r
+ */\r
+L.Map.include({\r
+       // @method addControl(control: Control): this\r
+       // Adds the given control to the map\r
+       addControl: function (control) {\r
+               control.addTo(this);\r
+               return this;\r
+       },\r
+\r
+       // @method removeControl(control: Control): this\r
+       // Removes the given control from the map\r
+       removeControl: function (control) {\r
+               control.remove();\r
+               return this;\r
+       },\r
+\r
+       _initControlPos: function () {\r
+               var corners = this._controlCorners = {},\r
+                   l = 'leaflet-',\r
+                   container = this._controlContainer =\r
+                           L.DomUtil.create('div', l + 'control-container', this._container);\r
+\r
+               function createCorner(vSide, hSide) {\r
+                       var className = l + vSide + ' ' + l + hSide;\r
+\r
+                       corners[vSide + hSide] = L.DomUtil.create('div', className, container);\r
+               }\r
+\r
+               createCorner('top', 'left');\r
+               createCorner('top', 'right');\r
+               createCorner('bottom', 'left');\r
+               createCorner('bottom', 'right');\r
+       },\r
+\r
+       _clearControlPos: function () {\r
+               L.DomUtil.remove(this._controlContainer);\r
+       }\r
+});\r
+
+
+
+/*\r
+ * @class Control.Zoom\r
+ * @aka L.Control.Zoom\r
+ * @inherits Control\r
+ *\r
+ * A basic zoom control with two buttons (zoom in and zoom out). It is put on the map by default unless you set its [`zoomControl` option](#map-zoomcontrol) to `false`. Extends `Control`.\r
  */\r
 \r
-L.Control.Layers = L.Control.extend({\r
+L.Control.Zoom = L.Control.extend({\r
+       // @section\r
+       // @aka Control.Zoom options\r
        options: {\r
-               collapsed: true,\r
-               position: 'topright',\r
-               autoZIndex: true\r
-       },\r
+               position: 'topleft',\r
 \r
-       initialize: function (baseLayers, overlays, options) {\r
-               L.setOptions(this, options);\r
+               // @option zoomInText: String = '+'\r
+               // The text set on the 'zoom in' button.\r
+               zoomInText: '+',\r
 \r
-               this._layers = {};\r
-               this._lastZIndex = 0;\r
-               this._handlingClick = false;\r
+               // @option zoomInTitle: String = 'Zoom in'\r
+               // The title set on the 'zoom in' button.\r
+               zoomInTitle: 'Zoom in',\r
 \r
-               for (var i in baseLayers) {\r
-                       this._addLayer(baseLayers[i], i);\r
-               }\r
+               // @option zoomOutText: String = '-'\r
+               // The text set on the 'zoom out' button.\r
+               zoomOutText: '-',\r
 \r
-               for (i in overlays) {\r
-                       this._addLayer(overlays[i], i, true);\r
-               }\r
+               // @option zoomOutTitle: String = 'Zoom out'\r
+               // The title set on the 'zoom out' button.\r
+               zoomOutTitle: 'Zoom out'\r
        },\r
 \r
        onAdd: function (map) {\r
-               this._initLayout();\r
-               this._update();\r
+               var zoomName = 'leaflet-control-zoom',\r
+                   container = L.DomUtil.create('div', zoomName + ' leaflet-bar'),\r
+                   options = this.options;\r
 \r
-               map\r
-                   .on('layeradd', this._onLayerChange, this)\r
-                   .on('layerremove', this._onLayerChange, this);\r
+               this._zoomInButton  = this._createButton(options.zoomInText, options.zoomInTitle,\r
+                       zoomName + '-in',  container, this._zoomIn);\r
+               this._zoomOutButton = this._createButton(options.zoomOutText, options.zoomOutTitle,\r
+                       zoomName + '-out', container, this._zoomOut);\r
 \r
-               return this._container;\r
+               this._updateDisabled();\r
+               map.on('zoomend zoomlevelschange', this._updateDisabled, this);\r
+\r
+               return container;\r
        },\r
 \r
        onRemove: function (map) {\r
-               map\r
-                   .off('layeradd', this._onLayerChange, this)\r
-                   .off('layerremove', this._onLayerChange, this);\r
+               map.off('zoomend zoomlevelschange', this._updateDisabled, this);\r
        },\r
 \r
-       addBaseLayer: function (layer, name) {\r
-               this._addLayer(layer, name);\r
-               this._update();\r
+       disable: function () {\r
+               this._disabled = true;\r
+               this._updateDisabled();\r
                return this;\r
        },\r
 \r
-       addOverlay: function (layer, name) {\r
-               this._addLayer(layer, name, true);\r
-               this._update();\r
+       enable: function () {\r
+               this._disabled = false;\r
+               this._updateDisabled();\r
                return this;\r
        },\r
 \r
-       removeLayer: function (layer) {\r
-               var id = L.stamp(layer);\r
-               delete this._layers[id];\r
-               this._update();\r
-               return this;\r
+       _zoomIn: function (e) {\r
+               if (!this._disabled && this._map._zoom < this._map.getMaxZoom()) {\r
+                       this._map.zoomIn(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1));\r
+               }\r
        },\r
 \r
-       _initLayout: function () {\r
-               var className = 'leaflet-control-layers',\r
-                   container = this._container = L.DomUtil.create('div', className);\r
-\r
-               //Makes this work on IE10 Touch devices by stopping it from firing a mouseout event when the touch is released\r
-               container.setAttribute('aria-haspopup', true);\r
-\r
-               if (!L.Browser.touch) {\r
-                       L.DomEvent\r
-                               .disableClickPropagation(container)\r
-                               .disableScrollPropagation(container);\r
-               } else {\r
-                       L.DomEvent.on(container, 'click', L.DomEvent.stopPropagation);\r
+       _zoomOut: function (e) {\r
+               if (!this._disabled && this._map._zoom > this._map.getMinZoom()) {\r
+                       this._map.zoomOut(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1));\r
                }\r
+       },\r
 \r
-               var form = this._form = L.DomUtil.create('form', className + '-list');\r
-\r
-               if (this.options.collapsed) {\r
-                       if (!L.Browser.android) {\r
-                               L.DomEvent\r
-                                   .on(container, 'mouseover', this._expand, this)\r
-                                   .on(container, 'mouseout', this._collapse, this);\r
-                       }\r
-                       var link = this._layersLink = L.DomUtil.create('a', className + '-toggle', container);\r
-                       link.href = '#';\r
-                       link.title = 'Layers';\r
-\r
-                       if (L.Browser.touch) {\r
-                               L.DomEvent\r
-                                   .on(link, 'click', L.DomEvent.stop)\r
-                                   .on(link, 'click', this._expand, this);\r
-                       }\r
-                       else {\r
-                               L.DomEvent.on(link, 'focus', this._expand, this);\r
-                       }\r
-                       //Work around for Firefox android issue https://github.com/Leaflet/Leaflet/issues/2033\r
-                       L.DomEvent.on(form, 'click', function () {\r
-                               setTimeout(L.bind(this._onInputClick, this), 0);\r
-                       }, this);\r
+       _createButton: function (html, title, className, container, fn) {\r
+               var link = L.DomUtil.create('a', className, container);\r
+               link.innerHTML = html;\r
+               link.href = '#';\r
+               link.title = title;\r
 \r
-                       this._map.on('click', this._collapse, this);\r
-                       // TODO keyboard accessibility\r
-               } else {\r
-                       this._expand();\r
-               }\r
+               /*\r
+                * Will force screen readers like VoiceOver to read this as "Zoom in - button"\r
+                */\r
+               link.setAttribute('role', 'button');\r
+               link.setAttribute('aria-label', title);\r
 \r
-               this._baseLayersList = L.DomUtil.create('div', className + '-base', form);\r
-               this._separator = L.DomUtil.create('div', className + '-separator', form);\r
-               this._overlaysList = L.DomUtil.create('div', className + '-overlays', form);\r
+               L.DomEvent\r
+                   .on(link, 'mousedown dblclick', L.DomEvent.stopPropagation)\r
+                   .on(link, 'click', L.DomEvent.stop)\r
+                   .on(link, 'click', fn, this)\r
+                   .on(link, 'click', this._refocusOnMap, this);\r
 \r
-               container.appendChild(form);\r
+               return link;\r
        },\r
 \r
-       _addLayer: function (layer, name, overlay) {\r
-               var id = L.stamp(layer);\r
+       _updateDisabled: function () {\r
+               var map = this._map,\r
+                   className = 'leaflet-disabled';\r
 \r
-               this._layers[id] = {\r
-                       layer: layer,\r
-                       name: name,\r
-                       overlay: overlay\r
-               };\r
+               L.DomUtil.removeClass(this._zoomInButton, className);\r
+               L.DomUtil.removeClass(this._zoomOutButton, className);\r
 \r
-               if (this.options.autoZIndex && layer.setZIndex) {\r
-                       this._lastZIndex++;\r
-                       layer.setZIndex(this._lastZIndex);\r
+               if (this._disabled || map._zoom === map.getMinZoom()) {\r
+                       L.DomUtil.addClass(this._zoomOutButton, className);\r
                }\r
-       },\r
-\r
-       _update: function () {\r
-               if (!this._container) {\r
-                       return;\r
+               if (this._disabled || map._zoom === map.getMaxZoom()) {\r
+                       L.DomUtil.addClass(this._zoomInButton, className);\r
                }\r
+       }\r
+});\r
 \r
-               this._baseLayersList.innerHTML = '';\r
-               this._overlaysList.innerHTML = '';\r
+// @namespace Map\r
+// @section Control options\r
+// @option zoomControl: Boolean = true\r
+// Whether a [zoom control](#control-zoom) is added to the map by default.\r
+L.Map.mergeOptions({\r
+       zoomControl: true\r
+});\r
 \r
-               var baseLayersPresent = false,\r
-                   overlaysPresent = false,\r
-                   i, obj;\r
+L.Map.addInitHook(function () {\r
+       if (this.options.zoomControl) {\r
+               this.zoomControl = new L.Control.Zoom();\r
+               this.addControl(this.zoomControl);\r
+       }\r
+});\r
 \r
-               for (i in this._layers) {\r
-                       obj = this._layers[i];\r
-                       this._addItem(obj);\r
-                       overlaysPresent = overlaysPresent || obj.overlay;\r
-                       baseLayersPresent = baseLayersPresent || !obj.overlay;\r
-               }\r
+// @namespace Control.Zoom\r
+// @factory L.control.zoom(options: Control.Zoom options)\r
+// Creates a zoom control\r
+L.control.zoom = function (options) {\r
+       return new L.Control.Zoom(options);\r
+};\r
+
+
+
+/*\r
+ * @class Control.Attribution\r
+ * @aka L.Control.Attribution\r
+ * @inherits Control\r
+ *\r
+ * The attribution control allows you to display attribution data in a small text box on a map. It is put on the map by default unless you set its [`attributionControl` option](#map-attributioncontrol) to `false`, and it fetches attribution texts from layers with the [`getAttribution` method](#layer-getattribution) automatically. Extends Control.\r
+ */\r
 \r
-               this._separator.style.display = overlaysPresent && baseLayersPresent ? '' : 'none';\r
+L.Control.Attribution = L.Control.extend({\r
+       // @section\r
+       // @aka Control.Attribution options\r
+       options: {\r
+               position: 'bottomright',\r
+\r
+               // @option prefix: String = 'Leaflet'\r
+               // The HTML text shown before the attributions. Pass `false` to disable.\r
+               prefix: '<a href="http://leafletjs.com" title="A JS library for interactive maps">Leaflet</a>'\r
        },\r
 \r
-       _onLayerChange: function (e) {\r
-               var obj = this._layers[L.stamp(e.layer)];\r
+       initialize: function (options) {\r
+               L.setOptions(this, options);\r
 \r
-               if (!obj) { return; }\r
+               this._attributions = {};\r
+       },\r
 \r
-               if (!this._handlingClick) {\r
-                       this._update();\r
+       onAdd: function (map) {\r
+               map.attributionControl = this;\r
+               this._container = L.DomUtil.create('div', 'leaflet-control-attribution');\r
+               if (L.DomEvent) {\r
+                       L.DomEvent.disableClickPropagation(this._container);\r
                }\r
 \r
-               var type = obj.overlay ?\r
-                       (e.type === 'layeradd' ? 'overlayadd' : 'overlayremove') :\r
-                       (e.type === 'layeradd' ? 'baselayerchange' : null);\r
-\r
-               if (type) {\r
-                       this._map.fire(type, obj);\r
+               // TODO ugly, refactor\r
+               for (var i in map._layers) {\r
+                       if (map._layers[i].getAttribution) {\r
+                               this.addAttribution(map._layers[i].getAttribution());\r
+                       }\r
                }\r
-       },\r
 \r
-       // IE7 bugs out if you create a radio dynamically, so you have to do it this hacky way (see http://bit.ly/PqYLBe)\r
-       _createRadioElement: function (name, checked) {\r
-\r
-               var radioHtml = '<input type="radio" class="leaflet-control-layers-selector" name="' + name + '"';\r
-               if (checked) {\r
-                       radioHtml += ' checked="checked"';\r
-               }\r
-               radioHtml += '/>';\r
+               this._update();\r
 \r
-               var radioFragment = document.createElement('div');\r
-               radioFragment.innerHTML = radioHtml;\r
+               return this._container;\r
+       },\r
 \r
-               return radioFragment.firstChild;\r
+       // @method setPrefix(prefix: String): this\r
+       // Sets the text before the attributions.\r
+       setPrefix: function (prefix) {\r
+               this.options.prefix = prefix;\r
+               this._update();\r
+               return this;\r
        },\r
 \r
-       _addItem: function (obj) {\r
-               var label = document.createElement('label'),\r
-                   input,\r
-                   checked = this._map.hasLayer(obj.layer);\r
+       // @method addAttribution(text: String): this\r
+       // Adds an attribution text (e.g. `'Vector data &copy; Mapbox'`).\r
+       addAttribution: function (text) {\r
+               if (!text) { return this; }\r
 \r
-               if (obj.overlay) {\r
-                       input = document.createElement('input');\r
-                       input.type = 'checkbox';\r
-                       input.className = 'leaflet-control-layers-selector';\r
-                       input.defaultChecked = checked;\r
-               } else {\r
-                       input = this._createRadioElement('leaflet-base-layers', checked);\r
+               if (!this._attributions[text]) {\r
+                       this._attributions[text] = 0;\r
                }\r
+               this._attributions[text]++;\r
 \r
-               input.layerId = L.stamp(obj.layer);\r
-\r
-               L.DomEvent.on(input, 'click', this._onInputClick, this);\r
+               this._update();\r
 \r
-               var name = document.createElement('span');\r
-               name.innerHTML = ' ' + obj.name;\r
+               return this;\r
+       },\r
 \r
-               label.appendChild(input);\r
-               label.appendChild(name);\r
+       // @method removeAttribution(text: String): this\r
+       // Removes an attribution text.\r
+       removeAttribution: function (text) {\r
+               if (!text) { return this; }\r
 \r
-               var container = obj.overlay ? this._overlaysList : this._baseLayersList;\r
-               container.appendChild(label);\r
+               if (this._attributions[text]) {\r
+                       this._attributions[text]--;\r
+                       this._update();\r
+               }\r
 \r
-               return label;\r
+               return this;\r
        },\r
 \r
-       _onInputClick: function () {\r
-               var i, input, obj,\r
-                   inputs = this._form.getElementsByTagName('input'),\r
-                   inputsLen = inputs.length;\r
-\r
-               this._handlingClick = true;\r
-\r
-               for (i = 0; i < inputsLen; i++) {\r
-                       input = inputs[i];\r
-                       obj = this._layers[input.layerId];\r
+       _update: function () {\r
+               if (!this._map) { return; }\r
 \r
-                       if (input.checked && !this._map.hasLayer(obj.layer)) {\r
-                               this._map.addLayer(obj.layer);\r
+               var attribs = [];\r
 \r
-                       } else if (!input.checked && this._map.hasLayer(obj.layer)) {\r
-                               this._map.removeLayer(obj.layer);\r
+               for (var i in this._attributions) {\r
+                       if (this._attributions[i]) {\r
+                               attribs.push(i);\r
                        }\r
                }\r
 \r
-               this._handlingClick = false;\r
+               var prefixAndAttribs = [];\r
+\r
+               if (this.options.prefix) {\r
+                       prefixAndAttribs.push(this.options.prefix);\r
+               }\r
+               if (attribs.length) {\r
+                       prefixAndAttribs.push(attribs.join(', '));\r
+               }\r
 \r
-               this._refocusOnMap();\r
-       },\r
+               this._container.innerHTML = prefixAndAttribs.join(' | ');\r
+       }\r
+});\r
 \r
-       _expand: function () {\r
-               L.DomUtil.addClass(this._container, 'leaflet-control-layers-expanded');\r
-       },\r
+// @namespace Map\r
+// @section Control options\r
+// @option attributionControl: Boolean = true\r
+// Whether a [attribution control](#control-attribution) is added to the map by default.\r
+L.Map.mergeOptions({\r
+       attributionControl: true\r
+});\r
 \r
-       _collapse: function () {\r
-               this._container.className = this._container.className.replace(' leaflet-control-layers-expanded', '');\r
+L.Map.addInitHook(function () {\r
+       if (this.options.attributionControl) {\r
+               new L.Control.Attribution().addTo(this);\r
        }\r
 });\r
 \r
-L.control.layers = function (baseLayers, overlays, options) {\r
-       return new L.Control.Layers(baseLayers, overlays, options);\r
+// @namespace Control.Attribution\r
+// @factory L.control.attribution(options: Control.Attribution options)\r
+// Creates an attribution control.\r
+L.control.attribution = function (options) {\r
+       return new L.Control.Attribution(options);\r
 };\r
 
 
-/*
- * L.PosAnimation is used by Leaflet internally for pan animations.
- */
-
-L.PosAnimation = L.Class.extend({
-       includes: L.Mixin.Events,
-
-       run: function (el, newPos, duration, easeLinearity) { // (HTMLElement, Point[, Number, Number])
-               this.stop();
-
-               this._el = el;
-               this._inProgress = true;
-               this._newPos = newPos;
-
-               this.fire('start');
-
-               el.style[L.DomUtil.TRANSITION] = 'all ' + (duration || 0.25) +
-                       's cubic-bezier(0,0,' + (easeLinearity || 0.5) + ',1)';
-
-               L.DomEvent.on(el, L.DomUtil.TRANSITION_END, this._onTransitionEnd, this);
-               L.DomUtil.setPosition(el, newPos);
-
-               // toggle reflow, Chrome flickers for some reason if you don't do this
-               L.Util.falseFn(el.offsetWidth);
-
-               // there's no native way to track value updates of transitioned properties, so we imitate this
-               this._stepTimer = setInterval(L.bind(this._onStep, this), 50);
-       },
-
-       stop: function () {
-               if (!this._inProgress) { return; }
-
-               // if we just removed the transition property, the element would jump to its final position,
-               // so we need to make it stay at the current position
-
-               L.DomUtil.setPosition(this._el, this._getPos());
-               this._onTransitionEnd();
-               L.Util.falseFn(this._el.offsetWidth); // force reflow in case we are about to start a new animation
-       },
-
-       _onStep: function () {
-               var stepPos = this._getPos();
-               if (!stepPos) {
-                       this._onTransitionEnd();
-                       return;
-               }
-               // jshint camelcase: false
-               // make L.DomUtil.getPosition return intermediate position value during animation
-               this._el._leaflet_pos = stepPos;
-
-               this.fire('step');
-       },
-
-       // you can't easily get intermediate values of properties animated with CSS3 Transitions,
-       // we need to parse computed style (in case of transform it returns matrix string)
-
-       _transformRe: /([-+]?(?:\d*\.)?\d+)\D*, ([-+]?(?:\d*\.)?\d+)\D*\)/,
-
-       _getPos: function () {
-               var left, top, matches,
-                   el = this._el,
-                   style = window.getComputedStyle(el);
-
-               if (L.Browser.any3d) {
-                       matches = style[L.DomUtil.TRANSFORM].match(this._transformRe);
-                       if (!matches) { return; }
-                       left = parseFloat(matches[1]);
-                       top  = parseFloat(matches[2]);
-               } else {
-                       left = parseFloat(style.left);
-                       top  = parseFloat(style.top);
-               }
-
-               return new L.Point(left, top, true);
-       },
-
-       _onTransitionEnd: function () {
-               L.DomEvent.off(this._el, L.DomUtil.TRANSITION_END, this._onTransitionEnd, this);
-
-               if (!this._inProgress) { return; }
-               this._inProgress = false;
-
-               this._el.style[L.DomUtil.TRANSITION] = '';
-
-               // jshint camelcase: false
-               // make sure L.DomUtil.getPosition returns the final position value after animation
-               this._el._leaflet_pos = this._newPos;
-
-               clearInterval(this._stepTimer);
-
-               this.fire('step').fire('end');
-       }
-
-});
-
-
-/*
- * Extends L.Map to handle panning animations.
- */
-
-L.Map.include({
-
-       setView: function (center, zoom, options) {
-
-               zoom = zoom === undefined ? this._zoom : this._limitZoom(zoom);
-               center = this._limitCenter(L.latLng(center), zoom, this.options.maxBounds);
-               options = options || {};
-
-               if (this._panAnim) {
-                       this._panAnim.stop();
-               }
-
-               if (this._loaded && !options.reset && options !== true) {
-
-                       if (options.animate !== undefined) {
-                               options.zoom = L.extend({animate: options.animate}, options.zoom);
-                               options.pan = L.extend({animate: options.animate}, options.pan);
-                       }
-
-                       // try animating pan or zoom
-                       var animated = (this._zoom !== zoom) ?
-                               this._tryAnimatedZoom && this._tryAnimatedZoom(center, zoom, options.zoom) :
-                               this._tryAnimatedPan(center, options.pan);
-
-                       if (animated) {
-                               // prevent resize handler call, the view will refresh after animation anyway
-                               clearTimeout(this._sizeTimer);
-                               return this;
-                       }
-               }
-
-               // animation didn't start, just reset the map view
-               this._resetView(center, zoom);
-
-               return this;
-       },
-
-       panBy: function (offset, options) {
-               offset = L.point(offset).round();
-               options = options || {};
-
-               if (!offset.x && !offset.y) {
-                       return this;
-               }
-
-               if (!this._panAnim) {
-                       this._panAnim = new L.PosAnimation();
-
-                       this._panAnim.on({
-                               'step': this._onPanTransitionStep,
-                               'end': this._onPanTransitionEnd
-                       }, this);
-               }
-
-               // don't fire movestart if animating inertia
-               if (!options.noMoveStart) {
-                       this.fire('movestart');
-               }
-
-               // animate pan unless animate: false specified
-               if (options.animate !== false) {
-                       L.DomUtil.addClass(this._mapPane, 'leaflet-pan-anim');
-
-                       var newPos = this._getMapPanePos().subtract(offset);
-                       this._panAnim.run(this._mapPane, newPos, options.duration || 0.25, options.easeLinearity);
-               } else {
-                       this._rawPanBy(offset);
-                       this.fire('move').fire('moveend');
-               }
-
-               return this;
-       },
-
-       _onPanTransitionStep: function () {
-               this.fire('move');
-       },
-
-       _onPanTransitionEnd: function () {
-               L.DomUtil.removeClass(this._mapPane, 'leaflet-pan-anim');
-               this.fire('moveend');
-       },
-
-       _tryAnimatedPan: function (center, options) {
-               // difference between the new and current centers in pixels
-               var offset = this._getCenterOffset(center)._floor();
-
-               // don't animate too far unless animate: true specified in options
-               if ((options && options.animate) !== true && !this.getSize().contains(offset)) { return false; }
-
-               this.panBy(offset, options);
-
-               return true;
-       }
-});
-
 
 /*
- * L.PosAnimation fallback implementation that powers Leaflet pan animations
- * in browsers that don't support CSS3 Transitions.
+ * @class Control.Scale
+ * @aka L.Control.Scale
+ * @inherits Control
+ *
+ * A simple scale control that shows the scale of the current center of screen in metric (m/km) and imperial (mi/ft) systems. Extends `Control`.
+ *
+ * @example
+ *
+ * ```js
+ * L.control.scale().addTo(map);
+ * ```
  */
 
-L.PosAnimation = L.DomUtil.TRANSITION ? L.PosAnimation : L.PosAnimation.extend({
-
-       run: function (el, newPos, duration, easeLinearity) { // (HTMLElement, Point[, Number, Number])
-               this.stop();
-
-               this._el = el;
-               this._inProgress = true;
-               this._duration = duration || 0.25;
-               this._easeOutPower = 1 / Math.max(easeLinearity || 0.5, 0.2);
-
-               this._startPos = L.DomUtil.getPosition(el);
-               this._offset = newPos.subtract(this._startPos);
-               this._startTime = +new Date();
-
-               this.fire('start');
-
-               this._animate();
-       },
-
-       stop: function () {
-               if (!this._inProgress) { return; }
-
-               this._step();
-               this._complete();
-       },
-
-       _animate: function () {
-               // animation loop
-               this._animId = L.Util.requestAnimFrame(this._animate, this);
-               this._step();
-       },
-
-       _step: function () {
-               var elapsed = (+new Date()) - this._startTime,
-                   duration = this._duration * 1000;
-
-               if (elapsed < duration) {
-                       this._runFrame(this._easeOut(elapsed / duration));
-               } else {
-                       this._runFrame(1);
-                       this._complete();
-               }
-       },
+L.Control.Scale = L.Control.extend({
+       // @section
+       // @aka Control.Scale options
+       options: {
+               position: 'bottomleft',
 
-       _runFrame: function (progress) {
-               var pos = this._startPos.add(this._offset.multiplyBy(progress));
-               L.DomUtil.setPosition(this._el, pos);
+               // @option maxWidth: Number = 100
+               // Maximum width of the control in pixels. The width is set dynamically to show round values (e.g. 100, 200, 500).
+               maxWidth: 100,
 
-               this.fire('step');
-       },
+               // @option metric: Boolean = True
+               // Whether to show the metric scale line (m/km).
+               metric: true,
 
-       _complete: function () {
-               L.Util.cancelAnimFrame(this._animId);
+               // @option imperial: Boolean = True
+               // Whether to show the imperial scale line (mi/ft).
+               imperial: true
 
-               this._inProgress = false;
-               this.fire('end');
+               // @option updateWhenIdle: Boolean = false
+               // If `true`, the control is updated on [`moveend`](#map-moveend), otherwise it's always up-to-date (updated on [`move`](#map-move)).
        },
 
-       _easeOut: function (t) {
-               return 1 - Math.pow(1 - t, this._easeOutPower);
-       }
-});
-
-
-/*
- * Extends L.Map to handle zoom animations.
- */
-
-L.Map.mergeOptions({
-       zoomAnimation: true,
-       zoomAnimationThreshold: 4
-});
-
-if (L.DomUtil.TRANSITION) {
-
-       L.Map.addInitHook(function () {
-               // don't animate on browsers without hardware-accelerated transitions or old Android/Opera
-               this._zoomAnimated = this.options.zoomAnimation && L.DomUtil.TRANSITION &&
-                               L.Browser.any3d && !L.Browser.android23 && !L.Browser.mobileOpera;
-
-               // zoom transitions run with the same duration for all layers, so if one of transitionend events
-               // happens after starting zoom animation (propagating to the map pane), we know that it ended globally
-               if (this._zoomAnimated) {
-                       L.DomEvent.on(this._mapPane, L.DomUtil.TRANSITION_END, this._catchTransitionEnd, this);
-               }
-       });
-}
+       onAdd: function (map) {
+               var className = 'leaflet-control-scale',
+                   container = L.DomUtil.create('div', className),
+                   options = this.options;
 
-L.Map.include(!L.DomUtil.TRANSITION ? {} : {
+               this._addScales(options, className + '-line', container);
 
-       _catchTransitionEnd: function (e) {
-               if (this._animatingZoom && e.propertyName.indexOf('transform') >= 0) {
-                       this._onZoomTransitionEnd();
-               }
-       },
+               map.on(options.updateWhenIdle ? 'moveend' : 'move', this._update, this);
+               map.whenReady(this._update, this);
 
-       _nothingToAnimate: function () {
-               return !this._container.getElementsByClassName('leaflet-zoom-animated').length;
+               return container;
        },
 
-       _tryAnimatedZoom: function (center, zoom, options) {
-
-               if (this._animatingZoom) { return true; }
-
-               options = options || {};
-
-               // don't animate if disabled, not supported or zoom difference is too large
-               if (!this._zoomAnimated || options.animate === false || this._nothingToAnimate() ||
-                       Math.abs(zoom - this._zoom) > this.options.zoomAnimationThreshold) { return false; }
-
-               // offset is the pixel coords of the zoom origin relative to the current center
-               var scale = this.getZoomScale(zoom),
-                   offset = this._getCenterOffset(center)._divideBy(1 - 1 / scale),
-                       origin = this._getCenterLayerPoint()._add(offset);
-
-               // don't animate if the zoom origin isn't within one screen from the current center, unless forced
-               if (options.animate !== true && !this.getSize().contains(offset)) { return false; }
-
-               this
-                   .fire('movestart')
-                   .fire('zoomstart');
-
-               this._animateZoom(center, zoom, origin, scale, null, true);
-
-               return true;
+       onRemove: function (map) {
+               map.off(this.options.updateWhenIdle ? 'moveend' : 'move', this._update, this);
        },
 
-       _animateZoom: function (center, zoom, origin, scale, delta, backwards, forTouchZoom) {
-
-               if (!forTouchZoom) {
-                       this._animatingZoom = true;
-               }
-
-               // put transform transition on all layers with leaflet-zoom-animated class
-               L.DomUtil.addClass(this._mapPane, 'leaflet-zoom-anim');
-
-               // remember what center/zoom to set after animation
-               this._animateToCenter = center;
-               this._animateToZoom = zoom;
-
-               // disable any dragging during animation
-               if (L.Draggable) {
-                       L.Draggable._disabled = true;
+       _addScales: function (options, className, container) {
+               if (options.metric) {
+                       this._mScale = L.DomUtil.create('div', className, container);
                }
-
-               L.Util.requestAnimFrame(function () {
-                       this.fire('zoomanim', {
-                               center: center,
-                               zoom: zoom,
-                               origin: origin,
-                               scale: scale,
-                               delta: delta,
-                               backwards: backwards
-                       });
-                       // horrible hack to work around a Chrome bug https://github.com/Leaflet/Leaflet/issues/3689
-                       setTimeout(L.bind(this._onZoomTransitionEnd, this), 250);
-               }, this);
-       },
-
-       _onZoomTransitionEnd: function () {
-               if (!this._animatingZoom) { return; }
-
-               this._animatingZoom = false;
-
-               L.DomUtil.removeClass(this._mapPane, 'leaflet-zoom-anim');
-
-               L.Util.requestAnimFrame(function () {
-                       this._resetView(this._animateToCenter, this._animateToZoom, true, true);
-
-                       if (L.Draggable) {
-                               L.Draggable._disabled = false;
-                       }
-               }, this);
-       }
-});
-
-
-/*
-       Zoom animation logic for L.TileLayer.
-*/
-
-L.TileLayer.include({
-       _animateZoom: function (e) {
-               if (!this._animating) {
-                       this._animating = true;
-                       this._prepareBgBuffer();
+               if (options.imperial) {
+                       this._iScale = L.DomUtil.create('div', className, container);
                }
-
-               var bg = this._bgBuffer,
-                   transform = L.DomUtil.TRANSFORM,
-                   initialTransform = e.delta ? L.DomUtil.getTranslateString(e.delta) : bg.style[transform],
-                   scaleStr = L.DomUtil.getScaleString(e.scale, e.origin);
-
-               bg.style[transform] = e.backwards ?
-                               scaleStr + ' ' + initialTransform :
-                               initialTransform + ' ' + scaleStr;
        },
 
-       _endZoomAnim: function () {
-               var front = this._tileContainer,
-                   bg = this._bgBuffer;
-
-               front.style.visibility = '';
-               front.parentNode.appendChild(front); // Bring to fore
-
-               // force reflow
-               L.Util.falseFn(bg.offsetWidth);
-
-               var zoom = this._map.getZoom();
-               if (zoom > this.options.maxZoom || zoom < this.options.minZoom) {
-                       this._clearBgBuffer();
-               }
-
-               this._animating = false;
-       },
+       _update: function () {
+               var map = this._map,
+                   y = map.getSize().y / 2;
 
-       _clearBgBuffer: function () {
-               var map = this._map;
+               var maxMeters = map.distance(
+                               map.containerPointToLatLng([0, y]),
+                               map.containerPointToLatLng([this.options.maxWidth, y]));
 
-               if (map && !map._animatingZoom && !map.touchZoom._zooming) {
-                       this._bgBuffer.innerHTML = '';
-                       this._bgBuffer.style[L.DomUtil.TRANSFORM] = '';
-               }
+               this._updateScales(maxMeters);
        },
 
-       _prepareBgBuffer: function () {
-
-               var front = this._tileContainer,
-                   bg = this._bgBuffer;
-
-               // if foreground layer doesn't have many tiles but bg layer does,
-               // keep the existing bg layer and just zoom it some more
-
-               var bgLoaded = this._getLoadedTilesPercentage(bg),
-                   frontLoaded = this._getLoadedTilesPercentage(front);
-
-               if (bg && bgLoaded > 0.5 && frontLoaded < 0.5) {
-
-                       front.style.visibility = 'hidden';
-                       this._stopLoadingImages(front);
-                       return;
+       _updateScales: function (maxMeters) {
+               if (this.options.metric && maxMeters) {
+                       this._updateMetric(maxMeters);
                }
+               if (this.options.imperial && maxMeters) {
+                       this._updateImperial(maxMeters);
+               }
+       },
 
-               // prepare the buffer to become the front tile pane
-               bg.style.visibility = 'hidden';
-               bg.style[L.DomUtil.TRANSFORM] = '';
-
-               // switch out the current layer to be the new bg layer (and vice-versa)
-               this._tileContainer = bg;
-               bg = this._bgBuffer = front;
-
-               this._stopLoadingImages(bg);
+       _updateMetric: function (maxMeters) {
+               var meters = this._getRoundNum(maxMeters),
+                   label = meters < 1000 ? meters + ' m' : (meters / 1000) + ' km';
 
-               //prevent bg buffer from clearing right after zoom
-               clearTimeout(this._clearBgBufferTimer);
+               this._updateScale(this._mScale, label, meters / maxMeters);
        },
 
-       _getLoadedTilesPercentage: function (container) {
-               var tiles = container.getElementsByTagName('img'),
-                   i, len, count = 0;
+       _updateImperial: function (maxMeters) {
+               var maxFeet = maxMeters * 3.2808399,
+                   maxMiles, miles, feet;
 
-               for (i = 0, len = tiles.length; i < len; i++) {
-                       if (tiles[i].complete) {
-                               count++;
-                       }
+               if (maxFeet > 5280) {
+                       maxMiles = maxFeet / 5280;
+                       miles = this._getRoundNum(maxMiles);
+                       this._updateScale(this._iScale, miles + ' mi', miles / maxMiles);
+
+               } else {
+                       feet = this._getRoundNum(maxFeet);
+                       this._updateScale(this._iScale, feet + ' ft', feet / maxFeet);
                }
-               return count / len;
        },
 
-       // stops loading all tiles in the background layer
-       _stopLoadingImages: function (container) {
-               var tiles = Array.prototype.slice.call(container.getElementsByTagName('img')),
-                   i, len, tile;
+       _updateScale: function (scale, text, ratio) {
+               scale.style.width = Math.round(this.options.maxWidth * ratio) + 'px';
+               scale.innerHTML = text;
+       },
 
-               for (i = 0, len = tiles.length; i < len; i++) {
-                       tile = tiles[i];
+       _getRoundNum: function (num) {
+               var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1),
+                   d = num / pow10;
 
-                       if (!tile.complete) {
-                               tile.onload = L.Util.falseFn;
-                               tile.onerror = L.Util.falseFn;
-                               tile.src = L.Util.emptyImageUrl;
+               d = d >= 10 ? 10 :
+                   d >= 5 ? 5 :
+                   d >= 3 ? 3 :
+                   d >= 2 ? 2 : 1;
 
-                               tile.parentNode.removeChild(tile);
-                       }
-               }
+               return pow10 * d;
        }
 });
 
 
+// @factory L.control.scale(options?: Control.Scale options)
+// Creates an scale control with the given options.
+L.control.scale = function (options) {
+       return new L.Control.Scale(options);
+};
+
+
+
 /*\r
- * Provides L.Map with convenient shortcuts for using browser geolocation features.\r
+ * @class Control.Layers\r
+ * @aka L.Control.Layers\r
+ * @inherits Control\r
+ *\r
+ * The layers control gives users the ability to switch between different base layers and switch overlays on/off (check out the [detailed example](http://leafletjs.com/examples/layers-control.html)). Extends `Control`.\r
+ *\r
+ * @example\r
+ *\r
+ * ```js\r
+ * var baseLayers = {\r
+ *     "Mapbox": mapbox,\r
+ *     "OpenStreetMap": osm\r
+ * };\r
+ *\r
+ * var overlays = {\r
+ *     "Marker": marker,\r
+ *     "Roads": roadsLayer\r
+ * };\r
+ *\r
+ * L.control.layers(baseLayers, overlays).addTo(map);\r
+ * ```\r
+ *\r
+ * The `baseLayers` and `overlays` parameters are object literals with layer names as keys and `Layer` objects as values:\r
+ *\r
+ * ```js\r
+ * {\r
+ *     "<someName1>": layer1,\r
+ *     "<someName2>": layer2\r
+ * }\r
+ * ```\r
+ *\r
+ * The layer names can contain HTML, which allows you to add additional styling to the items:\r
+ *\r
+ * ```js\r
+ * {"<img src='my-layer-icon' /> <span class='my-layer-item'>My Layer</span>": myLayer}\r
+ * ```\r
  */\r
 \r
-L.Map.include({\r
-       _defaultLocateOptions: {\r
-               watch: false,\r
-               setView: false,\r
-               maxZoom: Infinity,\r
-               timeout: 10000,\r
-               maximumAge: 0,\r
-               enableHighAccuracy: false\r
+\r
+L.Control.Layers = L.Control.extend({\r
+       // @section\r
+       // @aka Control.Layers options\r
+       options: {\r
+               // @option collapsed: Boolean = true\r
+               // If `true`, the control will be collapsed into an icon and expanded on mouse hover or touch.\r
+               collapsed: true,\r
+               position: 'topright',\r
+\r
+               // @option autoZIndex: Boolean = true\r
+               // If `true`, the control will assign zIndexes in increasing order to all of its layers so that the order is preserved when switching them on/off.\r
+               autoZIndex: true,\r
+\r
+               // @option hideSingleBase: Boolean = false\r
+               // If `true`, the base layers in the control will be hidden when there is only one.\r
+               hideSingleBase: false,\r
+\r
+               // @option sortLayers: Boolean = false\r
+               // Whether to sort the layers. When `false`, layers will keep the order\r
+               // in which they were added to the control.\r
+               sortLayers: false,\r
+\r
+               // @option sortFunction: Function = *\r
+               // A [compare function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)\r
+               // that will be used for sorting the layers, when `sortLayers` is `true`.\r
+               // The function receives both the `L.Layer` instances and their names, as in\r
+               // `sortFunction(layerA, layerB, nameA, nameB)`.\r
+               // By default, it sorts layers alphabetically by their name.\r
+               sortFunction: function (layerA, layerB, nameA, nameB) {\r
+                       return nameA < nameB ? -1 : (nameB < nameA ? 1 : 0);\r
+               }\r
        },\r
 \r
-       locate: function (/*Object*/ options) {\r
+       initialize: function (baseLayers, overlays, options) {\r
+               L.setOptions(this, options);\r
 \r
-               options = this._locateOptions = L.extend(this._defaultLocateOptions, options);\r
+               this._layers = [];\r
+               this._lastZIndex = 0;\r
+               this._handlingClick = false;\r
 \r
-               if (!navigator.geolocation) {\r
-                       this._handleGeolocationError({\r
-                               code: 0,\r
-                               message: 'Geolocation not supported.'\r
-                       });\r
-                       return this;\r
+               for (var i in baseLayers) {\r
+                       this._addLayer(baseLayers[i], i);\r
                }\r
 \r
-               var onResponse = L.bind(this._handleGeolocationResponse, this),\r
-                       onError = L.bind(this._handleGeolocationError, this);\r
+               for (i in overlays) {\r
+                       this._addLayer(overlays[i], i, true);\r
+               }\r
+       },\r
 \r
-               if (options.watch) {\r
-                       this._locationWatchId =\r
-                               navigator.geolocation.watchPosition(onResponse, onError, options);\r
+       onAdd: function (map) {\r
+               this._initLayout();\r
+               this._update();\r
+\r
+               this._map = map;\r
+               map.on('zoomend', this._checkDisabledLayers, this);\r
+\r
+               return this._container;\r
+       },\r
+\r
+       onRemove: function () {\r
+               this._map.off('zoomend', this._checkDisabledLayers, this);\r
+\r
+               for (var i = 0; i < this._layers.length; i++) {\r
+                       this._layers[i].layer.off('add remove', this._onLayerChange, this);\r
+               }\r
+       },\r
+\r
+       // @method addBaseLayer(layer: Layer, name: String): this\r
+       // Adds a base layer (radio button entry) with the given name to the control.\r
+       addBaseLayer: function (layer, name) {\r
+               this._addLayer(layer, name);\r
+               return (this._map) ? this._update() : this;\r
+       },\r
+\r
+       // @method addOverlay(layer: Layer, name: String): this\r
+       // Adds an overlay (checkbox entry) with the given name to the control.\r
+       addOverlay: function (layer, name) {\r
+               this._addLayer(layer, name, true);\r
+               return (this._map) ? this._update() : this;\r
+       },\r
+\r
+       // @method removeLayer(layer: Layer): this\r
+       // Remove the given layer from the control.\r
+       removeLayer: function (layer) {\r
+               layer.off('add remove', this._onLayerChange, this);\r
+\r
+               var obj = this._getLayer(L.stamp(layer));\r
+               if (obj) {\r
+                       this._layers.splice(this._layers.indexOf(obj), 1);\r
+               }\r
+               return (this._map) ? this._update() : this;\r
+       },\r
+\r
+       // @method expand(): this\r
+       // Expand the control container if collapsed.\r
+       expand: function () {\r
+               L.DomUtil.addClass(this._container, 'leaflet-control-layers-expanded');\r
+               this._form.style.height = null;\r
+               var acceptableHeight = this._map.getSize().y - (this._container.offsetTop + 50);\r
+               if (acceptableHeight < this._form.clientHeight) {\r
+                       L.DomUtil.addClass(this._form, 'leaflet-control-layers-scrollbar');\r
+                       this._form.style.height = acceptableHeight + 'px';\r
                } else {\r
-                       navigator.geolocation.getCurrentPosition(onResponse, onError, options);\r
+                       L.DomUtil.removeClass(this._form, 'leaflet-control-layers-scrollbar');\r
                }\r
+               this._checkDisabledLayers();\r
                return this;\r
        },\r
 \r
-       stopLocate: function () {\r
-               if (navigator.geolocation) {\r
-                       navigator.geolocation.clearWatch(this._locationWatchId);\r
+       // @method collapse(): this\r
+       // Collapse the control container if expanded.\r
+       collapse: function () {\r
+               L.DomUtil.removeClass(this._container, 'leaflet-control-layers-expanded');\r
+               return this;\r
+       },\r
+\r
+       _initLayout: function () {\r
+               var className = 'leaflet-control-layers',\r
+                   container = this._container = L.DomUtil.create('div', className),\r
+                   collapsed = this.options.collapsed;\r
+\r
+               // makes this work on IE touch devices by stopping it from firing a mouseout event when the touch is released\r
+               container.setAttribute('aria-haspopup', true);\r
+\r
+               L.DomEvent.disableClickPropagation(container);\r
+               if (!L.Browser.touch) {\r
+                       L.DomEvent.disableScrollPropagation(container);\r
                }\r
-               if (this._locateOptions) {\r
-                       this._locateOptions.setView = false;\r
+\r
+               var form = this._form = L.DomUtil.create('form', className + '-list');\r
+\r
+               if (collapsed) {\r
+                       this._map.on('click', this.collapse, this);\r
+\r
+                       if (!L.Browser.android) {\r
+                               L.DomEvent.on(container, {\r
+                                       mouseenter: this.expand,\r
+                                       mouseleave: this.collapse\r
+                               }, this);\r
+                       }\r
                }\r
-               return this;\r
+\r
+               var link = this._layersLink = L.DomUtil.create('a', className + '-toggle', container);\r
+               link.href = '#';\r
+               link.title = 'Layers';\r
+\r
+               if (L.Browser.touch) {\r
+                       L.DomEvent\r
+                           .on(link, 'click', L.DomEvent.stop)\r
+                           .on(link, 'click', this.expand, this);\r
+               } else {\r
+                       L.DomEvent.on(link, 'focus', this.expand, this);\r
+               }\r
+\r
+               // work around for Firefox Android issue https://github.com/Leaflet/Leaflet/issues/2033\r
+               L.DomEvent.on(form, 'click', function () {\r
+                       setTimeout(L.bind(this._onInputClick, this), 0);\r
+               }, this);\r
+\r
+               // TODO keyboard accessibility\r
+\r
+               if (!collapsed) {\r
+                       this.expand();\r
+               }\r
+\r
+               this._baseLayersList = L.DomUtil.create('div', className + '-base', form);\r
+               this._separator = L.DomUtil.create('div', className + '-separator', form);\r
+               this._overlaysList = L.DomUtil.create('div', className + '-overlays', form);\r
+\r
+               container.appendChild(form);\r
        },\r
 \r
-       _handleGeolocationError: function (error) {\r
-               var c = error.code,\r
-                   message = error.message ||\r
-                           (c === 1 ? 'permission denied' :\r
-                           (c === 2 ? 'position unavailable' : 'timeout'));\r
+       _getLayer: function (id) {\r
+               for (var i = 0; i < this._layers.length; i++) {\r
 \r
-               if (this._locateOptions.setView && !this._loaded) {\r
-                       this.fitWorld();\r
+                       if (this._layers[i] && L.stamp(this._layers[i].layer) === id) {\r
+                               return this._layers[i];\r
+                       }\r
                }\r
+       },\r
 \r
-               this.fire('locationerror', {\r
-                       code: c,\r
-                       message: 'Geolocation error: ' + message + '.'\r
+       _addLayer: function (layer, name, overlay) {\r
+               layer.on('add remove', this._onLayerChange, this);\r
+\r
+               this._layers.push({\r
+                       layer: layer,\r
+                       name: name,\r
+                       overlay: overlay\r
                });\r
+\r
+               if (this.options.sortLayers) {\r
+                       this._layers.sort(L.bind(function (a, b) {\r
+                               return this.options.sortFunction(a.layer, b.layer, a.name, b.name);\r
+                       }, this));\r
+               }\r
+\r
+               if (this.options.autoZIndex && layer.setZIndex) {\r
+                       this._lastZIndex++;\r
+                       layer.setZIndex(this._lastZIndex);\r
+               }\r
        },\r
 \r
-       _handleGeolocationResponse: function (pos) {\r
-               var lat = pos.coords.latitude,\r
-                   lng = pos.coords.longitude,\r
-                   latlng = new L.LatLng(lat, lng),\r
+       _update: function () {\r
+               if (!this._container) { return this; }\r
 \r
-                   latAccuracy = 180 * pos.coords.accuracy / 40075017,\r
-                   lngAccuracy = latAccuracy / Math.cos(L.LatLng.DEG_TO_RAD * lat),\r
+               L.DomUtil.empty(this._baseLayersList);\r
+               L.DomUtil.empty(this._overlaysList);\r
 \r
-                   bounds = L.latLngBounds(\r
-                           [lat - latAccuracy, lng - lngAccuracy],\r
-                           [lat + latAccuracy, lng + lngAccuracy]),\r
+               var baseLayersPresent, overlaysPresent, i, obj, baseLayersCount = 0;\r
 \r
-                   options = this._locateOptions;\r
+               for (i = 0; i < this._layers.length; i++) {\r
+                       obj = this._layers[i];\r
+                       this._addItem(obj);\r
+                       overlaysPresent = overlaysPresent || obj.overlay;\r
+                       baseLayersPresent = baseLayersPresent || !obj.overlay;\r
+                       baseLayersCount += !obj.overlay ? 1 : 0;\r
+               }\r
 \r
-               if (options.setView) {\r
-                       var zoom = Math.min(this.getBoundsZoom(bounds), options.maxZoom);\r
-                       this.setView(latlng, zoom);\r
+               // Hide base layers section if there's only one layer.\r
+               if (this.options.hideSingleBase) {\r
+                       baseLayersPresent = baseLayersPresent && baseLayersCount > 1;\r
+                       this._baseLayersList.style.display = baseLayersPresent ? '' : 'none';\r
                }\r
 \r
-               var data = {\r
-                       latlng: latlng,\r
-                       bounds: bounds,\r
-                       timestamp: pos.timestamp\r
-               };\r
+               this._separator.style.display = overlaysPresent && baseLayersPresent ? '' : 'none';\r
 \r
-               for (var i in pos.coords) {\r
-                       if (typeof pos.coords[i] === 'number') {\r
-                               data[i] = pos.coords[i];\r
+               return this;\r
+       },\r
+\r
+       _onLayerChange: function (e) {\r
+               if (!this._handlingClick) {\r
+                       this._update();\r
+               }\r
+\r
+               var obj = this._getLayer(L.stamp(e.target));\r
+\r
+               // @namespace Map\r
+               // @section Layer events\r
+               // @event baselayerchange: LayersControlEvent\r
+               // Fired when the base layer is changed through the [layer control](#control-layers).\r
+               // @event overlayadd: LayersControlEvent\r
+               // Fired when an overlay is selected through the [layer control](#control-layers).\r
+               // @event overlayremove: LayersControlEvent\r
+               // Fired when an overlay is deselected through the [layer control](#control-layers).\r
+               // @namespace Control.Layers\r
+               var type = obj.overlay ?\r
+                       (e.type === 'add' ? 'overlayadd' : 'overlayremove') :\r
+                       (e.type === 'add' ? 'baselayerchange' : null);\r
+\r
+               if (type) {\r
+                       this._map.fire(type, obj);\r
+               }\r
+       },\r
+\r
+       // IE7 bugs out if you create a radio dynamically, so you have to do it this hacky way (see http://bit.ly/PqYLBe)\r
+       _createRadioElement: function (name, checked) {\r
+\r
+               var radioHtml = '<input type="radio" class="leaflet-control-layers-selector" name="' +\r
+                               name + '"' + (checked ? ' checked="checked"' : '') + '/>';\r
+\r
+               var radioFragment = document.createElement('div');\r
+               radioFragment.innerHTML = radioHtml;\r
+\r
+               return radioFragment.firstChild;\r
+       },\r
+\r
+       _addItem: function (obj) {\r
+               var label = document.createElement('label'),\r
+                   checked = this._map.hasLayer(obj.layer),\r
+                   input;\r
+\r
+               if (obj.overlay) {\r
+                       input = document.createElement('input');\r
+                       input.type = 'checkbox';\r
+                       input.className = 'leaflet-control-layers-selector';\r
+                       input.defaultChecked = checked;\r
+               } else {\r
+                       input = this._createRadioElement('leaflet-base-layers', checked);\r
+               }\r
+\r
+               input.layerId = L.stamp(obj.layer);\r
+\r
+               L.DomEvent.on(input, 'click', this._onInputClick, this);\r
+\r
+               var name = document.createElement('span');\r
+               name.innerHTML = ' ' + obj.name;\r
+\r
+               // Helps from preventing layer control flicker when checkboxes are disabled\r
+               // https://github.com/Leaflet/Leaflet/issues/2771\r
+               var holder = document.createElement('div');\r
+\r
+               label.appendChild(holder);\r
+               holder.appendChild(input);\r
+               holder.appendChild(name);\r
+\r
+               var container = obj.overlay ? this._overlaysList : this._baseLayersList;\r
+               container.appendChild(label);\r
+\r
+               this._checkDisabledLayers();\r
+               return label;\r
+       },\r
+\r
+       _onInputClick: function () {\r
+               var inputs = this._form.getElementsByTagName('input'),\r
+                   input, layer, hasLayer;\r
+               var addedLayers = [],\r
+                   removedLayers = [];\r
+\r
+               this._handlingClick = true;\r
+\r
+               for (var i = inputs.length - 1; i >= 0; i--) {\r
+                       input = inputs[i];\r
+                       layer = this._getLayer(input.layerId).layer;\r
+                       hasLayer = this._map.hasLayer(layer);\r
+\r
+                       if (input.checked && !hasLayer) {\r
+                               addedLayers.push(layer);\r
+\r
+                       } else if (!input.checked && hasLayer) {\r
+                               removedLayers.push(layer);\r
                        }\r
                }\r
 \r
-               this.fire('locationfound', data);\r
+               // Bugfix issue 2318: Should remove all old layers before readding new ones\r
+               for (i = 0; i < removedLayers.length; i++) {\r
+                       this._map.removeLayer(removedLayers[i]);\r
+               }\r
+               for (i = 0; i < addedLayers.length; i++) {\r
+                       this._map.addLayer(addedLayers[i]);\r
+               }\r
+\r
+               this._handlingClick = false;\r
+\r
+               this._refocusOnMap();\r
+       },\r
+\r
+       _checkDisabledLayers: function () {\r
+               var inputs = this._form.getElementsByTagName('input'),\r
+                   input,\r
+                   layer,\r
+                   zoom = this._map.getZoom();\r
+\r
+               for (var i = inputs.length - 1; i >= 0; i--) {\r
+                       input = inputs[i];\r
+                       layer = this._getLayer(input.layerId).layer;\r
+                       input.disabled = (layer.options.minZoom !== undefined && zoom < layer.options.minZoom) ||\r
+                                        (layer.options.maxZoom !== undefined && zoom > layer.options.maxZoom);\r
+\r
+               }\r
+       },\r
+\r
+       _expand: function () {\r
+               // Backward compatibility, remove me in 1.1.\r
+               return this.expand();\r
+       },\r
+\r
+       _collapse: function () {\r
+               // Backward compatibility, remove me in 1.1.\r
+               return this.collapse();\r
        }\r
+\r
 });\r
+\r
+\r
+// @factory L.control.layers(baselayers?: Object, overlays?: Object, options?: Control.Layers options)\r
+// Creates an attribution control with the given layers. Base layers will be switched with radio buttons, while overlays will be switched with checkboxes. Note that all base layers should be passed in the base layers object, but only one should be added to the map during map instantiation.\r
+L.control.layers = function (baseLayers, overlays, options) {\r
+       return new L.Control.Layers(baseLayers, overlays, options);\r
+};\r
+
 
 
-}(window, document));
\ No newline at end of file
+}(window, document));
+//# sourceMappingURL=leaflet-src.map
\ No newline at end of file
index c161c31..c6d920a 100644 (file)
@@ -1,16 +1,12 @@
 /* required styles */\r
 \r
-.leaflet-map-pane,\r
+.leaflet-pane,\r
 .leaflet-tile,\r
 .leaflet-marker-icon,\r
 .leaflet-marker-shadow,\r
-.leaflet-tile-pane,\r
 .leaflet-tile-container,\r
-.leaflet-overlay-pane,\r
-.leaflet-shadow-pane,\r
-.leaflet-marker-pane,\r
-.leaflet-popup-pane,\r
-.leaflet-overlay-pane svg,\r
+.leaflet-pane > svg,\r
+.leaflet-pane > canvas,\r
 .leaflet-zoom-box,\r
 .leaflet-image-layer,\r
 .leaflet-layer {\r
@@ -20,8 +16,6 @@
        }\r
 .leaflet-container {\r
        overflow: hidden;\r
-       -ms-touch-action: none;\r
-       touch-action: none;\r
        }\r
 .leaflet-tile,\r
 .leaflet-marker-icon,\r
        -webkit-user-select: none;\r
           -moz-user-select: none;\r
                user-select: none;\r
-       -webkit-user-drag: none;\r
+         -webkit-user-drag: none;\r
+       }\r
+/* Safari renders non-retina tile on retina better with this, but Chrome is worse */\r
+.leaflet-safari .leaflet-tile {\r
+       image-rendering: -webkit-optimize-contrast;\r
+       }\r
+/* hack that prevents hw layers "stretching" when loading new tiles */\r
+.leaflet-safari .leaflet-tile-container {\r
+       width: 1600px;\r
+       height: 1600px;\r
+       -webkit-transform-origin: 0 0;\r
        }\r
 .leaflet-marker-icon,\r
 .leaflet-marker-shadow {\r
        display: block;\r
        }\r
-/* map is broken in FF if you have max-width: 100% on tiles */\r
-.leaflet-container img {\r
+/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */\r
+/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */\r
+.leaflet-container .leaflet-overlay-pane svg,\r
+.leaflet-container .leaflet-marker-pane img,\r
+.leaflet-container .leaflet-shadow-pane img,\r
+.leaflet-container .leaflet-tile-pane img,\r
+.leaflet-container img.leaflet-image-layer {\r
        max-width: none !important;\r
        }\r
-/* stupid Android 2 doesn't understand "max-width: none" properly */\r
-.leaflet-container img.leaflet-image-layer {\r
-       max-width: 15000px !important;\r
+\r
+.leaflet-container.leaflet-touch-zoom {\r
+       -ms-touch-action: pan-x pan-y;\r
+       touch-action: pan-x pan-y;\r
        }\r
+.leaflet-container.leaflet-touch-drag {\r
+       -ms-touch-action: pinch-zoom;\r
+       }\r
+.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom {\r
+       -ms-touch-action: none;\r
+       touch-action: none;\r
+}\r
 .leaflet-tile {\r
        filter: inherit;\r
        visibility: hidden;\r
 .leaflet-zoom-box {\r
        width: 0;\r
        height: 0;\r
+       -moz-box-sizing: border-box;\r
+            box-sizing: border-box;\r
+       z-index: 800;\r
        }\r
 /* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */\r
 .leaflet-overlay-pane svg {\r
        -moz-user-select: none;\r
        }\r
 \r
-.leaflet-tile-pane    { z-index: 2; }\r
-.leaflet-objects-pane { z-index: 3; }\r
-.leaflet-overlay-pane { z-index: 4; }\r
-.leaflet-shadow-pane  { z-index: 5; }\r
-.leaflet-marker-pane  { z-index: 6; }\r
-.leaflet-popup-pane   { z-index: 7; }\r
+.leaflet-pane         { z-index: 400; }\r
+\r
+.leaflet-tile-pane    { z-index: 200; }\r
+.leaflet-overlay-pane { z-index: 400; }\r
+.leaflet-shadow-pane  { z-index: 500; }\r
+.leaflet-marker-pane  { z-index: 600; }\r
+.leaflet-tooltip-pane   { z-index: 650; }\r
+.leaflet-popup-pane   { z-index: 700; }\r
+\r
+.leaflet-map-pane canvas { z-index: 100; }\r
+.leaflet-map-pane svg    { z-index: 200; }\r
 \r
 .leaflet-vml-shape {\r
        width: 1px;\r
 \r
 .leaflet-control {\r
        position: relative;\r
-       z-index: 7;\r
+       z-index: 800;\r
+       pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */\r
        pointer-events: auto;\r
        }\r
 .leaflet-top,\r
 \r
 /* zoom and fade animations */\r
 \r
-.leaflet-fade-anim .leaflet-tile,\r
+.leaflet-fade-anim .leaflet-tile {\r
+       will-change: opacity;\r
+       }\r
 .leaflet-fade-anim .leaflet-popup {\r
        opacity: 0;\r
        -webkit-transition: opacity 0.2s linear;\r
             -o-transition: opacity 0.2s linear;\r
                transition: opacity 0.2s linear;\r
        }\r
-.leaflet-fade-anim .leaflet-tile-loaded,\r
 .leaflet-fade-anim .leaflet-map-pane .leaflet-popup {\r
        opacity: 1;\r
        }\r
-\r
+.leaflet-zoom-animated {\r
+       -webkit-transform-origin: 0 0;\r
+           -ms-transform-origin: 0 0;\r
+               transform-origin: 0 0;\r
+       }\r
+.leaflet-zoom-anim .leaflet-zoom-animated {\r
+       will-change: transform;\r
+       }\r
 .leaflet-zoom-anim .leaflet-zoom-animated {\r
        -webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);\r
           -moz-transition:    -moz-transform 0.25s cubic-bezier(0,0,0.25,1);\r
                transition:         transform 0.25s cubic-bezier(0,0,0.25,1);\r
        }\r
 .leaflet-zoom-anim .leaflet-tile,\r
-.leaflet-pan-anim .leaflet-tile,\r
-.leaflet-touching .leaflet-zoom-animated {\r
+.leaflet-pan-anim .leaflet-tile {\r
        -webkit-transition: none;\r
           -moz-transition: none;\r
             -o-transition: none;\r
 \r
 /* cursors */\r
 \r
-.leaflet-clickable {\r
+.leaflet-interactive {\r
        cursor: pointer;\r
        }\r
-.leaflet-container {\r
+.leaflet-grab {\r
        cursor: -webkit-grab;\r
        cursor:    -moz-grab;\r
        }\r
+.leaflet-crosshair,\r
+.leaflet-crosshair .leaflet-interactive {\r
+       cursor: crosshair;\r
+       }\r
 .leaflet-popup-pane,\r
 .leaflet-control {\r
        cursor: auto;\r
        }\r
-.leaflet-dragging .leaflet-container,\r
-.leaflet-dragging .leaflet-clickable {\r
+.leaflet-dragging .leaflet-grab,\r
+.leaflet-dragging .leaflet-grab .leaflet-interactive,\r
+.leaflet-dragging .leaflet-marker-draggable {\r
        cursor: move;\r
        cursor: -webkit-grabbing;\r
        cursor:    -moz-grabbing;\r
        }\r
 \r
+/* marker & overlays interactivity */\r
+.leaflet-marker-icon,\r
+.leaflet-marker-shadow,\r
+.leaflet-image-layer,\r
+.leaflet-pane > svg path,\r
+.leaflet-tile-container {\r
+       pointer-events: none;\r
+       }\r
+\r
+.leaflet-marker-icon.leaflet-interactive,\r
+.leaflet-image-layer.leaflet-interactive,\r
+.leaflet-pane > svg path.leaflet-interactive {\r
+       pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */\r
+       pointer-events: auto;\r
+       }\r
 \r
 /* visual tweaks */\r
 \r
        color: #333;\r
        background: #fff;\r
        }\r
+.leaflet-control-layers-scrollbar {\r
+       overflow-y: scroll;\r
+       padding-right: 5px;\r
+       }\r
 .leaflet-control-layers-selector {\r
        margin-top: 2px;\r
        position: relative;\r
        margin: 5px -10px 5px -6px;\r
        }\r
 \r
+/* Default icon URLs */\r
+.leaflet-default-icon-path {\r
+       background-image: url(images/marker-icon.png);\r
+       }\r
+\r
 \r
 /* attribution and scale controls */\r
 \r
        font-size: 11px;\r
        white-space: nowrap;\r
        overflow: hidden;\r
-       -moz-box-sizing: content-box;\r
-            box-sizing: content-box;\r
+       -moz-box-sizing: border-box;\r
+            box-sizing: border-box;\r
 \r
        background: #fff;\r
        background: rgba(255, 255, 255, 0.5);\r
 .leaflet-popup {\r
        position: absolute;\r
        text-align: center;\r
+       margin-bottom: 20px;\r
        }\r
 .leaflet-popup-content-wrapper {\r
        padding: 1px;\r
        margin: 18px 0;\r
        }\r
 .leaflet-popup-tip-container {\r
-       margin: 0 auto;\r
        width: 40px;\r
        height: 20px;\r
-       position: relative;\r
+       position: absolute;\r
+       left: 50%;\r
+       margin-left: -20px;\r
        overflow: hidden;\r
+       pointer-events: none;\r
        }\r
 .leaflet-popup-tip {\r
        width: 17px;\r
 .leaflet-popup-content-wrapper,\r
 .leaflet-popup-tip {\r
        background: white;\r
-\r
+       color: #333;\r
        box-shadow: 0 3px 14px rgba(0,0,0,0.4);\r
        }\r
 .leaflet-container a.leaflet-popup-close-button {\r
        top: 0;\r
        right: 0;\r
        padding: 4px 4px 0 0;\r
+       border: none;\r
        text-align: center;\r
        width: 18px;\r
        height: 14px;\r
        background: #fff;\r
        border: 1px solid #666;\r
        }\r
+\r
+\r
+/* Tooltip */\r
+/* Base styles for the element that has a tooltip */\r
+.leaflet-tooltip {\r
+       position: absolute;\r
+       padding: 6px;\r
+       background-color: #fff;\r
+       border: 1px solid #fff;\r
+       border-radius: 3px;\r
+       color: #222;\r
+       white-space: nowrap;\r
+       -webkit-user-select: none;\r
+       -moz-user-select: none;\r
+       -ms-user-select: none;\r
+       user-select: none;\r
+       pointer-events: none;\r
+       box-shadow: 0 1px 3px rgba(0,0,0,0.4);\r
+       }\r
+.leaflet-tooltip.leaflet-clickable {\r
+       cursor: pointer;\r
+       pointer-events: auto;\r
+       }\r
+.leaflet-tooltip-top:before,\r
+.leaflet-tooltip-bottom:before,\r
+.leaflet-tooltip-left:before,\r
+.leaflet-tooltip-right:before {\r
+       position: absolute;\r
+       pointer-events: none;\r
+       border: 6px solid transparent;\r
+       background: transparent;\r
+       content: "";\r
+       }\r
+\r
+/* Directions */\r
+\r
+.leaflet-tooltip-bottom {\r
+       margin-top: 6px;\r
+}\r
+.leaflet-tooltip-top {\r
+       margin-top: -6px;\r
+}\r
+.leaflet-tooltip-bottom:before,\r
+.leaflet-tooltip-top:before {\r
+       left: 50%;\r
+       margin-left: -6px;\r
+       }\r
+.leaflet-tooltip-top:before {\r
+       bottom: 0;\r
+       margin-bottom: -12px;\r
+       border-top-color: #fff;\r
+       }\r
+.leaflet-tooltip-bottom:before {\r
+       top: 0;\r
+       margin-top: -12px;\r
+       margin-left: -6px;\r
+       border-bottom-color: #fff;\r
+       }\r
+.leaflet-tooltip-left {\r
+       margin-left: -6px;\r
+}\r
+.leaflet-tooltip-right {\r
+       margin-left: 6px;\r
+}\r
+.leaflet-tooltip-left:before,\r
+.leaflet-tooltip-right:before {\r
+       top: 50%;\r
+       margin-top: -6px;\r
+       }\r
+.leaflet-tooltip-left:before {\r
+       right: 0;\r
+       margin-right: -12px;\r
+       border-left-color: #fff;\r
+       }\r
+.leaflet-tooltip-right:before {\r
+       left: 0;\r
+       margin-left: -12px;\r
+       border-right-color: #fff;\r
+       }\r
index ee5ff5a..24042d1 100644 (file)
@@ -1,9 +1,9 @@
 /*
- Leaflet, a JavaScript library for mobile-friendly interactive maps. http://leafletjs.com
- (c) 2010-2013, Vladimir Agafonkin
- (c) 2010-2011, CloudMade
+ Leaflet 1.0.3+ed36a04, a JS library for interactive maps. http://leafletjs.com
+ (c) 2010-2016 Vladimir Agafonkin, (c) 2010-2011 CloudMade
 */
-!function(t,e,i){var n=t.L,o={};o.version="0.7.7","object"==typeof module&&"object"==typeof module.exports?module.exports=o:"function"==typeof define&&define.amd&&define(o),o.noConflict=function(){return t.L=n,this},t.L=o,o.Util={extend:function(t){var e,i,n,o,s=Array.prototype.slice.call(arguments,1);for(i=0,n=s.length;n>i;i++){o=s[i]||{};for(e in o)o.hasOwnProperty(e)&&(t[e]=o[e])}return t},bind:function(t,e){var i=arguments.length>2?Array.prototype.slice.call(arguments,2):null;return function(){return t.apply(e,i||arguments)}},stamp:function(){var t=0,e="_leaflet_id";return function(i){return i[e]=i[e]||++t,i[e]}}(),invokeEach:function(t,e,i){var n,o;if("object"==typeof t){o=Array.prototype.slice.call(arguments,3);for(n in t)e.apply(i,[n,t[n]].concat(o));return!0}return!1},limitExecByInterval:function(t,e,i){var n,o;return function s(){var a=arguments;return n?void(o=!0):(n=!0,setTimeout(function(){n=!1,o&&(s.apply(i,a),o=!1)},e),void t.apply(i,a))}},falseFn:function(){return!1},formatNum:function(t,e){var i=Math.pow(10,e||5);return Math.round(t*i)/i},trim:function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")},splitWords:function(t){return o.Util.trim(t).split(/\s+/)},setOptions:function(t,e){return t.options=o.extend({},t.options,e),t.options},getParamString:function(t,e,i){var n=[];for(var o in t)n.push(encodeURIComponent(i?o.toUpperCase():o)+"="+encodeURIComponent(t[o]));return(e&&-1!==e.indexOf("?")?"&":"?")+n.join("&")},template:function(t,e){return t.replace(/\{ *([\w_]+) *\}/g,function(t,n){var o=e[n];if(o===i)throw new Error("No value provided for variable "+t);return"function"==typeof o&&(o=o(e)),o})},isArray:Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},emptyImageUrl:"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="},function(){function e(e){var i,n,o=["webkit","moz","o","ms"];for(i=0;i<o.length&&!n;i++)n=t[o[i]+e];return n}function i(e){var i=+new Date,o=Math.max(0,16-(i-n));return n=i+o,t.setTimeout(e,o)}var n=0,s=t.requestAnimationFrame||e("RequestAnimationFrame")||i,a=t.cancelAnimationFrame||e("CancelAnimationFrame")||e("CancelRequestAnimationFrame")||function(e){t.clearTimeout(e)};o.Util.requestAnimFrame=function(e,n,a,r){return e=o.bind(e,n),a&&s===i?void e():s.call(t,e,r)},o.Util.cancelAnimFrame=function(e){e&&a.call(t,e)}}(),o.extend=o.Util.extend,o.bind=o.Util.bind,o.stamp=o.Util.stamp,o.setOptions=o.Util.setOptions,o.Class=function(){},o.Class.extend=function(t){var e=function(){this.initialize&&this.initialize.apply(this,arguments),this._initHooks&&this.callInitHooks()},i=function(){};i.prototype=this.prototype;var n=new i;n.constructor=e,e.prototype=n;for(var s in this)this.hasOwnProperty(s)&&"prototype"!==s&&(e[s]=this[s]);t.statics&&(o.extend(e,t.statics),delete t.statics),t.includes&&(o.Util.extend.apply(null,[n].concat(t.includes)),delete t.includes),t.options&&n.options&&(t.options=o.extend({},n.options,t.options)),o.extend(n,t),n._initHooks=[];var a=this;return e.__super__=a.prototype,n.callInitHooks=function(){if(!this._initHooksCalled){a.prototype.callInitHooks&&a.prototype.callInitHooks.call(this),this._initHooksCalled=!0;for(var t=0,e=n._initHooks.length;e>t;t++)n._initHooks[t].call(this)}},e},o.Class.include=function(t){o.extend(this.prototype,t)},o.Class.mergeOptions=function(t){o.extend(this.prototype.options,t)},o.Class.addInitHook=function(t){var e=Array.prototype.slice.call(arguments,1),i="function"==typeof t?t:function(){this[t].apply(this,e)};this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(i)};var s="_leaflet_events";o.Mixin={},o.Mixin.Events={addEventListener:function(t,e,i){if(o.Util.invokeEach(t,this.addEventListener,this,e,i))return this;var n,a,r,h,l,u,c,d=this[s]=this[s]||{},p=i&&i!==this&&o.stamp(i);for(t=o.Util.splitWords(t),n=0,a=t.length;a>n;n++)r={action:e,context:i||this},h=t[n],p?(l=h+"_idx",u=l+"_len",c=d[l]=d[l]||{},c[p]||(c[p]=[],d[u]=(d[u]||0)+1),c[p].push(r)):(d[h]=d[h]||[],d[h].push(r));return this},hasEventListeners:function(t){var e=this[s];return!!e&&(t in e&&e[t].length>0||t+"_idx"in e&&e[t+"_idx_len"]>0)},removeEventListener:function(t,e,i){if(!this[s])return this;if(!t)return this.clearAllEventListeners();if(o.Util.invokeEach(t,this.removeEventListener,this,e,i))return this;var n,a,r,h,l,u,c,d,p,_=this[s],m=i&&i!==this&&o.stamp(i);for(t=o.Util.splitWords(t),n=0,a=t.length;a>n;n++)if(r=t[n],u=r+"_idx",c=u+"_len",d=_[u],e){if(h=m&&d?d[m]:_[r]){for(l=h.length-1;l>=0;l--)h[l].action!==e||i&&h[l].context!==i||(p=h.splice(l,1),p[0].action=o.Util.falseFn);i&&d&&0===h.length&&(delete d[m],_[c]--)}}else delete _[r],delete _[u],delete _[c];return this},clearAllEventListeners:function(){return delete this[s],this},fireEvent:function(t,e){if(!this.hasEventListeners(t))return this;var i,n,a,r,h,l=o.Util.extend({},e,{type:t,target:this}),u=this[s];if(u[t])for(i=u[t].slice(),n=0,a=i.length;a>n;n++)i[n].action.call(i[n].context,l);r=u[t+"_idx"];for(h in r)if(i=r[h].slice())for(n=0,a=i.length;a>n;n++)i[n].action.call(i[n].context,l);return this},addOneTimeEventListener:function(t,e,i){if(o.Util.invokeEach(t,this.addOneTimeEventListener,this,e,i))return this;var n=o.bind(function(){this.removeEventListener(t,e,i).removeEventListener(t,n,i)},this);return this.addEventListener(t,e,i).addEventListener(t,n,i)}},o.Mixin.Events.on=o.Mixin.Events.addEventListener,o.Mixin.Events.off=o.Mixin.Events.removeEventListener,o.Mixin.Events.once=o.Mixin.Events.addOneTimeEventListener,o.Mixin.Events.fire=o.Mixin.Events.fireEvent,function(){var n="ActiveXObject"in t,s=n&&!e.addEventListener,a=navigator.userAgent.toLowerCase(),r=-1!==a.indexOf("webkit"),h=-1!==a.indexOf("chrome"),l=-1!==a.indexOf("phantom"),u=-1!==a.indexOf("android"),c=-1!==a.search("android [23]"),d=-1!==a.indexOf("gecko"),p=typeof orientation!=i+"",_=!t.PointerEvent&&t.MSPointerEvent,m=t.PointerEvent&&t.navigator.pointerEnabled||_,f="devicePixelRatio"in t&&t.devicePixelRatio>1||"matchMedia"in t&&t.matchMedia("(min-resolution:144dpi)")&&t.matchMedia("(min-resolution:144dpi)").matches,g=e.documentElement,v=n&&"transition"in g.style,y="WebKitCSSMatrix"in t&&"m11"in new t.WebKitCSSMatrix&&!c,P="MozPerspective"in g.style,L="OTransition"in g.style,x=!t.L_DISABLE_3D&&(v||y||P||L)&&!l,w=!t.L_NO_TOUCH&&!l&&(m||"ontouchstart"in t||t.DocumentTouch&&e instanceof t.DocumentTouch);o.Browser={ie:n,ielt9:s,webkit:r,gecko:d&&!r&&!t.opera&&!n,android:u,android23:c,chrome:h,ie3d:v,webkit3d:y,gecko3d:P,opera3d:L,any3d:x,mobile:p,mobileWebkit:p&&r,mobileWebkit3d:p&&y,mobileOpera:p&&t.opera,touch:w,msPointer:_,pointer:m,retina:f}}(),o.Point=function(t,e,i){this.x=i?Math.round(t):t,this.y=i?Math.round(e):e},o.Point.prototype={clone:function(){return new o.Point(this.x,this.y)},add:function(t){return this.clone()._add(o.point(t))},_add:function(t){return this.x+=t.x,this.y+=t.y,this},subtract:function(t){return this.clone()._subtract(o.point(t))},_subtract:function(t){return this.x-=t.x,this.y-=t.y,this},divideBy:function(t){return this.clone()._divideBy(t)},_divideBy:function(t){return this.x/=t,this.y/=t,this},multiplyBy:function(t){return this.clone()._multiplyBy(t)},_multiplyBy:function(t){return this.x*=t,this.y*=t,this},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},distanceTo:function(t){t=o.point(t);var e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)},equals:function(t){return t=o.point(t),t.x===this.x&&t.y===this.y},contains:function(t){return t=o.point(t),Math.abs(t.x)<=Math.abs(this.x)&&Math.abs(t.y)<=Math.abs(this.y)},toString:function(){return"Point("+o.Util.formatNum(this.x)+", "+o.Util.formatNum(this.y)+")"}},o.point=function(t,e,n){return t instanceof o.Point?t:o.Util.isArray(t)?new o.Point(t[0],t[1]):t===i||null===t?t:new o.Point(t,e,n)},o.Bounds=function(t,e){if(t)for(var i=e?[t,e]:t,n=0,o=i.length;o>n;n++)this.extend(i[n])},o.Bounds.prototype={extend:function(t){return t=o.point(t),this.min||this.max?(this.min.x=Math.min(t.x,this.min.x),this.max.x=Math.max(t.x,this.max.x),this.min.y=Math.min(t.y,this.min.y),this.max.y=Math.max(t.y,this.max.y)):(this.min=t.clone(),this.max=t.clone()),this},getCenter:function(t){return new o.Point((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,t)},getBottomLeft:function(){return new o.Point(this.min.x,this.max.y)},getTopRight:function(){return new o.Point(this.max.x,this.min.y)},getSize:function(){return this.max.subtract(this.min)},contains:function(t){var e,i;return t="number"==typeof t[0]||t instanceof o.Point?o.point(t):o.bounds(t),t instanceof o.Bounds?(e=t.min,i=t.max):e=i=t,e.x>=this.min.x&&i.x<=this.max.x&&e.y>=this.min.y&&i.y<=this.max.y},intersects:function(t){t=o.bounds(t);var e=this.min,i=this.max,n=t.min,s=t.max,a=s.x>=e.x&&n.x<=i.x,r=s.y>=e.y&&n.y<=i.y;return a&&r},isValid:function(){return!(!this.min||!this.max)}},o.bounds=function(t,e){return!t||t instanceof o.Bounds?t:new o.Bounds(t,e)},o.Transformation=function(t,e,i,n){this._a=t,this._b=e,this._c=i,this._d=n},o.Transformation.prototype={transform:function(t,e){return this._transform(t.clone(),e)},_transform:function(t,e){return e=e||1,t.x=e*(this._a*t.x+this._b),t.y=e*(this._c*t.y+this._d),t},untransform:function(t,e){return e=e||1,new o.Point((t.x/e-this._b)/this._a,(t.y/e-this._d)/this._c)}},o.DomUtil={get:function(t){return"string"==typeof t?e.getElementById(t):t},getStyle:function(t,i){var n=t.style[i];if(!n&&t.currentStyle&&(n=t.currentStyle[i]),(!n||"auto"===n)&&e.defaultView){var o=e.defaultView.getComputedStyle(t,null);n=o?o[i]:null}return"auto"===n?null:n},getViewportOffset:function(t){var i,n=0,s=0,a=t,r=e.body,h=e.documentElement;do{if(n+=a.offsetTop||0,s+=a.offsetLeft||0,n+=parseInt(o.DomUtil.getStyle(a,"borderTopWidth"),10)||0,s+=parseInt(o.DomUtil.getStyle(a,"borderLeftWidth"),10)||0,i=o.DomUtil.getStyle(a,"position"),a.offsetParent===r&&"absolute"===i)break;if("fixed"===i){n+=r.scrollTop||h.scrollTop||0,s+=r.scrollLeft||h.scrollLeft||0;break}if("relative"===i&&!a.offsetLeft){var l=o.DomUtil.getStyle(a,"width"),u=o.DomUtil.getStyle(a,"max-width"),c=a.getBoundingClientRect();("none"!==l||"none"!==u)&&(s+=c.left+a.clientLeft),n+=c.top+(r.scrollTop||h.scrollTop||0);break}a=a.offsetParent}while(a);a=t;do{if(a===r)break;n-=a.scrollTop||0,s-=a.scrollLeft||0,a=a.parentNode}while(a);return new o.Point(s,n)},documentIsLtr:function(){return o.DomUtil._docIsLtrCached||(o.DomUtil._docIsLtrCached=!0,o.DomUtil._docIsLtr="ltr"===o.DomUtil.getStyle(e.body,"direction")),o.DomUtil._docIsLtr},create:function(t,i,n){var o=e.createElement(t);return o.className=i,n&&n.appendChild(o),o},hasClass:function(t,e){if(t.classList!==i)return t.classList.contains(e);var n=o.DomUtil._getClass(t);return n.length>0&&new RegExp("(^|\\s)"+e+"(\\s|$)").test(n)},addClass:function(t,e){if(t.classList!==i)for(var n=o.Util.splitWords(e),s=0,a=n.length;a>s;s++)t.classList.add(n[s]);else if(!o.DomUtil.hasClass(t,e)){var r=o.DomUtil._getClass(t);o.DomUtil._setClass(t,(r?r+" ":"")+e)}},removeClass:function(t,e){t.classList!==i?t.classList.remove(e):o.DomUtil._setClass(t,o.Util.trim((" "+o.DomUtil._getClass(t)+" ").replace(" "+e+" "," ")))},_setClass:function(t,e){t.className.baseVal===i?t.className=e:t.className.baseVal=e},_getClass:function(t){return t.className.baseVal===i?t.className:t.className.baseVal},setOpacity:function(t,e){if("opacity"in t.style)t.style.opacity=e;else if("filter"in t.style){var i=!1,n="DXImageTransform.Microsoft.Alpha";try{i=t.filters.item(n)}catch(o){if(1===e)return}e=Math.round(100*e),i?(i.Enabled=100!==e,i.Opacity=e):t.style.filter+=" progid:"+n+"(opacity="+e+")"}},testProp:function(t){for(var i=e.documentElement.style,n=0;n<t.length;n++)if(t[n]in i)return t[n];return!1},getTranslateString:function(t){var e=o.Browser.webkit3d,i="translate"+(e?"3d":"")+"(",n=(e?",0":"")+")";return i+t.x+"px,"+t.y+"px"+n},getScaleString:function(t,e){var i=o.DomUtil.getTranslateString(e.add(e.multiplyBy(-1*t))),n=" scale("+t+") ";return i+n},setPosition:function(t,e,i){t._leaflet_pos=e,!i&&o.Browser.any3d?t.style[o.DomUtil.TRANSFORM]=o.DomUtil.getTranslateString(e):(t.style.left=e.x+"px",t.style.top=e.y+"px")},getPosition:function(t){return t._leaflet_pos}},o.DomUtil.TRANSFORM=o.DomUtil.testProp(["transform","WebkitTransform","OTransform","MozTransform","msTransform"]),o.DomUtil.TRANSITION=o.DomUtil.testProp(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),o.DomUtil.TRANSITION_END="webkitTransition"===o.DomUtil.TRANSITION||"OTransition"===o.DomUtil.TRANSITION?o.DomUtil.TRANSITION+"End":"transitionend",function(){if("onselectstart"in e)o.extend(o.DomUtil,{disableTextSelection:function(){o.DomEvent.on(t,"selectstart",o.DomEvent.preventDefault)},enableTextSelection:function(){o.DomEvent.off(t,"selectstart",o.DomEvent.preventDefault)}});else{var i=o.DomUtil.testProp(["userSelect","WebkitUserSelect","OUserSelect","MozUserSelect","msUserSelect"]);o.extend(o.DomUtil,{disableTextSelection:function(){if(i){var t=e.documentElement.style;this._userSelect=t[i],t[i]="none"}},enableTextSelection:function(){i&&(e.documentElement.style[i]=this._userSelect,delete this._userSelect)}})}o.extend(o.DomUtil,{disableImageDrag:function(){o.DomEvent.on(t,"dragstart",o.DomEvent.preventDefault)},enableImageDrag:function(){o.DomEvent.off(t,"dragstart",o.DomEvent.preventDefault)}})}(),o.LatLng=function(t,e,n){if(t=parseFloat(t),e=parseFloat(e),isNaN(t)||isNaN(e))throw new Error("Invalid LatLng object: ("+t+", "+e+")");this.lat=t,this.lng=e,n!==i&&(this.alt=parseFloat(n))},o.extend(o.LatLng,{DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,MAX_MARGIN:1e-9}),o.LatLng.prototype={equals:function(t){if(!t)return!1;t=o.latLng(t);var e=Math.max(Math.abs(this.lat-t.lat),Math.abs(this.lng-t.lng));return e<=o.LatLng.MAX_MARGIN},toString:function(t){return"LatLng("+o.Util.formatNum(this.lat,t)+", "+o.Util.formatNum(this.lng,t)+")"},distanceTo:function(t){t=o.latLng(t);var e=6378137,i=o.LatLng.DEG_TO_RAD,n=(t.lat-this.lat)*i,s=(t.lng-this.lng)*i,a=this.lat*i,r=t.lat*i,h=Math.sin(n/2),l=Math.sin(s/2),u=h*h+l*l*Math.cos(a)*Math.cos(r);return 2*e*Math.atan2(Math.sqrt(u),Math.sqrt(1-u))},wrap:function(t,e){var i=this.lng;return t=t||-180,e=e||180,i=(i+e)%(e-t)+(t>i||i===e?e:t),new o.LatLng(this.lat,i)}},o.latLng=function(t,e){return t instanceof o.LatLng?t:o.Util.isArray(t)?"number"==typeof t[0]||"string"==typeof t[0]?new o.LatLng(t[0],t[1],t[2]):null:t===i||null===t?t:"object"==typeof t&&"lat"in t?new o.LatLng(t.lat,"lng"in t?t.lng:t.lon):e===i?null:new o.LatLng(t,e)},o.LatLngBounds=function(t,e){if(t)for(var i=e?[t,e]:t,n=0,o=i.length;o>n;n++)this.extend(i[n])},o.LatLngBounds.prototype={extend:function(t){if(!t)return this;var e=o.latLng(t);return t=null!==e?e:o.latLngBounds(t),t instanceof o.LatLng?this._southWest||this._northEast?(this._southWest.lat=Math.min(t.lat,this._southWest.lat),this._southWest.lng=Math.min(t.lng,this._southWest.lng),this._northEast.lat=Math.max(t.lat,this._northEast.lat),this._northEast.lng=Math.max(t.lng,this._northEast.lng)):(this._southWest=new o.LatLng(t.lat,t.lng),this._northEast=new o.LatLng(t.lat,t.lng)):t instanceof o.LatLngBounds&&(this.extend(t._southWest),this.extend(t._northEast)),this},pad:function(t){var e=this._southWest,i=this._northEast,n=Math.abs(e.lat-i.lat)*t,s=Math.abs(e.lng-i.lng)*t;return new o.LatLngBounds(new o.LatLng(e.lat-n,e.lng-s),new o.LatLng(i.lat+n,i.lng+s))},getCenter:function(){return new o.LatLng((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new o.LatLng(this.getNorth(),this.getWest())},getSouthEast:function(){return new o.LatLng(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(t){t="number"==typeof t[0]||t instanceof o.LatLng?o.latLng(t):o.latLngBounds(t);var e,i,n=this._southWest,s=this._northEast;return t instanceof o.LatLngBounds?(e=t.getSouthWest(),i=t.getNorthEast()):e=i=t,e.lat>=n.lat&&i.lat<=s.lat&&e.lng>=n.lng&&i.lng<=s.lng},intersects:function(t){t=o.latLngBounds(t);var e=this._southWest,i=this._northEast,n=t.getSouthWest(),s=t.getNorthEast(),a=s.lat>=e.lat&&n.lat<=i.lat,r=s.lng>=e.lng&&n.lng<=i.lng;return a&&r},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")},equals:function(t){return t?(t=o.latLngBounds(t),this._southWest.equals(t.getSouthWest())&&this._northEast.equals(t.getNorthEast())):!1},isValid:function(){return!(!this._southWest||!this._northEast)}},o.latLngBounds=function(t,e){return!t||t instanceof o.LatLngBounds?t:new o.LatLngBounds(t,e)},o.Projection={},o.Projection.SphericalMercator={MAX_LATITUDE:85.0511287798,project:function(t){var e=o.LatLng.DEG_TO_RAD,i=this.MAX_LATITUDE,n=Math.max(Math.min(i,t.lat),-i),s=t.lng*e,a=n*e;return a=Math.log(Math.tan(Math.PI/4+a/2)),new o.Point(s,a)},unproject:function(t){var e=o.LatLng.RAD_TO_DEG,i=t.x*e,n=(2*Math.atan(Math.exp(t.y))-Math.PI/2)*e;return new o.LatLng(n,i)}},o.Projection.LonLat={project:function(t){return new o.Point(t.lng,t.lat)},unproject:function(t){return new o.LatLng(t.y,t.x)}},o.CRS={latLngToPoint:function(t,e){var i=this.projection.project(t),n=this.scale(e);return this.transformation._transform(i,n)},pointToLatLng:function(t,e){var i=this.scale(e),n=this.transformation.untransform(t,i);return this.projection.unproject(n)},project:function(t){return this.projection.project(t)},scale:function(t){return 256*Math.pow(2,t)},getSize:function(t){var e=this.scale(t);return o.point(e,e)}},o.CRS.Simple=o.extend({},o.CRS,{projection:o.Projection.LonLat,transformation:new o.Transformation(1,0,-1,0),scale:function(t){return Math.pow(2,t)}}),o.CRS.EPSG3857=o.extend({},o.CRS,{code:"EPSG:3857",projection:o.Projection.SphericalMercator,transformation:new o.Transformation(.5/Math.PI,.5,-.5/Math.PI,.5),project:function(t){var e=this.projection.project(t),i=6378137;return e.multiplyBy(i)}}),o.CRS.EPSG900913=o.extend({},o.CRS.EPSG3857,{code:"EPSG:900913"}),o.CRS.EPSG4326=o.extend({},o.CRS,{code:"EPSG:4326",projection:o.Projection.LonLat,transformation:new o.Transformation(1/360,.5,-1/360,.5)}),o.Map=o.Class.extend({includes:o.Mixin.Events,options:{crs:o.CRS.EPSG3857,fadeAnimation:o.DomUtil.TRANSITION&&!o.Browser.android23,trackResize:!0,markerZoomAnimation:o.DomUtil.TRANSITION&&o.Browser.any3d},initialize:function(t,e){e=o.setOptions(this,e),this._initContainer(t),this._initLayout(),this._onResize=o.bind(this._onResize,this),this._initEvents(),e.maxBounds&&this.setMaxBounds(e.maxBounds),e.center&&e.zoom!==i&&this.setView(o.latLng(e.center),e.zoom,{reset:!0}),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._tileLayersNum=0,this.callInitHooks(),this._addLayers(e.layers)},setView:function(t,e){return e=e===i?this.getZoom():e,this._resetView(o.latLng(t),this._limitZoom(e)),this},setZoom:function(t,e){return this._loaded?this.setView(this.getCenter(),t,{zoom:e}):(this._zoom=this._limitZoom(t),this)},zoomIn:function(t,e){return this.setZoom(this._zoom+(t||1),e)},zoomOut:function(t,e){return this.setZoom(this._zoom-(t||1),e)},setZoomAround:function(t,e,i){var n=this.getZoomScale(e),s=this.getSize().divideBy(2),a=t instanceof o.Point?t:this.latLngToContainerPoint(t),r=a.subtract(s).multiplyBy(1-1/n),h=this.containerPointToLatLng(s.add(r));return this.setView(h,e,{zoom:i})},fitBounds:function(t,e){e=e||{},t=t.getBounds?t.getBounds():o.latLngBounds(t);var i=o.point(e.paddingTopLeft||e.padding||[0,0]),n=o.point(e.paddingBottomRight||e.padding||[0,0]),s=this.getBoundsZoom(t,!1,i.add(n));s=e.maxZoom?Math.min(e.maxZoom,s):s;var a=n.subtract(i).divideBy(2),r=this.project(t.getSouthWest(),s),h=this.project(t.getNorthEast(),s),l=this.unproject(r.add(h).divideBy(2).add(a),s);return this.setView(l,s,e)},fitWorld:function(t){return this.fitBounds([[-90,-180],[90,180]],t)},panTo:function(t,e){return this.setView(t,this._zoom,{pan:e})},panBy:function(t){return this.fire("movestart"),this._rawPanBy(o.point(t)),this.fire("move"),this.fire("moveend")},setMaxBounds:function(t){return t=o.latLngBounds(t),this.options.maxBounds=t,t?(this._loaded&&this._panInsideMaxBounds(),this.on("moveend",this._panInsideMaxBounds,this)):this.off("moveend",this._panInsideMaxBounds,this)},panInsideBounds:function(t,e){var i=this.getCenter(),n=this._limitCenter(i,this._zoom,t);return i.equals(n)?this:this.panTo(n,e)},addLayer:function(t){var e=o.stamp(t);return this._layers[e]?this:(this._layers[e]=t,!t.options||isNaN(t.options.maxZoom)&&isNaN(t.options.minZoom)||(this._zoomBoundLayers[e]=t,this._updateZoomLevels()),this.options.zoomAnimation&&o.TileLayer&&t instanceof o.TileLayer&&(this._tileLayersNum++,this._tileLayersToLoad++,t.on("load",this._onTileLayerLoad,this)),this._loaded&&this._layerAdd(t),this)},removeLayer:function(t){var e=o.stamp(t);return this._layers[e]?(this._loaded&&t.onRemove(this),delete this._layers[e],this._loaded&&this.fire("layerremove",{layer:t}),this._zoomBoundLayers[e]&&(delete this._zoomBoundLayers[e],this._updateZoomLevels()),this.options.zoomAnimation&&o.TileLayer&&t instanceof o.TileLayer&&(this._tileLayersNum--,this._tileLayersToLoad--,t.off("load",this._onTileLayerLoad,this)),this):this},hasLayer:function(t){return t?o.stamp(t)in this._layers:!1},eachLayer:function(t,e){for(var i in this._layers)t.call(e,this._layers[i]);return this},invalidateSize:function(t){if(!this._loaded)return this;t=o.extend({animate:!1,pan:!0},t===!0?{animate:!0}:t);var e=this.getSize();this._sizeChanged=!0,this._initialCenter=null;var i=this.getSize(),n=e.divideBy(2).round(),s=i.divideBy(2).round(),a=n.subtract(s);return a.x||a.y?(t.animate&&t.pan?this.panBy(a):(t.pan&&this._rawPanBy(a),this.fire("move"),t.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(o.bind(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:e,newSize:i})):this},addHandler:function(t,e){if(!e)return this;var i=this[t]=new e(this);return this._handlers.push(i),this.options[t]&&i.enable(),this},remove:function(){this._loaded&&this.fire("unload"),this._initEvents("off");try{delete this._container._leaflet}catch(t){this._container._leaflet=i}return this._clearPanes(),this._clearControlPos&&this._clearControlPos(),this._clearHandlers(),this},getCenter:function(){return this._checkIfLoaded(),this._initialCenter&&!this._moved()?this._initialCenter:this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var t=this.getPixelBounds(),e=this.unproject(t.getBottomLeft()),i=this.unproject(t.getTopRight());return new o.LatLngBounds(e,i)},getMinZoom:function(){return this.options.minZoom===i?this._layersMinZoom===i?0:this._layersMinZoom:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===i?this._layersMaxZoom===i?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(t,e,i){t=o.latLngBounds(t);var n,s=this.getMinZoom()-(e?1:0),a=this.getMaxZoom(),r=this.getSize(),h=t.getNorthWest(),l=t.getSouthEast(),u=!0;i=o.point(i||[0,0]);do s++,n=this.project(l,s).subtract(this.project(h,s)).add(i),u=e?n.x<r.x||n.y<r.y:r.contains(n);while(u&&a>=s);return u&&e?null:e?s:s-1},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new o.Point(this._container.clientWidth,this._container.clientHeight),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(){var t=this._getTopLeftPoint();return new o.Bounds(t,t.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._initialTopLeftPoint},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(t){var e=this.options.crs;return e.scale(t)/e.scale(this._zoom)},getScaleZoom:function(t){return this._zoom+Math.log(t)/Math.LN2},project:function(t,e){return e=e===i?this._zoom:e,this.options.crs.latLngToPoint(o.latLng(t),e)},unproject:function(t,e){return e=e===i?this._zoom:e,this.options.crs.pointToLatLng(o.point(t),e)},layerPointToLatLng:function(t){var e=o.point(t).add(this.getPixelOrigin());return this.unproject(e)},latLngToLayerPoint:function(t){var e=this.project(o.latLng(t))._round();return e._subtract(this.getPixelOrigin())},containerPointToLayerPoint:function(t){return o.point(t).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(t){return o.point(t).add(this._getMapPanePos())},containerPointToLatLng:function(t){var e=this.containerPointToLayerPoint(o.point(t));return this.layerPointToLatLng(e)},latLngToContainerPoint:function(t){return this.layerPointToContainerPoint(this.latLngToLayerPoint(o.latLng(t)))},mouseEventToContainerPoint:function(t){return o.DomEvent.getMousePosition(t,this._container)},mouseEventToLayerPoint:function(t){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(t))},mouseEventToLatLng:function(t){return this.layerPointToLatLng(this.mouseEventToLayerPoint(t))},_initContainer:function(t){var e=this._container=o.DomUtil.get(t);if(!e)throw new Error("Map container not found.");if(e._leaflet)throw new Error("Map container is already initialized.");e._leaflet=!0},_initLayout:function(){var t=this._container;o.DomUtil.addClass(t,"leaflet-container"+(o.Browser.touch?" leaflet-touch":"")+(o.Browser.retina?" leaflet-retina":"")+(o.Browser.ielt9?" leaflet-oldie":"")+(this.options.fadeAnimation?" leaflet-fade-anim":""));var e=o.DomUtil.getStyle(t,"position");"absolute"!==e&&"relative"!==e&&"fixed"!==e&&(t.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var t=this._panes={};this._mapPane=t.mapPane=this._createPane("leaflet-map-pane",this._container),this._tilePane=t.tilePane=this._createPane("leaflet-tile-pane",this._mapPane),t.objectsPane=this._createPane("leaflet-objects-pane",this._mapPane),t.shadowPane=this._createPane("leaflet-shadow-pane"),t.overlayPane=this._createPane("leaflet-overlay-pane"),t.markerPane=this._createPane("leaflet-marker-pane"),t.popupPane=this._createPane("leaflet-popup-pane");var e=" leaflet-zoom-hide";this.options.markerZoomAnimation||(o.DomUtil.addClass(t.markerPane,e),o.DomUtil.addClass(t.shadowPane,e),o.DomUtil.addClass(t.popupPane,e))},_createPane:function(t,e){return o.DomUtil.create("div",t,e||this._panes.objectsPane)},_clearPanes:function(){this._container.removeChild(this._mapPane)},_addLayers:function(t){t=t?o.Util.isArray(t)?t:[t]:[];for(var e=0,i=t.length;i>e;e++)this.addLayer(t[e])},_resetView:function(t,e,i,n){var s=this._zoom!==e;n||(this.fire("movestart"),s&&this.fire("zoomstart")),this._zoom=e,this._initialCenter=t,this._initialTopLeftPoint=this._getNewTopLeftPoint(t),i?this._initialTopLeftPoint._add(this._getMapPanePos()):o.DomUtil.setPosition(this._mapPane,new o.Point(0,0)),this._tileLayersToLoad=this._tileLayersNum;var a=!this._loaded;this._loaded=!0,this.fire("viewreset",{hard:!i}),a&&(this.fire("load"),this.eachLayer(this._layerAdd,this)),this.fire("move"),(s||n)&&this.fire("zoomend"),this.fire("moveend",{hard:!i})},_rawPanBy:function(t){o.DomUtil.setPosition(this._mapPane,this._getMapPanePos().subtract(t))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_updateZoomLevels:function(){var t,e=1/0,n=-(1/0),o=this._getZoomSpan();for(t in this._zoomBoundLayers){var s=this._zoomBoundLayers[t];isNaN(s.options.minZoom)||(e=Math.min(e,s.options.minZoom)),isNaN(s.options.maxZoom)||(n=Math.max(n,s.options.maxZoom))}t===i?this._layersMaxZoom=this._layersMinZoom=i:(this._layersMaxZoom=n,this._layersMinZoom=e),o!==this._getZoomSpan()&&this.fire("zoomlevelschange")},_panInsideMaxBounds:function(){this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(e){if(o.DomEvent){e=e||"on",o.DomEvent[e](this._container,"click",this._onMouseClick,this);var i,n,s=["dblclick","mousedown","mouseup","mouseenter","mouseleave","mousemove","contextmenu"];for(i=0,n=s.length;n>i;i++)o.DomEvent[e](this._container,s[i],this._fireMouseEvent,this);this.options.trackResize&&o.DomEvent[e](t,"resize",this._onResize,this)}},_onResize:function(){o.Util.cancelAnimFrame(this._resizeRequest),this._resizeRequest=o.Util.requestAnimFrame(function(){this.invalidateSize({debounceMoveend:!0})},this,!1,this._container)},_onMouseClick:function(t){!this._loaded||!t._simulated&&(this.dragging&&this.dragging.moved()||this.boxZoom&&this.boxZoom.moved())||o.DomEvent._skipped(t)||(this.fire("preclick"),this._fireMouseEvent(t))},_fireMouseEvent:function(t){if(this._loaded&&!o.DomEvent._skipped(t)){var e=t.type;if(e="mouseenter"===e?"mouseover":"mouseleave"===e?"mouseout":e,this.hasEventListeners(e)){"contextmenu"===e&&o.DomEvent.preventDefault(t);var i=this.mouseEventToContainerPoint(t),n=this.containerPointToLayerPoint(i),s=this.layerPointToLatLng(n);this.fire(e,{latlng:s,layerPoint:n,containerPoint:i,originalEvent:t})}}},_onTileLayerLoad:function(){this._tileLayersToLoad--,this._tileLayersNum&&!this._tileLayersToLoad&&this.fire("tilelayersload")},_clearHandlers:function(){for(var t=0,e=this._handlers.length;e>t;t++)this._handlers[t].disable()},whenReady:function(t,e){return this._loaded?t.call(e||this,this):this.on("load",t,e),this},_layerAdd:function(t){t.onAdd(this),this.fire("layeradd",{layer:t})},_getMapPanePos:function(){return o.DomUtil.getPosition(this._mapPane)},_moved:function(){var t=this._getMapPanePos();return t&&!t.equals([0,0])},_getTopLeftPoint:function(){return this.getPixelOrigin().subtract(this._getMapPanePos())},_getNewTopLeftPoint:function(t,e){var i=this.getSize()._divideBy(2);return this.project(t,e)._subtract(i)._round()},_latLngToNewLayerPoint:function(t,e,i){var n=this._getNewTopLeftPoint(i,e).add(this._getMapPanePos());return this.project(t,e)._subtract(n)},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(t){return this.latLngToLayerPoint(t).subtract(this._getCenterLayerPoint())},_limitCenter:function(t,e,i){if(!i)return t;var n=this.project(t,e),s=this.getSize().divideBy(2),a=new o.Bounds(n.subtract(s),n.add(s)),r=this._getBoundsOffset(a,i,e);return this.unproject(n.add(r),e)},_limitOffset:function(t,e){if(!e)return t;var i=this.getPixelBounds(),n=new o.Bounds(i.min.add(t),i.max.add(t));return t.add(this._getBoundsOffset(n,e))},_getBoundsOffset:function(t,e,i){var n=this.project(e.getNorthWest(),i).subtract(t.min),s=this.project(e.getSouthEast(),i).subtract(t.max),a=this._rebound(n.x,-s.x),r=this._rebound(n.y,-s.y);return new o.Point(a,r)},_rebound:function(t,e){return t+e>0?Math.round(t-e)/2:Math.max(0,Math.ceil(t))-Math.max(0,Math.floor(e))},_limitZoom:function(t){var e=this.getMinZoom(),i=this.getMaxZoom();return Math.max(e,Math.min(i,t))}}),o.map=function(t,e){return new o.Map(t,e)},o.Projection.Mercator={MAX_LATITUDE:85.0840591556,R_MINOR:6356752.314245179,R_MAJOR:6378137,project:function(t){var e=o.LatLng.DEG_TO_RAD,i=this.MAX_LATITUDE,n=Math.max(Math.min(i,t.lat),-i),s=this.R_MAJOR,a=this.R_MINOR,r=t.lng*e*s,h=n*e,l=a/s,u=Math.sqrt(1-l*l),c=u*Math.sin(h);c=Math.pow((1-c)/(1+c),.5*u);var d=Math.tan(.5*(.5*Math.PI-h))/c;return h=-s*Math.log(d),new o.Point(r,h)},unproject:function(t){for(var e,i=o.LatLng.RAD_TO_DEG,n=this.R_MAJOR,s=this.R_MINOR,a=t.x*i/n,r=s/n,h=Math.sqrt(1-r*r),l=Math.exp(-t.y/n),u=Math.PI/2-2*Math.atan(l),c=15,d=1e-7,p=c,_=.1;Math.abs(_)>d&&--p>0;)e=h*Math.sin(u),_=Math.PI/2-2*Math.atan(l*Math.pow((1-e)/(1+e),.5*h))-u,u+=_;return new o.LatLng(u*i,a)}},o.CRS.EPSG3395=o.extend({},o.CRS,{code:"EPSG:3395",projection:o.Projection.Mercator,
-transformation:function(){var t=o.Projection.Mercator,e=t.R_MAJOR,i=.5/(Math.PI*e);return new o.Transformation(i,.5,-i,.5)}()}),o.TileLayer=o.Class.extend({includes:o.Mixin.Events,options:{minZoom:0,maxZoom:18,tileSize:256,subdomains:"abc",errorTileUrl:"",attribution:"",zoomOffset:0,opacity:1,unloadInvisibleTiles:o.Browser.mobile,updateWhenIdle:o.Browser.mobile},initialize:function(t,e){e=o.setOptions(this,e),e.detectRetina&&o.Browser.retina&&e.maxZoom>0&&(e.tileSize=Math.floor(e.tileSize/2),e.zoomOffset++,e.minZoom>0&&e.minZoom--,this.options.maxZoom--),e.bounds&&(e.bounds=o.latLngBounds(e.bounds)),this._url=t;var i=this.options.subdomains;"string"==typeof i&&(this.options.subdomains=i.split(""))},onAdd:function(t){this._map=t,this._animated=t._zoomAnimated,this._initContainer(),t.on({viewreset:this._reset,moveend:this._update},this),this._animated&&t.on({zoomanim:this._animateZoom,zoomend:this._endZoomAnim},this),this.options.updateWhenIdle||(this._limitedUpdate=o.Util.limitExecByInterval(this._update,150,this),t.on("move",this._limitedUpdate,this)),this._reset(),this._update()},addTo:function(t){return t.addLayer(this),this},onRemove:function(t){this._container.parentNode.removeChild(this._container),t.off({viewreset:this._reset,moveend:this._update},this),this._animated&&t.off({zoomanim:this._animateZoom,zoomend:this._endZoomAnim},this),this.options.updateWhenIdle||t.off("move",this._limitedUpdate,this),this._container=null,this._map=null},bringToFront:function(){var t=this._map._panes.tilePane;return this._container&&(t.appendChild(this._container),this._setAutoZIndex(t,Math.max)),this},bringToBack:function(){var t=this._map._panes.tilePane;return this._container&&(t.insertBefore(this._container,t.firstChild),this._setAutoZIndex(t,Math.min)),this},getAttribution:function(){return this.options.attribution},getContainer:function(){return this._container},setOpacity:function(t){return this.options.opacity=t,this._map&&this._updateOpacity(),this},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},setUrl:function(t,e){return this._url=t,e||this.redraw(),this},redraw:function(){return this._map&&(this._reset({hard:!0}),this._update()),this},_updateZIndex:function(){this._container&&this.options.zIndex!==i&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(t,e){var i,n,o,s=t.children,a=-e(1/0,-(1/0));for(n=0,o=s.length;o>n;n++)s[n]!==this._container&&(i=parseInt(s[n].style.zIndex,10),isNaN(i)||(a=e(a,i)));this.options.zIndex=this._container.style.zIndex=(isFinite(a)?a:0)+e(1,-1)},_updateOpacity:function(){var t,e=this._tiles;if(o.Browser.ielt9)for(t in e)o.DomUtil.setOpacity(e[t],this.options.opacity);else o.DomUtil.setOpacity(this._container,this.options.opacity)},_initContainer:function(){var t=this._map._panes.tilePane;if(!this._container){if(this._container=o.DomUtil.create("div","leaflet-layer"),this._updateZIndex(),this._animated){var e="leaflet-tile-container";this._bgBuffer=o.DomUtil.create("div",e,this._container),this._tileContainer=o.DomUtil.create("div",e,this._container)}else this._tileContainer=this._container;t.appendChild(this._container),this.options.opacity<1&&this._updateOpacity()}},_reset:function(t){for(var e in this._tiles)this.fire("tileunload",{tile:this._tiles[e]});this._tiles={},this._tilesToLoad=0,this.options.reuseTiles&&(this._unusedTiles=[]),this._tileContainer.innerHTML="",this._animated&&t&&t.hard&&this._clearBgBuffer(),this._initContainer()},_getTileSize:function(){var t=this._map,e=t.getZoom()+this.options.zoomOffset,i=this.options.maxNativeZoom,n=this.options.tileSize;return i&&e>i&&(n=Math.round(t.getZoomScale(e)/t.getZoomScale(i)*n)),n},_update:function(){if(this._map){var t=this._map,e=t.getPixelBounds(),i=t.getZoom(),n=this._getTileSize();if(!(i>this.options.maxZoom||i<this.options.minZoom)){var s=o.bounds(e.min.divideBy(n)._floor(),e.max.divideBy(n)._floor());this._addTilesFromCenterOut(s),(this.options.unloadInvisibleTiles||this.options.reuseTiles)&&this._removeOtherTiles(s)}}},_addTilesFromCenterOut:function(t){var i,n,s,a=[],r=t.getCenter();for(i=t.min.y;i<=t.max.y;i++)for(n=t.min.x;n<=t.max.x;n++)s=new o.Point(n,i),this._tileShouldBeLoaded(s)&&a.push(s);var h=a.length;if(0!==h){a.sort(function(t,e){return t.distanceTo(r)-e.distanceTo(r)});var l=e.createDocumentFragment();for(this._tilesToLoad||this.fire("loading"),this._tilesToLoad+=h,n=0;h>n;n++)this._addTile(a[n],l);this._tileContainer.appendChild(l)}},_tileShouldBeLoaded:function(t){if(t.x+":"+t.y in this._tiles)return!1;var e=this.options;if(!e.continuousWorld){var i=this._getWrapTileNum();if(e.noWrap&&(t.x<0||t.x>=i.x)||t.y<0||t.y>=i.y)return!1}if(e.bounds){var n=this._getTileSize(),o=t.multiplyBy(n),s=o.add([n,n]),a=this._map.unproject(o),r=this._map.unproject(s);if(e.continuousWorld||e.noWrap||(a=a.wrap(),r=r.wrap()),!e.bounds.intersects([a,r]))return!1}return!0},_removeOtherTiles:function(t){var e,i,n,o;for(o in this._tiles)e=o.split(":"),i=parseInt(e[0],10),n=parseInt(e[1],10),(i<t.min.x||i>t.max.x||n<t.min.y||n>t.max.y)&&this._removeTile(o)},_removeTile:function(t){var e=this._tiles[t];this.fire("tileunload",{tile:e,url:e.src}),this.options.reuseTiles?(o.DomUtil.removeClass(e,"leaflet-tile-loaded"),this._unusedTiles.push(e)):e.parentNode===this._tileContainer&&this._tileContainer.removeChild(e),o.Browser.android||(e.onload=null,e.src=o.Util.emptyImageUrl),delete this._tiles[t]},_addTile:function(t,e){var i=this._getTilePos(t),n=this._getTile();o.DomUtil.setPosition(n,i,o.Browser.chrome),this._tiles[t.x+":"+t.y]=n,this._loadTile(n,t),n.parentNode!==this._tileContainer&&e.appendChild(n)},_getZoomForUrl:function(){var t=this.options,e=this._map.getZoom();return t.zoomReverse&&(e=t.maxZoom-e),e+=t.zoomOffset,t.maxNativeZoom?Math.min(e,t.maxNativeZoom):e},_getTilePos:function(t){var e=this._map.getPixelOrigin(),i=this._getTileSize();return t.multiplyBy(i).subtract(e)},getTileUrl:function(t){return o.Util.template(this._url,o.extend({s:this._getSubdomain(t),z:t.z,x:t.x,y:t.y},this.options))},_getWrapTileNum:function(){var t=this._map.options.crs,e=t.getSize(this._map.getZoom());return e.divideBy(this._getTileSize())._floor()},_adjustTilePoint:function(t){var e=this._getWrapTileNum();this.options.continuousWorld||this.options.noWrap||(t.x=(t.x%e.x+e.x)%e.x),this.options.tms&&(t.y=e.y-t.y-1),t.z=this._getZoomForUrl()},_getSubdomain:function(t){var e=Math.abs(t.x+t.y)%this.options.subdomains.length;return this.options.subdomains[e]},_getTile:function(){if(this.options.reuseTiles&&this._unusedTiles.length>0){var t=this._unusedTiles.pop();return this._resetTile(t),t}return this._createTile()},_resetTile:function(){},_createTile:function(){var t=o.DomUtil.create("img","leaflet-tile");return t.style.width=t.style.height=this._getTileSize()+"px",t.galleryimg="no",t.onselectstart=t.onmousemove=o.Util.falseFn,o.Browser.ielt9&&this.options.opacity!==i&&o.DomUtil.setOpacity(t,this.options.opacity),o.Browser.mobileWebkit3d&&(t.style.WebkitBackfaceVisibility="hidden"),t},_loadTile:function(t,e){t._layer=this,t.onload=this._tileOnLoad,t.onerror=this._tileOnError,this._adjustTilePoint(e),t.src=this.getTileUrl(e),this.fire("tileloadstart",{tile:t,url:t.src})},_tileLoaded:function(){this._tilesToLoad--,this._animated&&o.DomUtil.addClass(this._tileContainer,"leaflet-zoom-animated"),this._tilesToLoad||(this.fire("load"),this._animated&&(clearTimeout(this._clearBgBufferTimer),this._clearBgBufferTimer=setTimeout(o.bind(this._clearBgBuffer,this),500)))},_tileOnLoad:function(){var t=this._layer;this.src!==o.Util.emptyImageUrl&&(o.DomUtil.addClass(this,"leaflet-tile-loaded"),t.fire("tileload",{tile:this,url:this.src})),t._tileLoaded()},_tileOnError:function(){var t=this._layer;t.fire("tileerror",{tile:this,url:this.src});var e=t.options.errorTileUrl;e&&(this.src=e),t._tileLoaded()}}),o.tileLayer=function(t,e){return new o.TileLayer(t,e)},o.TileLayer.WMS=o.TileLayer.extend({defaultWmsParams:{service:"WMS",request:"GetMap",version:"1.1.1",layers:"",styles:"",format:"image/jpeg",transparent:!1},initialize:function(t,e){this._url=t;var i=o.extend({},this.defaultWmsParams),n=e.tileSize||this.options.tileSize;e.detectRetina&&o.Browser.retina?i.width=i.height=2*n:i.width=i.height=n;for(var s in e)this.options.hasOwnProperty(s)||"crs"===s||(i[s]=e[s]);this.wmsParams=i,o.setOptions(this,e)},onAdd:function(t){this._crs=this.options.crs||t.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var e=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[e]=this._crs.code,o.TileLayer.prototype.onAdd.call(this,t)},getTileUrl:function(t){var e=this._map,i=this.options.tileSize,n=t.multiplyBy(i),s=n.add([i,i]),a=this._crs.project(e.unproject(n,t.z)),r=this._crs.project(e.unproject(s,t.z)),h=this._wmsVersion>=1.3&&this._crs===o.CRS.EPSG4326?[r.y,a.x,a.y,r.x].join(","):[a.x,r.y,r.x,a.y].join(","),l=o.Util.template(this._url,{s:this._getSubdomain(t)});return l+o.Util.getParamString(this.wmsParams,l,!0)+"&BBOX="+h},setParams:function(t,e){return o.extend(this.wmsParams,t),e||this.redraw(),this}}),o.tileLayer.wms=function(t,e){return new o.TileLayer.WMS(t,e)},o.TileLayer.Canvas=o.TileLayer.extend({options:{async:!1},initialize:function(t){o.setOptions(this,t)},redraw:function(){this._map&&(this._reset({hard:!0}),this._update());for(var t in this._tiles)this._redrawTile(this._tiles[t]);return this},_redrawTile:function(t){this.drawTile(t,t._tilePoint,this._map._zoom)},_createTile:function(){var t=o.DomUtil.create("canvas","leaflet-tile");return t.width=t.height=this.options.tileSize,t.onselectstart=t.onmousemove=o.Util.falseFn,t},_loadTile:function(t,e){t._layer=this,t._tilePoint=e,this._redrawTile(t),this.options.async||this.tileDrawn(t)},drawTile:function(){},tileDrawn:function(t){this._tileOnLoad.call(t)}}),o.tileLayer.canvas=function(t){return new o.TileLayer.Canvas(t)},o.ImageOverlay=o.Class.extend({includes:o.Mixin.Events,options:{opacity:1},initialize:function(t,e,i){this._url=t,this._bounds=o.latLngBounds(e),o.setOptions(this,i)},onAdd:function(t){this._map=t,this._image||this._initImage(),t._panes.overlayPane.appendChild(this._image),t.on("viewreset",this._reset,this),t.options.zoomAnimation&&o.Browser.any3d&&t.on("zoomanim",this._animateZoom,this),this._reset()},onRemove:function(t){t.getPanes().overlayPane.removeChild(this._image),t.off("viewreset",this._reset,this),t.options.zoomAnimation&&t.off("zoomanim",this._animateZoom,this)},addTo:function(t){return t.addLayer(this),this},setOpacity:function(t){return this.options.opacity=t,this._updateOpacity(),this},bringToFront:function(){return this._image&&this._map._panes.overlayPane.appendChild(this._image),this},bringToBack:function(){var t=this._map._panes.overlayPane;return this._image&&t.insertBefore(this._image,t.firstChild),this},setUrl:function(t){this._url=t,this._image.src=this._url},getAttribution:function(){return this.options.attribution},_initImage:function(){this._image=o.DomUtil.create("img","leaflet-image-layer"),this._map.options.zoomAnimation&&o.Browser.any3d?o.DomUtil.addClass(this._image,"leaflet-zoom-animated"):o.DomUtil.addClass(this._image,"leaflet-zoom-hide"),this._updateOpacity(),o.extend(this._image,{galleryimg:"no",onselectstart:o.Util.falseFn,onmousemove:o.Util.falseFn,onload:o.bind(this._onImageLoad,this),src:this._url})},_animateZoom:function(t){var e=this._map,i=this._image,n=e.getZoomScale(t.zoom),s=this._bounds.getNorthWest(),a=this._bounds.getSouthEast(),r=e._latLngToNewLayerPoint(s,t.zoom,t.center),h=e._latLngToNewLayerPoint(a,t.zoom,t.center)._subtract(r),l=r._add(h._multiplyBy(.5*(1-1/n)));i.style[o.DomUtil.TRANSFORM]=o.DomUtil.getTranslateString(l)+" scale("+n+") "},_reset:function(){var t=this._image,e=this._map.latLngToLayerPoint(this._bounds.getNorthWest()),i=this._map.latLngToLayerPoint(this._bounds.getSouthEast())._subtract(e);o.DomUtil.setPosition(t,e),t.style.width=i.x+"px",t.style.height=i.y+"px"},_onImageLoad:function(){this.fire("load")},_updateOpacity:function(){o.DomUtil.setOpacity(this._image,this.options.opacity)}}),o.imageOverlay=function(t,e,i){return new o.ImageOverlay(t,e,i)},o.Icon=o.Class.extend({options:{className:""},initialize:function(t){o.setOptions(this,t)},createIcon:function(t){return this._createIcon("icon",t)},createShadow:function(t){return this._createIcon("shadow",t)},_createIcon:function(t,e){var i=this._getIconUrl(t);if(!i){if("icon"===t)throw new Error("iconUrl not set in Icon options (see the docs).");return null}var n;return n=e&&"IMG"===e.tagName?this._createImg(i,e):this._createImg(i),this._setIconStyles(n,t),n},_setIconStyles:function(t,e){var i,n=this.options,s=o.point(n[e+"Size"]);i="shadow"===e?o.point(n.shadowAnchor||n.iconAnchor):o.point(n.iconAnchor),!i&&s&&(i=s.divideBy(2,!0)),t.className="leaflet-marker-"+e+" "+n.className,i&&(t.style.marginLeft=-i.x+"px",t.style.marginTop=-i.y+"px"),s&&(t.style.width=s.x+"px",t.style.height=s.y+"px")},_createImg:function(t,i){return i=i||e.createElement("img"),i.src=t,i},_getIconUrl:function(t){return o.Browser.retina&&this.options[t+"RetinaUrl"]?this.options[t+"RetinaUrl"]:this.options[t+"Url"]}}),o.icon=function(t){return new o.Icon(t)},o.Icon.Default=o.Icon.extend({options:{iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],shadowSize:[41,41]},_getIconUrl:function(t){var e=t+"Url";if(this.options[e])return this.options[e];o.Browser.retina&&"icon"===t&&(t+="-2x");var i=o.Icon.Default.imagePath;if(!i)throw new Error("Couldn't autodetect L.Icon.Default.imagePath, set it manually.");return i+"/marker-"+t+".png"}}),o.Icon.Default.imagePath=function(){var t,i,n,o,s,a=e.getElementsByTagName("script"),r=/[\/^]leaflet[\-\._]?([\w\-\._]*)\.js\??/;for(t=0,i=a.length;i>t;t++)if(n=a[t].src,o=n.match(r))return s=n.split(r)[0],(s?s+"/":"")+"images"}(),o.Marker=o.Class.extend({includes:o.Mixin.Events,options:{icon:new o.Icon.Default,title:"",alt:"",clickable:!0,draggable:!1,keyboard:!0,zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250},initialize:function(t,e){o.setOptions(this,e),this._latlng=o.latLng(t)},onAdd:function(t){this._map=t,t.on("viewreset",this.update,this),this._initIcon(),this.update(),this.fire("add"),t.options.zoomAnimation&&t.options.markerZoomAnimation&&t.on("zoomanim",this._animateZoom,this)},addTo:function(t){return t.addLayer(this),this},onRemove:function(t){this.dragging&&this.dragging.disable(),this._removeIcon(),this._removeShadow(),this.fire("remove"),t.off({viewreset:this.update,zoomanim:this._animateZoom},this),this._map=null},getLatLng:function(){return this._latlng},setLatLng:function(t){return this._latlng=o.latLng(t),this.update(),this.fire("move",{latlng:this._latlng})},setZIndexOffset:function(t){return this.options.zIndexOffset=t,this.update(),this},setIcon:function(t){return this.options.icon=t,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup),this},update:function(){return this._icon&&this._setPos(this._map.latLngToLayerPoint(this._latlng).round()),this},_initIcon:function(){var t=this.options,e=this._map,i=e.options.zoomAnimation&&e.options.markerZoomAnimation,n=i?"leaflet-zoom-animated":"leaflet-zoom-hide",s=t.icon.createIcon(this._icon),a=!1;s!==this._icon&&(this._icon&&this._removeIcon(),a=!0,t.title&&(s.title=t.title),t.alt&&(s.alt=t.alt)),o.DomUtil.addClass(s,n),t.keyboard&&(s.tabIndex="0"),this._icon=s,this._initInteraction(),t.riseOnHover&&o.DomEvent.on(s,"mouseover",this._bringToFront,this).on(s,"mouseout",this._resetZIndex,this);var r=t.icon.createShadow(this._shadow),h=!1;r!==this._shadow&&(this._removeShadow(),h=!0),r&&o.DomUtil.addClass(r,n),this._shadow=r,t.opacity<1&&this._updateOpacity();var l=this._map._panes;a&&l.markerPane.appendChild(this._icon),r&&h&&l.shadowPane.appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&o.DomEvent.off(this._icon,"mouseover",this._bringToFront).off(this._icon,"mouseout",this._resetZIndex),this._map._panes.markerPane.removeChild(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&this._map._panes.shadowPane.removeChild(this._shadow),this._shadow=null},_setPos:function(t){o.DomUtil.setPosition(this._icon,t),this._shadow&&o.DomUtil.setPosition(this._shadow,t),this._zIndex=t.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(t){this._icon.style.zIndex=this._zIndex+t},_animateZoom:function(t){var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center).round();this._setPos(e)},_initInteraction:function(){if(this.options.clickable){var t=this._icon,e=["dblclick","mousedown","mouseover","mouseout","contextmenu"];o.DomUtil.addClass(t,"leaflet-clickable"),o.DomEvent.on(t,"click",this._onMouseClick,this),o.DomEvent.on(t,"keypress",this._onKeyPress,this);for(var i=0;i<e.length;i++)o.DomEvent.on(t,e[i],this._fireMouseEvent,this);o.Handler.MarkerDrag&&(this.dragging=new o.Handler.MarkerDrag(this),this.options.draggable&&this.dragging.enable())}},_onMouseClick:function(t){var e=this.dragging&&this.dragging.moved();(this.hasEventListeners(t.type)||e)&&o.DomEvent.stopPropagation(t),e||(this.dragging&&this.dragging._enabled||!this._map.dragging||!this._map.dragging.moved())&&this.fire(t.type,{originalEvent:t,latlng:this._latlng})},_onKeyPress:function(t){13===t.keyCode&&this.fire("click",{originalEvent:t,latlng:this._latlng})},_fireMouseEvent:function(t){this.fire(t.type,{originalEvent:t,latlng:this._latlng}),"contextmenu"===t.type&&this.hasEventListeners(t.type)&&o.DomEvent.preventDefault(t),"mousedown"!==t.type?o.DomEvent.stopPropagation(t):o.DomEvent.preventDefault(t)},setOpacity:function(t){return this.options.opacity=t,this._map&&this._updateOpacity(),this},_updateOpacity:function(){o.DomUtil.setOpacity(this._icon,this.options.opacity),this._shadow&&o.DomUtil.setOpacity(this._shadow,this.options.opacity)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)}}),o.marker=function(t,e){return new o.Marker(t,e)},o.DivIcon=o.Icon.extend({options:{iconSize:[12,12],className:"leaflet-div-icon",html:!1},createIcon:function(t){var i=t&&"DIV"===t.tagName?t:e.createElement("div"),n=this.options;return n.html!==!1?i.innerHTML=n.html:i.innerHTML="",n.bgPos&&(i.style.backgroundPosition=-n.bgPos.x+"px "+-n.bgPos.y+"px"),this._setIconStyles(i,"icon"),i},createShadow:function(){return null}}),o.divIcon=function(t){return new o.DivIcon(t)},o.Map.mergeOptions({closePopupOnClick:!0}),o.Popup=o.Class.extend({includes:o.Mixin.Events,options:{minWidth:50,maxWidth:300,autoPan:!0,closeButton:!0,offset:[0,7],autoPanPadding:[5,5],keepInView:!1,className:"",zoomAnimation:!0},initialize:function(t,e){o.setOptions(this,t),this._source=e,this._animated=o.Browser.any3d&&this.options.zoomAnimation,this._isOpen=!1},onAdd:function(t){this._map=t,this._container||this._initLayout();var e=t.options.fadeAnimation;e&&o.DomUtil.setOpacity(this._container,0),t._panes.popupPane.appendChild(this._container),t.on(this._getEvents(),this),this.update(),e&&o.DomUtil.setOpacity(this._container,1),this.fire("open"),t.fire("popupopen",{popup:this}),this._source&&this._source.fire("popupopen",{popup:this})},addTo:function(t){return t.addLayer(this),this},openOn:function(t){return t.openPopup(this),this},onRemove:function(t){t._panes.popupPane.removeChild(this._container),o.Util.falseFn(this._container.offsetWidth),t.off(this._getEvents(),this),t.options.fadeAnimation&&o.DomUtil.setOpacity(this._container,0),this._map=null,this.fire("close"),t.fire("popupclose",{popup:this}),this._source&&this._source.fire("popupclose",{popup:this})},getLatLng:function(){return this._latlng},setLatLng:function(t){return this._latlng=o.latLng(t),this._map&&(this._updatePosition(),this._adjustPan()),this},getContent:function(){return this._content},setContent:function(t){return this._content=t,this.update(),this},update:function(){this._map&&(this._container.style.visibility="hidden",this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility="",this._adjustPan())},_getEvents:function(){var t={viewreset:this._updatePosition};return this._animated&&(t.zoomanim=this._zoomAnimation),("closeOnClick"in this.options?this.options.closeOnClick:this._map.options.closePopupOnClick)&&(t.preclick=this._close),this.options.keepInView&&(t.moveend=this._adjustPan),t},_close:function(){this._map&&this._map.closePopup(this)},_initLayout:function(){var t,e="leaflet-popup",i=e+" "+this.options.className+" leaflet-zoom-"+(this._animated?"animated":"hide"),n=this._container=o.DomUtil.create("div",i);this.options.closeButton&&(t=this._closeButton=o.DomUtil.create("a",e+"-close-button",n),t.href="#close",t.innerHTML="&#215;",o.DomEvent.disableClickPropagation(t),o.DomEvent.on(t,"click",this._onCloseButtonClick,this));var s=this._wrapper=o.DomUtil.create("div",e+"-content-wrapper",n);o.DomEvent.disableClickPropagation(s),this._contentNode=o.DomUtil.create("div",e+"-content",s),o.DomEvent.disableScrollPropagation(this._contentNode),o.DomEvent.on(s,"contextmenu",o.DomEvent.stopPropagation),this._tipContainer=o.DomUtil.create("div",e+"-tip-container",n),this._tip=o.DomUtil.create("div",e+"-tip",this._tipContainer)},_updateContent:function(){if(this._content){if("string"==typeof this._content)this._contentNode.innerHTML=this._content;else{for(;this._contentNode.hasChildNodes();)this._contentNode.removeChild(this._contentNode.firstChild);this._contentNode.appendChild(this._content)}this.fire("contentupdate")}},_updateLayout:function(){var t=this._contentNode,e=t.style;e.width="",e.whiteSpace="nowrap";var i=t.offsetWidth;i=Math.min(i,this.options.maxWidth),i=Math.max(i,this.options.minWidth),e.width=i+1+"px",e.whiteSpace="",e.height="";var n=t.offsetHeight,s=this.options.maxHeight,a="leaflet-popup-scrolled";s&&n>s?(e.height=s+"px",o.DomUtil.addClass(t,a)):o.DomUtil.removeClass(t,a),this._containerWidth=this._container.offsetWidth},_updatePosition:function(){if(this._map){var t=this._map.latLngToLayerPoint(this._latlng),e=this._animated,i=o.point(this.options.offset);e&&o.DomUtil.setPosition(this._container,t),this._containerBottom=-i.y-(e?0:t.y),this._containerLeft=-Math.round(this._containerWidth/2)+i.x+(e?0:t.x),this._container.style.bottom=this._containerBottom+"px",this._container.style.left=this._containerLeft+"px"}},_zoomAnimation:function(t){var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center);o.DomUtil.setPosition(this._container,e)},_adjustPan:function(){if(this.options.autoPan){var t=this._map,e=this._container.offsetHeight,i=this._containerWidth,n=new o.Point(this._containerLeft,-e-this._containerBottom);this._animated&&n._add(o.DomUtil.getPosition(this._container));var s=t.layerPointToContainerPoint(n),a=o.point(this.options.autoPanPadding),r=o.point(this.options.autoPanPaddingTopLeft||a),h=o.point(this.options.autoPanPaddingBottomRight||a),l=t.getSize(),u=0,c=0;s.x+i+h.x>l.x&&(u=s.x+i-l.x+h.x),s.x-u-r.x<0&&(u=s.x-r.x),s.y+e+h.y>l.y&&(c=s.y+e-l.y+h.y),s.y-c-r.y<0&&(c=s.y-r.y),(u||c)&&t.fire("autopanstart").panBy([u,c])}},_onCloseButtonClick:function(t){this._close(),o.DomEvent.stop(t)}}),o.popup=function(t,e){return new o.Popup(t,e)},o.Map.include({openPopup:function(t,e,i){if(this.closePopup(),!(t instanceof o.Popup)){var n=t;t=new o.Popup(i).setLatLng(e).setContent(n)}return t._isOpen=!0,this._popup=t,this.addLayer(t)},closePopup:function(t){return t&&t!==this._popup||(t=this._popup,this._popup=null),t&&(this.removeLayer(t),t._isOpen=!1),this}}),o.Marker.include({openPopup:function(){return this._popup&&this._map&&!this._map.hasLayer(this._popup)&&(this._popup.setLatLng(this._latlng),this._map.openPopup(this._popup)),this},closePopup:function(){return this._popup&&this._popup._close(),this},togglePopup:function(){return this._popup&&(this._popup._isOpen?this.closePopup():this.openPopup()),this},bindPopup:function(t,e){var i=o.point(this.options.icon.options.popupAnchor||[0,0]);return i=i.add(o.Popup.prototype.options.offset),e&&e.offset&&(i=i.add(e.offset)),e=o.extend({offset:i},e),this._popupHandlersAdded||(this.on("click",this.togglePopup,this).on("remove",this.closePopup,this).on("move",this._movePopup,this),this._popupHandlersAdded=!0),t instanceof o.Popup?(o.setOptions(t,e),this._popup=t,t._source=this):this._popup=new o.Popup(e,this).setContent(t),this},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},unbindPopup:function(){return this._popup&&(this._popup=null,this.off("click",this.togglePopup,this).off("remove",this.closePopup,this).off("move",this._movePopup,this),this._popupHandlersAdded=!1),this},getPopup:function(){return this._popup},_movePopup:function(t){this._popup.setLatLng(t.latlng)}}),o.LayerGroup=o.Class.extend({initialize:function(t){this._layers={};var e,i;if(t)for(e=0,i=t.length;i>e;e++)this.addLayer(t[e])},addLayer:function(t){var e=this.getLayerId(t);return this._layers[e]=t,this._map&&this._map.addLayer(t),this},removeLayer:function(t){var e=t in this._layers?t:this.getLayerId(t);return this._map&&this._layers[e]&&this._map.removeLayer(this._layers[e]),delete this._layers[e],this},hasLayer:function(t){return t?t in this._layers||this.getLayerId(t)in this._layers:!1},clearLayers:function(){return this.eachLayer(this.removeLayer,this),this},invoke:function(t){var e,i,n=Array.prototype.slice.call(arguments,1);for(e in this._layers)i=this._layers[e],i[t]&&i[t].apply(i,n);return this},onAdd:function(t){this._map=t,this.eachLayer(t.addLayer,t)},onRemove:function(t){this.eachLayer(t.removeLayer,t),this._map=null},addTo:function(t){return t.addLayer(this),this},eachLayer:function(t,e){for(var i in this._layers)t.call(e,this._layers[i]);return this},getLayer:function(t){return this._layers[t]},getLayers:function(){var t=[];for(var e in this._layers)t.push(this._layers[e]);return t},setZIndex:function(t){return this.invoke("setZIndex",t)},getLayerId:function(t){return o.stamp(t)}}),o.layerGroup=function(t){return new o.LayerGroup(t)},o.FeatureGroup=o.LayerGroup.extend({includes:o.Mixin.Events,statics:{EVENTS:"click dblclick mouseover mouseout mousemove contextmenu popupopen popupclose"},addLayer:function(t){return this.hasLayer(t)?this:("on"in t&&t.on(o.FeatureGroup.EVENTS,this._propagateEvent,this),o.LayerGroup.prototype.addLayer.call(this,t),this._popupContent&&t.bindPopup&&t.bindPopup(this._popupContent,this._popupOptions),this.fire("layeradd",{layer:t}))},removeLayer:function(t){return this.hasLayer(t)?(t in this._layers&&(t=this._layers[t]),"off"in t&&t.off(o.FeatureGroup.EVENTS,this._propagateEvent,this),o.LayerGroup.prototype.removeLayer.call(this,t),this._popupContent&&this.invoke("unbindPopup"),this.fire("layerremove",{layer:t})):this},bindPopup:function(t,e){return this._popupContent=t,this._popupOptions=e,this.invoke("bindPopup",t,e)},openPopup:function(t){for(var e in this._layers){this._layers[e].openPopup(t);break}return this},setStyle:function(t){return this.invoke("setStyle",t)},bringToFront:function(){return this.invoke("bringToFront")},bringToBack:function(){return this.invoke("bringToBack")},getBounds:function(){var t=new o.LatLngBounds;return this.eachLayer(function(e){t.extend(e instanceof o.Marker?e.getLatLng():e.getBounds())}),t},_propagateEvent:function(t){t=o.extend({layer:t.target,target:this},t),this.fire(t.type,t)}}),o.featureGroup=function(t){return new o.FeatureGroup(t)},o.Path=o.Class.extend({includes:[o.Mixin.Events],statics:{CLIP_PADDING:function(){var e=o.Browser.mobile?1280:2e3,i=(e/Math.max(t.outerWidth,t.outerHeight)-1)/2;return Math.max(0,Math.min(.5,i))}()},options:{stroke:!0,color:"#0033ff",dashArray:null,lineCap:null,lineJoin:null,weight:5,opacity:.5,fill:!1,fillColor:null,fillOpacity:.2,clickable:!0},initialize:function(t){o.setOptions(this,t)},onAdd:function(t){this._map=t,this._container||(this._initElements(),this._initEvents()),this.projectLatlngs(),this._updatePath(),this._container&&this._map._pathRoot.appendChild(this._container),this.fire("add"),t.on({viewreset:this.projectLatlngs,moveend:this._updatePath},this)},addTo:function(t){return t.addLayer(this),this},onRemove:function(t){t._pathRoot.removeChild(this._container),this.fire("remove"),this._map=null,o.Browser.vml&&(this._container=null,this._stroke=null,this._fill=null),t.off({viewreset:this.projectLatlngs,moveend:this._updatePath},this)},projectLatlngs:function(){},setStyle:function(t){return o.setOptions(this,t),this._container&&this._updateStyle(),this},redraw:function(){return this._map&&(this.projectLatlngs(),this._updatePath()),this}}),o.Map.include({_updatePathViewport:function(){var t=o.Path.CLIP_PADDING,e=this.getSize(),i=o.DomUtil.getPosition(this._mapPane),n=i.multiplyBy(-1)._subtract(e.multiplyBy(t)._round()),s=n.add(e.multiplyBy(1+2*t)._round());this._pathViewport=new o.Bounds(n,s)}}),o.Path.SVG_NS="http://www.w3.org/2000/svg",o.Browser.svg=!(!e.createElementNS||!e.createElementNS(o.Path.SVG_NS,"svg").createSVGRect),o.Path=o.Path.extend({statics:{SVG:o.Browser.svg},bringToFront:function(){var t=this._map._pathRoot,e=this._container;return e&&t.lastChild!==e&&t.appendChild(e),this},bringToBack:function(){var t=this._map._pathRoot,e=this._container,i=t.firstChild;return e&&i!==e&&t.insertBefore(e,i),this},getPathString:function(){},_createElement:function(t){return e.createElementNS(o.Path.SVG_NS,t)},_initElements:function(){this._map._initPathRoot(),this._initPath(),this._initStyle()},_initPath:function(){this._container=this._createElement("g"),this._path=this._createElement("path"),this.options.className&&o.DomUtil.addClass(this._path,this.options.className),this._container.appendChild(this._path)},_initStyle:function(){this.options.stroke&&(this._path.setAttribute("stroke-linejoin","round"),this._path.setAttribute("stroke-linecap","round")),this.options.fill&&this._path.setAttribute("fill-rule","evenodd"),this.options.pointerEvents&&this._path.setAttribute("pointer-events",this.options.pointerEvents),this.options.clickable||this.options.pointerEvents||this._path.setAttribute("pointer-events","none"),this._updateStyle()},_updateStyle:function(){this.options.stroke?(this._path.setAttribute("stroke",this.options.color),this._path.setAttribute("stroke-opacity",this.options.opacity),this._path.setAttribute("stroke-width",this.options.weight),this.options.dashArray?this._path.setAttribute("stroke-dasharray",this.options.dashArray):this._path.removeAttribute("stroke-dasharray"),this.options.lineCap&&this._path.setAttribute("stroke-linecap",this.options.lineCap),this.options.lineJoin&&this._path.setAttribute("stroke-linejoin",this.options.lineJoin)):this._path.setAttribute("stroke","none"),this.options.fill?(this._path.setAttribute("fill",this.options.fillColor||this.options.color),this._path.setAttribute("fill-opacity",this.options.fillOpacity)):this._path.setAttribute("fill","none")},_updatePath:function(){var t=this.getPathString();t||(t="M0 0"),this._path.setAttribute("d",t)},_initEvents:function(){if(this.options.clickable){(o.Browser.svg||!o.Browser.vml)&&o.DomUtil.addClass(this._path,"leaflet-clickable"),o.DomEvent.on(this._container,"click",this._onMouseClick,this);for(var t=["dblclick","mousedown","mouseover","mouseout","mousemove","contextmenu"],e=0;e<t.length;e++)o.DomEvent.on(this._container,t[e],this._fireMouseEvent,this)}},_onMouseClick:function(t){this._map.dragging&&this._map.dragging.moved()||this._fireMouseEvent(t)},_fireMouseEvent:function(t){if(this._map&&this.hasEventListeners(t.type)){var e=this._map,i=e.mouseEventToContainerPoint(t),n=e.containerPointToLayerPoint(i),s=e.layerPointToLatLng(n);this.fire(t.type,{latlng:s,layerPoint:n,containerPoint:i,originalEvent:t}),"contextmenu"===t.type&&o.DomEvent.preventDefault(t),"mousemove"!==t.type&&o.DomEvent.stopPropagation(t)}}}),o.Map.include({_initPathRoot:function(){this._pathRoot||(this._pathRoot=o.Path.prototype._createElement("svg"),this._panes.overlayPane.appendChild(this._pathRoot),this.options.zoomAnimation&&o.Browser.any3d?(o.DomUtil.addClass(this._pathRoot,"leaflet-zoom-animated"),
-this.on({zoomanim:this._animatePathZoom,zoomend:this._endPathZoom})):o.DomUtil.addClass(this._pathRoot,"leaflet-zoom-hide"),this.on("moveend",this._updateSvgViewport),this._updateSvgViewport())},_animatePathZoom:function(t){var e=this.getZoomScale(t.zoom),i=this._getCenterOffset(t.center)._multiplyBy(-e)._add(this._pathViewport.min);this._pathRoot.style[o.DomUtil.TRANSFORM]=o.DomUtil.getTranslateString(i)+" scale("+e+") ",this._pathZooming=!0},_endPathZoom:function(){this._pathZooming=!1},_updateSvgViewport:function(){if(!this._pathZooming){this._updatePathViewport();var t=this._pathViewport,e=t.min,i=t.max,n=i.x-e.x,s=i.y-e.y,a=this._pathRoot,r=this._panes.overlayPane;o.Browser.mobileWebkit&&r.removeChild(a),o.DomUtil.setPosition(a,e),a.setAttribute("width",n),a.setAttribute("height",s),a.setAttribute("viewBox",[e.x,e.y,n,s].join(" ")),o.Browser.mobileWebkit&&r.appendChild(a)}}}),o.Path.include({bindPopup:function(t,e){return t instanceof o.Popup?this._popup=t:((!this._popup||e)&&(this._popup=new o.Popup(e,this)),this._popup.setContent(t)),this._popupHandlersAdded||(this.on("click",this._openPopup,this).on("remove",this.closePopup,this),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this._popup=null,this.off("click",this._openPopup).off("remove",this.closePopup),this._popupHandlersAdded=!1),this},openPopup:function(t){return this._popup&&(t=t||this._latlng||this._latlngs[Math.floor(this._latlngs.length/2)],this._openPopup({latlng:t})),this},closePopup:function(){return this._popup&&this._popup._close(),this},_openPopup:function(t){this._popup.setLatLng(t.latlng),this._map.openPopup(this._popup)}}),o.Browser.vml=!o.Browser.svg&&function(){try{var t=e.createElement("div");t.innerHTML='<v:shape adj="1"/>';var i=t.firstChild;return i.style.behavior="url(#default#VML)",i&&"object"==typeof i.adj}catch(n){return!1}}(),o.Path=o.Browser.svg||!o.Browser.vml?o.Path:o.Path.extend({statics:{VML:!0,CLIP_PADDING:.02},_createElement:function(){try{return e.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(t){return e.createElement("<lvml:"+t+' class="lvml">')}}catch(t){return function(t){return e.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}(),_initPath:function(){var t=this._container=this._createElement("shape");o.DomUtil.addClass(t,"leaflet-vml-shape"+(this.options.className?" "+this.options.className:"")),this.options.clickable&&o.DomUtil.addClass(t,"leaflet-clickable"),t.coordsize="1 1",this._path=this._createElement("path"),t.appendChild(this._path),this._map._pathRoot.appendChild(t)},_initStyle:function(){this._updateStyle()},_updateStyle:function(){var t=this._stroke,e=this._fill,i=this.options,n=this._container;n.stroked=i.stroke,n.filled=i.fill,i.stroke?(t||(t=this._stroke=this._createElement("stroke"),t.endcap="round",n.appendChild(t)),t.weight=i.weight+"px",t.color=i.color,t.opacity=i.opacity,i.dashArray?t.dashStyle=o.Util.isArray(i.dashArray)?i.dashArray.join(" "):i.dashArray.replace(/( *, *)/g," "):t.dashStyle="",i.lineCap&&(t.endcap=i.lineCap.replace("butt","flat")),i.lineJoin&&(t.joinstyle=i.lineJoin)):t&&(n.removeChild(t),this._stroke=null),i.fill?(e||(e=this._fill=this._createElement("fill"),n.appendChild(e)),e.color=i.fillColor||i.color,e.opacity=i.fillOpacity):e&&(n.removeChild(e),this._fill=null)},_updatePath:function(){var t=this._container.style;t.display="none",this._path.v=this.getPathString()+" ",t.display=""}}),o.Map.include(o.Browser.svg||!o.Browser.vml?{}:{_initPathRoot:function(){if(!this._pathRoot){var t=this._pathRoot=e.createElement("div");t.className="leaflet-vml-container",this._panes.overlayPane.appendChild(t),this.on("moveend",this._updatePathViewport),this._updatePathViewport()}}}),o.Browser.canvas=function(){return!!e.createElement("canvas").getContext}(),o.Path=o.Path.SVG&&!t.L_PREFER_CANVAS||!o.Browser.canvas?o.Path:o.Path.extend({statics:{CANVAS:!0,SVG:!1},redraw:function(){return this._map&&(this.projectLatlngs(),this._requestUpdate()),this},setStyle:function(t){return o.setOptions(this,t),this._map&&(this._updateStyle(),this._requestUpdate()),this},onRemove:function(t){t.off("viewreset",this.projectLatlngs,this).off("moveend",this._updatePath,this),this.options.clickable&&(this._map.off("click",this._onClick,this),this._map.off("mousemove",this._onMouseMove,this)),this._requestUpdate(),this.fire("remove"),this._map=null},_requestUpdate:function(){this._map&&!o.Path._updateRequest&&(o.Path._updateRequest=o.Util.requestAnimFrame(this._fireMapMoveEnd,this._map))},_fireMapMoveEnd:function(){o.Path._updateRequest=null,this.fire("moveend")},_initElements:function(){this._map._initPathRoot(),this._ctx=this._map._canvasCtx},_updateStyle:function(){var t=this.options;t.stroke&&(this._ctx.lineWidth=t.weight,this._ctx.strokeStyle=t.color),t.fill&&(this._ctx.fillStyle=t.fillColor||t.color),t.lineCap&&(this._ctx.lineCap=t.lineCap),t.lineJoin&&(this._ctx.lineJoin=t.lineJoin)},_drawPath:function(){var t,e,i,n,s,a;for(this._ctx.beginPath(),t=0,i=this._parts.length;i>t;t++){for(e=0,n=this._parts[t].length;n>e;e++)s=this._parts[t][e],a=(0===e?"move":"line")+"To",this._ctx[a](s.x,s.y);this instanceof o.Polygon&&this._ctx.closePath()}},_checkIfEmpty:function(){return!this._parts.length},_updatePath:function(){if(!this._checkIfEmpty()){var t=this._ctx,e=this.options;this._drawPath(),t.save(),this._updateStyle(),e.fill&&(t.globalAlpha=e.fillOpacity,t.fill(e.fillRule||"evenodd")),e.stroke&&(t.globalAlpha=e.opacity,t.stroke()),t.restore()}},_initEvents:function(){this.options.clickable&&(this._map.on("mousemove",this._onMouseMove,this),this._map.on("click dblclick contextmenu",this._fireMouseEvent,this))},_fireMouseEvent:function(t){this._containsPoint(t.layerPoint)&&this.fire(t.type,t)},_onMouseMove:function(t){this._map&&!this._map._animatingZoom&&(this._containsPoint(t.layerPoint)?(this._ctx.canvas.style.cursor="pointer",this._mouseInside=!0,this.fire("mouseover",t)):this._mouseInside&&(this._ctx.canvas.style.cursor="",this._mouseInside=!1,this.fire("mouseout",t)))}}),o.Map.include(o.Path.SVG&&!t.L_PREFER_CANVAS||!o.Browser.canvas?{}:{_initPathRoot:function(){var t,i=this._pathRoot;i||(i=this._pathRoot=e.createElement("canvas"),i.style.position="absolute",t=this._canvasCtx=i.getContext("2d"),t.lineCap="round",t.lineJoin="round",this._panes.overlayPane.appendChild(i),this.options.zoomAnimation&&(this._pathRoot.className="leaflet-zoom-animated",this.on("zoomanim",this._animatePathZoom),this.on("zoomend",this._endPathZoom)),this.on("moveend",this._updateCanvasViewport),this._updateCanvasViewport())},_updateCanvasViewport:function(){if(!this._pathZooming){this._updatePathViewport();var t=this._pathViewport,e=t.min,i=t.max.subtract(e),n=this._pathRoot;o.DomUtil.setPosition(n,e),n.width=i.x,n.height=i.y,n.getContext("2d").translate(-e.x,-e.y)}}}),o.LineUtil={simplify:function(t,e){if(!e||!t.length)return t.slice();var i=e*e;return t=this._reducePoints(t,i),t=this._simplifyDP(t,i)},pointToSegmentDistance:function(t,e,i){return Math.sqrt(this._sqClosestPointOnSegment(t,e,i,!0))},closestPointOnSegment:function(t,e,i){return this._sqClosestPointOnSegment(t,e,i)},_simplifyDP:function(t,e){var n=t.length,o=typeof Uint8Array!=i+""?Uint8Array:Array,s=new o(n);s[0]=s[n-1]=1,this._simplifyDPStep(t,s,e,0,n-1);var a,r=[];for(a=0;n>a;a++)s[a]&&r.push(t[a]);return r},_simplifyDPStep:function(t,e,i,n,o){var s,a,r,h=0;for(a=n+1;o-1>=a;a++)r=this._sqClosestPointOnSegment(t[a],t[n],t[o],!0),r>h&&(s=a,h=r);h>i&&(e[s]=1,this._simplifyDPStep(t,e,i,n,s),this._simplifyDPStep(t,e,i,s,o))},_reducePoints:function(t,e){for(var i=[t[0]],n=1,o=0,s=t.length;s>n;n++)this._sqDist(t[n],t[o])>e&&(i.push(t[n]),o=n);return s-1>o&&i.push(t[s-1]),i},clipSegment:function(t,e,i,n){var o,s,a,r=n?this._lastCode:this._getBitCode(t,i),h=this._getBitCode(e,i);for(this._lastCode=h;;){if(!(r|h))return[t,e];if(r&h)return!1;o=r||h,s=this._getEdgeIntersection(t,e,o,i),a=this._getBitCode(s,i),o===r?(t=s,r=a):(e=s,h=a)}},_getEdgeIntersection:function(t,e,i,n){var s=e.x-t.x,a=e.y-t.y,r=n.min,h=n.max;return 8&i?new o.Point(t.x+s*(h.y-t.y)/a,h.y):4&i?new o.Point(t.x+s*(r.y-t.y)/a,r.y):2&i?new o.Point(h.x,t.y+a*(h.x-t.x)/s):1&i?new o.Point(r.x,t.y+a*(r.x-t.x)/s):void 0},_getBitCode:function(t,e){var i=0;return t.x<e.min.x?i|=1:t.x>e.max.x&&(i|=2),t.y<e.min.y?i|=4:t.y>e.max.y&&(i|=8),i},_sqDist:function(t,e){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n},_sqClosestPointOnSegment:function(t,e,i,n){var s,a=e.x,r=e.y,h=i.x-a,l=i.y-r,u=h*h+l*l;return u>0&&(s=((t.x-a)*h+(t.y-r)*l)/u,s>1?(a=i.x,r=i.y):s>0&&(a+=h*s,r+=l*s)),h=t.x-a,l=t.y-r,n?h*h+l*l:new o.Point(a,r)}},o.Polyline=o.Path.extend({initialize:function(t,e){o.Path.prototype.initialize.call(this,e),this._latlngs=this._convertLatLngs(t)},options:{smoothFactor:1,noClip:!1},projectLatlngs:function(){this._originalPoints=[];for(var t=0,e=this._latlngs.length;e>t;t++)this._originalPoints[t]=this._map.latLngToLayerPoint(this._latlngs[t])},getPathString:function(){for(var t=0,e=this._parts.length,i="";e>t;t++)i+=this._getPathPartStr(this._parts[t]);return i},getLatLngs:function(){return this._latlngs},setLatLngs:function(t){return this._latlngs=this._convertLatLngs(t),this.redraw()},addLatLng:function(t){return this._latlngs.push(o.latLng(t)),this.redraw()},spliceLatLngs:function(){var t=[].splice.apply(this._latlngs,arguments);return this._convertLatLngs(this._latlngs,!0),this.redraw(),t},closestLayerPoint:function(t){for(var e,i,n=1/0,s=this._parts,a=null,r=0,h=s.length;h>r;r++)for(var l=s[r],u=1,c=l.length;c>u;u++){e=l[u-1],i=l[u];var d=o.LineUtil._sqClosestPointOnSegment(t,e,i,!0);n>d&&(n=d,a=o.LineUtil._sqClosestPointOnSegment(t,e,i))}return a&&(a.distance=Math.sqrt(n)),a},getBounds:function(){return new o.LatLngBounds(this.getLatLngs())},_convertLatLngs:function(t,e){var i,n,s=e?t:[];for(i=0,n=t.length;n>i;i++){if(o.Util.isArray(t[i])&&"number"!=typeof t[i][0])return;s[i]=o.latLng(t[i])}return s},_initEvents:function(){o.Path.prototype._initEvents.call(this)},_getPathPartStr:function(t){for(var e,i=o.Path.VML,n=0,s=t.length,a="";s>n;n++)e=t[n],i&&e._round(),a+=(n?"L":"M")+e.x+" "+e.y;return a},_clipPoints:function(){var t,e,i,n=this._originalPoints,s=n.length;if(this.options.noClip)return void(this._parts=[n]);this._parts=[];var a=this._parts,r=this._map._pathViewport,h=o.LineUtil;for(t=0,e=0;s-1>t;t++)i=h.clipSegment(n[t],n[t+1],r,t),i&&(a[e]=a[e]||[],a[e].push(i[0]),(i[1]!==n[t+1]||t===s-2)&&(a[e].push(i[1]),e++))},_simplifyPoints:function(){for(var t=this._parts,e=o.LineUtil,i=0,n=t.length;n>i;i++)t[i]=e.simplify(t[i],this.options.smoothFactor)},_updatePath:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),o.Path.prototype._updatePath.call(this))}}),o.polyline=function(t,e){return new o.Polyline(t,e)},o.PolyUtil={},o.PolyUtil.clipPolygon=function(t,e){var i,n,s,a,r,h,l,u,c,d=[1,4,2,8],p=o.LineUtil;for(n=0,l=t.length;l>n;n++)t[n]._code=p._getBitCode(t[n],e);for(a=0;4>a;a++){for(u=d[a],i=[],n=0,l=t.length,s=l-1;l>n;s=n++)r=t[n],h=t[s],r._code&u?h._code&u||(c=p._getEdgeIntersection(h,r,u,e),c._code=p._getBitCode(c,e),i.push(c)):(h._code&u&&(c=p._getEdgeIntersection(h,r,u,e),c._code=p._getBitCode(c,e),i.push(c)),i.push(r));t=i}return t},o.Polygon=o.Polyline.extend({options:{fill:!0},initialize:function(t,e){o.Polyline.prototype.initialize.call(this,t,e),this._initWithHoles(t)},_initWithHoles:function(t){var e,i,n;if(t&&o.Util.isArray(t[0])&&"number"!=typeof t[0][0])for(this._latlngs=this._convertLatLngs(t[0]),this._holes=t.slice(1),e=0,i=this._holes.length;i>e;e++)n=this._holes[e]=this._convertLatLngs(this._holes[e]),n[0].equals(n[n.length-1])&&n.pop();t=this._latlngs,t.length>=2&&t[0].equals(t[t.length-1])&&t.pop()},projectLatlngs:function(){if(o.Polyline.prototype.projectLatlngs.call(this),this._holePoints=[],this._holes){var t,e,i,n;for(t=0,i=this._holes.length;i>t;t++)for(this._holePoints[t]=[],e=0,n=this._holes[t].length;n>e;e++)this._holePoints[t][e]=this._map.latLngToLayerPoint(this._holes[t][e])}},setLatLngs:function(t){return t&&o.Util.isArray(t[0])&&"number"!=typeof t[0][0]?(this._initWithHoles(t),this.redraw()):o.Polyline.prototype.setLatLngs.call(this,t)},_clipPoints:function(){var t=this._originalPoints,e=[];if(this._parts=[t].concat(this._holePoints),!this.options.noClip){for(var i=0,n=this._parts.length;n>i;i++){var s=o.PolyUtil.clipPolygon(this._parts[i],this._map._pathViewport);s.length&&e.push(s)}this._parts=e}},_getPathPartStr:function(t){var e=o.Polyline.prototype._getPathPartStr.call(this,t);return e+(o.Browser.svg?"z":"x")}}),o.polygon=function(t,e){return new o.Polygon(t,e)},function(){function t(t){return o.FeatureGroup.extend({initialize:function(t,e){this._layers={},this._options=e,this.setLatLngs(t)},setLatLngs:function(e){var i=0,n=e.length;for(this.eachLayer(function(t){n>i?t.setLatLngs(e[i++]):this.removeLayer(t)},this);n>i;)this.addLayer(new t(e[i++],this._options));return this},getLatLngs:function(){var t=[];return this.eachLayer(function(e){t.push(e.getLatLngs())}),t}})}o.MultiPolyline=t(o.Polyline),o.MultiPolygon=t(o.Polygon),o.multiPolyline=function(t,e){return new o.MultiPolyline(t,e)},o.multiPolygon=function(t,e){return new o.MultiPolygon(t,e)}}(),o.Rectangle=o.Polygon.extend({initialize:function(t,e){o.Polygon.prototype.initialize.call(this,this._boundsToLatLngs(t),e)},setBounds:function(t){this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return t=o.latLngBounds(t),[t.getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}}),o.rectangle=function(t,e){return new o.Rectangle(t,e)},o.Circle=o.Path.extend({initialize:function(t,e,i){o.Path.prototype.initialize.call(this,i),this._latlng=o.latLng(t),this._mRadius=e},options:{fill:!0},setLatLng:function(t){return this._latlng=o.latLng(t),this.redraw()},setRadius:function(t){return this._mRadius=t,this.redraw()},projectLatlngs:function(){var t=this._getLngRadius(),e=this._latlng,i=this._map.latLngToLayerPoint([e.lat,e.lng-t]);this._point=this._map.latLngToLayerPoint(e),this._radius=Math.max(this._point.x-i.x,1)},getBounds:function(){var t=this._getLngRadius(),e=this._mRadius/40075017*360,i=this._latlng;return new o.LatLngBounds([i.lat-e,i.lng-t],[i.lat+e,i.lng+t])},getLatLng:function(){return this._latlng},getPathString:function(){var t=this._point,e=this._radius;return this._checkIfEmpty()?"":o.Browser.svg?"M"+t.x+","+(t.y-e)+"A"+e+","+e+",0,1,1,"+(t.x-.1)+","+(t.y-e)+" z":(t._round(),e=Math.round(e),"AL "+t.x+","+t.y+" "+e+","+e+" 0,23592600")},getRadius:function(){return this._mRadius},_getLatRadius:function(){return this._mRadius/40075017*360},_getLngRadius:function(){return this._getLatRadius()/Math.cos(o.LatLng.DEG_TO_RAD*this._latlng.lat)},_checkIfEmpty:function(){if(!this._map)return!1;var t=this._map._pathViewport,e=this._radius,i=this._point;return i.x-e>t.max.x||i.y-e>t.max.y||i.x+e<t.min.x||i.y+e<t.min.y}}),o.circle=function(t,e,i){return new o.Circle(t,e,i)},o.CircleMarker=o.Circle.extend({options:{radius:10,weight:2},initialize:function(t,e){o.Circle.prototype.initialize.call(this,t,null,e),this._radius=this.options.radius},projectLatlngs:function(){this._point=this._map.latLngToLayerPoint(this._latlng)},_updateStyle:function(){o.Circle.prototype._updateStyle.call(this),this.setRadius(this.options.radius)},setLatLng:function(t){return o.Circle.prototype.setLatLng.call(this,t),this._popup&&this._popup._isOpen&&this._popup.setLatLng(t),this},setRadius:function(t){return this.options.radius=this._radius=t,this.redraw()},getRadius:function(){return this._radius}}),o.circleMarker=function(t,e){return new o.CircleMarker(t,e)},o.Polyline.include(o.Path.CANVAS?{_containsPoint:function(t,e){var i,n,s,a,r,h,l,u=this.options.weight/2;for(o.Browser.touch&&(u+=10),i=0,a=this._parts.length;a>i;i++)for(l=this._parts[i],n=0,r=l.length,s=r-1;r>n;s=n++)if((e||0!==n)&&(h=o.LineUtil.pointToSegmentDistance(t,l[s],l[n]),u>=h))return!0;return!1}}:{}),o.Polygon.include(o.Path.CANVAS?{_containsPoint:function(t){var e,i,n,s,a,r,h,l,u=!1;if(o.Polyline.prototype._containsPoint.call(this,t,!0))return!0;for(s=0,h=this._parts.length;h>s;s++)for(e=this._parts[s],a=0,l=e.length,r=l-1;l>a;r=a++)i=e[a],n=e[r],i.y>t.y!=n.y>t.y&&t.x<(n.x-i.x)*(t.y-i.y)/(n.y-i.y)+i.x&&(u=!u);return u}}:{}),o.Circle.include(o.Path.CANVAS?{_drawPath:function(){var t=this._point;this._ctx.beginPath(),this._ctx.arc(t.x,t.y,this._radius,0,2*Math.PI,!1)},_containsPoint:function(t){var e=this._point,i=this.options.stroke?this.options.weight/2:0;return t.distanceTo(e)<=this._radius+i}}:{}),o.CircleMarker.include(o.Path.CANVAS?{_updateStyle:function(){o.Path.prototype._updateStyle.call(this)}}:{}),o.GeoJSON=o.FeatureGroup.extend({initialize:function(t,e){o.setOptions(this,e),this._layers={},t&&this.addData(t)},addData:function(t){var e,i,n,s=o.Util.isArray(t)?t:t.features;if(s){for(e=0,i=s.length;i>e;e++)n=s[e],(n.geometries||n.geometry||n.features||n.coordinates)&&this.addData(s[e]);return this}var a=this.options;if(!a.filter||a.filter(t)){var r=o.GeoJSON.geometryToLayer(t,a.pointToLayer,a.coordsToLatLng,a);return r.feature=o.GeoJSON.asFeature(t),r.defaultOptions=r.options,this.resetStyle(r),a.onEachFeature&&a.onEachFeature(t,r),this.addLayer(r)}},resetStyle:function(t){var e=this.options.style;e&&(o.Util.extend(t.options,t.defaultOptions),this._setLayerStyle(t,e))},setStyle:function(t){this.eachLayer(function(e){this._setLayerStyle(e,t)},this)},_setLayerStyle:function(t,e){"function"==typeof e&&(e=e(t.feature)),t.setStyle&&t.setStyle(e)}}),o.extend(o.GeoJSON,{geometryToLayer:function(t,e,i,n){var s,a,r,h,l="Feature"===t.type?t.geometry:t,u=l.coordinates,c=[];switch(i=i||this.coordsToLatLng,l.type){case"Point":return s=i(u),e?e(t,s):new o.Marker(s);case"MultiPoint":for(r=0,h=u.length;h>r;r++)s=i(u[r]),c.push(e?e(t,s):new o.Marker(s));return new o.FeatureGroup(c);case"LineString":return a=this.coordsToLatLngs(u,0,i),new o.Polyline(a,n);case"Polygon":if(2===u.length&&!u[1].length)throw new Error("Invalid GeoJSON object.");return a=this.coordsToLatLngs(u,1,i),new o.Polygon(a,n);case"MultiLineString":return a=this.coordsToLatLngs(u,1,i),new o.MultiPolyline(a,n);case"MultiPolygon":return a=this.coordsToLatLngs(u,2,i),new o.MultiPolygon(a,n);case"GeometryCollection":for(r=0,h=l.geometries.length;h>r;r++)c.push(this.geometryToLayer({geometry:l.geometries[r],type:"Feature",properties:t.properties},e,i,n));return new o.FeatureGroup(c);default:throw new Error("Invalid GeoJSON object.")}},coordsToLatLng:function(t){return new o.LatLng(t[1],t[0],t[2])},coordsToLatLngs:function(t,e,i){var n,o,s,a=[];for(o=0,s=t.length;s>o;o++)n=e?this.coordsToLatLngs(t[o],e-1,i):(i||this.coordsToLatLng)(t[o]),a.push(n);return a},latLngToCoords:function(t){var e=[t.lng,t.lat];return t.alt!==i&&e.push(t.alt),e},latLngsToCoords:function(t){for(var e=[],i=0,n=t.length;n>i;i++)e.push(o.GeoJSON.latLngToCoords(t[i]));return e},getFeature:function(t,e){return t.feature?o.extend({},t.feature,{geometry:e}):o.GeoJSON.asFeature(e)},asFeature:function(t){return"Feature"===t.type?t:{type:"Feature",properties:{},geometry:t}}});var a={toGeoJSON:function(){return o.GeoJSON.getFeature(this,{type:"Point",coordinates:o.GeoJSON.latLngToCoords(this.getLatLng())})}};o.Marker.include(a),o.Circle.include(a),o.CircleMarker.include(a),o.Polyline.include({toGeoJSON:function(){return o.GeoJSON.getFeature(this,{type:"LineString",coordinates:o.GeoJSON.latLngsToCoords(this.getLatLngs())})}}),o.Polygon.include({toGeoJSON:function(){var t,e,i,n=[o.GeoJSON.latLngsToCoords(this.getLatLngs())];if(n[0].push(n[0][0]),this._holes)for(t=0,e=this._holes.length;e>t;t++)i=o.GeoJSON.latLngsToCoords(this._holes[t]),i.push(i[0]),n.push(i);return o.GeoJSON.getFeature(this,{type:"Polygon",coordinates:n})}}),function(){function t(t){return function(){var e=[];return this.eachLayer(function(t){e.push(t.toGeoJSON().geometry.coordinates)}),o.GeoJSON.getFeature(this,{type:t,coordinates:e})}}o.MultiPolyline.include({toGeoJSON:t("MultiLineString")}),o.MultiPolygon.include({toGeoJSON:t("MultiPolygon")}),o.LayerGroup.include({toGeoJSON:function(){var e,i=this.feature&&this.feature.geometry,n=[];if(i&&"MultiPoint"===i.type)return t("MultiPoint").call(this);var s=i&&"GeometryCollection"===i.type;return this.eachLayer(function(t){t.toGeoJSON&&(e=t.toGeoJSON(),n.push(s?e.geometry:o.GeoJSON.asFeature(e)))}),s?o.GeoJSON.getFeature(this,{geometries:n,type:"GeometryCollection"}):{type:"FeatureCollection",features:n}}})}(),o.geoJson=function(t,e){return new o.GeoJSON(t,e)},o.DomEvent={addListener:function(t,e,i,n){var s,a,r,h=o.stamp(i),l="_leaflet_"+e+h;return t[l]?this:(s=function(e){return i.call(n||t,e||o.DomEvent._getEvent())},o.Browser.pointer&&0===e.indexOf("touch")?this.addPointerListener(t,e,s,h):(o.Browser.touch&&"dblclick"===e&&this.addDoubleTapListener&&this.addDoubleTapListener(t,s,h),"addEventListener"in t?"mousewheel"===e?(t.addEventListener("DOMMouseScroll",s,!1),t.addEventListener(e,s,!1)):"mouseenter"===e||"mouseleave"===e?(a=s,r="mouseenter"===e?"mouseover":"mouseout",s=function(e){return o.DomEvent._checkMouse(t,e)?a(e):void 0},t.addEventListener(r,s,!1)):"click"===e&&o.Browser.android?(a=s,s=function(t){return o.DomEvent._filterClick(t,a)},t.addEventListener(e,s,!1)):t.addEventListener(e,s,!1):"attachEvent"in t&&t.attachEvent("on"+e,s),t[l]=s,this))},removeListener:function(t,e,i){var n=o.stamp(i),s="_leaflet_"+e+n,a=t[s];return a?(o.Browser.pointer&&0===e.indexOf("touch")?this.removePointerListener(t,e,n):o.Browser.touch&&"dblclick"===e&&this.removeDoubleTapListener?this.removeDoubleTapListener(t,n):"removeEventListener"in t?"mousewheel"===e?(t.removeEventListener("DOMMouseScroll",a,!1),t.removeEventListener(e,a,!1)):"mouseenter"===e||"mouseleave"===e?t.removeEventListener("mouseenter"===e?"mouseover":"mouseout",a,!1):t.removeEventListener(e,a,!1):"detachEvent"in t&&t.detachEvent("on"+e,a),t[s]=null,this):this},stopPropagation:function(t){return t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,o.DomEvent._skipped(t),this},disableScrollPropagation:function(t){var e=o.DomEvent.stopPropagation;return o.DomEvent.on(t,"mousewheel",e).on(t,"MozMousePixelScroll",e)},disableClickPropagation:function(t){for(var e=o.DomEvent.stopPropagation,i=o.Draggable.START.length-1;i>=0;i--)o.DomEvent.on(t,o.Draggable.START[i],e);return o.DomEvent.on(t,"click",o.DomEvent._fakeStop).on(t,"dblclick",e)},preventDefault:function(t){return t.preventDefault?t.preventDefault():t.returnValue=!1,this},stop:function(t){return o.DomEvent.preventDefault(t).stopPropagation(t)},getMousePosition:function(t,e){if(!e)return new o.Point(t.clientX,t.clientY);var i=e.getBoundingClientRect();return new o.Point(t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop)},getWheelDelta:function(t){var e=0;return t.wheelDelta&&(e=t.wheelDelta/120),t.detail&&(e=-t.detail/3),e},_skipEvents:{},_fakeStop:function(t){o.DomEvent._skipEvents[t.type]=!0},_skipped:function(t){var e=this._skipEvents[t.type];return this._skipEvents[t.type]=!1,e},_checkMouse:function(t,e){var i=e.relatedTarget;if(!i)return!0;try{for(;i&&i!==t;)i=i.parentNode}catch(n){return!1}return i!==t},_getEvent:function(){var e=t.event;if(!e)for(var i=arguments.callee.caller;i&&(e=i.arguments[0],!e||t.Event!==e.constructor);)i=i.caller;return e},_filterClick:function(t,e){var i=t.timeStamp||t.originalEvent.timeStamp,n=o.DomEvent._lastClick&&i-o.DomEvent._lastClick;return n&&n>100&&500>n||t.target._simulatedClick&&!t._simulated?void o.DomEvent.stop(t):(o.DomEvent._lastClick=i,e(t))}},o.DomEvent.on=o.DomEvent.addListener,o.DomEvent.off=o.DomEvent.removeListener,o.Draggable=o.Class.extend({includes:o.Mixin.Events,statics:{START:o.Browser.touch?["touchstart","mousedown"]:["mousedown"],END:{mousedown:"mouseup",touchstart:"touchend",pointerdown:"touchend",MSPointerDown:"touchend"},MOVE:{mousedown:"mousemove",touchstart:"touchmove",pointerdown:"touchmove",MSPointerDown:"touchmove"}},initialize:function(t,e){this._element=t,this._dragStartTarget=e||t},enable:function(){if(!this._enabled){for(var t=o.Draggable.START.length-1;t>=0;t--)o.DomEvent.on(this._dragStartTarget,o.Draggable.START[t],this._onDown,this);this._enabled=!0}},disable:function(){if(this._enabled){for(var t=o.Draggable.START.length-1;t>=0;t--)o.DomEvent.off(this._dragStartTarget,o.Draggable.START[t],this._onDown,this);this._enabled=!1,this._moved=!1}},_onDown:function(t){if(this._moved=!1,!t.shiftKey&&(1===t.which||1===t.button||t.touches)&&(o.DomEvent.stopPropagation(t),!o.Draggable._disabled&&(o.DomUtil.disableImageDrag(),o.DomUtil.disableTextSelection(),!this._moving))){var i=t.touches?t.touches[0]:t;this._startPoint=new o.Point(i.clientX,i.clientY),this._startPos=this._newPos=o.DomUtil.getPosition(this._element),o.DomEvent.on(e,o.Draggable.MOVE[t.type],this._onMove,this).on(e,o.Draggable.END[t.type],this._onUp,this)}},_onMove:function(t){if(t.touches&&t.touches.length>1)return void(this._moved=!0);var i=t.touches&&1===t.touches.length?t.touches[0]:t,n=new o.Point(i.clientX,i.clientY),s=n.subtract(this._startPoint);(s.x||s.y)&&(o.Browser.touch&&Math.abs(s.x)+Math.abs(s.y)<3||(o.DomEvent.preventDefault(t),this._moved||(this.fire("dragstart"),this._moved=!0,this._startPos=o.DomUtil.getPosition(this._element).subtract(s),o.DomUtil.addClass(e.body,"leaflet-dragging"),this._lastTarget=t.target||t.srcElement,o.DomUtil.addClass(this._lastTarget,"leaflet-drag-target")),this._newPos=this._startPos.add(s),this._moving=!0,o.Util.cancelAnimFrame(this._animRequest),this._animRequest=o.Util.requestAnimFrame(this._updatePosition,this,!0,this._dragStartTarget)))},_updatePosition:function(){this.fire("predrag"),o.DomUtil.setPosition(this._element,this._newPos),this.fire("drag")},_onUp:function(){o.DomUtil.removeClass(e.body,"leaflet-dragging"),this._lastTarget&&(o.DomUtil.removeClass(this._lastTarget,"leaflet-drag-target"),this._lastTarget=null);for(var t in o.Draggable.MOVE)o.DomEvent.off(e,o.Draggable.MOVE[t],this._onMove).off(e,o.Draggable.END[t],this._onUp);o.DomUtil.enableImageDrag(),o.DomUtil.enableTextSelection(),this._moved&&this._moving&&(o.Util.cancelAnimFrame(this._animRequest),this.fire("dragend",{distance:this._newPos.distanceTo(this._startPos)})),this._moving=!1}}),o.Handler=o.Class.extend({initialize:function(t){this._map=t},enable:function(){this._enabled||(this._enabled=!0,this.addHooks())},disable:function(){this._enabled&&(this._enabled=!1,this.removeHooks())},enabled:function(){return!!this._enabled}}),o.Map.mergeOptions({dragging:!0,inertia:!o.Browser.android23,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,inertiaThreshold:o.Browser.touch?32:18,easeLinearity:.25,worldCopyJump:!1}),o.Map.Drag=o.Handler.extend({addHooks:function(){if(!this._draggable){var t=this._map;this._draggable=new o.Draggable(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDrag,this),t.on("viewreset",this._onViewReset,this),t.whenReady(this._onViewReset,this))}this._draggable.enable()},removeHooks:function(){this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},_onDragStart:function(){var t=this._map;t._panAnim&&t._panAnim.stop(),t.fire("movestart").fire("dragstart"),t.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(){if(this._map.options.inertia){var t=this._lastTime=+new Date,e=this._lastPos=this._draggable._newPos;this._positions.push(e),this._times.push(t),t-this._times[0]>200&&(this._positions.shift(),this._times.shift())}this._map.fire("move").fire("drag")},_onViewReset:function(){var t=this._map.getSize()._divideBy(2),e=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=e.subtract(t).x,this._worldWidth=this._map.project([0,180]).x},_onPreDrag:function(){var t=this._worldWidth,e=Math.round(t/2),i=this._initialWorldOffset,n=this._draggable._newPos.x,o=(n-e+i)%t+e-i,s=(n+e+i)%t-e-i,a=Math.abs(o+i)<Math.abs(s+i)?o:s;this._draggable._newPos.x=a},_onDragEnd:function(t){var e=this._map,i=e.options,n=+new Date-this._lastTime,s=!i.inertia||n>i.inertiaThreshold||!this._positions[0];if(e.fire("dragend",t),s)e.fire("moveend");else{var a=this._lastPos.subtract(this._positions[0]),r=(this._lastTime+n-this._times[0])/1e3,h=i.easeLinearity,l=a.multiplyBy(h/r),u=l.distanceTo([0,0]),c=Math.min(i.inertiaMaxSpeed,u),d=l.multiplyBy(c/u),p=c/(i.inertiaDeceleration*h),_=d.multiplyBy(-p/2).round();_.x&&_.y?(_=e._limitOffset(_,e.options.maxBounds),o.Util.requestAnimFrame(function(){e.panBy(_,{duration:p,easeLinearity:h,noMoveStart:!0})})):e.fire("moveend")}}}),o.Map.addInitHook("addHandler","dragging",o.Map.Drag),o.Map.mergeOptions({doubleClickZoom:!0}),o.Map.DoubleClickZoom=o.Handler.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(t){var e=this._map,i=e.getZoom()+(t.originalEvent.shiftKey?-1:1);"center"===e.options.doubleClickZoom?e.setZoom(i):e.setZoomAround(t.containerPoint,i)}}),o.Map.addInitHook("addHandler","doubleClickZoom",o.Map.DoubleClickZoom),o.Map.mergeOptions({scrollWheelZoom:!0}),o.Map.ScrollWheelZoom=o.Handler.extend({addHooks:function(){o.DomEvent.on(this._map._container,"mousewheel",this._onWheelScroll,this),o.DomEvent.on(this._map._container,"MozMousePixelScroll",o.DomEvent.preventDefault),this._delta=0},removeHooks:function(){o.DomEvent.off(this._map._container,"mousewheel",this._onWheelScroll),o.DomEvent.off(this._map._container,"MozMousePixelScroll",o.DomEvent.preventDefault)},_onWheelScroll:function(t){var e=o.DomEvent.getWheelDelta(t);this._delta+=e,this._lastMousePos=this._map.mouseEventToContainerPoint(t),this._startTime||(this._startTime=+new Date);var i=Math.max(40-(+new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(o.bind(this._performZoom,this),i),o.DomEvent.preventDefault(t),o.DomEvent.stopPropagation(t)},_performZoom:function(){var t=this._map,e=this._delta,i=t.getZoom();e=e>0?Math.ceil(e):Math.floor(e),e=Math.max(Math.min(e,4),-4),e=t._limitZoom(i+e)-i,this._delta=0,this._startTime=null,e&&("center"===t.options.scrollWheelZoom?t.setZoom(i+e):t.setZoomAround(this._lastMousePos,i+e))}}),o.Map.addInitHook("addHandler","scrollWheelZoom",o.Map.ScrollWheelZoom),o.extend(o.DomEvent,{_touchstart:o.Browser.msPointer?"MSPointerDown":o.Browser.pointer?"pointerdown":"touchstart",_touchend:o.Browser.msPointer?"MSPointerUp":o.Browser.pointer?"pointerup":"touchend",addDoubleTapListener:function(t,i,n){function s(t){var e;if(o.Browser.pointer?(_.push(t.pointerId),e=_.length):e=t.touches.length,!(e>1)){var i=Date.now(),n=i-(r||i);h=t.touches?t.touches[0]:t,l=n>0&&u>=n,r=i}}function a(t){if(o.Browser.pointer){var e=_.indexOf(t.pointerId);if(-1===e)return;_.splice(e,1)}if(l){if(o.Browser.pointer){var n,s={};for(var a in h)n=h[a],"function"==typeof n?s[a]=n.bind(h):s[a]=n;h=s}h.type="dblclick",i(h),r=null}}var r,h,l=!1,u=250,c="_leaflet_",d=this._touchstart,p=this._touchend,_=[];t[c+d+n]=s,t[c+p+n]=a;var m=o.Browser.pointer?e.documentElement:t;return t.addEventListener(d,s,!1),m.addEventListener(p,a,!1),o.Browser.pointer&&m.addEventListener(o.DomEvent.POINTER_CANCEL,a,!1),this},removeDoubleTapListener:function(t,i){var n="_leaflet_";return t.removeEventListener(this._touchstart,t[n+this._touchstart+i],!1),(o.Browser.pointer?e.documentElement:t).removeEventListener(this._touchend,t[n+this._touchend+i],!1),o.Browser.pointer&&e.documentElement.removeEventListener(o.DomEvent.POINTER_CANCEL,t[n+this._touchend+i],!1),this}}),o.extend(o.DomEvent,{POINTER_DOWN:o.Browser.msPointer?"MSPointerDown":"pointerdown",POINTER_MOVE:o.Browser.msPointer?"MSPointerMove":"pointermove",POINTER_UP:o.Browser.msPointer?"MSPointerUp":"pointerup",POINTER_CANCEL:o.Browser.msPointer?"MSPointerCancel":"pointercancel",_pointers:[],_pointerDocumentListener:!1,addPointerListener:function(t,e,i,n){switch(e){case"touchstart":return this.addPointerListenerStart(t,e,i,n);
-case"touchend":return this.addPointerListenerEnd(t,e,i,n);case"touchmove":return this.addPointerListenerMove(t,e,i,n);default:throw"Unknown touch event type"}},addPointerListenerStart:function(t,i,n,s){var a="_leaflet_",r=this._pointers,h=function(t){"mouse"!==t.pointerType&&t.pointerType!==t.MSPOINTER_TYPE_MOUSE&&o.DomEvent.preventDefault(t);for(var e=!1,i=0;i<r.length;i++)if(r[i].pointerId===t.pointerId){e=!0;break}e||r.push(t),t.touches=r.slice(),t.changedTouches=[t],n(t)};if(t[a+"touchstart"+s]=h,t.addEventListener(this.POINTER_DOWN,h,!1),!this._pointerDocumentListener){var l=function(t){for(var e=0;e<r.length;e++)if(r[e].pointerId===t.pointerId){r.splice(e,1);break}};e.documentElement.addEventListener(this.POINTER_UP,l,!1),e.documentElement.addEventListener(this.POINTER_CANCEL,l,!1),this._pointerDocumentListener=!0}return this},addPointerListenerMove:function(t,e,i,n){function o(t){if(t.pointerType!==t.MSPOINTER_TYPE_MOUSE&&"mouse"!==t.pointerType||0!==t.buttons){for(var e=0;e<a.length;e++)if(a[e].pointerId===t.pointerId){a[e]=t;break}t.touches=a.slice(),t.changedTouches=[t],i(t)}}var s="_leaflet_",a=this._pointers;return t[s+"touchmove"+n]=o,t.addEventListener(this.POINTER_MOVE,o,!1),this},addPointerListenerEnd:function(t,e,i,n){var o="_leaflet_",s=this._pointers,a=function(t){for(var e=0;e<s.length;e++)if(s[e].pointerId===t.pointerId){s.splice(e,1);break}t.touches=s.slice(),t.changedTouches=[t],i(t)};return t[o+"touchend"+n]=a,t.addEventListener(this.POINTER_UP,a,!1),t.addEventListener(this.POINTER_CANCEL,a,!1),this},removePointerListener:function(t,e,i){var n="_leaflet_",o=t[n+e+i];switch(e){case"touchstart":t.removeEventListener(this.POINTER_DOWN,o,!1);break;case"touchmove":t.removeEventListener(this.POINTER_MOVE,o,!1);break;case"touchend":t.removeEventListener(this.POINTER_UP,o,!1),t.removeEventListener(this.POINTER_CANCEL,o,!1)}return this}}),o.Map.mergeOptions({touchZoom:o.Browser.touch&&!o.Browser.android23,bounceAtZoomLimits:!0}),o.Map.TouchZoom=o.Handler.extend({addHooks:function(){o.DomEvent.on(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){o.DomEvent.off(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(t){var i=this._map;if(t.touches&&2===t.touches.length&&!i._animatingZoom&&!this._zooming){var n=i.mouseEventToLayerPoint(t.touches[0]),s=i.mouseEventToLayerPoint(t.touches[1]),a=i._getCenterLayerPoint();this._startCenter=n.add(s)._divideBy(2),this._startDist=n.distanceTo(s),this._moved=!1,this._zooming=!0,this._centerOffset=a.subtract(this._startCenter),i._panAnim&&i._panAnim.stop(),o.DomEvent.on(e,"touchmove",this._onTouchMove,this).on(e,"touchend",this._onTouchEnd,this),o.DomEvent.preventDefault(t)}},_onTouchMove:function(t){var e=this._map;if(t.touches&&2===t.touches.length&&this._zooming){var i=e.mouseEventToLayerPoint(t.touches[0]),n=e.mouseEventToLayerPoint(t.touches[1]);this._scale=i.distanceTo(n)/this._startDist,this._delta=i._add(n)._divideBy(2)._subtract(this._startCenter),1!==this._scale&&(e.options.bounceAtZoomLimits||!(e.getZoom()===e.getMinZoom()&&this._scale<1||e.getZoom()===e.getMaxZoom()&&this._scale>1))&&(this._moved||(o.DomUtil.addClass(e._mapPane,"leaflet-touching"),e.fire("movestart").fire("zoomstart"),this._moved=!0),o.Util.cancelAnimFrame(this._animRequest),this._animRequest=o.Util.requestAnimFrame(this._updateOnMove,this,!0,this._map._container),o.DomEvent.preventDefault(t))}},_updateOnMove:function(){var t=this._map,e=this._getScaleOrigin(),i=t.layerPointToLatLng(e),n=t.getScaleZoom(this._scale);t._animateZoom(i,n,this._startCenter,this._scale,this._delta,!1,!0)},_onTouchEnd:function(){if(!this._moved||!this._zooming)return void(this._zooming=!1);var t=this._map;this._zooming=!1,o.DomUtil.removeClass(t._mapPane,"leaflet-touching"),o.Util.cancelAnimFrame(this._animRequest),o.DomEvent.off(e,"touchmove",this._onTouchMove).off(e,"touchend",this._onTouchEnd);var i=this._getScaleOrigin(),n=t.layerPointToLatLng(i),s=t.getZoom(),a=t.getScaleZoom(this._scale)-s,r=a>0?Math.ceil(a):Math.floor(a),h=t._limitZoom(s+r),l=t.getZoomScale(h)/this._scale;t._animateZoom(n,h,i,l)},_getScaleOrigin:function(){var t=this._centerOffset.subtract(this._delta).divideBy(this._scale);return this._startCenter.add(t)}}),o.Map.addInitHook("addHandler","touchZoom",o.Map.TouchZoom),o.Map.mergeOptions({tap:!0,tapTolerance:15}),o.Map.Tap=o.Handler.extend({addHooks:function(){o.DomEvent.on(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){o.DomEvent.off(this._map._container,"touchstart",this._onDown,this)},_onDown:function(t){if(t.touches){if(o.DomEvent.preventDefault(t),this._fireClick=!0,t.touches.length>1)return this._fireClick=!1,void clearTimeout(this._holdTimeout);var i=t.touches[0],n=i.target;this._startPos=this._newPos=new o.Point(i.clientX,i.clientY),n.tagName&&"a"===n.tagName.toLowerCase()&&o.DomUtil.addClass(n,"leaflet-active"),this._holdTimeout=setTimeout(o.bind(function(){this._isTapValid()&&(this._fireClick=!1,this._onUp(),this._simulateEvent("contextmenu",i))},this),1e3),o.DomEvent.on(e,"touchmove",this._onMove,this).on(e,"touchend",this._onUp,this)}},_onUp:function(t){if(clearTimeout(this._holdTimeout),o.DomEvent.off(e,"touchmove",this._onMove,this).off(e,"touchend",this._onUp,this),this._fireClick&&t&&t.changedTouches){var i=t.changedTouches[0],n=i.target;n&&n.tagName&&"a"===n.tagName.toLowerCase()&&o.DomUtil.removeClass(n,"leaflet-active"),this._isTapValid()&&this._simulateEvent("click",i)}},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_onMove:function(t){var e=t.touches[0];this._newPos=new o.Point(e.clientX,e.clientY)},_simulateEvent:function(i,n){var o=e.createEvent("MouseEvents");o._simulated=!0,n.target._simulatedClick=!0,o.initMouseEvent(i,!0,!0,t,1,n.screenX,n.screenY,n.clientX,n.clientY,!1,!1,!1,!1,0,null),n.target.dispatchEvent(o)}}),o.Browser.touch&&!o.Browser.pointer&&o.Map.addInitHook("addHandler","tap",o.Map.Tap),o.Map.mergeOptions({boxZoom:!0}),o.Map.BoxZoom=o.Handler.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._moved=!1},addHooks:function(){o.DomEvent.on(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){o.DomEvent.off(this._container,"mousedown",this._onMouseDown),this._moved=!1},moved:function(){return this._moved},_onMouseDown:function(t){return this._moved=!1,!t.shiftKey||1!==t.which&&1!==t.button?!1:(o.DomUtil.disableTextSelection(),o.DomUtil.disableImageDrag(),this._startLayerPoint=this._map.mouseEventToLayerPoint(t),void o.DomEvent.on(e,"mousemove",this._onMouseMove,this).on(e,"mouseup",this._onMouseUp,this).on(e,"keydown",this._onKeyDown,this))},_onMouseMove:function(t){this._moved||(this._box=o.DomUtil.create("div","leaflet-zoom-box",this._pane),o.DomUtil.setPosition(this._box,this._startLayerPoint),this._container.style.cursor="crosshair",this._map.fire("boxzoomstart"));var e=this._startLayerPoint,i=this._box,n=this._map.mouseEventToLayerPoint(t),s=n.subtract(e),a=new o.Point(Math.min(n.x,e.x),Math.min(n.y,e.y));o.DomUtil.setPosition(i,a),this._moved=!0,i.style.width=Math.max(0,Math.abs(s.x)-4)+"px",i.style.height=Math.max(0,Math.abs(s.y)-4)+"px"},_finish:function(){this._moved&&(this._pane.removeChild(this._box),this._container.style.cursor=""),o.DomUtil.enableTextSelection(),o.DomUtil.enableImageDrag(),o.DomEvent.off(e,"mousemove",this._onMouseMove).off(e,"mouseup",this._onMouseUp).off(e,"keydown",this._onKeyDown)},_onMouseUp:function(t){this._finish();var e=this._map,i=e.mouseEventToLayerPoint(t);if(!this._startLayerPoint.equals(i)){var n=new o.LatLngBounds(e.layerPointToLatLng(this._startLayerPoint),e.layerPointToLatLng(i));e.fitBounds(n),e.fire("boxzoomend",{boxZoomBounds:n})}},_onKeyDown:function(t){27===t.keyCode&&this._finish()}}),o.Map.addInitHook("addHandler","boxZoom",o.Map.BoxZoom),o.Map.mergeOptions({keyboard:!0,keyboardPanOffset:80,keyboardZoomOffset:1}),o.Map.Keyboard=o.Handler.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,173]},initialize:function(t){this._map=t,this._setPanOffset(t.options.keyboardPanOffset),this._setZoomOffset(t.options.keyboardZoomOffset)},addHooks:function(){var t=this._map._container;-1===t.tabIndex&&(t.tabIndex="0"),o.DomEvent.on(t,"focus",this._onFocus,this).on(t,"blur",this._onBlur,this).on(t,"mousedown",this._onMouseDown,this),this._map.on("focus",this._addHooks,this).on("blur",this._removeHooks,this)},removeHooks:function(){this._removeHooks();var t=this._map._container;o.DomEvent.off(t,"focus",this._onFocus,this).off(t,"blur",this._onBlur,this).off(t,"mousedown",this._onMouseDown,this),this._map.off("focus",this._addHooks,this).off("blur",this._removeHooks,this)},_onMouseDown:function(){if(!this._focused){var i=e.body,n=e.documentElement,o=i.scrollTop||n.scrollTop,s=i.scrollLeft||n.scrollLeft;this._map._container.focus(),t.scrollTo(s,o)}},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanOffset:function(t){var e,i,n=this._panKeys={},o=this.keyCodes;for(e=0,i=o.left.length;i>e;e++)n[o.left[e]]=[-1*t,0];for(e=0,i=o.right.length;i>e;e++)n[o.right[e]]=[t,0];for(e=0,i=o.down.length;i>e;e++)n[o.down[e]]=[0,t];for(e=0,i=o.up.length;i>e;e++)n[o.up[e]]=[0,-1*t]},_setZoomOffset:function(t){var e,i,n=this._zoomKeys={},o=this.keyCodes;for(e=0,i=o.zoomIn.length;i>e;e++)n[o.zoomIn[e]]=t;for(e=0,i=o.zoomOut.length;i>e;e++)n[o.zoomOut[e]]=-t},_addHooks:function(){o.DomEvent.on(e,"keydown",this._onKeyDown,this)},_removeHooks:function(){o.DomEvent.off(e,"keydown",this._onKeyDown,this)},_onKeyDown:function(t){var e=t.keyCode,i=this._map;if(e in this._panKeys){if(i._panAnim&&i._panAnim._inProgress)return;i.panBy(this._panKeys[e]),i.options.maxBounds&&i.panInsideBounds(i.options.maxBounds)}else{if(!(e in this._zoomKeys))return;i.setZoom(i.getZoom()+this._zoomKeys[e])}o.DomEvent.stop(t)}}),o.Map.addInitHook("addHandler","keyboard",o.Map.Keyboard),o.Handler.MarkerDrag=o.Handler.extend({initialize:function(t){this._marker=t},addHooks:function(){var t=this._marker._icon;this._draggable||(this._draggable=new o.Draggable(t,t)),this._draggable.on("dragstart",this._onDragStart,this).on("drag",this._onDrag,this).on("dragend",this._onDragEnd,this),this._draggable.enable(),o.DomUtil.addClass(this._marker._icon,"leaflet-marker-draggable")},removeHooks:function(){this._draggable.off("dragstart",this._onDragStart,this).off("drag",this._onDrag,this).off("dragend",this._onDragEnd,this),this._draggable.disable(),o.DomUtil.removeClass(this._marker._icon,"leaflet-marker-draggable")},moved:function(){return this._draggable&&this._draggable._moved},_onDragStart:function(){this._marker.closePopup().fire("movestart").fire("dragstart")},_onDrag:function(){var t=this._marker,e=t._shadow,i=o.DomUtil.getPosition(t._icon),n=t._map.layerPointToLatLng(i);e&&o.DomUtil.setPosition(e,i),t._latlng=n,t.fire("move",{latlng:n}).fire("drag")},_onDragEnd:function(t){this._marker.fire("moveend").fire("dragend",t)}}),o.Control=o.Class.extend({options:{position:"topright"},initialize:function(t){o.setOptions(this,t)},getPosition:function(){return this.options.position},setPosition:function(t){var e=this._map;return e&&e.removeControl(this),this.options.position=t,e&&e.addControl(this),this},getContainer:function(){return this._container},addTo:function(t){this._map=t;var e=this._container=this.onAdd(t),i=this.getPosition(),n=t._controlCorners[i];return o.DomUtil.addClass(e,"leaflet-control"),-1!==i.indexOf("bottom")?n.insertBefore(e,n.firstChild):n.appendChild(e),this},removeFrom:function(t){var e=this.getPosition(),i=t._controlCorners[e];return i.removeChild(this._container),this._map=null,this.onRemove&&this.onRemove(t),this},_refocusOnMap:function(){this._map&&this._map.getContainer().focus()}}),o.control=function(t){return new o.Control(t)},o.Map.include({addControl:function(t){return t.addTo(this),this},removeControl:function(t){return t.removeFrom(this),this},_initControlPos:function(){function t(t,s){var a=i+t+" "+i+s;e[t+s]=o.DomUtil.create("div",a,n)}var e=this._controlCorners={},i="leaflet-",n=this._controlContainer=o.DomUtil.create("div",i+"control-container",this._container);t("top","left"),t("top","right"),t("bottom","left"),t("bottom","right")},_clearControlPos:function(){this._container.removeChild(this._controlContainer)}}),o.Control.Zoom=o.Control.extend({options:{position:"topleft",zoomInText:"+",zoomInTitle:"Zoom in",zoomOutText:"-",zoomOutTitle:"Zoom out"},onAdd:function(t){var e="leaflet-control-zoom",i=o.DomUtil.create("div",e+" leaflet-bar");return this._map=t,this._zoomInButton=this._createButton(this.options.zoomInText,this.options.zoomInTitle,e+"-in",i,this._zoomIn,this),this._zoomOutButton=this._createButton(this.options.zoomOutText,this.options.zoomOutTitle,e+"-out",i,this._zoomOut,this),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this),i},onRemove:function(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)},_zoomIn:function(t){this._map.zoomIn(t.shiftKey?3:1)},_zoomOut:function(t){this._map.zoomOut(t.shiftKey?3:1)},_createButton:function(t,e,i,n,s,a){var r=o.DomUtil.create("a",i,n);r.innerHTML=t,r.href="#",r.title=e;var h=o.DomEvent.stopPropagation;return o.DomEvent.on(r,"click",h).on(r,"mousedown",h).on(r,"dblclick",h).on(r,"click",o.DomEvent.preventDefault).on(r,"click",s,a).on(r,"click",this._refocusOnMap,a),r},_updateDisabled:function(){var t=this._map,e="leaflet-disabled";o.DomUtil.removeClass(this._zoomInButton,e),o.DomUtil.removeClass(this._zoomOutButton,e),t._zoom===t.getMinZoom()&&o.DomUtil.addClass(this._zoomOutButton,e),t._zoom===t.getMaxZoom()&&o.DomUtil.addClass(this._zoomInButton,e)}}),o.Map.mergeOptions({zoomControl:!0}),o.Map.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new o.Control.Zoom,this.addControl(this.zoomControl))}),o.control.zoom=function(t){return new o.Control.Zoom(t)},o.Control.Attribution=o.Control.extend({options:{position:"bottomright",prefix:'<a href="http://leafletjs.com" title="A JS library for interactive maps">Leaflet</a>'},initialize:function(t){o.setOptions(this,t),this._attributions={}},onAdd:function(t){this._container=o.DomUtil.create("div","leaflet-control-attribution"),o.DomEvent.disableClickPropagation(this._container);for(var e in t._layers)t._layers[e].getAttribution&&this.addAttribution(t._layers[e].getAttribution());return t.on("layeradd",this._onLayerAdd,this).on("layerremove",this._onLayerRemove,this),this._update(),this._container},onRemove:function(t){t.off("layeradd",this._onLayerAdd).off("layerremove",this._onLayerRemove)},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t?(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update(),this):void 0},removeAttribution:function(t){return t?(this._attributions[t]&&(this._attributions[t]--,this._update()),this):void 0},_update:function(){if(this._map){var t=[];for(var e in this._attributions)this._attributions[e]&&t.push(e);var i=[];this.options.prefix&&i.push(this.options.prefix),t.length&&i.push(t.join(", ")),this._container.innerHTML=i.join(" | ")}},_onLayerAdd:function(t){t.layer.getAttribution&&this.addAttribution(t.layer.getAttribution())},_onLayerRemove:function(t){t.layer.getAttribution&&this.removeAttribution(t.layer.getAttribution())}}),o.Map.mergeOptions({attributionControl:!0}),o.Map.addInitHook(function(){this.options.attributionControl&&(this.attributionControl=(new o.Control.Attribution).addTo(this))}),o.control.attribution=function(t){return new o.Control.Attribution(t)},o.Control.Scale=o.Control.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0,updateWhenIdle:!1},onAdd:function(t){this._map=t;var e="leaflet-control-scale",i=o.DomUtil.create("div",e),n=this.options;return this._addScales(n,e,i),t.on(n.updateWhenIdle?"moveend":"move",this._update,this),t.whenReady(this._update,this),i},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(t,e,i){t.metric&&(this._mScale=o.DomUtil.create("div",e+"-line",i)),t.imperial&&(this._iScale=o.DomUtil.create("div",e+"-line",i))},_update:function(){var t=this._map.getBounds(),e=t.getCenter().lat,i=6378137*Math.PI*Math.cos(e*Math.PI/180),n=i*(t.getNorthEast().lng-t.getSouthWest().lng)/180,o=this._map.getSize(),s=this.options,a=0;o.x>0&&(a=n*(s.maxWidth/o.x)),this._updateScales(s,a)},_updateScales:function(t,e){t.metric&&e&&this._updateMetric(e),t.imperial&&e&&this._updateImperial(e)},_updateMetric:function(t){var e=this._getRoundNum(t);this._mScale.style.width=this._getScaleWidth(e/t)+"px",this._mScale.innerHTML=1e3>e?e+" m":e/1e3+" km"},_updateImperial:function(t){var e,i,n,o=3.2808399*t,s=this._iScale;o>5280?(e=o/5280,i=this._getRoundNum(e),s.style.width=this._getScaleWidth(i/e)+"px",s.innerHTML=i+" mi"):(n=this._getRoundNum(o),s.style.width=this._getScaleWidth(n/o)+"px",s.innerHTML=n+" ft")},_getScaleWidth:function(t){return Math.round(this.options.maxWidth*t)-10},_getRoundNum:function(t){var e=Math.pow(10,(Math.floor(t)+"").length-1),i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:1,e*i}}),o.control.scale=function(t){return new o.Control.Scale(t)},o.Control.Layers=o.Control.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0},initialize:function(t,e,i){o.setOptions(this,i),this._layers={},this._lastZIndex=0,this._handlingClick=!1;for(var n in t)this._addLayer(t[n],n);for(n in e)this._addLayer(e[n],n,!0)},onAdd:function(t){return this._initLayout(),this._update(),t.on("layeradd",this._onLayerChange,this).on("layerremove",this._onLayerChange,this),this._container},onRemove:function(t){t.off("layeradd",this._onLayerChange,this).off("layerremove",this._onLayerChange,this)},addBaseLayer:function(t,e){return this._addLayer(t,e),this._update(),this},addOverlay:function(t,e){return this._addLayer(t,e,!0),this._update(),this},removeLayer:function(t){var e=o.stamp(t);return delete this._layers[e],this._update(),this},_initLayout:function(){var t="leaflet-control-layers",e=this._container=o.DomUtil.create("div",t);e.setAttribute("aria-haspopup",!0),o.Browser.touch?o.DomEvent.on(e,"click",o.DomEvent.stopPropagation):o.DomEvent.disableClickPropagation(e).disableScrollPropagation(e);var i=this._form=o.DomUtil.create("form",t+"-list");if(this.options.collapsed){o.Browser.android||o.DomEvent.on(e,"mouseover",this._expand,this).on(e,"mouseout",this._collapse,this);var n=this._layersLink=o.DomUtil.create("a",t+"-toggle",e);n.href="#",n.title="Layers",o.Browser.touch?o.DomEvent.on(n,"click",o.DomEvent.stop).on(n,"click",this._expand,this):o.DomEvent.on(n,"focus",this._expand,this),o.DomEvent.on(i,"click",function(){setTimeout(o.bind(this._onInputClick,this),0)},this),this._map.on("click",this._collapse,this)}else this._expand();this._baseLayersList=o.DomUtil.create("div",t+"-base",i),this._separator=o.DomUtil.create("div",t+"-separator",i),this._overlaysList=o.DomUtil.create("div",t+"-overlays",i),e.appendChild(i)},_addLayer:function(t,e,i){var n=o.stamp(t);this._layers[n]={layer:t,name:e,overlay:i},this.options.autoZIndex&&t.setZIndex&&(this._lastZIndex++,t.setZIndex(this._lastZIndex))},_update:function(){if(this._container){this._baseLayersList.innerHTML="",this._overlaysList.innerHTML="";var t,e,i=!1,n=!1;for(t in this._layers)e=this._layers[t],this._addItem(e),n=n||e.overlay,i=i||!e.overlay;this._separator.style.display=n&&i?"":"none"}},_onLayerChange:function(t){var e=this._layers[o.stamp(t.layer)];if(e){this._handlingClick||this._update();var i=e.overlay?"layeradd"===t.type?"overlayadd":"overlayremove":"layeradd"===t.type?"baselayerchange":null;i&&this._map.fire(i,e)}},_createRadioElement:function(t,i){var n='<input type="radio" class="leaflet-control-layers-selector" name="'+t+'"';i&&(n+=' checked="checked"'),n+="/>";var o=e.createElement("div");return o.innerHTML=n,o.firstChild},_addItem:function(t){var i,n=e.createElement("label"),s=this._map.hasLayer(t.layer);t.overlay?(i=e.createElement("input"),i.type="checkbox",i.className="leaflet-control-layers-selector",i.defaultChecked=s):i=this._createRadioElement("leaflet-base-layers",s),i.layerId=o.stamp(t.layer),o.DomEvent.on(i,"click",this._onInputClick,this);var a=e.createElement("span");a.innerHTML=" "+t.name,n.appendChild(i),n.appendChild(a);var r=t.overlay?this._overlaysList:this._baseLayersList;return r.appendChild(n),n},_onInputClick:function(){var t,e,i,n=this._form.getElementsByTagName("input"),o=n.length;for(this._handlingClick=!0,t=0;o>t;t++)e=n[t],i=this._layers[e.layerId],e.checked&&!this._map.hasLayer(i.layer)?this._map.addLayer(i.layer):!e.checked&&this._map.hasLayer(i.layer)&&this._map.removeLayer(i.layer);this._handlingClick=!1,this._refocusOnMap()},_expand:function(){o.DomUtil.addClass(this._container,"leaflet-control-layers-expanded")},_collapse:function(){this._container.className=this._container.className.replace(" leaflet-control-layers-expanded","")}}),o.control.layers=function(t,e,i){return new o.Control.Layers(t,e,i)},o.PosAnimation=o.Class.extend({includes:o.Mixin.Events,run:function(t,e,i,n){this.stop(),this._el=t,this._inProgress=!0,this._newPos=e,this.fire("start"),t.style[o.DomUtil.TRANSITION]="all "+(i||.25)+"s cubic-bezier(0,0,"+(n||.5)+",1)",o.DomEvent.on(t,o.DomUtil.TRANSITION_END,this._onTransitionEnd,this),o.DomUtil.setPosition(t,e),o.Util.falseFn(t.offsetWidth),this._stepTimer=setInterval(o.bind(this._onStep,this),50)},stop:function(){this._inProgress&&(o.DomUtil.setPosition(this._el,this._getPos()),this._onTransitionEnd(),o.Util.falseFn(this._el.offsetWidth))},_onStep:function(){var t=this._getPos();return t?(this._el._leaflet_pos=t,void this.fire("step")):void this._onTransitionEnd()},_transformRe:/([-+]?(?:\d*\.)?\d+)\D*, ([-+]?(?:\d*\.)?\d+)\D*\)/,_getPos:function(){var e,i,n,s=this._el,a=t.getComputedStyle(s);if(o.Browser.any3d){if(n=a[o.DomUtil.TRANSFORM].match(this._transformRe),!n)return;e=parseFloat(n[1]),i=parseFloat(n[2])}else e=parseFloat(a.left),i=parseFloat(a.top);return new o.Point(e,i,!0)},_onTransitionEnd:function(){o.DomEvent.off(this._el,o.DomUtil.TRANSITION_END,this._onTransitionEnd,this),this._inProgress&&(this._inProgress=!1,this._el.style[o.DomUtil.TRANSITION]="",this._el._leaflet_pos=this._newPos,clearInterval(this._stepTimer),this.fire("step").fire("end"))}}),o.Map.include({setView:function(t,e,n){if(e=e===i?this._zoom:this._limitZoom(e),t=this._limitCenter(o.latLng(t),e,this.options.maxBounds),n=n||{},this._panAnim&&this._panAnim.stop(),this._loaded&&!n.reset&&n!==!0){n.animate!==i&&(n.zoom=o.extend({animate:n.animate},n.zoom),n.pan=o.extend({animate:n.animate},n.pan));var s=this._zoom!==e?this._tryAnimatedZoom&&this._tryAnimatedZoom(t,e,n.zoom):this._tryAnimatedPan(t,n.pan);if(s)return clearTimeout(this._sizeTimer),this}return this._resetView(t,e),this},panBy:function(t,e){if(t=o.point(t).round(),e=e||{},!t.x&&!t.y)return this;if(this._panAnim||(this._panAnim=new o.PosAnimation,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),e.noMoveStart||this.fire("movestart"),e.animate!==!1){o.DomUtil.addClass(this._mapPane,"leaflet-pan-anim");var i=this._getMapPanePos().subtract(t);this._panAnim.run(this._mapPane,i,e.duration||.25,e.easeLinearity)}else this._rawPanBy(t),this.fire("move").fire("moveend");return this},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){o.DomUtil.removeClass(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(t,e){var i=this._getCenterOffset(t)._floor();return(e&&e.animate)===!0||this.getSize().contains(i)?(this.panBy(i,e),!0):!1}}),o.PosAnimation=o.DomUtil.TRANSITION?o.PosAnimation:o.PosAnimation.extend({run:function(t,e,i,n){this.stop(),this._el=t,this._inProgress=!0,this._duration=i||.25,this._easeOutPower=1/Math.max(n||.5,.2),this._startPos=o.DomUtil.getPosition(t),this._offset=e.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(),this._complete())},_animate:function(){this._animId=o.Util.requestAnimFrame(this._animate,this),this._step()},_step:function(){var t=+new Date-this._startTime,e=1e3*this._duration;e>t?this._runFrame(this._easeOut(t/e)):(this._runFrame(1),this._complete())},_runFrame:function(t){var e=this._startPos.add(this._offset.multiplyBy(t));o.DomUtil.setPosition(this._el,e),this.fire("step")},_complete:function(){o.Util.cancelAnimFrame(this._animId),this._inProgress=!1,this.fire("end")},_easeOut:function(t){return 1-Math.pow(1-t,this._easeOutPower)}}),o.Map.mergeOptions({zoomAnimation:!0,zoomAnimationThreshold:4}),o.DomUtil.TRANSITION&&o.Map.addInitHook(function(){this._zoomAnimated=this.options.zoomAnimation&&o.DomUtil.TRANSITION&&o.Browser.any3d&&!o.Browser.android23&&!o.Browser.mobileOpera,this._zoomAnimated&&o.DomEvent.on(this._mapPane,o.DomUtil.TRANSITION_END,this._catchTransitionEnd,this)}),o.Map.include(o.DomUtil.TRANSITION?{_catchTransitionEnd:function(t){this._animatingZoom&&t.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(t,e,i){if(this._animatingZoom)return!0;if(i=i||{},!this._zoomAnimated||i.animate===!1||this._nothingToAnimate()||Math.abs(e-this._zoom)>this.options.zoomAnimationThreshold)return!1;var n=this.getZoomScale(e),o=this._getCenterOffset(t)._divideBy(1-1/n),s=this._getCenterLayerPoint()._add(o);return i.animate===!0||this.getSize().contains(o)?(this.fire("movestart").fire("zoomstart"),this._animateZoom(t,e,s,n,null,!0),!0):!1},_animateZoom:function(t,e,i,n,s,a,r){r||(this._animatingZoom=!0),o.DomUtil.addClass(this._mapPane,"leaflet-zoom-anim"),this._animateToCenter=t,this._animateToZoom=e,o.Draggable&&(o.Draggable._disabled=!0),o.Util.requestAnimFrame(function(){this.fire("zoomanim",{center:t,zoom:e,origin:i,scale:n,delta:s,backwards:a}),setTimeout(o.bind(this._onZoomTransitionEnd,this),250)},this)},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._animatingZoom=!1,o.DomUtil.removeClass(this._mapPane,"leaflet-zoom-anim"),o.Util.requestAnimFrame(function(){this._resetView(this._animateToCenter,this._animateToZoom,!0,!0),o.Draggable&&(o.Draggable._disabled=!1)},this))}}:{}),o.TileLayer.include({_animateZoom:function(t){this._animating||(this._animating=!0,this._prepareBgBuffer());var e=this._bgBuffer,i=o.DomUtil.TRANSFORM,n=t.delta?o.DomUtil.getTranslateString(t.delta):e.style[i],s=o.DomUtil.getScaleString(t.scale,t.origin);e.style[i]=t.backwards?s+" "+n:n+" "+s},_endZoomAnim:function(){var t=this._tileContainer,e=this._bgBuffer;t.style.visibility="",t.parentNode.appendChild(t),o.Util.falseFn(e.offsetWidth);var i=this._map.getZoom();(i>this.options.maxZoom||i<this.options.minZoom)&&this._clearBgBuffer(),this._animating=!1},_clearBgBuffer:function(){var t=this._map;!t||t._animatingZoom||t.touchZoom._zooming||(this._bgBuffer.innerHTML="",this._bgBuffer.style[o.DomUtil.TRANSFORM]="")},_prepareBgBuffer:function(){var t=this._tileContainer,e=this._bgBuffer,i=this._getLoadedTilesPercentage(e),n=this._getLoadedTilesPercentage(t);return e&&i>.5&&.5>n?(t.style.visibility="hidden",void this._stopLoadingImages(t)):(e.style.visibility="hidden",e.style[o.DomUtil.TRANSFORM]="",this._tileContainer=e,e=this._bgBuffer=t,this._stopLoadingImages(e),void clearTimeout(this._clearBgBufferTimer))},_getLoadedTilesPercentage:function(t){var e,i,n=t.getElementsByTagName("img"),o=0;for(e=0,i=n.length;i>e;e++)n[e].complete&&o++;return o/i},_stopLoadingImages:function(t){var e,i,n,s=Array.prototype.slice.call(t.getElementsByTagName("img"));for(e=0,i=s.length;i>e;e++)n=s[e],n.complete||(n.onload=o.Util.falseFn,n.onerror=o.Util.falseFn,n.src=o.Util.emptyImageUrl,n.parentNode.removeChild(n))}}),o.Map.include({_defaultLocateOptions:{watch:!1,setView:!1,maxZoom:1/0,timeout:1e4,maximumAge:0,enableHighAccuracy:!1},locate:function(t){if(t=this._locateOptions=o.extend(this._defaultLocateOptions,t),!navigator.geolocation)return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var e=o.bind(this._handleGeolocationResponse,this),i=o.bind(this._handleGeolocationError,this);return t.watch?this._locationWatchId=navigator.geolocation.watchPosition(e,i,t):navigator.geolocation.getCurrentPosition(e,i,t),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(t){var e=t.code,i=t.message||(1===e?"permission denied":2===e?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:e,message:"Geolocation error: "+i+"."})},_handleGeolocationResponse:function(t){var e=t.coords.latitude,i=t.coords.longitude,n=new o.LatLng(e,i),s=180*t.coords.accuracy/40075017,a=s/Math.cos(o.LatLng.DEG_TO_RAD*e),r=o.latLngBounds([e-s,i-a],[e+s,i+a]),h=this._locateOptions;if(h.setView){var l=Math.min(this.getBoundsZoom(r),h.maxZoom);this.setView(n,l)}var u={latlng:n,bounds:r,timestamp:t.timestamp};for(var c in t.coords)"number"==typeof t.coords[c]&&(u[c]=t.coords[c]);this.fire("locationfound",u)}})}(window,document);
\ No newline at end of file
+!function(t,e,i){function n(){var e=t.L;o.noConflict=function(){return t.L=e,this},t.L=o}var o={version:"1.0.3+ed36a04"};"object"==typeof module&&"object"==typeof module.exports?module.exports=o:"function"==typeof define&&define.amd&&define(o),"undefined"!=typeof t&&n(),o.Util={extend:function(t){var e,i,n,o;for(i=1,n=arguments.length;i<n;i++){o=arguments[i];for(e in o)t[e]=o[e]}return t},create:Object.create||function(){function t(){}return function(e){return t.prototype=e,new t}}(),bind:function(t,e){var i=Array.prototype.slice;if(t.bind)return t.bind.apply(t,i.call(arguments,1));var n=i.call(arguments,2);return function(){return t.apply(e,n.length?n.concat(i.call(arguments)):arguments)}},stamp:function(t){return t._leaflet_id=t._leaflet_id||++o.Util.lastId,t._leaflet_id},lastId:0,throttle:function(t,e,i){var n,o,s,r;return r=function(){n=!1,o&&(s.apply(i,o),o=!1)},s=function(){n?o=arguments:(t.apply(i,arguments),setTimeout(r,e),n=!0)}},wrapNum:function(t,e,i){var n=e[1],o=e[0],s=n-o;return t===n&&i?t:((t-o)%s+s)%s+o},falseFn:function(){return!1},formatNum:function(t,e){var i=Math.pow(10,e||5);return Math.round(t*i)/i},trim:function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")},splitWords:function(t){return o.Util.trim(t).split(/\s+/)},setOptions:function(t,e){t.hasOwnProperty("options")||(t.options=t.options?o.Util.create(t.options):{});for(var i in e)t.options[i]=e[i];return t.options},getParamString:function(t,e,i){var n=[];for(var o in t)n.push(encodeURIComponent(i?o.toUpperCase():o)+"="+encodeURIComponent(t[o]));return(e&&e.indexOf("?")!==-1?"&":"?")+n.join("&")},template:function(t,e){return t.replace(o.Util.templateRe,function(t,n){var o=e[n];if(o===i)throw new Error("No value provided for variable "+t);return"function"==typeof o&&(o=o(e)),o})},templateRe:/\{ *([\w_\-]+) *\}/g,isArray:Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},indexOf:function(t,e){for(var i=0;i<t.length;i++)if(t[i]===e)return i;return-1},emptyImageUrl:"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="},function(){function e(e){return t["webkit"+e]||t["moz"+e]||t["ms"+e]}function i(e){var i=+new Date,o=Math.max(0,16-(i-n));return n=i+o,t.setTimeout(e,o)}var n=0,s=t.requestAnimationFrame||e("RequestAnimationFrame")||i,r=t.cancelAnimationFrame||e("CancelAnimationFrame")||e("CancelRequestAnimationFrame")||function(e){t.clearTimeout(e)};o.Util.requestAnimFrame=function(e,n,r){return r&&s===i?void e.call(n):s.call(t,o.bind(e,n))},o.Util.cancelAnimFrame=function(e){e&&r.call(t,e)}}(),o.extend=o.Util.extend,o.bind=o.Util.bind,o.stamp=o.Util.stamp,o.setOptions=o.Util.setOptions,o.Class=function(){},o.Class.extend=function(t){var e=function(){this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()},i=e.__super__=this.prototype,n=o.Util.create(i);n.constructor=e,e.prototype=n;for(var s in this)this.hasOwnProperty(s)&&"prototype"!==s&&(e[s]=this[s]);return t.statics&&(o.extend(e,t.statics),delete t.statics),t.includes&&(o.Util.extend.apply(null,[n].concat(t.includes)),delete t.includes),n.options&&(t.options=o.Util.extend(o.Util.create(n.options),t.options)),o.extend(n,t),n._initHooks=[],n.callInitHooks=function(){if(!this._initHooksCalled){i.callInitHooks&&i.callInitHooks.call(this),this._initHooksCalled=!0;for(var t=0,e=n._initHooks.length;t<e;t++)n._initHooks[t].call(this)}},e},o.Class.include=function(t){return o.extend(this.prototype,t),this},o.Class.mergeOptions=function(t){return o.extend(this.prototype.options,t),this},o.Class.addInitHook=function(t){var e=Array.prototype.slice.call(arguments,1),i="function"==typeof t?t:function(){this[t].apply(this,e)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(i),this},o.Evented=o.Class.extend({on:function(t,e,i){if("object"==typeof t)for(var n in t)this._on(n,t[n],e);else{t=o.Util.splitWords(t);for(var s=0,r=t.length;s<r;s++)this._on(t[s],e,i)}return this},off:function(t,e,i){if(t)if("object"==typeof t)for(var n in t)this._off(n,t[n],e);else{t=o.Util.splitWords(t);for(var s=0,r=t.length;s<r;s++)this._off(t[s],e,i)}else delete this._events;return this},_on:function(t,e,n){this._events=this._events||{};var o=this._events[t];o||(o=[],this._events[t]=o),n===this&&(n=i);for(var s={fn:e,ctx:n},r=o,a=0,h=r.length;a<h;a++)if(r[a].fn===e&&r[a].ctx===n)return;r.push(s)},_off:function(t,e,n){var s,r,a;if(this._events&&(s=this._events[t])){if(!e){for(r=0,a=s.length;r<a;r++)s[r].fn=o.Util.falseFn;return void delete this._events[t]}if(n===this&&(n=i),s)for(r=0,a=s.length;r<a;r++){var h=s[r];if(h.ctx===n&&h.fn===e)return h.fn=o.Util.falseFn,this._firingCount&&(this._events[t]=s=s.slice()),void s.splice(r,1)}}},fire:function(t,e,i){if(!this.listens(t,i))return this;var n=o.Util.extend({},e,{type:t,target:this});if(this._events){var s=this._events[t];if(s){this._firingCount=this._firingCount+1||1;for(var r=0,a=s.length;r<a;r++){var h=s[r];h.fn.call(h.ctx||this,n)}this._firingCount--}}return i&&this._propagateEvent(n),this},listens:function(t,e){var i=this._events&&this._events[t];if(i&&i.length)return!0;if(e)for(var n in this._eventParents)if(this._eventParents[n].listens(t,e))return!0;return!1},once:function(t,e,i){if("object"==typeof t){for(var n in t)this.once(n,t[n],e);return this}var s=o.bind(function(){this.off(t,e,i).off(t,s,i)},this);return this.on(t,e,i).on(t,s,i)},addEventParent:function(t){return this._eventParents=this._eventParents||{},this._eventParents[o.stamp(t)]=t,this},removeEventParent:function(t){return this._eventParents&&delete this._eventParents[o.stamp(t)],this},_propagateEvent:function(t){for(var e in this._eventParents)this._eventParents[e].fire(t.type,o.extend({layer:t.target},t),!0)}});var s=o.Evented.prototype;s.addEventListener=s.on,s.removeEventListener=s.clearAllEventListeners=s.off,s.addOneTimeEventListener=s.once,s.fireEvent=s.fire,s.hasEventListeners=s.listens,o.Mixin={Events:s},function(){var i=navigator.userAgent.toLowerCase(),n=e.documentElement,s="ActiveXObject"in t,r=i.indexOf("webkit")!==-1,a=i.indexOf("phantom")!==-1,h=i.search("android [23]")!==-1,l=i.indexOf("chrome")!==-1,u=i.indexOf("gecko")!==-1&&!r&&!t.opera&&!s,c=0===navigator.platform.indexOf("Win"),d="undefined"!=typeof orientation||i.indexOf("mobile")!==-1,_=!t.PointerEvent&&t.MSPointerEvent,m=t.PointerEvent||_,p=s&&"transition"in n.style,f="WebKitCSSMatrix"in t&&"m11"in new t.WebKitCSSMatrix&&!h,g="MozPerspective"in n.style,v="OTransition"in n.style,y=!t.L_NO_TOUCH&&(m||"ontouchstart"in t||t.DocumentTouch&&e instanceof t.DocumentTouch);o.Browser={ie:s,ielt9:s&&!e.addEventListener,edge:"msLaunchUri"in navigator&&!("documentMode"in e),webkit:r,gecko:u,android:i.indexOf("android")!==-1,android23:h,chrome:l,safari:!l&&i.indexOf("safari")!==-1,win:c,ie3d:p,webkit3d:f,gecko3d:g,opera12:v,any3d:!t.L_DISABLE_3D&&(p||f||g)&&!v&&!a,mobile:d,mobileWebkit:d&&r,mobileWebkit3d:d&&f,mobileOpera:d&&t.opera,mobileGecko:d&&u,touch:!!y,msPointer:!!_,pointer:!!m,retina:(t.devicePixelRatio||t.screen.deviceXDPI/t.screen.logicalXDPI)>1}}(),o.Point=function(t,e,i){this.x=i?Math.round(t):t,this.y=i?Math.round(e):e},o.Point.prototype={clone:function(){return new o.Point(this.x,this.y)},add:function(t){return this.clone()._add(o.point(t))},_add:function(t){return this.x+=t.x,this.y+=t.y,this},subtract:function(t){return this.clone()._subtract(o.point(t))},_subtract:function(t){return this.x-=t.x,this.y-=t.y,this},divideBy:function(t){return this.clone()._divideBy(t)},_divideBy:function(t){return this.x/=t,this.y/=t,this},multiplyBy:function(t){return this.clone()._multiplyBy(t)},_multiplyBy:function(t){return this.x*=t,this.y*=t,this},scaleBy:function(t){return new o.Point(this.x*t.x,this.y*t.y)},unscaleBy:function(t){return new o.Point(this.x/t.x,this.y/t.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},distanceTo:function(t){t=o.point(t);var e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)},equals:function(t){return t=o.point(t),t.x===this.x&&t.y===this.y},contains:function(t){return t=o.point(t),Math.abs(t.x)<=Math.abs(this.x)&&Math.abs(t.y)<=Math.abs(this.y)},toString:function(){return"Point("+o.Util.formatNum(this.x)+", "+o.Util.formatNum(this.y)+")"}},o.point=function(t,e,n){return t instanceof o.Point?t:o.Util.isArray(t)?new o.Point(t[0],t[1]):t===i||null===t?t:"object"==typeof t&&"x"in t&&"y"in t?new o.Point(t.x,t.y):new o.Point(t,e,n)},o.Bounds=function(t,e){if(t)for(var i=e?[t,e]:t,n=0,o=i.length;n<o;n++)this.extend(i[n])},o.Bounds.prototype={extend:function(t){return t=o.point(t),this.min||this.max?(this.min.x=Math.min(t.x,this.min.x),this.max.x=Math.max(t.x,this.max.x),this.min.y=Math.min(t.y,this.min.y),this.max.y=Math.max(t.y,this.max.y)):(this.min=t.clone(),this.max=t.clone()),this},getCenter:function(t){return new o.Point((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,t)},getBottomLeft:function(){return new o.Point(this.min.x,this.max.y)},getTopRight:function(){return new o.Point(this.max.x,this.min.y)},getSize:function(){return this.max.subtract(this.min)},contains:function(t){var e,i;return t="number"==typeof t[0]||t instanceof o.Point?o.point(t):o.bounds(t),t instanceof o.Bounds?(e=t.min,i=t.max):e=i=t,e.x>=this.min.x&&i.x<=this.max.x&&e.y>=this.min.y&&i.y<=this.max.y},intersects:function(t){t=o.bounds(t);var e=this.min,i=this.max,n=t.min,s=t.max,r=s.x>=e.x&&n.x<=i.x,a=s.y>=e.y&&n.y<=i.y;return r&&a},overlaps:function(t){t=o.bounds(t);var e=this.min,i=this.max,n=t.min,s=t.max,r=s.x>e.x&&n.x<i.x,a=s.y>e.y&&n.y<i.y;return r&&a},isValid:function(){return!(!this.min||!this.max)}},o.bounds=function(t,e){return!t||t instanceof o.Bounds?t:new o.Bounds(t,e)},o.Transformation=function(t,e,i,n){this._a=t,this._b=e,this._c=i,this._d=n},o.Transformation.prototype={transform:function(t,e){return this._transform(t.clone(),e)},_transform:function(t,e){return e=e||1,t.x=e*(this._a*t.x+this._b),t.y=e*(this._c*t.y+this._d),t},untransform:function(t,e){return e=e||1,new o.Point((t.x/e-this._b)/this._a,(t.y/e-this._d)/this._c)}},o.DomUtil={get:function(t){return"string"==typeof t?e.getElementById(t):t},getStyle:function(t,i){var n=t.style[i]||t.currentStyle&&t.currentStyle[i];if((!n||"auto"===n)&&e.defaultView){var o=e.defaultView.getComputedStyle(t,null);n=o?o[i]:null}return"auto"===n?null:n},create:function(t,i,n){var o=e.createElement(t);return o.className=i||"",n&&n.appendChild(o),o},remove:function(t){var e=t.parentNode;e&&e.removeChild(t)},empty:function(t){for(;t.firstChild;)t.removeChild(t.firstChild)},toFront:function(t){t.parentNode.appendChild(t)},toBack:function(t){var e=t.parentNode;e.insertBefore(t,e.firstChild)},hasClass:function(t,e){if(t.classList!==i)return t.classList.contains(e);var n=o.DomUtil.getClass(t);return n.length>0&&new RegExp("(^|\\s)"+e+"(\\s|$)").test(n)},addClass:function(t,e){if(t.classList!==i)for(var n=o.Util.splitWords(e),s=0,r=n.length;s<r;s++)t.classList.add(n[s]);else if(!o.DomUtil.hasClass(t,e)){var a=o.DomUtil.getClass(t);o.DomUtil.setClass(t,(a?a+" ":"")+e)}},removeClass:function(t,e){t.classList!==i?t.classList.remove(e):o.DomUtil.setClass(t,o.Util.trim((" "+o.DomUtil.getClass(t)+" ").replace(" "+e+" "," ")))},setClass:function(t,e){t.className.baseVal===i?t.className=e:t.className.baseVal=e},getClass:function(t){return t.className.baseVal===i?t.className:t.className.baseVal},setOpacity:function(t,e){"opacity"in t.style?t.style.opacity=e:"filter"in t.style&&o.DomUtil._setOpacityIE(t,e)},_setOpacityIE:function(t,e){var i=!1,n="DXImageTransform.Microsoft.Alpha";try{i=t.filters.item(n)}catch(t){if(1===e)return}e=Math.round(100*e),i?(i.Enabled=100!==e,i.Opacity=e):t.style.filter+=" progid:"+n+"(opacity="+e+")"},testProp:function(t){for(var i=e.documentElement.style,n=0;n<t.length;n++)if(t[n]in i)return t[n];return!1},setTransform:function(t,e,i){var n=e||new o.Point(0,0);t.style[o.DomUtil.TRANSFORM]=(o.Browser.ie3d?"translate("+n.x+"px,"+n.y+"px)":"translate3d("+n.x+"px,"+n.y+"px,0)")+(i?" scale("+i+")":"")},setPosition:function(t,e){t._leaflet_pos=e,o.Browser.any3d?o.DomUtil.setTransform(t,e):(t.style.left=e.x+"px",t.style.top=e.y+"px")},getPosition:function(t){return t._leaflet_pos||new o.Point(0,0)}},function(){o.DomUtil.TRANSFORM=o.DomUtil.testProp(["transform","WebkitTransform","OTransform","MozTransform","msTransform"]);var i=o.DomUtil.TRANSITION=o.DomUtil.testProp(["webkitTransition","transition","OTransition","MozTransition","msTransition"]);if(o.DomUtil.TRANSITION_END="webkitTransition"===i||"OTransition"===i?i+"End":"transitionend","onselectstart"in e)o.DomUtil.disableTextSelection=function(){o.DomEvent.on(t,"selectstart",o.DomEvent.preventDefault)},o.DomUtil.enableTextSelection=function(){o.DomEvent.off(t,"selectstart",o.DomEvent.preventDefault)};else{var n=o.DomUtil.testProp(["userSelect","WebkitUserSelect","OUserSelect","MozUserSelect","msUserSelect"]);o.DomUtil.disableTextSelection=function(){if(n){var t=e.documentElement.style;this._userSelect=t[n],t[n]="none"}},o.DomUtil.enableTextSelection=function(){n&&(e.documentElement.style[n]=this._userSelect,delete this._userSelect)}}o.DomUtil.disableImageDrag=function(){o.DomEvent.on(t,"dragstart",o.DomEvent.preventDefault)},o.DomUtil.enableImageDrag=function(){o.DomEvent.off(t,"dragstart",o.DomEvent.preventDefault)},o.DomUtil.preventOutline=function(e){for(;e.tabIndex===-1;)e=e.parentNode;e&&e.style&&(o.DomUtil.restoreOutline(),this._outlineElement=e,this._outlineStyle=e.style.outline,e.style.outline="none",o.DomEvent.on(t,"keydown",o.DomUtil.restoreOutline,this))},o.DomUtil.restoreOutline=function(){this._outlineElement&&(this._outlineElement.style.outline=this._outlineStyle,delete this._outlineElement,delete this._outlineStyle,o.DomEvent.off(t,"keydown",o.DomUtil.restoreOutline,this))}}(),o.LatLng=function(t,e,n){if(isNaN(t)||isNaN(e))throw new Error("Invalid LatLng object: ("+t+", "+e+")");this.lat=+t,this.lng=+e,n!==i&&(this.alt=+n)},o.LatLng.prototype={equals:function(t,e){if(!t)return!1;t=o.latLng(t);var n=Math.max(Math.abs(this.lat-t.lat),Math.abs(this.lng-t.lng));return n<=(e===i?1e-9:e)},toString:function(t){return"LatLng("+o.Util.formatNum(this.lat,t)+", "+o.Util.formatNum(this.lng,t)+")"},distanceTo:function(t){return o.CRS.Earth.distance(this,o.latLng(t))},wrap:function(){return o.CRS.Earth.wrapLatLng(this)},toBounds:function(t){var e=180*t/40075017,i=e/Math.cos(Math.PI/180*this.lat);return o.latLngBounds([this.lat-e,this.lng-i],[this.lat+e,this.lng+i])},clone:function(){return new o.LatLng(this.lat,this.lng,this.alt)}},o.latLng=function(t,e,n){return t instanceof o.LatLng?t:o.Util.isArray(t)&&"object"!=typeof t[0]?3===t.length?new o.LatLng(t[0],t[1],t[2]):2===t.length?new o.LatLng(t[0],t[1]):null:t===i||null===t?t:"object"==typeof t&&"lat"in t?new o.LatLng(t.lat,"lng"in t?t.lng:t.lon,t.alt):e===i?null:new o.LatLng(t,e,n)},o.LatLngBounds=function(t,e){if(t)for(var i=e?[t,e]:t,n=0,o=i.length;n<o;n++)this.extend(i[n])},o.LatLngBounds.prototype={extend:function(t){var e,i,n=this._southWest,s=this._northEast;if(t instanceof o.LatLng)e=t,i=t;else{if(!(t instanceof o.LatLngBounds))return t?this.extend(o.latLng(t)||o.latLngBounds(t)):this;if(e=t._southWest,i=t._northEast,!e||!i)return this}return n||s?(n.lat=Math.min(e.lat,n.lat),n.lng=Math.min(e.lng,n.lng),s.lat=Math.max(i.lat,s.lat),s.lng=Math.max(i.lng,s.lng)):(this._southWest=new o.LatLng(e.lat,e.lng),this._northEast=new o.LatLng(i.lat,i.lng)),this},pad:function(t){var e=this._southWest,i=this._northEast,n=Math.abs(e.lat-i.lat)*t,s=Math.abs(e.lng-i.lng)*t;return new o.LatLngBounds(new o.LatLng(e.lat-n,e.lng-s),new o.LatLng(i.lat+n,i.lng+s))},getCenter:function(){return new o.LatLng((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new o.LatLng(this.getNorth(),this.getWest())},getSouthEast:function(){return new o.LatLng(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(t){t="number"==typeof t[0]||t instanceof o.LatLng||"lat"in t?o.latLng(t):o.latLngBounds(t);var e,i,n=this._southWest,s=this._northEast;return t instanceof o.LatLngBounds?(e=t.getSouthWest(),i=t.getNorthEast()):e=i=t,e.lat>=n.lat&&i.lat<=s.lat&&e.lng>=n.lng&&i.lng<=s.lng},intersects:function(t){t=o.latLngBounds(t);var e=this._southWest,i=this._northEast,n=t.getSouthWest(),s=t.getNorthEast(),r=s.lat>=e.lat&&n.lat<=i.lat,a=s.lng>=e.lng&&n.lng<=i.lng;return r&&a},overlaps:function(t){t=o.latLngBounds(t);var e=this._southWest,i=this._northEast,n=t.getSouthWest(),s=t.getNorthEast(),r=s.lat>e.lat&&n.lat<i.lat,a=s.lng>e.lng&&n.lng<i.lng;return r&&a},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")},equals:function(t){return!!t&&(t=o.latLngBounds(t),this._southWest.equals(t.getSouthWest())&&this._northEast.equals(t.getNorthEast()))},isValid:function(){return!(!this._southWest||!this._northEast)}},o.latLngBounds=function(t,e){return t instanceof o.LatLngBounds?t:new o.LatLngBounds(t,e)},o.Projection={},o.Projection.LonLat={project:function(t){return new o.Point(t.lng,t.lat)},unproject:function(t){return new o.LatLng(t.y,t.x)},bounds:o.bounds([-180,-90],[180,90])},o.Projection.SphericalMercator={R:6378137,MAX_LATITUDE:85.0511287798,project:function(t){var e=Math.PI/180,i=this.MAX_LATITUDE,n=Math.max(Math.min(i,t.lat),-i),s=Math.sin(n*e);return new o.Point(this.R*t.lng*e,this.R*Math.log((1+s)/(1-s))/2)},unproject:function(t){var e=180/Math.PI;return new o.LatLng((2*Math.atan(Math.exp(t.y/this.R))-Math.PI/2)*e,t.x*e/this.R)},bounds:function(){var t=6378137*Math.PI;return o.bounds([-t,-t],[t,t])}()},o.CRS={latLngToPoint:function(t,e){var i=this.projection.project(t),n=this.scale(e);return this.transformation._transform(i,n)},pointToLatLng:function(t,e){var i=this.scale(e),n=this.transformation.untransform(t,i);return this.projection.unproject(n)},project:function(t){return this.projection.project(t)},unproject:function(t){return this.projection.unproject(t)},scale:function(t){return 256*Math.pow(2,t)},zoom:function(t){return Math.log(t/256)/Math.LN2},getProjectedBounds:function(t){if(this.infinite)return null;var e=this.projection.bounds,i=this.scale(t),n=this.transformation.transform(e.min,i),s=this.transformation.transform(e.max,i);return o.bounds(n,s)},infinite:!1,wrapLatLng:function(t){var e=this.wrapLng?o.Util.wrapNum(t.lng,this.wrapLng,!0):t.lng,i=this.wrapLat?o.Util.wrapNum(t.lat,this.wrapLat,!0):t.lat,n=t.alt;return o.latLng(i,e,n)},wrapLatLngBounds:function(t){var e=t.getCenter(),i=this.wrapLatLng(e),n=e.lat-i.lat,s=e.lng-i.lng;if(0===n&&0===s)return t;var r=t.getSouthWest(),a=t.getNorthEast(),h=o.latLng({lat:r.lat-n,lng:r.lng-s}),l=o.latLng({lat:a.lat-n,lng:a.lng-s});return new o.LatLngBounds(h,l)}},o.CRS.Simple=o.extend({},o.CRS,{projection:o.Projection.LonLat,transformation:new o.Transformation(1,0,-1,0),scale:function(t){return Math.pow(2,t)},zoom:function(t){return Math.log(t)/Math.LN2},distance:function(t,e){var i=e.lng-t.lng,n=e.lat-t.lat;return Math.sqrt(i*i+n*n)},infinite:!0}),o.CRS.Earth=o.extend({},o.CRS,{wrapLng:[-180,180],R:6371e3,distance:function(t,e){var i=Math.PI/180,n=t.lat*i,o=e.lat*i,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos((e.lng-t.lng)*i);return this.R*Math.acos(Math.min(s,1))}}),o.CRS.EPSG3857=o.extend({},o.CRS.Earth,{code:"EPSG:3857",projection:o.Projection.SphericalMercator,transformation:function(){var t=.5/(Math.PI*o.Projection.SphericalMercator.R);return new o.Transformation(t,.5,-t,.5)}()}),o.CRS.EPSG900913=o.extend({},o.CRS.EPSG3857,{code:"EPSG:900913"}),o.CRS.EPSG4326=o.extend({},o.CRS.Earth,{code:"EPSG:4326",projection:o.Projection.LonLat,transformation:new o.Transformation(1/180,1,-1/180,.5)}),o.Map=o.Evented.extend({options:{crs:o.CRS.EPSG3857,center:i,zoom:i,minZoom:i,maxZoom:i,layers:[],maxBounds:i,renderer:i,zoomAnimation:!0,zoomAnimationThreshold:4,fadeAnimation:!0,markerZoomAnimation:!0,transform3DLimit:8388608,zoomSnap:1,zoomDelta:1,trackResize:!0},initialize:function(t,e){e=o.setOptions(this,e),this._initContainer(t),this._initLayout(),this._onResize=o.bind(this._onResize,this),this._initEvents(),e.maxBounds&&this.setMaxBounds(e.maxBounds),e.zoom!==i&&(this._zoom=this._limitZoom(e.zoom)),e.center&&e.zoom!==i&&this.setView(o.latLng(e.center),e.zoom,{reset:!0}),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this.callInitHooks(),this._zoomAnimated=o.DomUtil.TRANSITION&&o.Browser.any3d&&!o.Browser.mobileOpera&&this.options.zoomAnimation,this._zoomAnimated&&(this._createAnimProxy(),o.DomEvent.on(this._proxy,o.DomUtil.TRANSITION_END,this._catchTransitionEnd,this)),this._addLayers(this.options.layers)},setView:function(t,e,n){if(e=e===i?this._zoom:this._limitZoom(e),t=this._limitCenter(o.latLng(t),e,this.options.maxBounds),n=n||{},this._stop(),this._loaded&&!n.reset&&n!==!0){n.animate!==i&&(n.zoom=o.extend({animate:n.animate},n.zoom),n.pan=o.extend({animate:n.animate,duration:n.duration},n.pan));var s=this._zoom!==e?this._tryAnimatedZoom&&this._tryAnimatedZoom(t,e,n.zoom):this._tryAnimatedPan(t,n.pan);if(s)return clearTimeout(this._sizeTimer),this}return this._resetView(t,e),this},setZoom:function(t,e){return this._loaded?this.setView(this.getCenter(),t,{zoom:e}):(this._zoom=t,this)},zoomIn:function(t,e){return t=t||(o.Browser.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom+t,e)},zoomOut:function(t,e){return t=t||(o.Browser.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom-t,e)},setZoomAround:function(t,e,i){var n=this.getZoomScale(e),s=this.getSize().divideBy(2),r=t instanceof o.Point?t:this.latLngToContainerPoint(t),a=r.subtract(s).multiplyBy(1-1/n),h=this.containerPointToLatLng(s.add(a));return this.setView(h,e,{zoom:i})},_getBoundsCenterZoom:function(t,e){e=e||{},t=t.getBounds?t.getBounds():o.latLngBounds(t);var i=o.point(e.paddingTopLeft||e.padding||[0,0]),n=o.point(e.paddingBottomRight||e.padding||[0,0]),s=this.getBoundsZoom(t,!1,i.add(n));s="number"==typeof e.maxZoom?Math.min(e.maxZoom,s):s;var r=n.subtract(i).divideBy(2),a=this.project(t.getSouthWest(),s),h=this.project(t.getNorthEast(),s),l=this.unproject(a.add(h).divideBy(2).add(r),s);return{center:l,zoom:s}},fitBounds:function(t,e){if(t=o.latLngBounds(t),!t.isValid())throw new Error("Bounds are not valid.");var i=this._getBoundsCenterZoom(t,e);return this.setView(i.center,i.zoom,e)},fitWorld:function(t){return this.fitBounds([[-90,-180],[90,180]],t)},panTo:function(t,e){return this.setView(t,this._zoom,{pan:e})},panBy:function(t,e){if(t=o.point(t).round(),e=e||{},!t.x&&!t.y)return this.fire("moveend");if(e.animate!==!0&&!this.getSize().contains(t))return this._resetView(this.unproject(this.project(this.getCenter()).add(t)),this.getZoom()),this;if(this._panAnim||(this._panAnim=new o.PosAnimation,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),e.noMoveStart||this.fire("movestart"),e.animate!==!1){o.DomUtil.addClass(this._mapPane,"leaflet-pan-anim");var i=this._getMapPanePos().subtract(t).round();this._panAnim.run(this._mapPane,i,e.duration||.25,e.easeLinearity)}else this._rawPanBy(t),this.fire("move").fire("moveend");return this},flyTo:function(t,e,n){function s(t){var e=t?-1:1,i=t?v:g,n=v*v-g*g+e*L*L*y*y,o=2*i*L*y,s=n/o,r=Math.sqrt(s*s+1)-s,a=r<1e-9?-18:Math.log(r);return a}function r(t){return(Math.exp(t)-Math.exp(-t))/2}function a(t){return(Math.exp(t)+Math.exp(-t))/2}function h(t){return r(t)/a(t)}function l(t){return g*(a(x)/a(x+P*t))}function u(t){return g*(a(x)*h(x+P*t)-r(x))/L}function c(t){return 1-Math.pow(1-t,1.5)}function d(){var i=(Date.now()-w)/T,n=c(i)*b;i<=1?(this._flyToFrame=o.Util.requestAnimFrame(d,this),this._move(this.unproject(_.add(m.subtract(_).multiplyBy(u(n)/y)),f),this.getScaleZoom(g/l(n),f),{flyTo:!0})):this._move(t,e)._moveEnd(!0)}if(n=n||{},n.animate===!1||!o.Browser.any3d)return this.setView(t,e,n);this._stop();var _=this.project(this.getCenter()),m=this.project(t),p=this.getSize(),f=this._zoom;t=o.latLng(t),e=e===i?f:e;var g=Math.max(p.x,p.y),v=g*this.getZoomScale(f,e),y=m.distanceTo(_)||1,P=1.42,L=P*P,x=s(0),w=Date.now(),b=(s(1)-x)/P,T=n.duration?1e3*n.duration:1e3*b*.8;return this._moveStart(!0),d.call(this),this},flyToBounds:function(t,e){var i=this._getBoundsCenterZoom(t,e);return this.flyTo(i.center,i.zoom,e)},setMaxBounds:function(t){return t=o.latLngBounds(t),t.isValid()?(this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this.options.maxBounds=t,this._loaded&&this._panInsideMaxBounds(),this.on("moveend",this._panInsideMaxBounds)):(this.options.maxBounds=null,this.off("moveend",this._panInsideMaxBounds))},setMinZoom:function(t){return this.options.minZoom=t,this._loaded&&this.getZoom()<this.options.minZoom?this.setZoom(t):this},setMaxZoom:function(t){return this.options.maxZoom=t,this._loaded&&this.getZoom()>this.options.maxZoom?this.setZoom(t):this},panInsideBounds:function(t,e){this._enforcingBounds=!0;var i=this.getCenter(),n=this._limitCenter(i,this._zoom,o.latLngBounds(t));return i.equals(n)||this.panTo(n,e),this._enforcingBounds=!1,this},invalidateSize:function(t){if(!this._loaded)return this;t=o.extend({animate:!1,pan:!0},t===!0?{animate:!0}:t);var e=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var i=this.getSize(),n=e.divideBy(2).round(),s=i.divideBy(2).round(),r=n.subtract(s);return r.x||r.y?(t.animate&&t.pan?this.panBy(r):(t.pan&&this._rawPanBy(r),this.fire("move"),t.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(o.bind(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:e,newSize:i})):this},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(t){if(t=this._locateOptions=o.extend({timeout:1e4,watch:!1},t),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var e=o.bind(this._handleGeolocationResponse,this),i=o.bind(this._handleGeolocationError,this);return t.watch?this._locationWatchId=navigator.geolocation.watchPosition(e,i,t):navigator.geolocation.getCurrentPosition(e,i,t),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(t){var e=t.code,i=t.message||(1===e?"permission denied":2===e?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:e,message:"Geolocation error: "+i+"."})},_handleGeolocationResponse:function(t){var e=t.coords.latitude,i=t.coords.longitude,n=new o.LatLng(e,i),s=n.toBounds(t.coords.accuracy),r=this._locateOptions;if(r.setView){var a=this.getBoundsZoom(s);this.setView(n,r.maxZoom?Math.min(a,r.maxZoom):a)}var h={latlng:n,bounds:s,timestamp:t.timestamp};for(var l in t.coords)"number"==typeof t.coords[l]&&(h[l]=t.coords[l]);this.fire("locationfound",h)},addHandler:function(t,e){if(!e)return this;var i=this[t]=new e(this);return this._handlers.push(i),this.options[t]&&i.enable(),this},remove:function(){if(this._initEvents(!0),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch(t){this._container._leaflet_id=i,this._containerId=i}o.DomUtil.remove(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._clearHandlers(),this._loaded&&this.fire("unload");for(var t in this._layers)this._layers[t].remove();return this},createPane:function(t,e){var i="leaflet-pane"+(t?" leaflet-"+t.replace("Pane","")+"-pane":""),n=o.DomUtil.create("div",i,e||this._mapPane);return t&&(this._panes[t]=n),n},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter:this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var t=this.getPixelBounds(),e=this.unproject(t.getBottomLeft()),i=this.unproject(t.getTopRight());return new o.LatLngBounds(e,i)},getMinZoom:function(){return this.options.minZoom===i?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===i?this._layersMaxZoom===i?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(t,e,i){t=o.latLngBounds(t),i=o.point(i||[0,0]);var n=this.getZoom()||0,s=this.getMinZoom(),r=this.getMaxZoom(),a=t.getNorthWest(),h=t.getSouthEast(),l=this.getSize().subtract(i),u=o.bounds(this.project(h,n),this.project(a,n)).getSize(),c=o.Browser.any3d?this.options.zoomSnap:1,d=Math.min(l.x/u.x,l.y/u.y);return n=this.getScaleZoom(d,n),c&&(n=Math.round(n/(c/100))*(c/100),n=e?Math.ceil(n/c)*c:Math.floor(n/c)*c),Math.max(s,Math.min(r,n))},getSize:function(){return this._size&&!this._sizeChanged||(this._size=new o.Point(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(t,e){var i=this._getTopLeftPoint(t,e);return new o.Bounds(i,i.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(t){return this.options.crs.getProjectedBounds(t===i?this.getZoom():t)},getPane:function(t){return"string"==typeof t?this._panes[t]:t},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(t,e){var n=this.options.crs;return e=e===i?this._zoom:e,n.scale(t)/n.scale(e)},getScaleZoom:function(t,e){var n=this.options.crs;e=e===i?this._zoom:e;var o=n.zoom(t*n.scale(e));return isNaN(o)?1/0:o},project:function(t,e){return e=e===i?this._zoom:e,this.options.crs.latLngToPoint(o.latLng(t),e)},unproject:function(t,e){return e=e===i?this._zoom:e,this.options.crs.pointToLatLng(o.point(t),e)},layerPointToLatLng:function(t){var e=o.point(t).add(this.getPixelOrigin());return this.unproject(e)},latLngToLayerPoint:function(t){var e=this.project(o.latLng(t))._round();return e._subtract(this.getPixelOrigin())},wrapLatLng:function(t){return this.options.crs.wrapLatLng(o.latLng(t))},wrapLatLngBounds:function(t){return this.options.crs.wrapLatLngBounds(o.latLngBounds(t))},distance:function(t,e){return this.options.crs.distance(o.latLng(t),o.latLng(e))},containerPointToLayerPoint:function(t){return o.point(t).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(t){return o.point(t).add(this._getMapPanePos())},containerPointToLatLng:function(t){var e=this.containerPointToLayerPoint(o.point(t));return this.layerPointToLatLng(e)},latLngToContainerPoint:function(t){return this.layerPointToContainerPoint(this.latLngToLayerPoint(o.latLng(t)))},mouseEventToContainerPoint:function(t){return o.DomEvent.getMousePosition(t,this._container)},mouseEventToLayerPoint:function(t){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(t))},mouseEventToLatLng:function(t){return this.layerPointToLatLng(this.mouseEventToLayerPoint(t))},_initContainer:function(t){var e=this._container=o.DomUtil.get(t);if(!e)throw new Error("Map container not found.");if(e._leaflet_id)throw new Error("Map container is already initialized.");o.DomEvent.addListener(e,"scroll",this._onScroll,this),this._containerId=o.Util.stamp(e)},_initLayout:function(){var t=this._container;this._fadeAnimated=this.options.fadeAnimation&&o.Browser.any3d,
+o.DomUtil.addClass(t,"leaflet-container"+(o.Browser.touch?" leaflet-touch":"")+(o.Browser.retina?" leaflet-retina":"")+(o.Browser.ielt9?" leaflet-oldie":"")+(o.Browser.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var e=o.DomUtil.getStyle(t,"position");"absolute"!==e&&"relative"!==e&&"fixed"!==e&&(t.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var t=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),o.DomUtil.setPosition(this._mapPane,new o.Point(0,0)),this.createPane("tilePane"),this.createPane("shadowPane"),this.createPane("overlayPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(o.DomUtil.addClass(t.markerPane,"leaflet-zoom-hide"),o.DomUtil.addClass(t.shadowPane,"leaflet-zoom-hide"))},_resetView:function(t,e){o.DomUtil.setPosition(this._mapPane,new o.Point(0,0));var i=!this._loaded;this._loaded=!0,e=this._limitZoom(e),this.fire("viewprereset");var n=this._zoom!==e;this._moveStart(n)._move(t,e)._moveEnd(n),this.fire("viewreset"),i&&this.fire("load")},_moveStart:function(t){return t&&this.fire("zoomstart"),this.fire("movestart")},_move:function(t,e,n){e===i&&(e=this._zoom);var o=this._zoom!==e;return this._zoom=e,this._lastCenter=t,this._pixelOrigin=this._getNewPixelOrigin(t),(o||n&&n.pinch)&&this.fire("zoom",n),this.fire("move",n)},_moveEnd:function(t){return t&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return o.Util.cancelAnimFrame(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(t){o.DomUtil.setPosition(this._mapPane,this._getMapPanePos().subtract(t))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(e){if(o.DomEvent){this._targets={},this._targets[o.stamp(this._container)]=this;var i=e?"off":"on";o.DomEvent[i](this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress",this._handleDOMEvent,this),this.options.trackResize&&o.DomEvent[i](t,"resize",this._onResize,this),o.Browser.any3d&&this.options.transform3DLimit&&this[i]("moveend",this._onMoveEnd)}},_onResize:function(){o.Util.cancelAnimFrame(this._resizeRequest),this._resizeRequest=o.Util.requestAnimFrame(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var t=this._getMapPanePos();Math.max(Math.abs(t.x),Math.abs(t.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(t,e){for(var i,n=[],s="mouseout"===e||"mouseover"===e,r=t.target||t.srcElement,a=!1;r;){if(i=this._targets[o.stamp(r)],i&&("click"===e||"preclick"===e)&&!t._simulated&&this._draggableMoved(i)){a=!0;break}if(i&&i.listens(e,!0)){if(s&&!o.DomEvent._isExternalTarget(r,t))break;if(n.push(i),s)break}if(r===this._container)break;r=r.parentNode}return n.length||a||s||!o.DomEvent._isExternalTarget(r,t)||(n=[this]),n},_handleDOMEvent:function(t){if(this._loaded&&!o.DomEvent._skipped(t)){var e="keypress"===t.type&&13===t.keyCode?"click":t.type;"mousedown"===e&&o.DomUtil.preventOutline(t.target||t.srcElement),this._fireDOMEvent(t,e)}},_fireDOMEvent:function(t,e,i){if("click"===t.type){var n=o.Util.extend({},t);n.type="preclick",this._fireDOMEvent(n,n.type,i)}if(!t._stopped&&(i=(i||[]).concat(this._findEventTargets(t,e)),i.length)){var s=i[0];"contextmenu"===e&&s.listens(e,!0)&&o.DomEvent.preventDefault(t);var r={originalEvent:t};if("keypress"!==t.type){var a=s instanceof o.Marker;r.containerPoint=a?this.latLngToContainerPoint(s.getLatLng()):this.mouseEventToContainerPoint(t),r.layerPoint=this.containerPointToLayerPoint(r.containerPoint),r.latlng=a?s.getLatLng():this.layerPointToLatLng(r.layerPoint)}for(var h=0;h<i.length;h++)if(i[h].fire(e,r,!0),r.originalEvent._stopped||i[h].options.nonBubblingEvents&&o.Util.indexOf(i[h].options.nonBubblingEvents,e)!==-1)return}},_draggableMoved:function(t){return t=t.dragging&&t.dragging.enabled()?t:this,t.dragging&&t.dragging.moved()||this.boxZoom&&this.boxZoom.moved()},_clearHandlers:function(){for(var t=0,e=this._handlers.length;t<e;t++)this._handlers[t].disable()},whenReady:function(t,e){return this._loaded?t.call(e||this,{target:this}):this.on("load",t,e),this},_getMapPanePos:function(){return o.DomUtil.getPosition(this._mapPane)||new o.Point(0,0)},_moved:function(){var t=this._getMapPanePos();return t&&!t.equals([0,0])},_getTopLeftPoint:function(t,e){var n=t&&e!==i?this._getNewPixelOrigin(t,e):this.getPixelOrigin();return n.subtract(this._getMapPanePos())},_getNewPixelOrigin:function(t,e){var i=this.getSize()._divideBy(2);return this.project(t,e)._subtract(i)._add(this._getMapPanePos())._round()},_latLngToNewLayerPoint:function(t,e,i){var n=this._getNewPixelOrigin(i,e);return this.project(t,e)._subtract(n)},_latLngBoundsToNewLayerBounds:function(t,e,i){var n=this._getNewPixelOrigin(i,e);return o.bounds([this.project(t.getSouthWest(),e)._subtract(n),this.project(t.getNorthWest(),e)._subtract(n),this.project(t.getSouthEast(),e)._subtract(n),this.project(t.getNorthEast(),e)._subtract(n)])},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(t){return this.latLngToLayerPoint(t).subtract(this._getCenterLayerPoint())},_limitCenter:function(t,e,i){if(!i)return t;var n=this.project(t,e),s=this.getSize().divideBy(2),r=new o.Bounds(n.subtract(s),n.add(s)),a=this._getBoundsOffset(r,i,e);return a.round().equals([0,0])?t:this.unproject(n.add(a),e)},_limitOffset:function(t,e){if(!e)return t;var i=this.getPixelBounds(),n=new o.Bounds(i.min.add(t),i.max.add(t));return t.add(this._getBoundsOffset(n,e))},_getBoundsOffset:function(t,e,i){var n=o.bounds(this.project(e.getNorthEast(),i),this.project(e.getSouthWest(),i)),s=n.min.subtract(t.min),r=n.max.subtract(t.max),a=this._rebound(s.x,-r.x),h=this._rebound(s.y,-r.y);return new o.Point(a,h)},_rebound:function(t,e){return t+e>0?Math.round(t-e)/2:Math.max(0,Math.ceil(t))-Math.max(0,Math.floor(e))},_limitZoom:function(t){var e=this.getMinZoom(),i=this.getMaxZoom(),n=o.Browser.any3d?this.options.zoomSnap:1;return n&&(t=Math.round(t/n)*n),Math.max(e,Math.min(i,t))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){o.DomUtil.removeClass(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(t,e){var i=this._getCenterOffset(t)._floor();return!((e&&e.animate)!==!0&&!this.getSize().contains(i))&&(this.panBy(i,e),!0)},_createAnimProxy:function(){var t=this._proxy=o.DomUtil.create("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(t),this.on("zoomanim",function(e){var i=o.DomUtil.TRANSFORM,n=t.style[i];o.DomUtil.setTransform(t,this.project(e.center,e.zoom),this.getZoomScale(e.zoom,1)),n===t.style[i]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",function(){var e=this.getCenter(),i=this.getZoom();o.DomUtil.setTransform(t,this.project(e,i),this.getZoomScale(i,1))},this)},_catchTransitionEnd:function(t){this._animatingZoom&&t.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(t,e,i){if(this._animatingZoom)return!0;if(i=i||{},!this._zoomAnimated||i.animate===!1||this._nothingToAnimate()||Math.abs(e-this._zoom)>this.options.zoomAnimationThreshold)return!1;var n=this.getZoomScale(e),s=this._getCenterOffset(t)._divideBy(1-1/n);return!(i.animate!==!0&&!this.getSize().contains(s))&&(o.Util.requestAnimFrame(function(){this._moveStart(!0)._animateZoom(t,e,!0)},this),!0)},_animateZoom:function(t,e,i,n){i&&(this._animatingZoom=!0,this._animateToCenter=t,this._animateToZoom=e,o.DomUtil.addClass(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:t,zoom:e,noUpdate:n}),setTimeout(o.bind(this._onZoomTransitionEnd,this),250)},_onZoomTransitionEnd:function(){this._animatingZoom&&(o.DomUtil.removeClass(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom),o.Util.requestAnimFrame(function(){this._moveEnd(!0)},this))}}),o.map=function(t,e){return new o.Map(t,e)},o.Layer=o.Evented.extend({options:{pane:"overlayPane",nonBubblingEvents:[],attribution:null},addTo:function(t){return t.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(t){return t&&t.removeLayer(this),this},getPane:function(t){return this._map.getPane(t?this.options[t]||t:this.options.pane)},addInteractiveTarget:function(t){return this._map._targets[o.stamp(t)]=this,this},removeInteractiveTarget:function(t){return delete this._map._targets[o.stamp(t)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(t){var e=t.target;if(e.hasLayer(this)){if(this._map=e,this._zoomAnimated=e._zoomAnimated,this.getEvents){var i=this.getEvents();e.on(i,this),this.once("remove",function(){e.off(i,this)},this)}this.onAdd(e),this.getAttribution&&e.attributionControl&&e.attributionControl.addAttribution(this.getAttribution()),this.fire("add"),e.fire("layeradd",{layer:this})}}}),o.Map.include({addLayer:function(t){var e=o.stamp(t);return this._layers[e]?this:(this._layers[e]=t,t._mapToAdd=this,t.beforeAdd&&t.beforeAdd(this),this.whenReady(t._layerAdd,t),this)},removeLayer:function(t){var e=o.stamp(t);return this._layers[e]?(this._loaded&&t.onRemove(this),t.getAttribution&&this.attributionControl&&this.attributionControl.removeAttribution(t.getAttribution()),delete this._layers[e],this._loaded&&(this.fire("layerremove",{layer:t}),t.fire("remove")),t._map=t._mapToAdd=null,this):this},hasLayer:function(t){return!!t&&o.stamp(t)in this._layers},eachLayer:function(t,e){for(var i in this._layers)t.call(e,this._layers[i]);return this},_addLayers:function(t){t=t?o.Util.isArray(t)?t:[t]:[];for(var e=0,i=t.length;e<i;e++)this.addLayer(t[e])},_addZoomLimit:function(t){!isNaN(t.options.maxZoom)&&isNaN(t.options.minZoom)||(this._zoomBoundLayers[o.stamp(t)]=t,this._updateZoomLevels())},_removeZoomLimit:function(t){var e=o.stamp(t);this._zoomBoundLayers[e]&&(delete this._zoomBoundLayers[e],this._updateZoomLevels())},_updateZoomLevels:function(){var t=1/0,e=-(1/0),n=this._getZoomSpan();for(var o in this._zoomBoundLayers){var s=this._zoomBoundLayers[o].options;t=s.minZoom===i?t:Math.min(t,s.minZoom),e=s.maxZoom===i?e:Math.max(e,s.maxZoom)}this._layersMaxZoom=e===-(1/0)?i:e,this._layersMinZoom=t===1/0?i:t,n!==this._getZoomSpan()&&this.fire("zoomlevelschange"),this.options.maxZoom===i&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===i&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom&&this.setZoom(this._layersMinZoom)}});var r="_leaflet_events";o.DomEvent={on:function(t,e,i,n){if("object"==typeof e)for(var s in e)this._on(t,s,e[s],i);else{e=o.Util.splitWords(e);for(var r=0,a=e.length;r<a;r++)this._on(t,e[r],i,n)}return this},off:function(t,e,i,n){if("object"==typeof e)for(var s in e)this._off(t,s,e[s],i);else{e=o.Util.splitWords(e);for(var r=0,a=e.length;r<a;r++)this._off(t,e[r],i,n)}return this},_on:function(e,i,n,s){var a=i+o.stamp(n)+(s?"_"+o.stamp(s):"");if(e[r]&&e[r][a])return this;var h=function(i){return n.call(s||e,i||t.event)},l=h;return o.Browser.pointer&&0===i.indexOf("touch")?this.addPointerListener(e,i,h,a):!o.Browser.touch||"dblclick"!==i||!this.addDoubleTapListener||o.Browser.pointer&&o.Browser.chrome?"addEventListener"in e?"mousewheel"===i?e.addEventListener("onwheel"in e?"wheel":"mousewheel",h,!1):"mouseenter"===i||"mouseleave"===i?(h=function(i){i=i||t.event,o.DomEvent._isExternalTarget(e,i)&&l(i)},e.addEventListener("mouseenter"===i?"mouseover":"mouseout",h,!1)):("click"===i&&o.Browser.android&&(h=function(t){return o.DomEvent._filterClick(t,l)}),e.addEventListener(i,h,!1)):"attachEvent"in e&&e.attachEvent("on"+i,h):this.addDoubleTapListener(e,h,a),e[r]=e[r]||{},e[r][a]=h,this},_off:function(t,e,i,n){var s=e+o.stamp(i)+(n?"_"+o.stamp(n):""),a=t[r]&&t[r][s];return a?(o.Browser.pointer&&0===e.indexOf("touch")?this.removePointerListener(t,e,s):o.Browser.touch&&"dblclick"===e&&this.removeDoubleTapListener?this.removeDoubleTapListener(t,s):"removeEventListener"in t?"mousewheel"===e?t.removeEventListener("onwheel"in t?"wheel":"mousewheel",a,!1):t.removeEventListener("mouseenter"===e?"mouseover":"mouseleave"===e?"mouseout":e,a,!1):"detachEvent"in t&&t.detachEvent("on"+e,a),t[r][s]=null,this):this},stopPropagation:function(t){return t.stopPropagation?t.stopPropagation():t.originalEvent?t.originalEvent._stopped=!0:t.cancelBubble=!0,o.DomEvent._skipped(t),this},disableScrollPropagation:function(t){return o.DomEvent.on(t,"mousewheel",o.DomEvent.stopPropagation)},disableClickPropagation:function(t){var e=o.DomEvent.stopPropagation;return o.DomEvent.on(t,o.Draggable.START.join(" "),e),o.DomEvent.on(t,{click:o.DomEvent._fakeStop,dblclick:e})},preventDefault:function(t){return t.preventDefault?t.preventDefault():t.returnValue=!1,this},stop:function(t){return o.DomEvent.preventDefault(t).stopPropagation(t)},getMousePosition:function(t,e){if(!e)return new o.Point(t.clientX,t.clientY);var i=e.getBoundingClientRect();return new o.Point(t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop)},_wheelPxFactor:o.Browser.win&&o.Browser.chrome?2:o.Browser.gecko?t.devicePixelRatio:1,getWheelDelta:function(t){return o.Browser.edge?t.wheelDeltaY/2:t.deltaY&&0===t.deltaMode?-t.deltaY/o.DomEvent._wheelPxFactor:t.deltaY&&1===t.deltaMode?20*-t.deltaY:t.deltaY&&2===t.deltaMode?60*-t.deltaY:t.deltaX||t.deltaZ?0:t.wheelDelta?(t.wheelDeltaY||t.wheelDelta)/2:t.detail&&Math.abs(t.detail)<32765?20*-t.detail:t.detail?t.detail/-32765*60:0},_skipEvents:{},_fakeStop:function(t){o.DomEvent._skipEvents[t.type]=!0},_skipped:function(t){var e=this._skipEvents[t.type];return this._skipEvents[t.type]=!1,e},_isExternalTarget:function(t,e){var i=e.relatedTarget;if(!i)return!0;try{for(;i&&i!==t;)i=i.parentNode}catch(t){return!1}return i!==t},_filterClick:function(t,e){var i=t.timeStamp||t.originalEvent&&t.originalEvent.timeStamp,n=o.DomEvent._lastClick&&i-o.DomEvent._lastClick;return n&&n>100&&n<500||t.target._simulatedClick&&!t._simulated?void o.DomEvent.stop(t):(o.DomEvent._lastClick=i,void e(t))}},o.DomEvent.addListener=o.DomEvent.on,o.DomEvent.removeListener=o.DomEvent.off,o.PosAnimation=o.Evented.extend({run:function(t,e,i,n){this.stop(),this._el=t,this._inProgress=!0,this._duration=i||.25,this._easeOutPower=1/Math.max(n||.5,.2),this._startPos=o.DomUtil.getPosition(t),this._offset=e.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=o.Util.requestAnimFrame(this._animate,this),this._step()},_step:function(t){var e=+new Date-this._startTime,i=1e3*this._duration;e<i?this._runFrame(this._easeOut(e/i),t):(this._runFrame(1),this._complete())},_runFrame:function(t,e){var i=this._startPos.add(this._offset.multiplyBy(t));e&&i._round(),o.DomUtil.setPosition(this._el,i),this.fire("step")},_complete:function(){o.Util.cancelAnimFrame(this._animId),this._inProgress=!1,this.fire("end")},_easeOut:function(t){return 1-Math.pow(1-t,this._easeOutPower)}}),o.Projection.Mercator={R:6378137,R_MINOR:6356752.314245179,bounds:o.bounds([-20037508.34279,-15496570.73972],[20037508.34279,18764656.23138]),project:function(t){var e=Math.PI/180,i=this.R,n=t.lat*e,s=this.R_MINOR/i,r=Math.sqrt(1-s*s),a=r*Math.sin(n),h=Math.tan(Math.PI/4-n/2)/Math.pow((1-a)/(1+a),r/2);return n=-i*Math.log(Math.max(h,1e-10)),new o.Point(t.lng*e*i,n)},unproject:function(t){for(var e,i=180/Math.PI,n=this.R,s=this.R_MINOR/n,r=Math.sqrt(1-s*s),a=Math.exp(-t.y/n),h=Math.PI/2-2*Math.atan(a),l=0,u=.1;l<15&&Math.abs(u)>1e-7;l++)e=r*Math.sin(h),e=Math.pow((1-e)/(1+e),r/2),u=Math.PI/2-2*Math.atan(a*e)-h,h+=u;return new o.LatLng(h*i,t.x*i/n)}},o.CRS.EPSG3395=o.extend({},o.CRS.Earth,{code:"EPSG:3395",projection:o.Projection.Mercator,transformation:function(){var t=.5/(Math.PI*o.Projection.Mercator.R);return new o.Transformation(t,.5,-t,.5)}()}),o.GridLayer=o.Layer.extend({options:{tileSize:256,opacity:1,updateWhenIdle:o.Browser.mobile,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:i,noWrap:!1,pane:"tilePane",className:"",keepBuffer:2},initialize:function(t){o.setOptions(this,t)},onAdd:function(){this._initContainer(),this._levels={},this._tiles={},this._resetView(),this._update()},beforeAdd:function(t){t._addZoomLimit(this)},onRemove:function(t){this._removeAllTiles(),o.DomUtil.remove(this._container),t._removeZoomLimit(this),this._container=null,this._tileZoom=null},bringToFront:function(){return this._map&&(o.DomUtil.toFront(this._container),this._setAutoZIndex(Math.max)),this},bringToBack:function(){return this._map&&(o.DomUtil.toBack(this._container),this._setAutoZIndex(Math.min)),this},getContainer:function(){return this._container},setOpacity:function(t){return this.options.opacity=t,this._updateOpacity(),this},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},isLoading:function(){return this._loading},redraw:function(){return this._map&&(this._removeAllTiles(),this._update()),this},getEvents:function(){var t={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||(this._onMove=o.Util.throttle(this._onMoveEnd,this.options.updateInterval,this)),t.move=this._onMove),this._zoomAnimated&&(t.zoomanim=this._animateZoom),t},createTile:function(){return e.createElement("div")},getTileSize:function(){var t=this.options.tileSize;return t instanceof o.Point?t:new o.Point(t,t)},_updateZIndex:function(){this._container&&this.options.zIndex!==i&&null!==this.options.zIndex&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(t){for(var e,i=this.getPane().children,n=-t(-(1/0),1/0),o=0,s=i.length;o<s;o++)e=i[o].style.zIndex,i[o]!==this._container&&e&&(n=t(n,+e));isFinite(n)&&(this.options.zIndex=n+t(-1,1),this._updateZIndex())},_updateOpacity:function(){if(this._map&&!o.Browser.ielt9){o.DomUtil.setOpacity(this._container,this.options.opacity);var t=+new Date,e=!1,i=!1;for(var n in this._tiles){var s=this._tiles[n];if(s.current&&s.loaded){var r=Math.min(1,(t-s.loaded)/200);o.DomUtil.setOpacity(s.el,r),r<1?e=!0:(s.active&&(i=!0),s.active=!0)}}i&&!this._noPrune&&this._pruneTiles(),e&&(o.Util.cancelAnimFrame(this._fadeFrame),this._fadeFrame=o.Util.requestAnimFrame(this._updateOpacity,this))}},_initContainer:function(){this._container||(this._container=o.DomUtil.create("div","leaflet-layer "+(this.options.className||"")),this._updateZIndex(),this.options.opacity<1&&this._updateOpacity(),this.getPane().appendChild(this._container))},_updateLevels:function(){var t=this._tileZoom,e=this.options.maxZoom;if(t===i)return i;for(var n in this._levels)this._levels[n].el.children.length||n===t?this._levels[n].el.style.zIndex=e-Math.abs(t-n):(o.DomUtil.remove(this._levels[n].el),this._removeTilesAtZoom(n),delete this._levels[n]);var s=this._levels[t],r=this._map;return s||(s=this._levels[t]={},s.el=o.DomUtil.create("div","leaflet-tile-container leaflet-zoom-animated",this._container),s.el.style.zIndex=e,s.origin=r.project(r.unproject(r.getPixelOrigin()),t).round(),s.zoom=t,this._setZoomTransform(s,r.getCenter(),r.getZoom()),o.Util.falseFn(s.el.offsetWidth)),this._level=s,s},_pruneTiles:function(){if(this._map){var t,e,i=this._map.getZoom();if(i>this.options.maxZoom||i<this.options.minZoom)return void this._removeAllTiles();for(t in this._tiles)e=this._tiles[t],e.retain=e.current;for(t in this._tiles)if(e=this._tiles[t],e.current&&!e.active){var n=e.coords;this._retainParent(n.x,n.y,n.z,n.z-5)||this._retainChildren(n.x,n.y,n.z,n.z+2)}for(t in this._tiles)this._tiles[t].retain||this._removeTile(t)}},_removeTilesAtZoom:function(t){for(var e in this._tiles)this._tiles[e].coords.z===t&&this._removeTile(e)},_removeAllTiles:function(){for(var t in this._tiles)this._removeTile(t)},_invalidateAll:function(){for(var t in this._levels)o.DomUtil.remove(this._levels[t].el),delete this._levels[t];this._removeAllTiles(),this._tileZoom=null},_retainParent:function(t,e,i,n){var s=Math.floor(t/2),r=Math.floor(e/2),a=i-1,h=new o.Point(+s,+r);h.z=+a;var l=this._tileCoordsToKey(h),u=this._tiles[l];return u&&u.active?(u.retain=!0,!0):(u&&u.loaded&&(u.retain=!0),a>n&&this._retainParent(s,r,a,n))},_retainChildren:function(t,e,i,n){for(var s=2*t;s<2*t+2;s++)for(var r=2*e;r<2*e+2;r++){var a=new o.Point(s,r);a.z=i+1;var h=this._tileCoordsToKey(a),l=this._tiles[h];l&&l.active?l.retain=!0:(l&&l.loaded&&(l.retain=!0),i+1<n&&this._retainChildren(s,r,i+1,n))}},_resetView:function(t){var e=t&&(t.pinch||t.flyTo);this._setView(this._map.getCenter(),this._map.getZoom(),e,e)},_animateZoom:function(t){this._setView(t.center,t.zoom,!0,t.noUpdate)},_setView:function(t,e,n,o){var s=Math.round(e);(this.options.maxZoom!==i&&s>this.options.maxZoom||this.options.minZoom!==i&&s<this.options.minZoom)&&(s=i);var r=this.options.updateWhenZooming&&s!==this._tileZoom;o&&!r||(this._tileZoom=s,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),s!==i&&this._update(t),n||this._pruneTiles(),this._noPrune=!!n),this._setZoomTransforms(t,e)},_setZoomTransforms:function(t,e){for(var i in this._levels)this._setZoomTransform(this._levels[i],t,e)},_setZoomTransform:function(t,e,i){var n=this._map.getZoomScale(i,t.zoom),s=t.origin.multiplyBy(n).subtract(this._map._getNewPixelOrigin(e,i)).round();o.Browser.any3d?o.DomUtil.setTransform(t.el,s,n):o.DomUtil.setPosition(t.el,s)},_resetGrid:function(){var t=this._map,e=t.options.crs,i=this._tileSize=this.getTileSize(),n=this._tileZoom,o=this._map.getPixelWorldBounds(this._tileZoom);o&&(this._globalTileRange=this._pxBoundsToTileRange(o)),this._wrapX=e.wrapLng&&!this.options.noWrap&&[Math.floor(t.project([0,e.wrapLng[0]],n).x/i.x),Math.ceil(t.project([0,e.wrapLng[1]],n).x/i.y)],this._wrapY=e.wrapLat&&!this.options.noWrap&&[Math.floor(t.project([e.wrapLat[0],0],n).y/i.x),Math.ceil(t.project([e.wrapLat[1],0],n).y/i.y)]},_onMoveEnd:function(){this._map&&!this._map._animatingZoom&&this._update()},_getTiledPixelBounds:function(t){var e=this._map,i=e._animatingZoom?Math.max(e._animateToZoom,e.getZoom()):e.getZoom(),n=e.getZoomScale(i,this._tileZoom),s=e.project(t,this._tileZoom).floor(),r=e.getSize().divideBy(2*n);return new o.Bounds(s.subtract(r),s.add(r))},_update:function(t){var n=this._map;if(n){var s=n.getZoom();if(t===i&&(t=n.getCenter()),this._tileZoom!==i){var r=this._getTiledPixelBounds(t),a=this._pxBoundsToTileRange(r),h=a.getCenter(),l=[],u=this.options.keepBuffer,c=new o.Bounds(a.getBottomLeft().subtract([u,-u]),a.getTopRight().add([u,-u]));for(var d in this._tiles){var _=this._tiles[d].coords;_.z===this._tileZoom&&c.contains(o.point(_.x,_.y))||(this._tiles[d].current=!1)}if(Math.abs(s-this._tileZoom)>1)return void this._setView(t,s);for(var m=a.min.y;m<=a.max.y;m++)for(var p=a.min.x;p<=a.max.x;p++){var f=new o.Point(p,m);if(f.z=this._tileZoom,this._isValidTile(f)){var g=this._tiles[this._tileCoordsToKey(f)];g?g.current=!0:l.push(f)}}if(l.sort(function(t,e){return t.distanceTo(h)-e.distanceTo(h)}),0!==l.length){this._loading||(this._loading=!0,this.fire("loading"));var v=e.createDocumentFragment();for(p=0;p<l.length;p++)this._addTile(l[p],v);this._level.el.appendChild(v)}}}},_isValidTile:function(t){var e=this._map.options.crs;if(!e.infinite){var i=this._globalTileRange;if(!e.wrapLng&&(t.x<i.min.x||t.x>i.max.x)||!e.wrapLat&&(t.y<i.min.y||t.y>i.max.y))return!1}if(!this.options.bounds)return!0;var n=this._tileCoordsToBounds(t);return o.latLngBounds(this.options.bounds).overlaps(n)},_keyToBounds:function(t){return this._tileCoordsToBounds(this._keyToTileCoords(t))},_tileCoordsToBounds:function(t){var e=this._map,i=this.getTileSize(),n=t.scaleBy(i),s=n.add(i),r=e.unproject(n,t.z),a=e.unproject(s,t.z),h=new o.LatLngBounds(r,a);return this.options.noWrap||e.wrapLatLngBounds(h),h},_tileCoordsToKey:function(t){return t.x+":"+t.y+":"+t.z},_keyToTileCoords:function(t){var e=t.split(":"),i=new o.Point(+e[0],+e[1]);return i.z=+e[2],i},_removeTile:function(t){var e=this._tiles[t];e&&(o.DomUtil.remove(e.el),delete this._tiles[t],this.fire("tileunload",{tile:e.el,coords:this._keyToTileCoords(t)}))},_initTile:function(t){o.DomUtil.addClass(t,"leaflet-tile");var e=this.getTileSize();t.style.width=e.x+"px",t.style.height=e.y+"px",t.onselectstart=o.Util.falseFn,t.onmousemove=o.Util.falseFn,o.Browser.ielt9&&this.options.opacity<1&&o.DomUtil.setOpacity(t,this.options.opacity),o.Browser.android&&!o.Browser.android23&&(t.style.WebkitBackfaceVisibility="hidden")},_addTile:function(t,e){var i=this._getTilePos(t),n=this._tileCoordsToKey(t),s=this.createTile(this._wrapCoords(t),o.bind(this._tileReady,this,t));this._initTile(s),this.createTile.length<2&&o.Util.requestAnimFrame(o.bind(this._tileReady,this,t,null,s)),o.DomUtil.setPosition(s,i),this._tiles[n]={el:s,coords:t,current:!0},e.appendChild(s),this.fire("tileloadstart",{tile:s,coords:t})},_tileReady:function(t,e,i){if(this._map){e&&this.fire("tileerror",{error:e,tile:i,coords:t});var n=this._tileCoordsToKey(t);i=this._tiles[n],i&&(i.loaded=+new Date,this._map._fadeAnimated?(o.DomUtil.setOpacity(i.el,0),o.Util.cancelAnimFrame(this._fadeFrame),this._fadeFrame=o.Util.requestAnimFrame(this._updateOpacity,this)):(i.active=!0,this._pruneTiles()),e||(o.DomUtil.addClass(i.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:i.el,coords:t})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),o.Browser.ielt9||!this._map._fadeAnimated?o.Util.requestAnimFrame(this._pruneTiles,this):setTimeout(o.bind(this._pruneTiles,this),250)))}},_getTilePos:function(t){return t.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(t){var e=new o.Point(this._wrapX?o.Util.wrapNum(t.x,this._wrapX):t.x,this._wrapY?o.Util.wrapNum(t.y,this._wrapY):t.y);return e.z=t.z,e},_pxBoundsToTileRange:function(t){var e=this.getTileSize();return new o.Bounds(t.min.unscaleBy(e).floor(),t.max.unscaleBy(e).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var t in this._tiles)if(!this._tiles[t].loaded)return!1;return!0}}),o.gridLayer=function(t){return new o.GridLayer(t)},o.TileLayer=o.GridLayer.extend({options:{minZoom:0,maxZoom:18,maxNativeZoom:null,minNativeZoom:null,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1},initialize:function(t,e){this._url=t,e=o.setOptions(this,e),e.detectRetina&&o.Browser.retina&&e.maxZoom>0&&(e.tileSize=Math.floor(e.tileSize/2),e.zoomReverse?(e.zoomOffset--,e.minZoom++):(e.zoomOffset++,e.maxZoom--),e.minZoom=Math.max(0,e.minZoom)),"string"==typeof e.subdomains&&(e.subdomains=e.subdomains.split("")),o.Browser.android||this.on("tileunload",this._onTileRemove)},setUrl:function(t,e){return this._url=t,e||this.redraw(),this},createTile:function(t,i){var n=e.createElement("img");return o.DomEvent.on(n,"load",o.bind(this._tileOnLoad,this,i,n)),o.DomEvent.on(n,"error",o.bind(this._tileOnError,this,i,n)),this.options.crossOrigin&&(n.crossOrigin=""),n.alt="",n.setAttribute("role","presentation"),n.src=this.getTileUrl(t),n},getTileUrl:function(t){var e={r:o.Browser.retina?"@2x":"",s:this._getSubdomain(t),x:t.x,y:t.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var i=this._globalTileRange.max.y-t.y;this.options.tms&&(e.y=i),e["-y"]=i}return o.Util.template(this._url,o.extend(e,this.options))},_tileOnLoad:function(t,e){o.Browser.ielt9?setTimeout(o.bind(t,this,null,e),0):t(null,e)},_tileOnError:function(t,e,i){var n=this.options.errorTileUrl;n&&e.src!==n&&(e.src=n),t(i,e)},getTileSize:function(){var t=this._map,e=o.GridLayer.prototype.getTileSize.call(this),i=this._tileZoom+this.options.zoomOffset,n=this.options.minNativeZoom,s=this.options.maxNativeZoom;return null!==n&&i<n?e.divideBy(t.getZoomScale(n,i)).round():null!==s&&i>s?e.divideBy(t.getZoomScale(s,i)).round():e},_onTileRemove:function(t){t.tile.onload=null},_getZoomForUrl:function(){var t=this._tileZoom,e=this.options.maxZoom,i=this.options.zoomReverse,n=this.options.zoomOffset,o=this.options.minNativeZoom,s=this.options.maxNativeZoom;return i&&(t=e-t),t+=n,null!==o&&t<o?o:null!==s&&t>s?s:t},_getSubdomain:function(t){var e=Math.abs(t.x+t.y)%this.options.subdomains.length;return this.options.subdomains[e]},_abortLoading:function(){var t,e;for(t in this._tiles)this._tiles[t].coords.z!==this._tileZoom&&(e=this._tiles[t].el,e.onload=o.Util.falseFn,e.onerror=o.Util.falseFn,e.complete||(e.src=o.Util.emptyImageUrl,o.DomUtil.remove(e)))}}),o.tileLayer=function(t,e){return new o.TileLayer(t,e)},o.TileLayer.WMS=o.TileLayer.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(t,e){this._url=t;var i=o.extend({},this.defaultWmsParams);for(var n in e)n in this.options||(i[n]=e[n]);e=o.setOptions(this,e),i.width=i.height=e.tileSize*(e.detectRetina&&o.Browser.retina?2:1),this.wmsParams=i},onAdd:function(t){this._crs=this.options.crs||t.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var e=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[e]=this._crs.code,o.TileLayer.prototype.onAdd.call(this,t)},getTileUrl:function(t){var e=this._tileCoordsToBounds(t),i=this._crs.project(e.getNorthWest()),n=this._crs.project(e.getSouthEast()),s=(this._wmsVersion>=1.3&&this._crs===o.CRS.EPSG4326?[n.y,i.x,i.y,n.x]:[i.x,n.y,n.x,i.y]).join(","),r=o.TileLayer.prototype.getTileUrl.call(this,t);return r+o.Util.getParamString(this.wmsParams,r,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+s},setParams:function(t,e){return o.extend(this.wmsParams,t),e||this.redraw(),this}}),o.tileLayer.wms=function(t,e){return new o.TileLayer.WMS(t,e)},o.ImageOverlay=o.Layer.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1},initialize:function(t,e,i){this._url=t,this._bounds=o.latLngBounds(e),o.setOptions(this,i)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(o.DomUtil.addClass(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){o.DomUtil.remove(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(t){return this.options.opacity=t,this._image&&this._updateOpacity(),this},setStyle:function(t){return t.opacity&&this.setOpacity(t.opacity),this},bringToFront:function(){return this._map&&o.DomUtil.toFront(this._image),this},bringToBack:function(){return this._map&&o.DomUtil.toBack(this._image),this},setUrl:function(t){return this._url=t,this._image&&(this._image.src=t),this},setBounds:function(t){return this._bounds=t,this._map&&this._reset(),this},getEvents:function(){var t={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(t.zoomanim=this._animateZoom),t},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var t=this._image=o.DomUtil.create("img","leaflet-image-layer "+(this._zoomAnimated?"leaflet-zoom-animated":""));t.onselectstart=o.Util.falseFn,t.onmousemove=o.Util.falseFn,t.onload=o.bind(this.fire,this,"load"),this.options.crossOrigin&&(t.crossOrigin=""),t.src=this._url,t.alt=this.options.alt},_animateZoom:function(t){var e=this._map.getZoomScale(t.zoom),i=this._map._latLngBoundsToNewLayerBounds(this._bounds,t.zoom,t.center).min;
+o.DomUtil.setTransform(this._image,i,e)},_reset:function(){var t=this._image,e=new o.Bounds(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),i=e.getSize();o.DomUtil.setPosition(t,e.min),t.style.width=i.x+"px",t.style.height=i.y+"px"},_updateOpacity:function(){o.DomUtil.setOpacity(this._image,this.options.opacity)}}),o.imageOverlay=function(t,e,i){return new o.ImageOverlay(t,e,i)},o.Icon=o.Class.extend({initialize:function(t){o.setOptions(this,t)},createIcon:function(t){return this._createIcon("icon",t)},createShadow:function(t){return this._createIcon("shadow",t)},_createIcon:function(t,e){var i=this._getIconUrl(t);if(!i){if("icon"===t)throw new Error("iconUrl not set in Icon options (see the docs).");return null}var n=this._createImg(i,e&&"IMG"===e.tagName?e:null);return this._setIconStyles(n,t),n},_setIconStyles:function(t,e){var i=this.options,n=i[e+"Size"];"number"==typeof n&&(n=[n,n]);var s=o.point(n),r=o.point("shadow"===e&&i.shadowAnchor||i.iconAnchor||s&&s.divideBy(2,!0));t.className="leaflet-marker-"+e+" "+(i.className||""),r&&(t.style.marginLeft=-r.x+"px",t.style.marginTop=-r.y+"px"),s&&(t.style.width=s.x+"px",t.style.height=s.y+"px")},_createImg:function(t,i){return i=i||e.createElement("img"),i.src=t,i},_getIconUrl:function(t){return o.Browser.retina&&this.options[t+"RetinaUrl"]||this.options[t+"Url"]}}),o.icon=function(t){return new o.Icon(t)},o.Icon.Default=o.Icon.extend({options:{iconUrl:"marker-icon.png",iconRetinaUrl:"marker-icon-2x.png",shadowUrl:"marker-shadow.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]},_getIconUrl:function(t){return o.Icon.Default.imagePath||(o.Icon.Default.imagePath=this._detectIconPath()),(this.options.imagePath||o.Icon.Default.imagePath)+o.Icon.prototype._getIconUrl.call(this,t)},_detectIconPath:function(){var t=o.DomUtil.create("div","leaflet-default-icon-path",e.body),i=o.DomUtil.getStyle(t,"background-image")||o.DomUtil.getStyle(t,"backgroundImage");return e.body.removeChild(t),0===i.indexOf("url")?i.replace(/^url\([\"\']?/,"").replace(/marker-icon\.png[\"\']?\)$/,""):""}}),o.Marker=o.Layer.extend({options:{icon:new o.Icon.Default,interactive:!0,draggable:!1,keyboard:!0,title:"",alt:"",zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:"markerPane",nonBubblingEvents:["click","dblclick","mouseover","mouseout","contextmenu"]},initialize:function(t,e){o.setOptions(this,e),this._latlng=o.latLng(t)},onAdd:function(t){this._zoomAnimated=this._zoomAnimated&&t.options.markerZoomAnimation,this._zoomAnimated&&t.on("zoomanim",this._animateZoom,this),this._initIcon(),this.update()},onRemove:function(t){this.dragging&&this.dragging.enabled()&&(this.options.draggable=!0,this.dragging.removeHooks()),this._zoomAnimated&&t.off("zoomanim",this._animateZoom,this),this._removeIcon(),this._removeShadow()},getEvents:function(){return{zoom:this.update,viewreset:this.update}},getLatLng:function(){return this._latlng},setLatLng:function(t){var e=this._latlng;return this._latlng=o.latLng(t),this.update(),this.fire("move",{oldLatLng:e,latlng:this._latlng})},setZIndexOffset:function(t){return this.options.zIndexOffset=t,this.update()},setIcon:function(t){return this.options.icon=t,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup,this._popup.options),this},getElement:function(){return this._icon},update:function(){if(this._icon){var t=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(t)}return this},_initIcon:function(){var t=this.options,e="leaflet-zoom-"+(this._zoomAnimated?"animated":"hide"),i=t.icon.createIcon(this._icon),n=!1;i!==this._icon&&(this._icon&&this._removeIcon(),n=!0,t.title&&(i.title=t.title),t.alt&&(i.alt=t.alt)),o.DomUtil.addClass(i,e),t.keyboard&&(i.tabIndex="0"),this._icon=i,t.riseOnHover&&this.on({mouseover:this._bringToFront,mouseout:this._resetZIndex});var s=t.icon.createShadow(this._shadow),r=!1;s!==this._shadow&&(this._removeShadow(),r=!0),s&&(o.DomUtil.addClass(s,e),s.alt=""),this._shadow=s,t.opacity<1&&this._updateOpacity(),n&&this.getPane().appendChild(this._icon),this._initInteraction(),s&&r&&this.getPane("shadowPane").appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&this.off({mouseover:this._bringToFront,mouseout:this._resetZIndex}),o.DomUtil.remove(this._icon),this.removeInteractiveTarget(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&o.DomUtil.remove(this._shadow),this._shadow=null},_setPos:function(t){o.DomUtil.setPosition(this._icon,t),this._shadow&&o.DomUtil.setPosition(this._shadow,t),this._zIndex=t.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(t){this._icon.style.zIndex=this._zIndex+t},_animateZoom:function(t){var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center).round();this._setPos(e)},_initInteraction:function(){if(this.options.interactive&&(o.DomUtil.addClass(this._icon,"leaflet-interactive"),this.addInteractiveTarget(this._icon),o.Handler.MarkerDrag)){var t=this.options.draggable;this.dragging&&(t=this.dragging.enabled(),this.dragging.disable()),this.dragging=new o.Handler.MarkerDrag(this),t&&this.dragging.enable()}},setOpacity:function(t){return this.options.opacity=t,this._map&&this._updateOpacity(),this},_updateOpacity:function(){var t=this.options.opacity;o.DomUtil.setOpacity(this._icon,t),this._shadow&&o.DomUtil.setOpacity(this._shadow,t)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)},_getPopupAnchor:function(){return this.options.icon.options.popupAnchor||[0,0]},_getTooltipAnchor:function(){return this.options.icon.options.tooltipAnchor||[0,0]}}),o.marker=function(t,e){return new o.Marker(t,e)},o.DivIcon=o.Icon.extend({options:{iconSize:[12,12],html:!1,bgPos:null,className:"leaflet-div-icon"},createIcon:function(t){var i=t&&"DIV"===t.tagName?t:e.createElement("div"),n=this.options;if(i.innerHTML=n.html!==!1?n.html:"",n.bgPos){var s=o.point(n.bgPos);i.style.backgroundPosition=-s.x+"px "+-s.y+"px"}return this._setIconStyles(i,"icon"),i},createShadow:function(){return null}}),o.divIcon=function(t){return new o.DivIcon(t)},o.DivOverlay=o.Layer.extend({options:{offset:[0,7],className:"",pane:"popupPane"},initialize:function(t,e){o.setOptions(this,t),this._source=e},onAdd:function(t){this._zoomAnimated=t._zoomAnimated,this._container||this._initLayout(),t._fadeAnimated&&o.DomUtil.setOpacity(this._container,0),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),t._fadeAnimated&&o.DomUtil.setOpacity(this._container,1),this.bringToFront()},onRemove:function(t){t._fadeAnimated?(o.DomUtil.setOpacity(this._container,0),this._removeTimeout=setTimeout(o.bind(o.DomUtil.remove,o.DomUtil,this._container),200)):o.DomUtil.remove(this._container)},getLatLng:function(){return this._latlng},setLatLng:function(t){return this._latlng=o.latLng(t),this._map&&(this._updatePosition(),this._adjustPan()),this},getContent:function(){return this._content},setContent:function(t){return this._content=t,this.update(),this},getElement:function(){return this._container},update:function(){this._map&&(this._container.style.visibility="hidden",this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility="",this._adjustPan())},getEvents:function(){var t={zoom:this._updatePosition,viewreset:this._updatePosition};return this._zoomAnimated&&(t.zoomanim=this._animateZoom),t},isOpen:function(){return!!this._map&&this._map.hasLayer(this)},bringToFront:function(){return this._map&&o.DomUtil.toFront(this._container),this},bringToBack:function(){return this._map&&o.DomUtil.toBack(this._container),this},_updateContent:function(){if(this._content){var t=this._contentNode,e="function"==typeof this._content?this._content(this._source||this):this._content;if("string"==typeof e)t.innerHTML=e;else{for(;t.hasChildNodes();)t.removeChild(t.firstChild);t.appendChild(e)}this.fire("contentupdate")}},_updatePosition:function(){if(this._map){var t=this._map.latLngToLayerPoint(this._latlng),e=o.point(this.options.offset),i=this._getAnchor();this._zoomAnimated?o.DomUtil.setPosition(this._container,t.add(i)):e=e.add(t).add(i);var n=this._containerBottom=-e.y,s=this._containerLeft=-Math.round(this._containerWidth/2)+e.x;this._container.style.bottom=n+"px",this._container.style.left=s+"px"}},_getAnchor:function(){return[0,0]}}),o.Popup=o.DivOverlay.extend({options:{maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,autoClose:!0,className:""},openOn:function(t){return t.openPopup(this),this},onAdd:function(t){o.DivOverlay.prototype.onAdd.call(this,t),t.fire("popupopen",{popup:this}),this._source&&(this._source.fire("popupopen",{popup:this},!0),this._source instanceof o.Path||this._source.on("preclick",o.DomEvent.stopPropagation))},onRemove:function(t){o.DivOverlay.prototype.onRemove.call(this,t),t.fire("popupclose",{popup:this}),this._source&&(this._source.fire("popupclose",{popup:this},!0),this._source instanceof o.Path||this._source.off("preclick",o.DomEvent.stopPropagation))},getEvents:function(){var t=o.DivOverlay.prototype.getEvents.call(this);return("closeOnClick"in this.options?this.options.closeOnClick:this._map.options.closePopupOnClick)&&(t.preclick=this._close),this.options.keepInView&&(t.moveend=this._adjustPan),t},_close:function(){this._map&&this._map.closePopup(this)},_initLayout:function(){var t="leaflet-popup",e=this._container=o.DomUtil.create("div",t+" "+(this.options.className||"")+" leaflet-zoom-animated");if(this.options.closeButton){var i=this._closeButton=o.DomUtil.create("a",t+"-close-button",e);i.href="#close",i.innerHTML="&#215;",o.DomEvent.on(i,"click",this._onCloseButtonClick,this)}var n=this._wrapper=o.DomUtil.create("div",t+"-content-wrapper",e);this._contentNode=o.DomUtil.create("div",t+"-content",n),o.DomEvent.disableClickPropagation(n).disableScrollPropagation(this._contentNode).on(n,"contextmenu",o.DomEvent.stopPropagation),this._tipContainer=o.DomUtil.create("div",t+"-tip-container",e),this._tip=o.DomUtil.create("div",t+"-tip",this._tipContainer)},_updateLayout:function(){var t=this._contentNode,e=t.style;e.width="",e.whiteSpace="nowrap";var i=t.offsetWidth;i=Math.min(i,this.options.maxWidth),i=Math.max(i,this.options.minWidth),e.width=i+1+"px",e.whiteSpace="",e.height="";var n=t.offsetHeight,s=this.options.maxHeight,r="leaflet-popup-scrolled";s&&n>s?(e.height=s+"px",o.DomUtil.addClass(t,r)):o.DomUtil.removeClass(t,r),this._containerWidth=this._container.offsetWidth},_animateZoom:function(t){var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center),i=this._getAnchor();o.DomUtil.setPosition(this._container,e.add(i))},_adjustPan:function(){if(!(!this.options.autoPan||this._map._panAnim&&this._map._panAnim._inProgress)){var t=this._map,e=parseInt(o.DomUtil.getStyle(this._container,"marginBottom"),10)||0,i=this._container.offsetHeight+e,n=this._containerWidth,s=new o.Point(this._containerLeft,-i-this._containerBottom);s._add(o.DomUtil.getPosition(this._container));var r=t.layerPointToContainerPoint(s),a=o.point(this.options.autoPanPadding),h=o.point(this.options.autoPanPaddingTopLeft||a),l=o.point(this.options.autoPanPaddingBottomRight||a),u=t.getSize(),c=0,d=0;r.x+n+l.x>u.x&&(c=r.x+n-u.x+l.x),r.x-c-h.x<0&&(c=r.x-h.x),r.y+i+l.y>u.y&&(d=r.y+i-u.y+l.y),r.y-d-h.y<0&&(d=r.y-h.y),(c||d)&&t.fire("autopanstart").panBy([c,d])}},_onCloseButtonClick:function(t){this._close(),o.DomEvent.stop(t)},_getAnchor:function(){return o.point(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),o.popup=function(t,e){return new o.Popup(t,e)},o.Map.mergeOptions({closePopupOnClick:!0}),o.Map.include({openPopup:function(t,e,i){return t instanceof o.Popup||(t=new o.Popup(i).setContent(t)),e&&t.setLatLng(e),this.hasLayer(t)?this:(this._popup&&this._popup.options.autoClose&&this.closePopup(),this._popup=t,this.addLayer(t))},closePopup:function(t){return t&&t!==this._popup||(t=this._popup,this._popup=null),t&&this.removeLayer(t),this}}),o.Layer.include({bindPopup:function(t,e){return t instanceof o.Popup?(o.setOptions(t,e),this._popup=t,t._source=this):(this._popup&&!e||(this._popup=new o.Popup(e,this)),this._popup.setContent(t)),this._popupHandlersAdded||(this.on({click:this._openPopup,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(t,e){if(t instanceof o.Layer||(e=t,t=this),t instanceof o.FeatureGroup)for(var i in this._layers){t=this._layers[i];break}return e||(e=t.getCenter?t.getCenter():t.getLatLng()),this._popup&&this._map&&(this._popup._source=t,this._popup.update(),this._map.openPopup(this._popup,e)),this},closePopup:function(){return this._popup&&this._popup._close(),this},togglePopup:function(t){return this._popup&&(this._popup._map?this.closePopup():this.openPopup(t)),this},isPopupOpen:function(){return!!this._popup&&this._popup.isOpen()},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},getPopup:function(){return this._popup},_openPopup:function(t){var e=t.layer||t.target;if(this._popup&&this._map)return o.DomEvent.stop(t),e instanceof o.Path?void this.openPopup(t.layer||t.target,t.latlng):void(this._map.hasLayer(this._popup)&&this._popup._source===e?this.closePopup():this.openPopup(e,t.latlng))},_movePopup:function(t){this._popup.setLatLng(t.latlng)}}),o.Tooltip=o.DivOverlay.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,interactive:!1,opacity:.9},onAdd:function(t){o.DivOverlay.prototype.onAdd.call(this,t),this.setOpacity(this.options.opacity),t.fire("tooltipopen",{tooltip:this}),this._source&&this._source.fire("tooltipopen",{tooltip:this},!0)},onRemove:function(t){o.DivOverlay.prototype.onRemove.call(this,t),t.fire("tooltipclose",{tooltip:this}),this._source&&this._source.fire("tooltipclose",{tooltip:this},!0)},getEvents:function(){var t=o.DivOverlay.prototype.getEvents.call(this);return o.Browser.touch&&!this.options.permanent&&(t.preclick=this._close),t},_close:function(){this._map&&this._map.closeTooltip(this)},_initLayout:function(){var t="leaflet-tooltip",e=t+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=o.DomUtil.create("div",e)},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(t){var e=this._map,i=this._container,n=e.latLngToContainerPoint(e.getCenter()),s=e.layerPointToContainerPoint(t),r=this.options.direction,a=i.offsetWidth,h=i.offsetHeight,l=o.point(this.options.offset),u=this._getAnchor();"top"===r?t=t.add(o.point(-a/2+l.x,-h+l.y+u.y,!0)):"bottom"===r?t=t.subtract(o.point(a/2-l.x,-l.y,!0)):"center"===r?t=t.subtract(o.point(a/2+l.x,h/2-u.y+l.y,!0)):"right"===r||"auto"===r&&s.x<n.x?(r="right",t=t.add(o.point(l.x+u.x,u.y-h/2+l.y,!0))):(r="left",t=t.subtract(o.point(a+u.x-l.x,h/2-u.y-l.y,!0))),o.DomUtil.removeClass(i,"leaflet-tooltip-right"),o.DomUtil.removeClass(i,"leaflet-tooltip-left"),o.DomUtil.removeClass(i,"leaflet-tooltip-top"),o.DomUtil.removeClass(i,"leaflet-tooltip-bottom"),o.DomUtil.addClass(i,"leaflet-tooltip-"+r),o.DomUtil.setPosition(i,t)},_updatePosition:function(){var t=this._map.latLngToLayerPoint(this._latlng);this._setPosition(t)},setOpacity:function(t){this.options.opacity=t,this._container&&o.DomUtil.setOpacity(this._container,t)},_animateZoom:function(t){var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center);this._setPosition(e)},_getAnchor:function(){return o.point(this._source&&this._source._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}}),o.tooltip=function(t,e){return new o.Tooltip(t,e)},o.Map.include({openTooltip:function(t,e,i){return t instanceof o.Tooltip||(t=new o.Tooltip(i).setContent(t)),e&&t.setLatLng(e),this.hasLayer(t)?this:this.addLayer(t)},closeTooltip:function(t){return t&&this.removeLayer(t),this}}),o.Layer.include({bindTooltip:function(t,e){return t instanceof o.Tooltip?(o.setOptions(t,e),this._tooltip=t,t._source=this):(this._tooltip&&!e||(this._tooltip=o.tooltip(e,this)),this._tooltip.setContent(t)),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this)&&this.openTooltip(),this},unbindTooltip:function(){return this._tooltip&&(this._initTooltipInteractions(!0),this.closeTooltip(),this._tooltip=null),this},_initTooltipInteractions:function(t){if(t||!this._tooltipHandlersAdded){var e=t?"off":"on",i={remove:this.closeTooltip,move:this._moveTooltip};this._tooltip.options.permanent?i.add=this._openTooltip:(i.mouseover=this._openTooltip,i.mouseout=this.closeTooltip,this._tooltip.options.sticky&&(i.mousemove=this._moveTooltip),o.Browser.touch&&(i.click=this._openTooltip)),this[e](i),this._tooltipHandlersAdded=!t}},openTooltip:function(t,e){if(t instanceof o.Layer||(e=t,t=this),t instanceof o.FeatureGroup)for(var i in this._layers){t=this._layers[i];break}return e||(e=t.getCenter?t.getCenter():t.getLatLng()),this._tooltip&&this._map&&(this._tooltip._source=t,this._tooltip.update(),this._map.openTooltip(this._tooltip,e),this._tooltip.options.interactive&&this._tooltip._container&&(o.DomUtil.addClass(this._tooltip._container,"leaflet-clickable"),this.addInteractiveTarget(this._tooltip._container))),this},closeTooltip:function(){return this._tooltip&&(this._tooltip._close(),this._tooltip.options.interactive&&this._tooltip._container&&(o.DomUtil.removeClass(this._tooltip._container,"leaflet-clickable"),this.removeInteractiveTarget(this._tooltip._container))),this},toggleTooltip:function(t){return this._tooltip&&(this._tooltip._map?this.closeTooltip():this.openTooltip(t)),this},isTooltipOpen:function(){return this._tooltip.isOpen()},setTooltipContent:function(t){return this._tooltip&&this._tooltip.setContent(t),this},getTooltip:function(){return this._tooltip},_openTooltip:function(t){var e=t.layer||t.target;this._tooltip&&this._map&&this.openTooltip(e,this._tooltip.options.sticky?t.latlng:i)},_moveTooltip:function(t){var e,i,n=t.latlng;this._tooltip.options.sticky&&t.originalEvent&&(e=this._map.mouseEventToContainerPoint(t.originalEvent),i=this._map.containerPointToLayerPoint(e),n=this._map.layerPointToLatLng(i)),this._tooltip.setLatLng(n)}}),o.LayerGroup=o.Layer.extend({initialize:function(t){this._layers={};var e,i;if(t)for(e=0,i=t.length;e<i;e++)this.addLayer(t[e])},addLayer:function(t){var e=this.getLayerId(t);return this._layers[e]=t,this._map&&this._map.addLayer(t),this},removeLayer:function(t){var e=t in this._layers?t:this.getLayerId(t);return this._map&&this._layers[e]&&this._map.removeLayer(this._layers[e]),delete this._layers[e],this},hasLayer:function(t){return!!t&&(t in this._layers||this.getLayerId(t)in this._layers)},clearLayers:function(){for(var t in this._layers)this.removeLayer(this._layers[t]);return this},invoke:function(t){var e,i,n=Array.prototype.slice.call(arguments,1);for(e in this._layers)i=this._layers[e],i[t]&&i[t].apply(i,n);return this},onAdd:function(t){for(var e in this._layers)t.addLayer(this._layers[e])},onRemove:function(t){for(var e in this._layers)t.removeLayer(this._layers[e])},eachLayer:function(t,e){for(var i in this._layers)t.call(e,this._layers[i]);return this},getLayer:function(t){return this._layers[t]},getLayers:function(){var t=[];for(var e in this._layers)t.push(this._layers[e]);return t},setZIndex:function(t){return this.invoke("setZIndex",t)},getLayerId:function(t){return o.stamp(t)}}),o.layerGroup=function(t){return new o.LayerGroup(t)},o.FeatureGroup=o.LayerGroup.extend({addLayer:function(t){return this.hasLayer(t)?this:(t.addEventParent(this),o.LayerGroup.prototype.addLayer.call(this,t),this.fire("layeradd",{layer:t}))},removeLayer:function(t){return this.hasLayer(t)?(t in this._layers&&(t=this._layers[t]),t.removeEventParent(this),o.LayerGroup.prototype.removeLayer.call(this,t),this.fire("layerremove",{layer:t})):this},setStyle:function(t){return this.invoke("setStyle",t)},bringToFront:function(){return this.invoke("bringToFront")},bringToBack:function(){return this.invoke("bringToBack")},getBounds:function(){var t=new o.LatLngBounds;for(var e in this._layers){var i=this._layers[e];t.extend(i.getBounds?i.getBounds():i.getLatLng())}return t}}),o.featureGroup=function(t){return new o.FeatureGroup(t)},o.Renderer=o.Layer.extend({options:{padding:.1},initialize:function(t){o.setOptions(this,t),o.stamp(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),this._zoomAnimated&&o.DomUtil.addClass(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){o.DomUtil.remove(this._container),this.off("update",this._updatePaths,this)},getEvents:function(){var t={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(t.zoomanim=this._onAnimZoom),t},_onAnimZoom:function(t){this._updateTransform(t.center,t.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(t,e){var i=this._map.getZoomScale(e,this._zoom),n=o.DomUtil.getPosition(this._container),s=this._map.getSize().multiplyBy(.5+this.options.padding),r=this._map.project(this._center,e),a=this._map.project(t,e),h=a.subtract(r),l=s.multiplyBy(-i).add(n).add(s).subtract(h);o.Browser.any3d?o.DomUtil.setTransform(this._container,l,i):o.DomUtil.setPosition(this._container,l)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var t in this._layers)this._layers[t]._reset()},_onZoomEnd:function(){for(var t in this._layers)this._layers[t]._project()},_updatePaths:function(){for(var t in this._layers)this._layers[t]._update()},_update:function(){var t=this.options.padding,e=this._map.getSize(),i=this._map.containerPointToLayerPoint(e.multiplyBy(-t)).round();this._bounds=new o.Bounds(i,i.add(e.multiplyBy(1+2*t)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),o.Map.include({getRenderer:function(t){var e=t.options.renderer||this._getPaneRenderer(t.options.pane)||this.options.renderer||this._renderer;return e||(e=this._renderer=this.options.preferCanvas&&o.canvas()||o.svg()),this.hasLayer(e)||this.addLayer(e),e},_getPaneRenderer:function(t){if("overlayPane"===t||t===i)return!1;var e=this._paneRenderers[t];return e===i&&(e=o.SVG&&o.svg({pane:t})||o.Canvas&&o.canvas({pane:t}),this._paneRenderers[t]=e),e}}),o.Path=o.Layer.extend({options:{stroke:!0,color:"#3388ff",weight:3,opacity:1,lineCap:"round",lineJoin:"round",dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:.2,fillRule:"evenodd",interactive:!0},beforeAdd:function(t){this._renderer=t.getRenderer(this)},onAdd:function(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)},onRemove:function(){this._renderer._removePath(this)},redraw:function(){return this._map&&this._renderer._updatePath(this),this},setStyle:function(t){return o.setOptions(this,t),this._renderer&&this._renderer._updateStyle(this),this},bringToFront:function(){return this._renderer&&this._renderer._bringToFront(this),this},bringToBack:function(){return this._renderer&&this._renderer._bringToBack(this),this},getElement:function(){return this._path},_reset:function(){this._project(),this._update()},_clickTolerance:function(){return(this.options.stroke?this.options.weight/2:0)+(o.Browser.touch?10:0)}}),o.LineUtil={simplify:function(t,e){if(!e||!t.length)return t.slice();var i=e*e;return t=this._reducePoints(t,i),t=this._simplifyDP(t,i)},pointToSegmentDistance:function(t,e,i){return Math.sqrt(this._sqClosestPointOnSegment(t,e,i,!0))},closestPointOnSegment:function(t,e,i){return this._sqClosestPointOnSegment(t,e,i)},_simplifyDP:function(t,e){var n=t.length,o=typeof Uint8Array!=i+""?Uint8Array:Array,s=new o(n);s[0]=s[n-1]=1,this._simplifyDPStep(t,s,e,0,n-1);var r,a=[];for(r=0;r<n;r++)s[r]&&a.push(t[r]);return a},_simplifyDPStep:function(t,e,i,n,o){var s,r,a,h=0;for(r=n+1;r<=o-1;r++)a=this._sqClosestPointOnSegment(t[r],t[n],t[o],!0),a>h&&(s=r,h=a);h>i&&(e[s]=1,this._simplifyDPStep(t,e,i,n,s),this._simplifyDPStep(t,e,i,s,o))},_reducePoints:function(t,e){for(var i=[t[0]],n=1,o=0,s=t.length;n<s;n++)this._sqDist(t[n],t[o])>e&&(i.push(t[n]),o=n);return o<s-1&&i.push(t[s-1]),i},clipSegment:function(t,e,i,n,o){var s,r,a,h=n?this._lastCode:this._getBitCode(t,i),l=this._getBitCode(e,i);for(this._lastCode=l;;){if(!(h|l))return[t,e];if(h&l)return!1;s=h||l,r=this._getEdgeIntersection(t,e,s,i,o),a=this._getBitCode(r,i),s===h?(t=r,h=a):(e=r,l=a)}},_getEdgeIntersection:function(t,e,i,n,s){var r,a,h=e.x-t.x,l=e.y-t.y,u=n.min,c=n.max;return 8&i?(r=t.x+h*(c.y-t.y)/l,a=c.y):4&i?(r=t.x+h*(u.y-t.y)/l,a=u.y):2&i?(r=c.x,a=t.y+l*(c.x-t.x)/h):1&i&&(r=u.x,a=t.y+l*(u.x-t.x)/h),new o.Point(r,a,s)},_getBitCode:function(t,e){var i=0;return t.x<e.min.x?i|=1:t.x>e.max.x&&(i|=2),t.y<e.min.y?i|=4:t.y>e.max.y&&(i|=8),i},_sqDist:function(t,e){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n},_sqClosestPointOnSegment:function(t,e,i,n){var s,r=e.x,a=e.y,h=i.x-r,l=i.y-a,u=h*h+l*l;return u>0&&(s=((t.x-r)*h+(t.y-a)*l)/u,s>1?(r=i.x,a=i.y):s>0&&(r+=h*s,a+=l*s)),h=t.x-r,l=t.y-a,n?h*h+l*l:new o.Point(r,a)}},o.Polyline=o.Path.extend({options:{smoothFactor:1,noClip:!1},initialize:function(t,e){o.setOptions(this,e),this._setLatLngs(t)},getLatLngs:function(){return this._latlngs},setLatLngs:function(t){return this._setLatLngs(t),this.redraw()},isEmpty:function(){return!this._latlngs.length},closestLayerPoint:function(t){for(var e,i,n=1/0,s=null,r=o.LineUtil._sqClosestPointOnSegment,a=0,h=this._parts.length;a<h;a++)for(var l=this._parts[a],u=1,c=l.length;u<c;u++){e=l[u-1],i=l[u];var d=r(t,e,i,!0);d<n&&(n=d,s=r(t,e,i))}return s&&(s.distance=Math.sqrt(n)),s},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");var t,e,i,n,o,s,r,a=this._rings[0],h=a.length;if(!h)return null;for(t=0,e=0;t<h-1;t++)e+=a[t].distanceTo(a[t+1])/2;if(0===e)return this._map.layerPointToLatLng(a[0]);for(t=0,n=0;t<h-1;t++)if(o=a[t],s=a[t+1],i=o.distanceTo(s),n+=i,n>e)return r=(n-e)/i,this._map.layerPointToLatLng([s.x-r*(s.x-o.x),s.y-r*(s.y-o.y)])},getBounds:function(){return this._bounds},addLatLng:function(t,e){return e=e||this._defaultShape(),t=o.latLng(t),e.push(t),this._bounds.extend(t),this.redraw()},_setLatLngs:function(t){this._bounds=new o.LatLngBounds,this._latlngs=this._convertLatLngs(t)},_defaultShape:function(){return o.Polyline._flat(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(t){for(var e=[],i=o.Polyline._flat(t),n=0,s=t.length;n<s;n++)i?(e[n]=o.latLng(t[n]),this._bounds.extend(e[n])):e[n]=this._convertLatLngs(t[n]);return e},_project:function(){var t=new o.Bounds;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,t);var e=this._clickTolerance(),i=new o.Point(e,e);this._bounds.isValid()&&t.isValid()&&(t.min._subtract(i),t.max._add(i),this._pxBounds=t)},_projectLatlngs:function(t,e,i){var n,s,r=t[0]instanceof o.LatLng,a=t.length;if(r){for(s=[],n=0;n<a;n++)s[n]=this._map.latLngToLayerPoint(t[n]),i.extend(s[n]);e.push(s)}else for(n=0;n<a;n++)this._projectLatlngs(t[n],e,i)},_clipPoints:function(){var t=this._renderer._bounds;if(this._parts=[],this._pxBounds&&this._pxBounds.intersects(t)){if(this.options.noClip)return void(this._parts=this._rings);var e,i,n,s,r,a,h,l=this._parts;for(e=0,n=0,s=this._rings.length;e<s;e++)for(h=this._rings[e],i=0,r=h.length;i<r-1;i++)a=o.LineUtil.clipSegment(h[i],h[i+1],t,i,!0),a&&(l[n]=l[n]||[],l[n].push(a[0]),a[1]===h[i+1]&&i!==r-2||(l[n].push(a[1]),n++))}},_simplifyPoints:function(){for(var t=this._parts,e=this.options.smoothFactor,i=0,n=t.length;i<n;i++)t[i]=o.LineUtil.simplify(t[i],e)},_update:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())},_updatePath:function(){this._renderer._updatePoly(this)}}),o.polyline=function(t,e){return new o.Polyline(t,e)},o.Polyline._flat=function(t){return!o.Util.isArray(t[0])||"object"!=typeof t[0][0]&&"undefined"!=typeof t[0][0]},o.PolyUtil={},o.PolyUtil.clipPolygon=function(t,e,i){var n,s,r,a,h,l,u,c,d,_=[1,4,2,8],m=o.LineUtil;for(s=0,u=t.length;s<u;s++)t[s]._code=m._getBitCode(t[s],e);for(a=0;a<4;a++){for(c=_[a],n=[],s=0,u=t.length,r=u-1;s<u;r=s++)h=t[s],l=t[r],h._code&c?l._code&c||(d=m._getEdgeIntersection(l,h,c,e,i),d._code=m._getBitCode(d,e),n.push(d)):(l._code&c&&(d=m._getEdgeIntersection(l,h,c,e,i),d._code=m._getBitCode(d,e),n.push(d)),n.push(h));t=n}return t},o.Polygon=o.Polyline.extend({options:{fill:!0},isEmpty:function(){return!this._latlngs.length||!this._latlngs[0].length},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");var t,e,i,n,o,s,r,a,h,l=this._rings[0],u=l.length;if(!u)return null;for(s=r=a=0,t=0,e=u-1;t<u;e=t++)i=l[t],n=l[e],o=i.y*n.x-n.y*i.x,r+=(i.x+n.x)*o,a+=(i.y+n.y)*o,s+=3*o;return h=0===s?l[0]:[r/s,a/s],this._map.layerPointToLatLng(h)},_convertLatLngs:function(t){var e=o.Polyline.prototype._convertLatLngs.call(this,t),i=e.length;return i>=2&&e[0]instanceof o.LatLng&&e[0].equals(e[i-1])&&e.pop(),e},_setLatLngs:function(t){o.Polyline.prototype._setLatLngs.call(this,t),o.Polyline._flat(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return o.Polyline._flat(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var t=this._renderer._bounds,e=this.options.weight,i=new o.Point(e,e);if(t=new o.Bounds(t.min.subtract(i),t.max.add(i)),this._parts=[],this._pxBounds&&this._pxBounds.intersects(t)){if(this.options.noClip)return void(this._parts=this._rings);for(var n,s=0,r=this._rings.length;s<r;s++)n=o.PolyUtil.clipPolygon(this._rings[s],t,!0),n.length&&this._parts.push(n)}},_updatePath:function(){this._renderer._updatePoly(this,!0)}}),o.polygon=function(t,e){return new o.Polygon(t,e)},o.Rectangle=o.Polygon.extend({initialize:function(t,e){o.Polygon.prototype.initialize.call(this,this._boundsToLatLngs(t),e)},setBounds:function(t){return this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return t=o.latLngBounds(t),[t.getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}}),o.rectangle=function(t,e){return new o.Rectangle(t,e)},o.CircleMarker=o.Path.extend({options:{fill:!0,radius:10},initialize:function(t,e){o.setOptions(this,e),this._latlng=o.latLng(t),this._radius=this.options.radius},setLatLng:function(t){return this._latlng=o.latLng(t),this.redraw(),this.fire("move",{latlng:this._latlng})},getLatLng:function(){return this._latlng},setRadius:function(t){return this.options.radius=this._radius=t,this.redraw()},getRadius:function(){return this._radius},setStyle:function(t){var e=t&&t.radius||this._radius;return o.Path.prototype.setStyle.call(this,t),this.setRadius(e),this},_project:function(){this._point=this._map.latLngToLayerPoint(this._latlng),this._updateBounds()},_updateBounds:function(){var t=this._radius,e=this._radiusY||t,i=this._clickTolerance(),n=[t+i,e+i];this._pxBounds=new o.Bounds(this._point.subtract(n),this._point.add(n))},_update:function(){this._map&&this._updatePath()},_updatePath:function(){this._renderer._updateCircle(this)},_empty:function(){return this._radius&&!this._renderer._bounds.intersects(this._pxBounds)}}),o.circleMarker=function(t,e){return new o.CircleMarker(t,e)},o.Circle=o.CircleMarker.extend({initialize:function(t,e,i){if("number"==typeof e&&(e=o.extend({},i,{radius:e})),o.setOptions(this,e),this._latlng=o.latLng(t),isNaN(this.options.radius))throw new Error("Circle radius cannot be NaN");this._mRadius=this.options.radius},setRadius:function(t){return this._mRadius=t,
+this.redraw()},getRadius:function(){return this._mRadius},getBounds:function(){var t=[this._radius,this._radiusY||this._radius];return new o.LatLngBounds(this._map.layerPointToLatLng(this._point.subtract(t)),this._map.layerPointToLatLng(this._point.add(t)))},setStyle:o.Path.prototype.setStyle,_project:function(){var t=this._latlng.lng,e=this._latlng.lat,i=this._map,n=i.options.crs;if(n.distance===o.CRS.Earth.distance){var s=Math.PI/180,r=this._mRadius/o.CRS.Earth.R/s,a=i.project([e+r,t]),h=i.project([e-r,t]),l=a.add(h).divideBy(2),u=i.unproject(l).lat,c=Math.acos((Math.cos(r*s)-Math.sin(e*s)*Math.sin(u*s))/(Math.cos(e*s)*Math.cos(u*s)))/s;(isNaN(c)||0===c)&&(c=r/Math.cos(Math.PI/180*e)),this._point=l.subtract(i.getPixelOrigin()),this._radius=isNaN(c)?0:Math.max(Math.round(l.x-i.project([u,t-c]).x),1),this._radiusY=Math.max(Math.round(l.y-a.y),1)}else{var d=n.unproject(n.project(this._latlng).subtract([this._mRadius,0]));this._point=i.latLngToLayerPoint(this._latlng),this._radius=this._point.x-i.latLngToLayerPoint(d).x}this._updateBounds()}}),o.circle=function(t,e,i){return new o.Circle(t,e,i)},o.SVG=o.Renderer.extend({getEvents:function(){var t=o.Renderer.prototype.getEvents.call(this);return t.zoomstart=this._onZoomStart,t},_initContainer:function(){this._container=o.SVG.create("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=o.SVG.create("g"),this._container.appendChild(this._rootGroup)},_onZoomStart:function(){this._update()},_update:function(){if(!this._map._animatingZoom||!this._bounds){o.Renderer.prototype._update.call(this);var t=this._bounds,e=t.getSize(),i=this._container;this._svgSize&&this._svgSize.equals(e)||(this._svgSize=e,i.setAttribute("width",e.x),i.setAttribute("height",e.y)),o.DomUtil.setPosition(i,t.min),i.setAttribute("viewBox",[t.min.x,t.min.y,e.x,e.y].join(" ")),this.fire("update")}},_initPath:function(t){var e=t._path=o.SVG.create("path");t.options.className&&o.DomUtil.addClass(e,t.options.className),t.options.interactive&&o.DomUtil.addClass(e,"leaflet-interactive"),this._updateStyle(t),this._layers[o.stamp(t)]=t},_addPath:function(t){this._rootGroup.appendChild(t._path),t.addInteractiveTarget(t._path)},_removePath:function(t){o.DomUtil.remove(t._path),t.removeInteractiveTarget(t._path),delete this._layers[o.stamp(t)]},_updatePath:function(t){t._project(),t._update()},_updateStyle:function(t){var e=t._path,i=t.options;e&&(i.stroke?(e.setAttribute("stroke",i.color),e.setAttribute("stroke-opacity",i.opacity),e.setAttribute("stroke-width",i.weight),e.setAttribute("stroke-linecap",i.lineCap),e.setAttribute("stroke-linejoin",i.lineJoin),i.dashArray?e.setAttribute("stroke-dasharray",i.dashArray):e.removeAttribute("stroke-dasharray"),i.dashOffset?e.setAttribute("stroke-dashoffset",i.dashOffset):e.removeAttribute("stroke-dashoffset")):e.setAttribute("stroke","none"),i.fill?(e.setAttribute("fill",i.fillColor||i.color),e.setAttribute("fill-opacity",i.fillOpacity),e.setAttribute("fill-rule",i.fillRule||"evenodd")):e.setAttribute("fill","none"))},_updatePoly:function(t,e){this._setPath(t,o.SVG.pointsToPath(t._parts,e))},_updateCircle:function(t){var e=t._point,i=t._radius,n=t._radiusY||i,o="a"+i+","+n+" 0 1,0 ",s=t._empty()?"M0 0":"M"+(e.x-i)+","+e.y+o+2*i+",0 "+o+2*-i+",0 ";this._setPath(t,s)},_setPath:function(t,e){t._path.setAttribute("d",e)},_bringToFront:function(t){o.DomUtil.toFront(t._path)},_bringToBack:function(t){o.DomUtil.toBack(t._path)}}),o.extend(o.SVG,{create:function(t){return e.createElementNS("http://www.w3.org/2000/svg",t)},pointsToPath:function(t,e){var i,n,s,r,a,h,l="";for(i=0,s=t.length;i<s;i++){for(a=t[i],n=0,r=a.length;n<r;n++)h=a[n],l+=(n?"L":"M")+h.x+" "+h.y;l+=e?o.Browser.svg?"z":"x":""}return l||"M0 0"}}),o.Browser.svg=!(!e.createElementNS||!o.SVG.create("svg").createSVGRect),o.svg=function(t){return o.Browser.svg||o.Browser.vml?new o.SVG(t):null},o.Browser.vml=!o.Browser.svg&&function(){try{var t=e.createElement("div");t.innerHTML='<v:shape adj="1"/>';var i=t.firstChild;return i.style.behavior="url(#default#VML)",i&&"object"==typeof i.adj}catch(t){return!1}}(),o.SVG.include(o.Browser.vml?{_initContainer:function(){this._container=o.DomUtil.create("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(o.Renderer.prototype._update.call(this),this.fire("update"))},_initPath:function(t){var e=t._container=o.SVG.create("shape");o.DomUtil.addClass(e,"leaflet-vml-shape "+(this.options.className||"")),e.coordsize="1 1",t._path=o.SVG.create("path"),e.appendChild(t._path),this._updateStyle(t),this._layers[o.stamp(t)]=t},_addPath:function(t){var e=t._container;this._container.appendChild(e),t.options.interactive&&t.addInteractiveTarget(e)},_removePath:function(t){var e=t._container;o.DomUtil.remove(e),t.removeInteractiveTarget(e),delete this._layers[o.stamp(t)]},_updateStyle:function(t){var e=t._stroke,i=t._fill,n=t.options,s=t._container;s.stroked=!!n.stroke,s.filled=!!n.fill,n.stroke?(e||(e=t._stroke=o.SVG.create("stroke")),s.appendChild(e),e.weight=n.weight+"px",e.color=n.color,e.opacity=n.opacity,n.dashArray?e.dashStyle=o.Util.isArray(n.dashArray)?n.dashArray.join(" "):n.dashArray.replace(/( *, *)/g," "):e.dashStyle="",e.endcap=n.lineCap.replace("butt","flat"),e.joinstyle=n.lineJoin):e&&(s.removeChild(e),t._stroke=null),n.fill?(i||(i=t._fill=o.SVG.create("fill")),s.appendChild(i),i.color=n.fillColor||n.color,i.opacity=n.fillOpacity):i&&(s.removeChild(i),t._fill=null)},_updateCircle:function(t){var e=t._point.round(),i=Math.round(t._radius),n=Math.round(t._radiusY||i);this._setPath(t,t._empty()?"M0 0":"AL "+e.x+","+e.y+" "+i+","+n+" 0,23592600")},_setPath:function(t,e){t._path.v=e},_bringToFront:function(t){o.DomUtil.toFront(t._container)},_bringToBack:function(t){o.DomUtil.toBack(t._container)}}:{}),o.Browser.vml&&(o.SVG.create=function(){try{return e.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(t){return e.createElement("<lvml:"+t+' class="lvml">')}}catch(t){return function(t){return e.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}()),o.Canvas=o.Renderer.extend({getEvents:function(){var t=o.Renderer.prototype.getEvents.call(this);return t.viewprereset=this._onViewPreReset,t},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){o.Renderer.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var t=this._container=e.createElement("canvas");o.DomEvent.on(t,"mousemove",o.Util.throttle(this._onMouseMove,32,this),this).on(t,"click dblclick mousedown mouseup contextmenu",this._onClick,this).on(t,"mouseout",this._handleMouseOut,this),this._ctx=t.getContext("2d")},_updatePaths:function(){if(!this._postponeUpdatePaths){var t;this._redrawBounds=null;for(var e in this._layers)t=this._layers[e],t._update();this._redraw()}},_update:function(){if(!this._map._animatingZoom||!this._bounds){this._drawnLayers={},o.Renderer.prototype._update.call(this);var t=this._bounds,e=this._container,i=t.getSize(),n=o.Browser.retina?2:1;o.DomUtil.setPosition(e,t.min),e.width=n*i.x,e.height=n*i.y,e.style.width=i.x+"px",e.style.height=i.y+"px",o.Browser.retina&&this._ctx.scale(2,2),this._ctx.translate(-t.min.x,-t.min.y),this.fire("update")}},_reset:function(){o.Renderer.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(t){this._updateDashArray(t),this._layers[o.stamp(t)]=t;var e=t._order={layer:t,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=e),this._drawLast=e,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(t){this._requestRedraw(t)},_removePath:function(t){var e=t._order,i=e.next,n=e.prev;i?i.prev=n:this._drawLast=n,n?n.next=i:this._drawFirst=i,delete t._order,delete this._layers[o.stamp(t)],this._requestRedraw(t)},_updatePath:function(t){this._extendRedrawBounds(t),t._project(),t._update(),this._requestRedraw(t)},_updateStyle:function(t){this._updateDashArray(t),this._requestRedraw(t)},_updateDashArray:function(t){if(t.options.dashArray){var e,i=t.options.dashArray.split(","),n=[];for(e=0;e<i.length;e++)n.push(Number(i[e]));t.options._dashArray=n}},_requestRedraw:function(t){this._map&&(this._extendRedrawBounds(t),this._redrawRequest=this._redrawRequest||o.Util.requestAnimFrame(this._redraw,this))},_extendRedrawBounds:function(t){var e=(t.options.weight||0)+1;this._redrawBounds=this._redrawBounds||new o.Bounds,this._redrawBounds.extend(t._pxBounds.min.subtract([e,e])),this._redrawBounds.extend(t._pxBounds.max.add([e,e]))},_redraw:function(){this._redrawRequest=null,this._redrawBounds&&(this._redrawBounds.min._floor(),this._redrawBounds.max._ceil()),this._clear(),this._draw(),this._redrawBounds=null},_clear:function(){var t=this._redrawBounds;if(t){var e=t.getSize();this._ctx.clearRect(t.min.x,t.min.y,e.x,e.y)}else this._ctx.clearRect(0,0,this._container.width,this._container.height)},_draw:function(){var t,e=this._redrawBounds;if(this._ctx.save(),e){var i=e.getSize();this._ctx.beginPath(),this._ctx.rect(e.min.x,e.min.y,i.x,i.y),this._ctx.clip()}this._drawing=!0;for(var n=this._drawFirst;n;n=n.next)t=n.layer,(!e||t._pxBounds&&t._pxBounds.intersects(e))&&t._updatePath();this._drawing=!1,this._ctx.restore()},_updatePoly:function(t,e){if(this._drawing){var i,n,o,s,r=t._parts,a=r.length,h=this._ctx;if(a){for(this._drawnLayers[t._leaflet_id]=t,h.beginPath(),h.setLineDash&&h.setLineDash(t.options&&t.options._dashArray||[]),i=0;i<a;i++){for(n=0,o=r[i].length;n<o;n++)s=r[i][n],h[n?"lineTo":"moveTo"](s.x,s.y);e&&h.closePath()}this._fillStroke(h,t)}}},_updateCircle:function(t){if(this._drawing&&!t._empty()){var e=t._point,i=this._ctx,n=t._radius,o=(t._radiusY||n)/n;this._drawnLayers[t._leaflet_id]=t,1!==o&&(i.save(),i.scale(1,o)),i.beginPath(),i.arc(e.x,e.y/o,n,0,2*Math.PI,!1),1!==o&&i.restore(),this._fillStroke(i,t)}},_fillStroke:function(t,e){var i=e.options;i.fill&&(t.globalAlpha=i.fillOpacity,t.fillStyle=i.fillColor||i.color,t.fill(i.fillRule||"evenodd")),i.stroke&&0!==i.weight&&(t.globalAlpha=i.opacity,t.lineWidth=i.weight,t.strokeStyle=i.color,t.lineCap=i.lineCap,t.lineJoin=i.lineJoin,t.stroke())},_onClick:function(t){for(var e,i,n=this._map.mouseEventToLayerPoint(t),s=this._drawFirst;s;s=s.next)e=s.layer,e.options.interactive&&e._containsPoint(n)&&!this._map._draggableMoved(e)&&(i=e);i&&(o.DomEvent._fakeStop(t),this._fireEvent([i],t))},_onMouseMove:function(t){if(this._map&&!this._map.dragging.moving()&&!this._map._animatingZoom){var e=this._map.mouseEventToLayerPoint(t);this._handleMouseHover(t,e)}},_handleMouseOut:function(t){var e=this._hoveredLayer;e&&(o.DomUtil.removeClass(this._container,"leaflet-interactive"),this._fireEvent([e],t,"mouseout"),this._hoveredLayer=null)},_handleMouseHover:function(t,e){for(var i,n,s=this._drawFirst;s;s=s.next)i=s.layer,i.options.interactive&&i._containsPoint(e)&&(n=i);n!==this._hoveredLayer&&(this._handleMouseOut(t),n&&(o.DomUtil.addClass(this._container,"leaflet-interactive"),this._fireEvent([n],t,"mouseover"),this._hoveredLayer=n)),this._hoveredLayer&&this._fireEvent([this._hoveredLayer],t)},_fireEvent:function(t,e,i){this._map._fireDOMEvent(e,i||e.type,t)},_bringToFront:function(t){var e=t._order,i=e.next,n=e.prev;i&&(i.prev=n,n?n.next=i:i&&(this._drawFirst=i),e.prev=this._drawLast,this._drawLast.next=e,e.next=null,this._drawLast=e,this._requestRedraw(t))},_bringToBack:function(t){var e=t._order,i=e.next,n=e.prev;n&&(n.next=i,i?i.prev=n:n&&(this._drawLast=n),e.prev=null,e.next=this._drawFirst,this._drawFirst.prev=e,this._drawFirst=e,this._requestRedraw(t))}}),o.Browser.canvas=function(){return!!e.createElement("canvas").getContext}(),o.canvas=function(t){return o.Browser.canvas?new o.Canvas(t):null},o.Polyline.prototype._containsPoint=function(t,e){var i,n,s,r,a,h,l=this._clickTolerance();if(!this._pxBounds.contains(t))return!1;for(i=0,r=this._parts.length;i<r;i++)for(h=this._parts[i],n=0,a=h.length,s=a-1;n<a;s=n++)if((e||0!==n)&&o.LineUtil.pointToSegmentDistance(t,h[s],h[n])<=l)return!0;return!1},o.Polygon.prototype._containsPoint=function(t){var e,i,n,s,r,a,h,l,u=!1;if(!this._pxBounds.contains(t))return!1;for(s=0,h=this._parts.length;s<h;s++)for(e=this._parts[s],r=0,l=e.length,a=l-1;r<l;a=r++)i=e[r],n=e[a],i.y>t.y!=n.y>t.y&&t.x<(n.x-i.x)*(t.y-i.y)/(n.y-i.y)+i.x&&(u=!u);return u||o.Polyline.prototype._containsPoint.call(this,t,!0)},o.CircleMarker.prototype._containsPoint=function(t){return t.distanceTo(this._point)<=this._radius+this._clickTolerance()},o.GeoJSON=o.FeatureGroup.extend({initialize:function(t,e){o.setOptions(this,e),this._layers={},t&&this.addData(t)},addData:function(t){var e,i,n,s=o.Util.isArray(t)?t:t.features;if(s){for(e=0,i=s.length;e<i;e++)n=s[e],(n.geometries||n.geometry||n.features||n.coordinates)&&this.addData(n);return this}var r=this.options;if(r.filter&&!r.filter(t))return this;var a=o.GeoJSON.geometryToLayer(t,r);return a?(a.feature=o.GeoJSON.asFeature(t),a.defaultOptions=a.options,this.resetStyle(a),r.onEachFeature&&r.onEachFeature(t,a),this.addLayer(a)):this},resetStyle:function(t){return t.options=o.Util.extend({},t.defaultOptions),this._setLayerStyle(t,this.options.style),this},setStyle:function(t){return this.eachLayer(function(e){this._setLayerStyle(e,t)},this)},_setLayerStyle:function(t,e){"function"==typeof e&&(e=e(t.feature)),t.setStyle&&t.setStyle(e)}}),o.extend(o.GeoJSON,{geometryToLayer:function(t,e){var i,n,s,r,a="Feature"===t.type?t.geometry:t,h=a?a.coordinates:null,l=[],u=e&&e.pointToLayer,c=e&&e.coordsToLatLng||this.coordsToLatLng;if(!h&&!a)return null;switch(a.type){case"Point":return i=c(h),u?u(t,i):new o.Marker(i);case"MultiPoint":for(s=0,r=h.length;s<r;s++)i=c(h[s]),l.push(u?u(t,i):new o.Marker(i));return new o.FeatureGroup(l);case"LineString":case"MultiLineString":return n=this.coordsToLatLngs(h,"LineString"===a.type?0:1,c),new o.Polyline(n,e);case"Polygon":case"MultiPolygon":return n=this.coordsToLatLngs(h,"Polygon"===a.type?1:2,c),new o.Polygon(n,e);case"GeometryCollection":for(s=0,r=a.geometries.length;s<r;s++){var d=this.geometryToLayer({geometry:a.geometries[s],type:"Feature",properties:t.properties},e);d&&l.push(d)}return new o.FeatureGroup(l);default:throw new Error("Invalid GeoJSON object.")}},coordsToLatLng:function(t){return new o.LatLng(t[1],t[0],t[2])},coordsToLatLngs:function(t,e,i){for(var n,o=[],s=0,r=t.length;s<r;s++)n=e?this.coordsToLatLngs(t[s],e-1,i):(i||this.coordsToLatLng)(t[s]),o.push(n);return o},latLngToCoords:function(t){return t.alt!==i?[t.lng,t.lat,t.alt]:[t.lng,t.lat]},latLngsToCoords:function(t,e,i){for(var n=[],s=0,r=t.length;s<r;s++)n.push(e?o.GeoJSON.latLngsToCoords(t[s],e-1,i):o.GeoJSON.latLngToCoords(t[s]));return!e&&i&&n.push(n[0]),n},getFeature:function(t,e){return t.feature?o.extend({},t.feature,{geometry:e}):o.GeoJSON.asFeature(e)},asFeature:function(t){return"Feature"===t.type||"FeatureCollection"===t.type?t:{type:"Feature",properties:{},geometry:t}}});var a={toGeoJSON:function(){return o.GeoJSON.getFeature(this,{type:"Point",coordinates:o.GeoJSON.latLngToCoords(this.getLatLng())})}};o.Marker.include(a),o.Circle.include(a),o.CircleMarker.include(a),o.Polyline.prototype.toGeoJSON=function(){var t=!o.Polyline._flat(this._latlngs),e=o.GeoJSON.latLngsToCoords(this._latlngs,t?1:0);return o.GeoJSON.getFeature(this,{type:(t?"Multi":"")+"LineString",coordinates:e})},o.Polygon.prototype.toGeoJSON=function(){var t=!o.Polyline._flat(this._latlngs),e=t&&!o.Polyline._flat(this._latlngs[0]),i=o.GeoJSON.latLngsToCoords(this._latlngs,e?2:t?1:0,!0);return t||(i=[i]),o.GeoJSON.getFeature(this,{type:(e?"Multi":"")+"Polygon",coordinates:i})},o.LayerGroup.include({toMultiPoint:function(){var t=[];return this.eachLayer(function(e){t.push(e.toGeoJSON().geometry.coordinates)}),o.GeoJSON.getFeature(this,{type:"MultiPoint",coordinates:t})},toGeoJSON:function(){var t=this.feature&&this.feature.geometry&&this.feature.geometry.type;if("MultiPoint"===t)return this.toMultiPoint();var e="GeometryCollection"===t,i=[];return this.eachLayer(function(t){if(t.toGeoJSON){var n=t.toGeoJSON();i.push(e?n.geometry:o.GeoJSON.asFeature(n))}}),e?o.GeoJSON.getFeature(this,{geometries:i,type:"GeometryCollection"}):{type:"FeatureCollection",features:i}}}),o.geoJSON=function(t,e){return new o.GeoJSON(t,e)},o.geoJson=o.geoJSON,o.Draggable=o.Evented.extend({options:{clickTolerance:3},statics:{START:o.Browser.touch?["touchstart","mousedown"]:["mousedown"],END:{mousedown:"mouseup",touchstart:"touchend",pointerdown:"touchend",MSPointerDown:"touchend"},MOVE:{mousedown:"mousemove",touchstart:"touchmove",pointerdown:"touchmove",MSPointerDown:"touchmove"}},initialize:function(t,e,i){this._element=t,this._dragStartTarget=e||t,this._preventOutline=i},enable:function(){this._enabled||(o.DomEvent.on(this._dragStartTarget,o.Draggable.START.join(" "),this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(o.Draggable._dragging===this&&this.finishDrag(),o.DomEvent.off(this._dragStartTarget,o.Draggable.START.join(" "),this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(t){if(!t._simulated&&this._enabled&&(this._moved=!1,!o.DomUtil.hasClass(this._element,"leaflet-zoom-anim")&&!(o.Draggable._dragging||t.shiftKey||1!==t.which&&1!==t.button&&!t.touches||(o.Draggable._dragging=this,this._preventOutline&&o.DomUtil.preventOutline(this._element),o.DomUtil.disableImageDrag(),o.DomUtil.disableTextSelection(),this._moving)))){this.fire("down");var i=t.touches?t.touches[0]:t;this._startPoint=new o.Point(i.clientX,i.clientY),o.DomEvent.on(e,o.Draggable.MOVE[t.type],this._onMove,this).on(e,o.Draggable.END[t.type],this._onUp,this)}},_onMove:function(i){if(!i._simulated&&this._enabled){if(i.touches&&i.touches.length>1)return void(this._moved=!0);var n=i.touches&&1===i.touches.length?i.touches[0]:i,s=new o.Point(n.clientX,n.clientY),r=s.subtract(this._startPoint);(r.x||r.y)&&(Math.abs(r.x)+Math.abs(r.y)<this.options.clickTolerance||(o.DomEvent.preventDefault(i),this._moved||(this.fire("dragstart"),this._moved=!0,this._startPos=o.DomUtil.getPosition(this._element).subtract(r),o.DomUtil.addClass(e.body,"leaflet-dragging"),this._lastTarget=i.target||i.srcElement,t.SVGElementInstance&&this._lastTarget instanceof SVGElementInstance&&(this._lastTarget=this._lastTarget.correspondingUseElement),o.DomUtil.addClass(this._lastTarget,"leaflet-drag-target")),this._newPos=this._startPos.add(r),this._moving=!0,o.Util.cancelAnimFrame(this._animRequest),this._lastEvent=i,this._animRequest=o.Util.requestAnimFrame(this._updatePosition,this,!0)))}},_updatePosition:function(){var t={originalEvent:this._lastEvent};this.fire("predrag",t),o.DomUtil.setPosition(this._element,this._newPos),this.fire("drag",t)},_onUp:function(t){!t._simulated&&this._enabled&&this.finishDrag()},finishDrag:function(){o.DomUtil.removeClass(e.body,"leaflet-dragging"),this._lastTarget&&(o.DomUtil.removeClass(this._lastTarget,"leaflet-drag-target"),this._lastTarget=null);for(var t in o.Draggable.MOVE)o.DomEvent.off(e,o.Draggable.MOVE[t],this._onMove,this).off(e,o.Draggable.END[t],this._onUp,this);o.DomUtil.enableImageDrag(),o.DomUtil.enableTextSelection(),this._moved&&this._moving&&(o.Util.cancelAnimFrame(this._animRequest),this.fire("dragend",{distance:this._newPos.distanceTo(this._startPos)})),this._moving=!1,o.Draggable._dragging=!1}}),o.Handler=o.Class.extend({initialize:function(t){this._map=t},enable:function(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}}),o.Map.mergeOptions({dragging:!0,inertia:!o.Browser.android23,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0}),o.Map.Drag=o.Handler.extend({addHooks:function(){if(!this._draggable){var t=this._map;this._draggable=new o.Draggable(t._mapPane,t._container),this._draggable.on({down:this._onDown,dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),t.on("zoomend",this._onZoomEnd,this),t.whenReady(this._onZoomEnd,this))}o.DomUtil.addClass(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){o.DomUtil.removeClass(this._map._container,"leaflet-grab"),o.DomUtil.removeClass(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDown:function(){this._map._stop()},_onDragStart:function(){var t=this._map;if(this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var e=o.latLngBounds(this._map.options.maxBounds);this._offsetLimit=o.bounds(this._map.latLngToContainerPoint(e.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(e.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;t.fire("movestart").fire("dragstart"),t.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(t){if(this._map.options.inertia){var e=this._lastTime=+new Date,i=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(i),this._times.push(e),e-this._times[0]>50&&(this._positions.shift(),this._times.shift())}this._map.fire("move",t).fire("drag",t)},_onZoomEnd:function(){var t=this._map.getSize().divideBy(2),e=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=e.subtract(t).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(t,e){return t-(t-e)*this._viscosity},_onPreDragLimit:function(){if(this._viscosity&&this._offsetLimit){var t=this._draggable._newPos.subtract(this._draggable._startPos),e=this._offsetLimit;t.x<e.min.x&&(t.x=this._viscousLimit(t.x,e.min.x)),t.y<e.min.y&&(t.y=this._viscousLimit(t.y,e.min.y)),t.x>e.max.x&&(t.x=this._viscousLimit(t.x,e.max.x)),t.y>e.max.y&&(t.y=this._viscousLimit(t.y,e.max.y)),this._draggable._newPos=this._draggable._startPos.add(t)}},_onPreDragWrap:function(){var t=this._worldWidth,e=Math.round(t/2),i=this._initialWorldOffset,n=this._draggable._newPos.x,o=(n-e+i)%t+e-i,s=(n+e+i)%t-e-i,r=Math.abs(o+i)<Math.abs(s+i)?o:s;this._draggable._absPos=this._draggable._newPos.clone(),this._draggable._newPos.x=r},_onDragEnd:function(t){var e=this._map,i=e.options,n=!i.inertia||this._times.length<2;if(e.fire("dragend",t),n)e.fire("moveend");else{var s=this._lastPos.subtract(this._positions[0]),r=(this._lastTime-this._times[0])/1e3,a=i.easeLinearity,h=s.multiplyBy(a/r),l=h.distanceTo([0,0]),u=Math.min(i.inertiaMaxSpeed,l),c=h.multiplyBy(u/l),d=u/(i.inertiaDeceleration*a),_=c.multiplyBy(-d/2).round();_.x||_.y?(_=e._limitOffset(_,e.options.maxBounds),o.Util.requestAnimFrame(function(){e.panBy(_,{duration:d,easeLinearity:a,noMoveStart:!0,animate:!0})})):e.fire("moveend")}}}),o.Map.addInitHook("addHandler","dragging",o.Map.Drag),o.Map.mergeOptions({doubleClickZoom:!0}),o.Map.DoubleClickZoom=o.Handler.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(t){var e=this._map,i=e.getZoom(),n=e.options.zoomDelta,o=t.originalEvent.shiftKey?i-n:i+n;"center"===e.options.doubleClickZoom?e.setZoom(o):e.setZoomAround(t.containerPoint,o)}}),o.Map.addInitHook("addHandler","doubleClickZoom",o.Map.DoubleClickZoom),o.Map.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60}),o.Map.ScrollWheelZoom=o.Handler.extend({addHooks:function(){o.DomEvent.on(this._map._container,"mousewheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){o.DomEvent.off(this._map._container,"mousewheel",this._onWheelScroll,this)},_onWheelScroll:function(t){var e=o.DomEvent.getWheelDelta(t),i=this._map.options.wheelDebounceTime;this._delta+=e,this._lastMousePos=this._map.mouseEventToContainerPoint(t),this._startTime||(this._startTime=+new Date);var n=Math.max(i-(+new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(o.bind(this._performZoom,this),n),o.DomEvent.stop(t)},_performZoom:function(){var t=this._map,e=t.getZoom(),i=this._map.options.zoomSnap||0;t._stop();var n=this._delta/(4*this._map.options.wheelPxPerZoomLevel),o=4*Math.log(2/(1+Math.exp(-Math.abs(n))))/Math.LN2,s=i?Math.ceil(o/i)*i:o,r=t._limitZoom(e+(this._delta>0?s:-s))-e;this._delta=0,this._startTime=null,r&&("center"===t.options.scrollWheelZoom?t.setZoom(e+r):t.setZoomAround(this._lastMousePos,e+r))}}),o.Map.addInitHook("addHandler","scrollWheelZoom",o.Map.ScrollWheelZoom),o.extend(o.DomEvent,{_touchstart:o.Browser.msPointer?"MSPointerDown":o.Browser.pointer?"pointerdown":"touchstart",_touchend:o.Browser.msPointer?"MSPointerUp":o.Browser.pointer?"pointerup":"touchend",addDoubleTapListener:function(t,e,i){function n(t){var e;if(o.Browser.pointer){if(!o.Browser.edge||"mouse"===t.pointerType)return;e=o.DomEvent._pointersCount}else e=t.touches.length;if(!(e>1)){var i=Date.now(),n=i-(r||i);a=t.touches?t.touches[0]:t,h=n>0&&n<=l,r=i}}function s(t){if(h&&!a.cancelBubble){if(o.Browser.pointer){if(!o.Browser.edge||"mouse"===t.pointerType)return;var i,n,s={};for(n in a)i=a[n],s[n]=i&&i.bind?i.bind(a):i;a=s}a.type="dblclick",e(a),r=null}}var r,a,h=!1,l=250,u="_leaflet_",c=this._touchstart,d=this._touchend;return t[u+c+i]=n,t[u+d+i]=s,t[u+"dblclick"+i]=e,t.addEventListener(c,n,!1),t.addEventListener(d,s,!1),t.addEventListener("dblclick",e,!1),this},removeDoubleTapListener:function(t,e){var i="_leaflet_",n=t[i+this._touchstart+e],s=t[i+this._touchend+e],r=t[i+"dblclick"+e];return t.removeEventListener(this._touchstart,n,!1),t.removeEventListener(this._touchend,s,!1),o.Browser.edge||t.removeEventListener("dblclick",r,!1),this}}),o.extend(o.DomEvent,{POINTER_DOWN:o.Browser.msPointer?"MSPointerDown":"pointerdown",POINTER_MOVE:o.Browser.msPointer?"MSPointerMove":"pointermove",POINTER_UP:o.Browser.msPointer?"MSPointerUp":"pointerup",POINTER_CANCEL:o.Browser.msPointer?"MSPointerCancel":"pointercancel",TAG_WHITE_LIST:["INPUT","SELECT","OPTION"],_pointers:{},_pointersCount:0,addPointerListener:function(t,e,i,n){return"touchstart"===e?this._addPointerStart(t,i,n):"touchmove"===e?this._addPointerMove(t,i,n):"touchend"===e&&this._addPointerEnd(t,i,n),this},removePointerListener:function(t,e,i){var n=t["_leaflet_"+e+i];return"touchstart"===e?t.removeEventListener(this.POINTER_DOWN,n,!1):"touchmove"===e?t.removeEventListener(this.POINTER_MOVE,n,!1):"touchend"===e&&(t.removeEventListener(this.POINTER_UP,n,!1),t.removeEventListener(this.POINTER_CANCEL,n,!1)),this},_addPointerStart:function(t,i,n){var s=o.bind(function(t){if("mouse"!==t.pointerType&&t.MSPOINTER_TYPE_MOUSE&&t.pointerType!==t.MSPOINTER_TYPE_MOUSE){if(!(this.TAG_WHITE_LIST.indexOf(t.target.tagName)<0))return;o.DomEvent.preventDefault(t)}this._handlePointer(t,i)},this);if(t["_leaflet_touchstart"+n]=s,t.addEventListener(this.POINTER_DOWN,s,!1),!this._pointerDocListener){var r=o.bind(this._globalPointerUp,this);e.documentElement.addEventListener(this.POINTER_DOWN,o.bind(this._globalPointerDown,this),!0),e.documentElement.addEventListener(this.POINTER_MOVE,o.bind(this._globalPointerMove,this),!0),e.documentElement.addEventListener(this.POINTER_UP,r,!0),e.documentElement.addEventListener(this.POINTER_CANCEL,r,!0),this._pointerDocListener=!0}},_globalPointerDown:function(t){this._pointers[t.pointerId]=t,this._pointersCount++},_globalPointerMove:function(t){this._pointers[t.pointerId]&&(this._pointers[t.pointerId]=t)},_globalPointerUp:function(t){delete this._pointers[t.pointerId],this._pointersCount--},_handlePointer:function(t,e){t.touches=[];for(var i in this._pointers)t.touches.push(this._pointers[i]);t.changedTouches=[t],e(t)},_addPointerMove:function(t,e,i){var n=o.bind(function(t){(t.pointerType!==t.MSPOINTER_TYPE_MOUSE&&"mouse"!==t.pointerType||0!==t.buttons)&&this._handlePointer(t,e)},this);t["_leaflet_touchmove"+i]=n,t.addEventListener(this.POINTER_MOVE,n,!1)},_addPointerEnd:function(t,e,i){var n=o.bind(function(t){this._handlePointer(t,e)},this);t["_leaflet_touchend"+i]=n,t.addEventListener(this.POINTER_UP,n,!1),t.addEventListener(this.POINTER_CANCEL,n,!1)}}),o.Map.mergeOptions({touchZoom:o.Browser.touch&&!o.Browser.android23,bounceAtZoomLimits:!0}),o.Map.TouchZoom=o.Handler.extend({addHooks:function(){o.DomUtil.addClass(this._map._container,"leaflet-touch-zoom"),o.DomEvent.on(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){o.DomUtil.removeClass(this._map._container,"leaflet-touch-zoom"),o.DomEvent.off(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(t){var i=this._map;if(t.touches&&2===t.touches.length&&!i._animatingZoom&&!this._zooming){var n=i.mouseEventToContainerPoint(t.touches[0]),s=i.mouseEventToContainerPoint(t.touches[1]);this._centerPoint=i.getSize()._divideBy(2),this._startLatLng=i.containerPointToLatLng(this._centerPoint),"center"!==i.options.touchZoom&&(this._pinchStartLatLng=i.containerPointToLatLng(n.add(s)._divideBy(2))),this._startDist=n.distanceTo(s),this._startZoom=i.getZoom(),this._moved=!1,this._zooming=!0,i._stop(),o.DomEvent.on(e,"touchmove",this._onTouchMove,this).on(e,"touchend",this._onTouchEnd,this),o.DomEvent.preventDefault(t)}},_onTouchMove:function(t){if(t.touches&&2===t.touches.length&&this._zooming){var e=this._map,i=e.mouseEventToContainerPoint(t.touches[0]),n=e.mouseEventToContainerPoint(t.touches[1]),s=i.distanceTo(n)/this._startDist;if(this._zoom=e.getScaleZoom(s,this._startZoom),!e.options.bounceAtZoomLimits&&(this._zoom<e.getMinZoom()&&s<1||this._zoom>e.getMaxZoom()&&s>1)&&(this._zoom=e._limitZoom(this._zoom)),"center"===e.options.touchZoom){if(this._center=this._startLatLng,1===s)return}else{var r=i._add(n)._divideBy(2)._subtract(this._centerPoint);if(1===s&&0===r.x&&0===r.y)return;this._center=e.unproject(e.project(this._pinchStartLatLng,this._zoom).subtract(r),this._zoom)}this._moved||(e._moveStart(!0),this._moved=!0),o.Util.cancelAnimFrame(this._animRequest);var a=o.bind(e._move,e,this._center,this._zoom,{pinch:!0,round:!1});this._animRequest=o.Util.requestAnimFrame(a,this,!0),o.DomEvent.preventDefault(t)}},_onTouchEnd:function(){return this._moved&&this._zooming?(this._zooming=!1,o.Util.cancelAnimFrame(this._animRequest),o.DomEvent.off(e,"touchmove",this._onTouchMove).off(e,"touchend",this._onTouchEnd),void(this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom)))):void(this._zooming=!1)}}),o.Map.addInitHook("addHandler","touchZoom",o.Map.TouchZoom),o.Map.mergeOptions({tap:!0,tapTolerance:15}),o.Map.Tap=o.Handler.extend({addHooks:function(){o.DomEvent.on(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){o.DomEvent.off(this._map._container,"touchstart",this._onDown,this)},_onDown:function(t){if(t.touches){if(o.DomEvent.preventDefault(t),this._fireClick=!0,t.touches.length>1)return this._fireClick=!1,void clearTimeout(this._holdTimeout);var i=t.touches[0],n=i.target;this._startPos=this._newPos=new o.Point(i.clientX,i.clientY),n.tagName&&"a"===n.tagName.toLowerCase()&&o.DomUtil.addClass(n,"leaflet-active"),this._holdTimeout=setTimeout(o.bind(function(){this._isTapValid()&&(this._fireClick=!1,this._onUp(),this._simulateEvent("contextmenu",i))},this),1e3),this._simulateEvent("mousedown",i),o.DomEvent.on(e,{touchmove:this._onMove,touchend:this._onUp},this)}},_onUp:function(t){if(clearTimeout(this._holdTimeout),o.DomEvent.off(e,{touchmove:this._onMove,touchend:this._onUp},this),this._fireClick&&t&&t.changedTouches){var i=t.changedTouches[0],n=i.target;n&&n.tagName&&"a"===n.tagName.toLowerCase()&&o.DomUtil.removeClass(n,"leaflet-active"),this._simulateEvent("mouseup",i),
+this._isTapValid()&&this._simulateEvent("click",i)}},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_onMove:function(t){var e=t.touches[0];this._newPos=new o.Point(e.clientX,e.clientY),this._simulateEvent("mousemove",e)},_simulateEvent:function(i,n){var o=e.createEvent("MouseEvents");o._simulated=!0,n.target._simulatedClick=!0,o.initMouseEvent(i,!0,!0,t,1,n.screenX,n.screenY,n.clientX,n.clientY,!1,!1,!1,!1,0,null),n.target.dispatchEvent(o)}}),o.Browser.touch&&!o.Browser.pointer&&o.Map.addInitHook("addHandler","tap",o.Map.Tap),o.Map.mergeOptions({boxZoom:!0}),o.Map.BoxZoom=o.Handler.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane},addHooks:function(){o.DomEvent.on(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){o.DomEvent.off(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_resetState:function(){this._moved=!1},_onMouseDown:function(t){return!(!t.shiftKey||1!==t.which&&1!==t.button)&&(this._resetState(),o.DomUtil.disableTextSelection(),o.DomUtil.disableImageDrag(),this._startPoint=this._map.mouseEventToContainerPoint(t),void o.DomEvent.on(e,{contextmenu:o.DomEvent.stop,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this))},_onMouseMove:function(t){this._moved||(this._moved=!0,this._box=o.DomUtil.create("div","leaflet-zoom-box",this._container),o.DomUtil.addClass(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(t);var e=new o.Bounds(this._point,this._startPoint),i=e.getSize();o.DomUtil.setPosition(this._box,e.min),this._box.style.width=i.x+"px",this._box.style.height=i.y+"px"},_finish:function(){this._moved&&(o.DomUtil.remove(this._box),o.DomUtil.removeClass(this._container,"leaflet-crosshair")),o.DomUtil.enableTextSelection(),o.DomUtil.enableImageDrag(),o.DomEvent.off(e,{contextmenu:o.DomEvent.stop,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(t){if((1===t.which||1===t.button)&&(this._finish(),this._moved)){setTimeout(o.bind(this._resetState,this),0);var e=new o.LatLngBounds(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(e).fire("boxzoomend",{boxZoomBounds:e})}},_onKeyDown:function(t){27===t.keyCode&&this._finish()}}),o.Map.addInitHook("addHandler","boxZoom",o.Map.BoxZoom),o.Map.mergeOptions({keyboard:!0,keyboardPanDelta:80}),o.Map.Keyboard=o.Handler.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,54,173]},initialize:function(t){this._map=t,this._setPanDelta(t.options.keyboardPanDelta),this._setZoomDelta(t.options.zoomDelta)},addHooks:function(){var t=this._map._container;t.tabIndex<=0&&(t.tabIndex="0"),o.DomEvent.on(t,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)},removeHooks:function(){this._removeHooks(),o.DomEvent.off(this._map._container,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)},_onMouseDown:function(){if(!this._focused){var i=e.body,n=e.documentElement,o=i.scrollTop||n.scrollTop,s=i.scrollLeft||n.scrollLeft;this._map._container.focus(),t.scrollTo(s,o)}},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanDelta:function(t){var e,i,n=this._panKeys={},o=this.keyCodes;for(e=0,i=o.left.length;e<i;e++)n[o.left[e]]=[-1*t,0];for(e=0,i=o.right.length;e<i;e++)n[o.right[e]]=[t,0];for(e=0,i=o.down.length;e<i;e++)n[o.down[e]]=[0,t];for(e=0,i=o.up.length;e<i;e++)n[o.up[e]]=[0,-1*t]},_setZoomDelta:function(t){var e,i,n=this._zoomKeys={},o=this.keyCodes;for(e=0,i=o.zoomIn.length;e<i;e++)n[o.zoomIn[e]]=t;for(e=0,i=o.zoomOut.length;e<i;e++)n[o.zoomOut[e]]=-t},_addHooks:function(){o.DomEvent.on(e,"keydown",this._onKeyDown,this)},_removeHooks:function(){o.DomEvent.off(e,"keydown",this._onKeyDown,this)},_onKeyDown:function(t){if(!(t.altKey||t.ctrlKey||t.metaKey)){var e,i=t.keyCode,n=this._map;if(i in this._panKeys){if(n._panAnim&&n._panAnim._inProgress)return;e=this._panKeys[i],t.shiftKey&&(e=o.point(e).multiplyBy(3)),n.panBy(e),n.options.maxBounds&&n.panInsideBounds(n.options.maxBounds)}else if(i in this._zoomKeys)n.setZoom(n.getZoom()+(t.shiftKey?3:1)*this._zoomKeys[i]);else{if(27!==i)return;n.closePopup()}o.DomEvent.stop(t)}}}),o.Map.addInitHook("addHandler","keyboard",o.Map.Keyboard),o.Handler.MarkerDrag=o.Handler.extend({initialize:function(t){this._marker=t},addHooks:function(){var t=this._marker._icon;this._draggable||(this._draggable=new o.Draggable(t,t,!0)),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),o.DomUtil.addClass(t,"leaflet-marker-draggable")},removeHooks:function(){this._draggable.off({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),this._marker._icon&&o.DomUtil.removeClass(this._marker._icon,"leaflet-marker-draggable")},moved:function(){return this._draggable&&this._draggable._moved},_onDragStart:function(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup().fire("movestart").fire("dragstart")},_onDrag:function(t){var e=this._marker,i=e._shadow,n=o.DomUtil.getPosition(e._icon),s=e._map.layerPointToLatLng(n);i&&o.DomUtil.setPosition(i,n),e._latlng=s,t.latlng=s,t.oldLatLng=this._oldLatLng,e.fire("move",t).fire("drag",t)},_onDragEnd:function(t){delete this._oldLatLng,this._marker.fire("moveend").fire("dragend",t)}}),o.Control=o.Class.extend({options:{position:"topright"},initialize:function(t){o.setOptions(this,t)},getPosition:function(){return this.options.position},setPosition:function(t){var e=this._map;return e&&e.removeControl(this),this.options.position=t,e&&e.addControl(this),this},getContainer:function(){return this._container},addTo:function(t){this.remove(),this._map=t;var e=this._container=this.onAdd(t),i=this.getPosition(),n=t._controlCorners[i];return o.DomUtil.addClass(e,"leaflet-control"),i.indexOf("bottom")!==-1?n.insertBefore(e,n.firstChild):n.appendChild(e),this},remove:function(){return this._map?(o.DomUtil.remove(this._container),this.onRemove&&this.onRemove(this._map),this._map=null,this):this},_refocusOnMap:function(t){this._map&&t&&t.screenX>0&&t.screenY>0&&this._map.getContainer().focus()}}),o.control=function(t){return new o.Control(t)},o.Map.include({addControl:function(t){return t.addTo(this),this},removeControl:function(t){return t.remove(),this},_initControlPos:function(){function t(t,s){var r=i+t+" "+i+s;e[t+s]=o.DomUtil.create("div",r,n)}var e=this._controlCorners={},i="leaflet-",n=this._controlContainer=o.DomUtil.create("div",i+"control-container",this._container);t("top","left"),t("top","right"),t("bottom","left"),t("bottom","right")},_clearControlPos:function(){o.DomUtil.remove(this._controlContainer)}}),o.Control.Zoom=o.Control.extend({options:{position:"topleft",zoomInText:"+",zoomInTitle:"Zoom in",zoomOutText:"-",zoomOutTitle:"Zoom out"},onAdd:function(t){var e="leaflet-control-zoom",i=o.DomUtil.create("div",e+" leaflet-bar"),n=this.options;return this._zoomInButton=this._createButton(n.zoomInText,n.zoomInTitle,e+"-in",i,this._zoomIn),this._zoomOutButton=this._createButton(n.zoomOutText,n.zoomOutTitle,e+"-out",i,this._zoomOut),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this),i},onRemove:function(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(t){!this._disabled&&this._map._zoom<this._map.getMaxZoom()&&this._map.zoomIn(this._map.options.zoomDelta*(t.shiftKey?3:1))},_zoomOut:function(t){!this._disabled&&this._map._zoom>this._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(t.shiftKey?3:1))},_createButton:function(t,e,i,n,s){var r=o.DomUtil.create("a",i,n);return r.innerHTML=t,r.href="#",r.title=e,r.setAttribute("role","button"),r.setAttribute("aria-label",e),o.DomEvent.on(r,"mousedown dblclick",o.DomEvent.stopPropagation).on(r,"click",o.DomEvent.stop).on(r,"click",s,this).on(r,"click",this._refocusOnMap,this),r},_updateDisabled:function(){var t=this._map,e="leaflet-disabled";o.DomUtil.removeClass(this._zoomInButton,e),o.DomUtil.removeClass(this._zoomOutButton,e),(this._disabled||t._zoom===t.getMinZoom())&&o.DomUtil.addClass(this._zoomOutButton,e),(this._disabled||t._zoom===t.getMaxZoom())&&o.DomUtil.addClass(this._zoomInButton,e)}}),o.Map.mergeOptions({zoomControl:!0}),o.Map.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new o.Control.Zoom,this.addControl(this.zoomControl))}),o.control.zoom=function(t){return new o.Control.Zoom(t)},o.Control.Attribution=o.Control.extend({options:{position:"bottomright",prefix:'<a href="http://leafletjs.com" title="A JS library for interactive maps">Leaflet</a>'},initialize:function(t){o.setOptions(this,t),this._attributions={}},onAdd:function(t){t.attributionControl=this,this._container=o.DomUtil.create("div","leaflet-control-attribution"),o.DomEvent&&o.DomEvent.disableClickPropagation(this._container);for(var e in t._layers)t._layers[e].getAttribution&&this.addAttribution(t._layers[e].getAttribution());return this._update(),this._container},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t?(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update(),this):this},removeAttribution:function(t){return t?(this._attributions[t]&&(this._attributions[t]--,this._update()),this):this},_update:function(){if(this._map){var t=[];for(var e in this._attributions)this._attributions[e]&&t.push(e);var i=[];this.options.prefix&&i.push(this.options.prefix),t.length&&i.push(t.join(", ")),this._container.innerHTML=i.join(" | ")}}}),o.Map.mergeOptions({attributionControl:!0}),o.Map.addInitHook(function(){this.options.attributionControl&&(new o.Control.Attribution).addTo(this)}),o.control.attribution=function(t){return new o.Control.Attribution(t)},o.Control.Scale=o.Control.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(t){var e="leaflet-control-scale",i=o.DomUtil.create("div",e),n=this.options;return this._addScales(n,e+"-line",i),t.on(n.updateWhenIdle?"moveend":"move",this._update,this),t.whenReady(this._update,this),i},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(t,e,i){t.metric&&(this._mScale=o.DomUtil.create("div",e,i)),t.imperial&&(this._iScale=o.DomUtil.create("div",e,i))},_update:function(){var t=this._map,e=t.getSize().y/2,i=t.distance(t.containerPointToLatLng([0,e]),t.containerPointToLatLng([this.options.maxWidth,e]));this._updateScales(i)},_updateScales:function(t){this.options.metric&&t&&this._updateMetric(t),this.options.imperial&&t&&this._updateImperial(t)},_updateMetric:function(t){var e=this._getRoundNum(t),i=e<1e3?e+" m":e/1e3+" km";this._updateScale(this._mScale,i,e/t)},_updateImperial:function(t){var e,i,n,o=3.2808399*t;o>5280?(e=o/5280,i=this._getRoundNum(e),this._updateScale(this._iScale,i+" mi",i/e)):(n=this._getRoundNum(o),this._updateScale(this._iScale,n+" ft",n/o))},_updateScale:function(t,e,i){t.style.width=Math.round(this.options.maxWidth*i)+"px",t.innerHTML=e},_getRoundNum:function(t){var e=Math.pow(10,(Math.floor(t)+"").length-1),i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:1,e*i}}),o.control.scale=function(t){return new o.Control.Scale(t)},o.Control.Layers=o.Control.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(t,e,i,n){return i<n?-1:n<i?1:0}},initialize:function(t,e,i){o.setOptions(this,i),this._layers=[],this._lastZIndex=0,this._handlingClick=!1;for(var n in t)this._addLayer(t[n],n);for(n in e)this._addLayer(e[n],n,!0)},onAdd:function(t){return this._initLayout(),this._update(),this._map=t,t.on("zoomend",this._checkDisabledLayers,this),this._container},onRemove:function(){this._map.off("zoomend",this._checkDisabledLayers,this);for(var t=0;t<this._layers.length;t++)this._layers[t].layer.off("add remove",this._onLayerChange,this)},addBaseLayer:function(t,e){return this._addLayer(t,e),this._map?this._update():this},addOverlay:function(t,e){return this._addLayer(t,e,!0),this._map?this._update():this},removeLayer:function(t){t.off("add remove",this._onLayerChange,this);var e=this._getLayer(o.stamp(t));return e&&this._layers.splice(this._layers.indexOf(e),1),this._map?this._update():this},expand:function(){o.DomUtil.addClass(this._container,"leaflet-control-layers-expanded"),this._form.style.height=null;var t=this._map.getSize().y-(this._container.offsetTop+50);return t<this._form.clientHeight?(o.DomUtil.addClass(this._form,"leaflet-control-layers-scrollbar"),this._form.style.height=t+"px"):o.DomUtil.removeClass(this._form,"leaflet-control-layers-scrollbar"),this._checkDisabledLayers(),this},collapse:function(){return o.DomUtil.removeClass(this._container,"leaflet-control-layers-expanded"),this},_initLayout:function(){var t="leaflet-control-layers",e=this._container=o.DomUtil.create("div",t),i=this.options.collapsed;e.setAttribute("aria-haspopup",!0),o.DomEvent.disableClickPropagation(e),o.Browser.touch||o.DomEvent.disableScrollPropagation(e);var n=this._form=o.DomUtil.create("form",t+"-list");i&&(this._map.on("click",this.collapse,this),o.Browser.android||o.DomEvent.on(e,{mouseenter:this.expand,mouseleave:this.collapse},this));var s=this._layersLink=o.DomUtil.create("a",t+"-toggle",e);s.href="#",s.title="Layers",o.Browser.touch?o.DomEvent.on(s,"click",o.DomEvent.stop).on(s,"click",this.expand,this):o.DomEvent.on(s,"focus",this.expand,this),o.DomEvent.on(n,"click",function(){setTimeout(o.bind(this._onInputClick,this),0)},this),i||this.expand(),this._baseLayersList=o.DomUtil.create("div",t+"-base",n),this._separator=o.DomUtil.create("div",t+"-separator",n),this._overlaysList=o.DomUtil.create("div",t+"-overlays",n),e.appendChild(n)},_getLayer:function(t){for(var e=0;e<this._layers.length;e++)if(this._layers[e]&&o.stamp(this._layers[e].layer)===t)return this._layers[e]},_addLayer:function(t,e,i){t.on("add remove",this._onLayerChange,this),this._layers.push({layer:t,name:e,overlay:i}),this.options.sortLayers&&this._layers.sort(o.bind(function(t,e){return this.options.sortFunction(t.layer,e.layer,t.name,e.name)},this)),this.options.autoZIndex&&t.setZIndex&&(this._lastZIndex++,t.setZIndex(this._lastZIndex))},_update:function(){if(!this._container)return this;o.DomUtil.empty(this._baseLayersList),o.DomUtil.empty(this._overlaysList);var t,e,i,n,s=0;for(i=0;i<this._layers.length;i++)n=this._layers[i],this._addItem(n),e=e||n.overlay,t=t||!n.overlay,s+=n.overlay?0:1;return this.options.hideSingleBase&&(t=t&&s>1,this._baseLayersList.style.display=t?"":"none"),this._separator.style.display=e&&t?"":"none",this},_onLayerChange:function(t){this._handlingClick||this._update();var e=this._getLayer(o.stamp(t.target)),i=e.overlay?"add"===t.type?"overlayadd":"overlayremove":"add"===t.type?"baselayerchange":null;i&&this._map.fire(i,e)},_createRadioElement:function(t,i){var n='<input type="radio" class="leaflet-control-layers-selector" name="'+t+'"'+(i?' checked="checked"':"")+"/>",o=e.createElement("div");return o.innerHTML=n,o.firstChild},_addItem:function(t){var i,n=e.createElement("label"),s=this._map.hasLayer(t.layer);t.overlay?(i=e.createElement("input"),i.type="checkbox",i.className="leaflet-control-layers-selector",i.defaultChecked=s):i=this._createRadioElement("leaflet-base-layers",s),i.layerId=o.stamp(t.layer),o.DomEvent.on(i,"click",this._onInputClick,this);var r=e.createElement("span");r.innerHTML=" "+t.name;var a=e.createElement("div");n.appendChild(a),a.appendChild(i),a.appendChild(r);var h=t.overlay?this._overlaysList:this._baseLayersList;return h.appendChild(n),this._checkDisabledLayers(),n},_onInputClick:function(){var t,e,i,n=this._form.getElementsByTagName("input"),o=[],s=[];this._handlingClick=!0;for(var r=n.length-1;r>=0;r--)t=n[r],e=this._getLayer(t.layerId).layer,i=this._map.hasLayer(e),t.checked&&!i?o.push(e):!t.checked&&i&&s.push(e);for(r=0;r<s.length;r++)this._map.removeLayer(s[r]);for(r=0;r<o.length;r++)this._map.addLayer(o[r]);this._handlingClick=!1,this._refocusOnMap()},_checkDisabledLayers:function(){for(var t,e,n=this._form.getElementsByTagName("input"),o=this._map.getZoom(),s=n.length-1;s>=0;s--)t=n[s],e=this._getLayer(t.layerId).layer,t.disabled=e.options.minZoom!==i&&o<e.options.minZoom||e.options.maxZoom!==i&&o>e.options.maxZoom},_expand:function(){return this.expand()},_collapse:function(){return this.collapse()}}),o.control.layers=function(t,e,i){return new o.Control.Layers(t,e,i)}}(window,document);
\ No newline at end of file
index c2b0535..bd59741 100644 (file)
 
                _addToggleButton: function () {
                        this._toggleDisplayButton = this.options.toggleDisplay ? this._createButton(
-                               '', this.options.strings.hideText, ('leaflet-control-minimap-toggle-display leaflet-control-minimap-toggle-display-' +
+                               '', this._toggleButtonInitialTitleText(), ('leaflet-control-minimap-toggle-display leaflet-control-minimap-toggle-display-' +
                                this.options.position), this._container, this._toggleDisplayButtonClicked, this) : undefined;
 
                        this._toggleDisplayButton.style.width = this.options.collapsedWidth + 'px';
                        this._toggleDisplayButton.style.height = this.options.collapsedHeight + 'px';
                },
 
+               _toggleButtonInitialTitleText: function () {
+                       if (this.options.minimized) {
+                               return this.options.strings.showText;
+                       } else {
+                               return this.options.strings.hideText;
+                       }
+               },
+
                _createButton: function (html, title, className, container, fn, context) {
                        var link = L.DomUtil.create('a', className, container);
                        link.innerHTML = html;
diff --git a/www/plugins/gis/lib/leaflet/plugins/Google.js b/www/plugins/gis/lib/leaflet/plugins/Google.js
deleted file mode 100755 (executable)
index 418783b..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Google layer using Google Maps API
- */
-
-/* global google: true */
-
-L.Google = L.Class.extend({
-       includes: L.Mixin.Events,
-
-       options: {
-               minZoom: 0,
-               maxZoom: 18,
-               tileSize: 256,
-               subdomains: 'abc',
-               errorTileUrl: '',
-               attribution: '',
-               opacity: 1,
-               continuousWorld: false,
-               noWrap: false,
-               mapOptions: {
-                       backgroundColor: '#dddddd'
-               }
-       },
-
-       // Possible types: SATELLITE, ROADMAP, HYBRID, TERRAIN
-       initialize: function (type, options) {
-               var _this = this;
-
-               this._ready = L.Google.isGoogleMapsReady();
-
-               L.Util.setOptions(this, options);
-
-               this._googleApiPromise = this._ready ? Promise.resolve(window.google) : L.Google.createGoogleApiPromise();
-
-               this._googleApiPromise
-               .then(function () {
-                       _this._ready = true;
-                       _this._initMapObject();
-                       _this._update();
-               });
-
-               this._type = type || 'SATELLITE';
-       },
-
-       onAdd: function (map, insertAtTheBottom) {
-               var _this = this;
-               this._googleApiPromise
-               .then(function () {
-                       _this._map = map;
-                       _this._insertAtTheBottom = insertAtTheBottom;
-
-                       // create a container div for tiles
-                       _this._initContainer();
-                       _this._initMapObject();
-
-                       // set up events
-                       map.on('viewreset', _this._reset, _this);
-
-                       _this._limitedUpdate = L.Util.limitExecByInterval(_this._update, 150, _this);
-                       map.on('move', _this._update, _this);
-
-                       map.on('zoomanim', _this._handleZoomAnim, _this);
-
-                       //20px instead of 1em to avoid a slight overlap with google's attribution
-                       map._controlCorners.bottomright.style.marginBottom = '20px';
-
-                       _this._reset();
-                       _this._update();
-               });
-       },
-
-       onRemove: function (map) {
-               map._container.removeChild(this._container);
-
-               map.off('viewreset', this._reset, this);
-
-               map.off('move', this._update, this);
-
-               map.off('zoomanim', this._handleZoomAnim, this);
-
-               map._controlCorners.bottomright.style.marginBottom = '0em';
-       },
-
-       getAttribution: function () {
-               return this.options.attribution;
-       },
-
-       setOpacity: function (opacity) {
-               this.options.opacity = opacity;
-               if (opacity < 1) {
-                       L.DomUtil.setOpacity(this._container, opacity);
-               }
-       },
-
-       setElementSize: function (e, size) {
-               e.style.width = size.x + 'px';
-               e.style.height = size.y + 'px';
-       },
-
-       _initContainer: function () {
-               var tilePane = this._map._container,
-                       first = tilePane.firstChild;
-
-               if (!this._container) {
-                       this._container = L.DomUtil.create('div', 'leaflet-google-layer leaflet-top leaflet-left');
-                       this._container.id = '_GMapContainer_' + L.Util.stamp(this);
-                       this._container.style.zIndex = 'auto';
-               }
-
-               tilePane.insertBefore(this._container, first);
-
-               this.setOpacity(this.options.opacity);
-               this.setElementSize(this._container, this._map.getSize());
-       },
-
-       _initMapObject: function () {
-               if (!this._ready || !this._container) return;
-               this._google_center = new google.maps.LatLng(0, 0);
-               var map = new google.maps.Map(this._container, {
-                       center: this._google_center,
-                       zoom: 0,
-                       tilt: 0,
-                       mapTypeId: google.maps.MapTypeId[this._type],
-                       disableDefaultUI: true,
-                       keyboardShortcuts: false,
-                       draggable: false,
-                       disableDoubleClickZoom: true,
-                       scrollwheel: false,
-                       streetViewControl: false,
-                       styles: this.options.mapOptions.styles,
-                       backgroundColor: this.options.mapOptions.backgroundColor
-               });
-
-               var _this = this;
-               this._reposition = google.maps.event.addListenerOnce(map, 'center_changed',
-                       function () { _this.onReposition(); });
-               this._google = map;
-
-               google.maps.event.addListenerOnce(map, 'idle',
-                       function () { _this._checkZoomLevels(); });
-               google.maps.event.addListenerOnce(map, 'tilesloaded',
-                       function () { _this.fire('load'); });
-               //Reporting that map-object was initialized.
-               this.fire('MapObjectInitialized', {mapObject: map});
-       },
-
-       _checkZoomLevels: function () {
-               //setting the zoom level on the Google map may result in a different zoom level than the one requested
-               //(it won't go beyond the level for which they have data).
-               // verify and make sure the zoom levels on both Leaflet and Google maps are consistent
-               if ((this._map.getZoom() !== undefined) && (this._google.getZoom() !== this._map.getZoom())) {
-                       //zoom levels are out of sync. Set the leaflet zoom level to match the google one
-                       this._map.setZoom(this._google.getZoom());
-               }
-       },
-
-       _reset: function () {
-               this._initContainer();
-       },
-
-       _update: function () {
-               if (!this._google) return;
-               this._resize();
-
-               var center = this._map.getCenter();
-               var _center = new google.maps.LatLng(center.lat, center.lng);
-
-               this._google.setCenter(_center);
-               if (this._map.getZoom() !== undefined)
-                       this._google.setZoom(Math.round(this._map.getZoom()));
-
-               this._checkZoomLevels();
-       },
-
-       _resize: function () {
-               var size = this._map.getSize();
-               if (this._container.style.width === size.x &&
-                               this._container.style.height === size.y)
-                       return;
-               this.setElementSize(this._container, size);
-               this.onReposition();
-       },
-
-
-       _handleZoomAnim: function (e) {
-               var center = e.center;
-               var _center = new google.maps.LatLng(center.lat, center.lng);
-
-               this._google.setCenter(_center);
-               this._google.setZoom(Math.round(e.zoom));
-       },
-
-
-       onReposition: function () {
-               if (!this._google) return;
-               google.maps.event.trigger(this._google, 'resize');
-       }
-});
-
-L.Google.isGoogleMapsReady = function () {
-       return !!window.google && !!window.google.maps && !!window.google.maps.Map;
-};
-
-// backwards compat
-L.Google.asyncInitialize = L.Google.isGoogleMapsReady;
-
-L.Google.maxApiChecks = 10;
-
-L.Google.apiCheckIntervalMilliSecs = 500;
-
-L.Google.createGoogleApiPromise = function () {
-       var checkCounter = 0;
-       var intervalId = null;
-
-       return new Promise(function (resolve, reject) {
-               intervalId = setInterval(function () {
-                       if (checkCounter >= L.Google.maxApiChecks && !L.Google.isGoogleMapsReady()) {
-                               clearInterval(intervalId);
-                               return reject(new Error('window.google not found after max attempts'));
-                       }
-                       if (L.Google.isGoogleMapsReady()) {
-                               clearInterval(intervalId);
-                               return resolve(window.google);
-                       }
-                       checkCounter++;
-               }, L.Google.apiCheckIntervalMilliSecs);
-       });
-};
diff --git a/www/plugins/gis/lib/leaflet/plugins/Leaflet.GoogleMutant.js b/www/plugins/gis/lib/leaflet/plugins/Leaflet.GoogleMutant.js
new file mode 100644 (file)
index 0000000..689a66b
--- /dev/null
@@ -0,0 +1,391 @@
+// Based on https://github.com/shramov/leaflet-plugins
+// GridLayer like https://avinmathew.com/leaflet-and-google-maps/ , but using MutationObserver instead of jQuery
+
+
+// 🍂class GridLayer.GoogleMutant
+// 🍂extends GridLayer
+L.GridLayer.GoogleMutant = L.GridLayer.extend({
+       includes: L.Mixin.Events,
+
+       options: {
+               minZoom: 0,
+               maxZoom: 18,
+               tileSize: 256,
+               subdomains: 'abc',
+               errorTileUrl: '',
+               attribution: '',        // The mutant container will add its own attribution anyways.
+               opacity: 1,
+               continuousWorld: false,
+               noWrap: false,
+               // 🍂option type: String = 'roadmap'
+               // Google's map type. Valid values are 'roadmap', 'satellite' or 'terrain'. 'hybrid' is not really supported.
+               type: 'roadmap',
+               maxNativeZoom: 21
+       },
+
+       initialize: function (options) {
+               L.GridLayer.prototype.initialize.call(this, options);
+
+               this._ready = !!window.google && !!window.google.maps && !!window.google.maps.Map;
+
+               this._GAPIPromise = this._ready ? Promise.resolve(window.google) : new Promise(function (resolve, reject) {
+                       var checkCounter = 0;
+                       var intervalId = null;
+                       intervalId = setInterval(function () {
+                               if (checkCounter >= 10) {
+                                       clearInterval(intervalId);
+                                       return reject(new Error('window.google not found after 10 attempts'));
+                               }
+                               if (!!window.google && !!window.google.maps && !!window.google.maps.Map) {
+                                       clearInterval(intervalId);
+                                       return resolve(window.google);
+                               }
+                               checkCounter++;
+                       }, 500);
+               });
+
+               // Couple data structures indexed by tile key
+               this._tileCallbacks = {};       // Callbacks for promises for tiles that are expected
+               this._freshTiles = {};  // Tiles from the mutant which haven't been requested yet
+
+               this._imagesPerTile = (this.options.type === 'hybrid') ? 2 : 1;
+               this.createTile = (this.options.type === 'hybrid') ? this._createMultiTile : this._createSingleTile;
+       },
+
+       onAdd: function (map) {
+               L.GridLayer.prototype.onAdd.call(this, map);
+               this._initMutantContainer();
+
+               this._GAPIPromise.then(function () {
+                       this._ready = true;
+                       this._map = map;
+
+                       this._initMutant();
+
+                       map.on('viewreset', this._reset, this);
+                       map.on('move', this._update, this);
+                       map.on('zoomend', this._handleZoomAnim, this);
+                       map.on('resize', this._resize, this);
+
+                       //20px instead of 1em to avoid a slight overlap with google's attribution
+                       map._controlCorners.bottomright.style.marginBottom = '20px';
+
+                       this._reset();
+                       this._update();
+               }.bind(this));
+       },
+
+       onRemove: function (map) {
+               L.GridLayer.prototype.onRemove.call(this, map);
+               map._container.removeChild(this._mutantContainer);
+               this._mutantContainer = undefined;
+
+               map.off('viewreset', this._reset, this);
+               map.off('move', this._update, this);
+               map.off('zoomend', this._handleZoomAnim, this);
+               map.off('resize', this._resize, this);
+
+               map._controlCorners.bottomright.style.marginBottom = '0em';
+       },
+
+       getAttribution: function () {
+               return this.options.attribution;
+       },
+
+       setOpacity: function (opacity) {
+               this.options.opacity = opacity;
+               if (opacity < 1) {
+                       L.DomUtil.setOpacity(this._mutantContainer, opacity);
+               }
+       },
+
+       setElementSize: function (e, size) {
+               e.style.width = size.x + 'px';
+               e.style.height = size.y + 'px';
+       },
+
+       _initMutantContainer: function () {
+               if (!this._mutantContainer) {
+                       this._mutantContainer = L.DomUtil.create('div', 'leaflet-google-mutant leaflet-top leaflet-left');
+                       this._mutantContainer.id = '_MutantContainer_' + L.Util.stamp(this._mutantContainer);
+//                     this._mutantContainer.style.zIndex = 'auto';
+                       this._mutantContainer.style.pointerEvents = 'none';
+
+                       this._map.getContainer().appendChild(this._mutantContainer);
+               }
+
+               this.setOpacity(this.options.opacity);
+               this.setElementSize(this._mutantContainer, this._map.getSize());
+
+               this._attachObserver(this._mutantContainer);
+       },
+
+       _initMutant: function () {
+               if (!this._ready || !this._mutantContainer) return;
+               this._mutantCenter = new google.maps.LatLng(0, 0);
+
+               var map = new google.maps.Map(this._mutantContainer, {
+                       center: this._mutantCenter,
+                       zoom: 0,
+                       tilt: 0,
+                       mapTypeId: this.options.type,
+                       disableDefaultUI: true,
+                       keyboardShortcuts: false,
+                       draggable: false,
+                       disableDoubleClickZoom: true,
+                       scrollwheel: false,
+                       streetViewControl: false,
+                       styles: this.options.styles || {},
+                       backgroundColor: 'transparent'
+               });
+
+               this._mutant = map;
+
+               // 🍂event spawned
+               // Fired when the mutant has been created.
+               this.fire('spawned', {mapObject: map});
+       },
+
+       _attachObserver: function _attachObserver (node) {
+//             console.log('Gonna observe', node);
+
+               var observer = new MutationObserver(this._onMutations.bind(this));
+
+               // pass in the target node, as well as the observer options
+               observer.observe(node, { childList: true, subtree: true });
+       },
+
+       _onMutations: function _onMutations (mutations) {
+               for (var i = 0; i < mutations.length; ++i) {
+                       var mutation = mutations[i];
+                       for (var j = 0; j < mutation.addedNodes.length; ++j) {
+                               var node = mutation.addedNodes[j];
+
+                               if (node instanceof HTMLImageElement) {
+                                       this._onMutatedImage(node);
+                               } else if (node instanceof HTMLElement) {
+                                       Array.prototype.forEach.call(node.querySelectorAll('img'), this._onMutatedImage.bind(this));
+                               }
+                       }
+               }
+       },
+
+       // Only images which 'src' attrib match this will be considered for moving around.
+       // Looks like some kind of string-based protobuf, maybe??
+       // Only the roads (and terrain, and vector-based stuff) match this pattern
+       _roadRegexp: /!1i(\d+)!2i(\d+)!3i(\d+)!/,
+
+       // On the other hand, raster imagery matches this other pattern
+       _satRegexp: /x=(\d+)&y=(\d+)&z=(\d+)/,
+
+       // On small viewports, when zooming in/out, a static image is requested
+       // This will not be moved around, just removed from the DOM.
+       _staticRegExp: /StaticMapService\.GetMapImage/,
+
+       _onMutatedImage: function _onMutatedImage (imgNode) {
+//             if (imgNode.src) {
+//                     console.log('caught mutated image: ', imgNode.src);
+//             }
+
+               var coords;
+               var match = imgNode.src.match(this._roadRegexp);
+               var sublayer, parent;
+
+               if (match) {
+                       coords = {
+                               z: match[1],
+                               x: match[2],
+                               y: match[3]
+                       };
+                       if (this._imagesPerTile > 1) { imgNode.style.zIndex = 1; }
+                       sublayer = 1;
+               } else {
+                       match = imgNode.src.match(this._satRegexp);
+                       if (match) {
+                               coords = {
+                                       x: match[1],
+                                       y: match[2],
+                                       z: match[3]
+                               };
+                       }
+//                     imgNode.style.zIndex = 0;
+                       sublayer = 0;
+               }
+
+               if (coords) {
+                       var key = this._tileCoordsToKey(coords);
+                       if (this._imagesPerTile > 1) { key += '/' + sublayer; }
+                       if (key in this._tileCallbacks && this._tileCallbacks[key]) {
+// console.log('Fullfilling callback ', key);
+                               this._tileCallbacks[key].pop()(imgNode);
+                               if (!this._tileCallbacks[key].length) { delete this._tileCallbacks[key]; }
+                       } else {
+// console.log('Caching for later', key);
+                               parent = imgNode.parentNode;
+                               if (parent) {
+                                       parent.removeChild(imgNode);
+                                       parent.removeChild = L.Util.falseFn;
+//                                     imgNode.parentNode.replaceChild(L.DomUtil.create('img'), imgNode);
+                               }
+                               if (key in this._freshTiles) {
+                                       this._freshTiles[key].push(imgNode);
+                               } else {
+                                       this._freshTiles[key] = [imgNode];
+                               }
+                       }
+               } else if (imgNode.src.match(this._staticRegExp)) {
+                       parent = imgNode.parentNode;
+                       if (parent) {
+                               // Remove the image, but don't store it anywhere.
+                               // Image needs to be replaced instead of removed, as the container
+                               // seems to be reused.
+                               imgNode.parentNode.replaceChild(L.DomUtil.create('img'), imgNode);
+                       }
+               }
+       },
+
+       // This will be used as this.createTile for 'roadmap', 'sat', 'terrain'
+       _createSingleTile: function createTile (coords, done) {
+               var key = this._tileCoordsToKey(coords);
+// console.log('Need:', key);
+
+               if (key in this._freshTiles) {
+                       var tile = this._freshTiles[key].pop();
+                       if (!this._freshTiles[key].length) { delete this._freshTiles[key]; }
+                       L.Util.requestAnimFrame(done);
+//                     console.log('Got ', key, ' from _freshTiles');
+                       return tile;
+               } else {
+                       var tileContainer = L.DomUtil.create('div');
+                       this._tileCallbacks[key] = this._tileCallbacks[key] || [];
+                       this._tileCallbacks[key].push( (function (c/*, k*/) {
+                               return function (imgNode) {
+                                       var parent = imgNode.parentNode;
+                                       if (parent) {
+                                               parent.removeChild(imgNode);
+                                               parent.removeChild = L.Util.falseFn;
+//                                             imgNode.parentNode.replaceChild(L.DomUtil.create('img'), imgNode);
+                                       }
+                                       c.appendChild(imgNode);
+                                       done();
+//                                     console.log('Sent ', k, ' to _tileCallbacks');
+                               }.bind(this);
+                       }.bind(this))(tileContainer/*, key*/) );
+
+                       return tileContainer;
+               }
+       },
+
+       // This will be used as this.createTile for 'hybrid'
+       _createMultiTile: function createTile (coords, done) {
+               var key = this._tileCoordsToKey(coords);
+
+               var tileContainer = L.DomUtil.create('div');
+               tileContainer.dataset.pending = this._imagesPerTile;
+
+               for (var i = 0; i < this._imagesPerTile; i++) {
+                       var key2 = key + '/' + i;
+                       if (key2 in this._freshTiles) {
+                               tileContainer.appendChild(this._freshTiles[key2].pop());
+                               if (!this._freshTiles[key2].length) { delete this._freshTiles[key2]; }
+                               tileContainer.dataset.pending--;
+//                             console.log('Got ', key2, ' from _freshTiles');
+                       } else {
+                               this._tileCallbacks[key2] = this._tileCallbacks[key2] || [];
+                               this._tileCallbacks[key2].push( (function (c/*, k2*/) {
+                                       return function (imgNode) {
+                                               var parent = imgNode.parentNode;
+                                               if (parent) {
+                                                       parent.removeChild(imgNode);
+                                                       parent.removeChild = L.Util.falseFn;
+//                                                     imgNode.parentNode.replaceChild(L.DomUtil.create('img'), imgNode);
+                                               }
+                                               c.appendChild(imgNode);
+                                               c.dataset.pending--;
+                                               if (!parseInt(c.dataset.pending)) { done(); }
+//                                             console.log('Sent ', k2, ' to _tileCallbacks, still ', c.dataset.pending, ' images to go');
+                                       }.bind(this);
+                               }.bind(this))(tileContainer/*, key2*/) );
+                       }
+               }
+
+               if (!parseInt(tileContainer.dataset.pending)) {
+                       L.Util.requestAnimFrame(done);
+               }
+               return tileContainer;
+       },
+
+       _checkZoomLevels: function () {
+               //setting the zoom level on the Google map may result in a different zoom level than the one requested
+               //(it won't go beyond the level for which they have data).
+               // verify and make sure the zoom levels on both Leaflet and Google maps are consistent
+               if ((this._map.getZoom() !== undefined) && (this._mutant.getZoom() !== this._map.getZoom())) {
+                       //zoom levels are out of sync. Set the leaflet zoom level to match the google one
+                       this._map.setZoom(this._mutant.getZoom());
+               }
+       },
+
+       _reset: function () {
+               this._initContainer();
+       },
+
+       _update: function () {
+               L.GridLayer.prototype._update.call(this);
+               if (!this._mutant) return;
+
+               var center = this._map.getCenter();
+               var _center = new google.maps.LatLng(center.lat, center.lng);
+
+               this._mutant.setCenter(_center);
+               var zoom = this._map.getZoom();
+               if (zoom !== undefined) {
+                       this._mutant.setZoom(Math.round(this._map.getZoom()));
+               }
+       },
+
+       _resize: function () {
+               var size = this._map.getSize();
+               if (this._mutantContainer.style.width === size.x &&
+                       this._mutantContainer.style.height === size.y)
+                       return;
+               this.setElementSize(this._mutantContainer, size);
+               if (!this._mutant) return;
+               google.maps.event.trigger(this._mutant, 'resize');
+       },
+
+       _handleZoomAnim: function () {
+               var center = this._map.getCenter();
+               var _center = new google.maps.LatLng(center.lat, center.lng);
+
+               this._mutant.setCenter(_center);
+               this._mutant.setZoom(Math.round(this._map.getZoom()));
+       },
+
+       // Agressively prune _freshtiles when a tile with the same key is removed,
+       // this prevents a problem where Leaflet keeps a loaded tile longer than
+       // GMaps, so that GMaps makes two requests but Leaflet only consumes one,
+       // polluting _freshTiles with stale data.
+       _removeTile: function (key) {
+               if (this._imagesPerTile > 1) {
+                       for (var i=0; i<this._imagesPerTile; i++) {
+                               var key2 = key + '/' + i;
+                               if (key2 in this._freshTiles) { delete this._freshTiles[key2]; }
+//                             console.log('Pruned spurious hybrid _freshTiles');
+                       }
+               } else {
+                       if (key in this._freshTiles) {
+                               delete this._freshTiles[key];
+//                             console.log('Pruned spurious _freshTiles', key);
+                       }
+               }
+
+               return L.GridLayer.prototype._removeTile.call(this, key);
+       }
+});
+
+
+// 🍂factory gridLayer.googleMutant(options)
+// Returns a new `GridLayer.GoogleMutant` given its options
+L.gridLayer.googleMutant = function (options) {
+       return new L.GridLayer.GoogleMutant(options);
+};
index ab2b9bc..740fc52 100755 (executable)
@@ -14,8 +14,9 @@
                        transform += ' rotate(' + this.options.iconAngle + 'deg)';
                        transform += ' translate(' + a.x + 'px, ' + a.y + 'px)';
                        i.style[L.DomUtil.TRANSFORM] += transform;
+                       i.style[L.DomUtil.TRANSFORM + 'Origin'] = '50% 50%';
                },
-               
+
                _getShortestEndDegree: function (startDegrees, endDegrees) {
                        var turnAngle = Math.abs(endDegrees - startDegrees);
                        var turnAnglePositive = (endDegrees - startDegrees) >= 0;
index d9bdb14..a0b81ef 100755 (executable)
@@ -1,6 +1,6 @@
 /* L.Control.FullScreen */
-.fullscreen-icon { background-image: url(icon-fullscreen.png); }
-.leaflet-retina .fullscreen-icon { background-image: url(icon-fullscreen-2x.png); background-size: 26px 26px; }
+.fullscreen-icon { background-image: url(images/icon-fullscreen.png); }
+.leaflet-retina .fullscreen-icon { background-image: url(images/icon-fullscreen-2x.png); background-size: 26px 26px; }
 /* one selector per rule as explained here : http://www.sitepoint.com/html5-full-screen-api/ */
 .leaflet-container:-webkit-full-screen { width: 100% !important; height: 100% !important; z-index: 99999; }
 .leaflet-container:-ms-fullscreen { width: 100% !important; height: 100% !important; z-index: 99999; }
index 22e2cbd..8d7be17 100644 (file)
                        }
                },
                Thunderforest: {
-                       url: '//{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png',
+                       url: '//{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png?apikey={apikey}',
                        options: {
                                attribution:
                                        '&copy; <a href="http://www.thunderforest.com/">Thunderforest</a>, {attribution.OpenStreetMap}',
                        }
                },
                BasemapAT: {
-                       url: '//maps{s}.wien.gv.at/basemap/{variant}/normal/google3857/{z}/{y}/{x}.{format}',
+                       url: 'https://maps{s}.wien.gv.at/basemap/{variant}/normal/google3857/{z}/{y}/{x}.{format}',
                        options: {
                                maxZoom: 19,
                                attribution: 'Datenquelle: <a href="www.basemap.at">basemap.at</a>',
                                variant: 'geolandbasemap'
                        },
                        variants: {
-                               basemap: 'geolandbasemap',
+                               basemap: {
+                                       options: {
+                                               maxZoom: 20, // currently only in Vienna
+                                               variant: 'geolandbasemap'
+                                       }
+                               },
                                grau: 'bmapgrau',
                                overlay: 'bmapoverlay',
                                highdpi: {
                                },
                                orthofoto: {
                                        options: {
+                                               maxZoom: 20, // currently only in Vienna
                                                variant: 'bmaporthofoto30cm',
                                                format: 'jpeg'
                                        }
index b7aad0e..2c3a9d3 100644 (file)
@@ -56,10 +56,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                }
 
                this._featureGroup = L.featureGroup();
-               this._featureGroup.on(L.FeatureGroup.EVENTS, this._propagateEvent, this);
+               this._featureGroup.addEventParent(this);
 
                this._nonPointGroup = L.featureGroup();
-               this._nonPointGroup.on(L.FeatureGroup.EVENTS, this._propagateEvent, this);
+               this._nonPointGroup.addEventParent(this);
 
                this._inZoomAnimation = 0;
                this._needsClustering = [];
@@ -79,11 +79,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
        addLayer: function (layer) {
 
                if (layer instanceof L.LayerGroup) {
-                       var array = [];
-                       for (var i in layer._layers) {
-                               array.push(layer._layers[i]);
-                       }
-                       return this.addLayers(array);
+                       return this.addLayers([layer]);
                }
 
                //Don't cluster non point data
@@ -113,9 +109,11 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                // Refresh bounds and weighted positions.
                this._topClusterLevel._recalculateBounds();
 
+               this._refreshClustersIcons();
+
                //Work out what is visible
                var visibleLayer = layer,
-                       currentZoom = this._map.getZoom();
+                   currentZoom = this._zoom;
                if (layer.__parent) {
                        while (visibleLayer.__parent._zoom >= currentZoom) {
                                visibleLayer = visibleLayer.__parent;
@@ -134,13 +132,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
        removeLayer: function (layer) {
 
-               if (layer instanceof L.LayerGroup)
-               {
-                       var array = [];
-                       for (var i in layer._layers) {
-                               array.push(layer._layers[i]);
-                       }
-                       return this.removeLayers(array);
+               if (layer instanceof L.LayerGroup) {
+                       return this.removeLayers([layer]);
                }
 
                //Non point layers
@@ -171,6 +164,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                // Refresh bounds and weighted positions.
                this._topClusterLevel._recalculateBounds();
 
+               this._refreshClustersIcons();
+
+               layer.off('move', this._childMarkerMoved, this);
+
                if (this._featureGroup.hasLayer(layer)) {
                        this._featureGroup.removeLayer(layer);
                        if (layer.clusterShow) {
@@ -183,19 +180,25 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
        //Takes an array of markers and adds them in bulk
        addLayers: function (layersArray) {
+               if (!L.Util.isArray(layersArray)) {
+                       return this.addLayer(layersArray);
+               }
+
                var fg = this._featureGroup,
-                       npg = this._nonPointGroup,
-                       chunked = this.options.chunkedLoading,
-                       chunkInterval = this.options.chunkInterval,
-                       chunkProgress = this.options.chunkProgress,
-                       newMarkers, i, l, m;
+                   npg = this._nonPointGroup,
+                   chunked = this.options.chunkedLoading,
+                   chunkInterval = this.options.chunkInterval,
+                   chunkProgress = this.options.chunkProgress,
+                   l = layersArray.length,
+                   offset = 0,
+                   originalArray = true,
+                   m;
 
                if (this._map) {
-                       var offset = 0,
-                               started = (new Date()).getTime();
+                       var started = (new Date()).getTime();
                        var process = L.bind(function () {
                                var start = (new Date()).getTime();
-                               for (; offset < layersArray.length; offset++) {
+                               for (; offset < l; offset++) {
                                        if (chunked && offset % 200 === 0) {
                                                // every couple hundred markers, instrument the time elapsed since processing started:
                                                var elapsed = (new Date()).getTime() - start;
@@ -206,6 +209,22 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
                                        m = layersArray[offset];
 
+                                       // Group of layers, append children to layersArray and skip.
+                                       // Side effects:
+                                       // - Total increases, so chunkProgress ratio jumps backward.
+                                       // - Groups are not included in this group, only their non-group child layers (hasLayer).
+                                       // Changing array length while looping does not affect performance in current browsers:
+                                       // http://jsperf.com/for-loop-changing-length/6
+                                       if (m instanceof L.LayerGroup) {
+                                               if (originalArray) {
+                                                       layersArray = layersArray.slice();
+                                                       originalArray = false;
+                                               }
+                                               this._extractNonGroupLayers(m, layersArray);
+                                               l = layersArray.length;
+                                               continue;
+                                       }
+
                                        //Not point data, can't be clustered
                                        if (!m.getLatLng) {
                                                npg.addLayer(m);
@@ -222,7 +241,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                                        if (m.__parent) {
                                                if (m.__parent.getChildCount() === 2) {
                                                        var markers = m.__parent.getAllChildMarkers(),
-                                                               otherMarker = markers[0] === m ? markers[1] : markers[0];
+                                                           otherMarker = markers[0] === m ? markers[1] : markers[0];
                                                        fg.removeLayer(otherMarker);
                                                }
                                        }
@@ -230,21 +249,16 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
                                if (chunkProgress) {
                                        // report progress and time elapsed:
-                                       chunkProgress(offset, layersArray.length, (new Date()).getTime() - started);
+                                       chunkProgress(offset, l, (new Date()).getTime() - started);
                                }
 
                                // Completed processing all markers.
-                               if (offset === layersArray.length) {
+                               if (offset === l) {
 
                                        // Refresh bounds and weighted positions.
                                        this._topClusterLevel._recalculateBounds();
 
-                                       //Update the icons of all those visible clusters that were affected
-                                       this._featureGroup.eachLayer(function (c) {
-                                               if (c instanceof L.MarkerCluster && c._iconNeedsUpdate) {
-                                                       c._updateIcon();
-                                               }
-                                       });
+                                       this._refreshClustersIcons();
 
                                        this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, this._currentShownBounds);
                                } else {
@@ -254,9 +268,21 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
                        process();
                } else {
-                       newMarkers = [];
-                       for (i = 0, l = layersArray.length; i < l; i++) {
-                               m = layersArray[i];
+                       var needsClustering = this._needsClustering;
+
+                       for (; offset < l; offset++) {
+                               m = layersArray[offset];
+
+                               // Group of layers, append children to layersArray and skip.
+                               if (m instanceof L.LayerGroup) {
+                                       if (originalArray) {
+                                               layersArray = layersArray.slice();
+                                               originalArray = false;
+                                       }
+                                       this._extractNonGroupLayers(m, layersArray);
+                                       l = layersArray.length;
+                                       continue;
+                               }
 
                                //Not point data, can't be clustered
                                if (!m.getLatLng) {
@@ -268,22 +294,35 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                                        continue;
                                }
 
-                               newMarkers.push(m);
+                               needsClustering.push(m);
                        }
-                       this._needsClustering = this._needsClustering.concat(newMarkers);
                }
                return this;
        },
 
        //Takes an array of markers and removes them in bulk
        removeLayers: function (layersArray) {
-               var i, l, m,
-                       fg = this._featureGroup,
-                       npg = this._nonPointGroup;
+               var i, m,
+                   l = layersArray.length,
+                   fg = this._featureGroup,
+                   npg = this._nonPointGroup,
+                   originalArray = true;
 
                if (!this._map) {
-                       for (i = 0, l = layersArray.length; i < l; i++) {
+                       for (i = 0; i < l; i++) {
                                m = layersArray[i];
+
+                               // Group of layers, append children to layersArray and skip.
+                               if (m instanceof L.LayerGroup) {
+                                       if (originalArray) {
+                                               layersArray = layersArray.slice();
+                                               originalArray = false;
+                                       }
+                                       this._extractNonGroupLayers(m, layersArray);
+                                       l = layersArray.length;
+                                       continue;
+                               }
+
                                this._arraySplice(this._needsClustering, m);
                                npg.removeLayer(m);
                                if (this.hasLayer(m)) {
@@ -295,15 +334,38 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
                if (this._unspiderfy) {
                        this._unspiderfy();
-                       for (i = 0, l = layersArray.length; i < l; i++) {
-                               m = layersArray[i];
+
+                       // Work on a copy of the array, so that next loop is not affected.
+                       var layersArray2 = layersArray.slice(),
+                           l2 = l;
+                       for (i = 0; i < l2; i++) {
+                               m = layersArray2[i];
+
+                               // Group of layers, append children to layersArray and skip.
+                               if (m instanceof L.LayerGroup) {
+                                       this._extractNonGroupLayers(m, layersArray2);
+                                       l2 = layersArray2.length;
+                                       continue;
+                               }
+
                                this._unspiderfyLayer(m);
                        }
                }
 
-               for (i = 0, l = layersArray.length; i < l; i++) {
+               for (i = 0; i < l; i++) {
                        m = layersArray[i];
 
+                       // Group of layers, append children to layersArray and skip.
+                       if (m instanceof L.LayerGroup) {
+                               if (originalArray) {
+                                       layersArray = layersArray.slice();
+                                       originalArray = false;
+                               }
+                               this._extractNonGroupLayers(m, layersArray);
+                               l = layersArray.length;
+                               continue;
+                       }
+
                        if (!m.__parent) {
                                npg.removeLayer(m);
                                continue;
@@ -322,15 +384,11 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                // Refresh bounds and weighted positions.
                this._topClusterLevel._recalculateBounds();
 
+               this._refreshClustersIcons();
+
                //Fix up the clusters and markers on the map
                this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, this._currentShownBounds);
 
-               fg.eachLayer(function (c) {
-                       if (c instanceof L.MarkerCluster) {
-                               c._updateIcon();
-                       }
-               });
-
                return this;
        },
 
@@ -354,6 +412,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                this._nonPointGroup.clearLayers();
 
                this.eachLayer(function (marker) {
+                       marker.off('move', this._childMarkerMoved, this);
                        delete marker.__parent;
                });
 
@@ -385,6 +444,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
        //Overrides LayerGroup.eachLayer
        eachLayer: function (method, context) {
                var markers = this._needsClustering.slice(),
+                       needsRemoving = this._needsRemoving,
                        i;
 
                if (this._topClusterLevel) {
@@ -392,7 +452,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                }
 
                for (i = markers.length - 1; i >= 0; i--) {
-                       method.call(context, markers[i]);
+                       if (needsRemoving.indexOf(markers[i]) === -1) {
+                               method.call(context, markers[i]);
+                       }
                }
 
                this._nonPointGroup.eachLayer(method, context);
@@ -470,7 +532,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                if (layer._icon && this._map.getBounds().contains(layer.getLatLng())) {
                        //Layer is visible ond on screen, immediate return
                        callback();
-               } else if (layer.__parent._zoom < this._map.getZoom()) {
+               } else if (layer.__parent._zoom < Math.round(this._map._zoom)) {
                        //Layer should be visible at this zoom level. It must not be on screen so just pan over to it
                        this._map.on('moveend', showMarker, this);
                        this._map.panTo(layer.getLatLng());
@@ -501,8 +563,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                        throw "Map has no maxZoom specified";
                }
 
-               this._featureGroup.onAdd(map);
-               this._nonPointGroup.onAdd(map);
+               this._featureGroup.addTo(map);
+               this._nonPointGroup.addTo(map);
 
                if (!this._gridClusters) {
                        this._generateInitialClusters();
@@ -517,7 +579,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                this._needsRemoving = [];
 
                //Remember the current zoom level and bounds
-               this._zoom = this._map.getZoom();
+               this._zoom = Math.round(this._map._zoom);
                this._currentShownBounds = this._getExpandedVisibleBounds();
 
                this._map.on('zoomend', this._zoomEnd, this);
@@ -553,8 +615,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
                //Clean up all the layers we added to the map
                this._hideCoverage();
-               this._featureGroup.onRemove(map);
-               this._nonPointGroup.onRemove(map);
+               this._featureGroup.remove();
+               this._nonPointGroup.remove();
 
                this._featureGroup.clearLayers();
 
@@ -586,7 +648,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
         * @private
         */
        _removeFromGridUnclustered: function (marker, z) {
-               var map = this._map,
+               var map             = this._map,
                    gridUnclustered = this._gridUnclustered;
 
                for (; z >= 0; z--) {
@@ -596,6 +658,16 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                }
        },
 
+       _childMarkerMoved: function (e) {
+               if (!this._ignoreMove) {
+                       e.target._latlng = e.oldLatLng;
+                       this.removeLayer(e.target);
+
+                       e.target._latlng = e.latlng;
+                       this.addLayer(e.target);
+               }
+       },
+
        //Internal function for removing a marker from everything.
        //dontUpdateMap: set to true if you will handle updating the map manually (for bulk functions)
        _removeLayer: function (marker, removeFromDistanceGrid, dontUpdateMap) {
@@ -645,9 +717,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                                        }
                                }
                        } else {
-                               if (!dontUpdateMap || !cluster._icon) {
-                                       cluster._updateIcon();
-                               }
+                               cluster._iconNeedsUpdate = true;
                        }
 
                        cluster = cluster.__parent;
@@ -666,16 +736,22 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                return false;
        },
 
-       _propagateEvent: function (e) {
-               if (e.layer instanceof L.MarkerCluster) {
+       //Override L.Evented.fire
+       fire: function (type, data, propagate) {
+               if (data && data.layer instanceof L.MarkerCluster) {
                        //Prevent multiple clustermouseover/off events if the icon is made up of stacked divs (Doesn't work in ie <= 8, no relatedTarget)
-                       if (e.originalEvent && this._isOrIsParent(e.layer._icon, e.originalEvent.relatedTarget)) {
+                       if (data.originalEvent && this._isOrIsParent(data.layer._icon, data.originalEvent.relatedTarget)) {
                                return;
                        }
-                       e.type = 'cluster' + e.type;
+                       type = 'cluster' + type;
                }
 
-               this.fire(e.type, e);
+               L.FeatureGroup.prototype.fire.call(this, type, data, propagate);
+       },
+
+       //Override L.Evented.listens
+       listens: function (type, propagate) {
+               return L.FeatureGroup.prototype.listens.call(this, type, propagate) || L.FeatureGroup.prototype.listens.call(this, 'cluster' + type, propagate);
        },
 
        //Default functionality
@@ -721,11 +797,12 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                        bottomCluster = bottomCluster._childClusters[0];
                }
 
-               if (bottomCluster._zoom === this._maxZoom && bottomCluster._childCount === cluster._childCount) {
+               if (bottomCluster._zoom === this._maxZoom &&
+                       bottomCluster._childCount === cluster._childCount &&
+                       this.options.spiderfyOnMaxZoom) {
+
                        // All child markers are contained in a single cluster from this._maxZoom to this cluster.
-                       if (this.options.spiderfyOnMaxZoom) {
-                               cluster.spiderfy();
-                       }
+                       cluster.spiderfy();
                } else if (this.options.zoomToBoundsOnClick) {
                        cluster.zoomToBounds();
                }
@@ -779,7 +856,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                }
                this._mergeSplitClusters();
 
-               this._zoom = this._map._zoom;
+               this._zoom = Math.round(this._map._zoom);
                this._currentShownBounds = this._getExpandedVisibleBounds();
        },
 
@@ -791,7 +868,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                var newBounds = this._getExpandedVisibleBounds();
 
                this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._zoom, newBounds);
-               this._topClusterLevel._recursivelyAddChildrenToMap(null, this._map._zoom, newBounds);
+               this._topClusterLevel._recursivelyAddChildrenToMap(null, Math.round(this._map._zoom), newBounds);
 
                this._currentShownBounds = newBounds;
                return;
@@ -836,6 +913,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                        this._overrideMarkerIcon(layer);
                }
 
+               layer.on('move', this._childMarkerMoved, this);
+
                //Find the lowest zoom level to slot this one in
                for (; zoom >= 0; zoom--) {
                        markerPoint = this._map.project(layer.getLatLng(), zoom); // calculate pixel position
@@ -887,6 +966,19 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                return;
        },
 
+       /**
+        * Refreshes the icon of all "dirty" visible clusters.
+        * Non-visible "dirty" clusters will be updated when they are added to the map.
+        * @private
+        */
+       _refreshClustersIcons: function () {
+               this._featureGroup.eachLayer(function (c) {
+                       if (c instanceof L.MarkerCluster && c._iconNeedsUpdate) {
+                               c._updateIcon();
+                       }
+               });
+       },
+
        //Enqueue code to fire after the marker expand/contract has happened
        _enqueue: function (fn) {
                this._queue.push(fn);
@@ -905,21 +997,22 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
        //Merge and split any existing clusters that are too big or small
        _mergeSplitClusters: function () {
+               var mapZoom = Math.round(this._map._zoom);
 
-               //Incase we are starting to split before the animation finished
+               //In case we are starting to split before the animation finished
                this._processQueue();
 
-               if (this._zoom < this._map._zoom && this._currentShownBounds.intersects(this._getExpandedVisibleBounds())) { //Zoom in, split
+               if (this._zoom < mapZoom && this._currentShownBounds.intersects(this._getExpandedVisibleBounds())) { //Zoom in, split
                        this._animationStart();
                        //Remove clusters now off screen
                        this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._zoom, this._getExpandedVisibleBounds());
 
-                       this._animationZoomIn(this._zoom, this._map._zoom);
+                       this._animationZoomIn(this._zoom, mapZoom);
 
-               } else if (this._zoom > this._map._zoom) { //Zoom out, merge
+               } else if (this._zoom > mapZoom) { //Zoom out, merge
                        this._animationStart();
 
-                       this._animationZoomOut(this._zoom, this._map._zoom);
+                       this._animationZoomOut(this._zoom, mapZoom);
                } else {
                        this._moveEnd();
                }
@@ -976,6 +1069,34 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
                }
        },
 
+       /**
+        * Extracts individual (i.e. non-group) layers from a Layer Group.
+        * @param group to extract layers from.
+        * @param output {Array} in which to store the extracted layers.
+        * @returns {*|Array}
+        * @private
+        */
+       _extractNonGroupLayers: function (group, output) {
+               var layers = group.getLayers(),
+                   i = 0,
+                   layer;
+
+               output = output || [];
+
+               for (; i < layers.length; i++) {
+                       layer = layers[i];
+
+                       if (layer instanceof L.LayerGroup) {
+                               this._extractNonGroupLayers(layer, output);
+                               continue;
+                       }
+
+                       output.push(layer);
+               }
+
+               return output;
+       },
+
        /**
         * Implements the singleMarkerMode option.
         * @param layer Marker to re-style using the Clusters iconCreateFunction.
@@ -1025,17 +1146,21 @@ L.MarkerClusterGroup.include({
                        this._animationAddLayerNonAnimated(layer, newCluster);
                }
        },
+
        _withAnimation: {
                //Animated versions here
                _animationStart: function () {
                        this._map._mapPane.className += ' leaflet-cluster-anim';
                        this._inZoomAnimation++;
                },
+
                _animationZoomIn: function (previousZoomLevel, newZoomLevel) {
                        var bounds = this._getExpandedVisibleBounds(),
                            fg     = this._featureGroup,
                            i;
 
+                       this._ignoreMove = true;
+
                        //Add all children of current clusters to map and remove those clusters from map
                        this._topClusterLevel._recursively(bounds, previousZoomLevel, 0, function (c) {
                                var startPos = c._latlng,
@@ -1082,6 +1207,8 @@ L.MarkerClusterGroup.include({
                                c._recursivelyRestoreChildPositions(newZoomLevel);
                        });
 
+                       this._ignoreMove = false;
+
                        //Remove the old clusters and close the zoom animation
                        this._enqueue(function () {
                                //update the positions of the just added clusters/markers
@@ -1102,6 +1229,7 @@ L.MarkerClusterGroup.include({
                        //Remove markers that were on the map before but won't be now
                        this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, previousZoomLevel, this._getExpandedVisibleBounds());
                },
+
                _animationAddLayer: function (layer, newCluster) {
                        var me = this,
                            fg = this._featureGroup;
@@ -1128,7 +1256,7 @@ L.MarkerClusterGroup.include({
                                        this._forceLayout();
 
                                        me._animationStart();
-                                       me._animationZoomOutSingle(newCluster, this._map.getMaxZoom(), this._map.getZoom());
+                                       me._animationZoomOutSingle(newCluster, this._map.getMaxZoom(), this._zoom);
                                }
                        }
                }
@@ -1155,7 +1283,9 @@ L.MarkerClusterGroup.include({
                        if (cluster._childCount === 1) {
                                var m = cluster._markers[0];
                                //If we were in a cluster animation at the time then the opacity and position of our child could be wrong now, so fix it
+                               this._ignoreMove = true;
                                m.setLatLng(m.getLatLng());
+                               this._ignoreMove = false;
                                if (m.clusterShow) {
                                        m.clusterShow();
                                }
@@ -1563,29 +1693,20 @@ L.MarkerCluster = L.Marker.extend({
                    zoom = this._zoom,
                    i, c;
 
-               if (zoomLevelToStart > zoom) { //Still going down to required depth, just recurse to child clusters
-                       for (i = childClusters.length - 1; i >= 0; i--) {
-                               c = childClusters[i];
-                               if (boundsToApplyTo.intersects(c._bounds)) {
-                                       c._recursively(boundsToApplyTo, zoomLevelToStart, zoomLevelToStop, runAtEveryLevel, runAtBottomLevel);
-                               }
-                       }
-               } else { //In required depth
-
+               if (zoomLevelToStart <= zoom) {
                        if (runAtEveryLevel) {
                                runAtEveryLevel(this);
                        }
-                       if (runAtBottomLevel && this._zoom === zoomLevelToStop) {
+                       if (runAtBottomLevel && zoom === zoomLevelToStop) {
                                runAtBottomLevel(this);
                        }
+               }
 
-                       //TODO: This loop is almost the same as above
-                       if (zoomLevelToStop > zoom) {
-                               for (i = childClusters.length - 1; i >= 0; i--) {
-                                       c = childClusters[i];
-                                       if (boundsToApplyTo.intersects(c._bounds)) {
-                                               c._recursively(boundsToApplyTo, zoomLevelToStart, zoomLevelToStop, runAtEveryLevel, runAtBottomLevel);
-                                       }
+               if (zoom < zoomLevelToStart || zoom < zoomLevelToStop) {
+                       for (i = childClusters.length - 1; i >= 0; i--) {
+                               c = childClusters[i];
+                               if (boundsToApplyTo.intersects(c._bounds)) {
+                                       c._recursively(boundsToApplyTo, zoomLevelToStart, zoomLevelToStop, runAtEveryLevel, runAtBottomLevel);
                                }
                        }
                }
@@ -2008,6 +2129,8 @@ L.MarkerCluster.include({
                        childMarkers = this.getAllChildMarkers(),
                        m, i;
 
+               group._ignoreMove = true;
+
                this.setOpacity(1);
                for (i = childMarkers.length - 1; i >= 0; i--) {
                        m = childMarkers[i];
@@ -2027,11 +2150,12 @@ L.MarkerCluster.include({
                                delete m._spiderLeg;
                        }
                }
-               
+
                group.fire('unspiderfied', {
                        cluster: this,
                        markers: childMarkers
                });
+               group._ignoreMove = false;
                group._spiderfied = null;
        }
 });
@@ -2045,6 +2169,8 @@ L.MarkerClusterNonAnimated = L.MarkerCluster.extend({
                        legOptions = this._group.options.spiderLegPolylineOptions,
                        i, m, leg, newPos;
 
+               group._ignoreMove = true;
+
                // Traverse in ascending order to make sure that inner circleMarkers are on top of further legs. Normal markers are re-ordered by newPosition.
                // The reverse order trick no longer improves performance on modern browsers.
                for (i = 0; i < childMarkers.length; i++) {
@@ -2066,6 +2192,8 @@ L.MarkerClusterNonAnimated = L.MarkerCluster.extend({
                        fg.addLayer(m);
                }
                this.setOpacity(0.3);
+
+               group._ignoreMove = false;
                group.fire('spiderfied', {
                        cluster: this,
                        markers: childMarkers
@@ -2107,6 +2235,8 @@ L.MarkerCluster.include({
                        legOptions.opacity = finalLegOpacity;
                }
 
+               group._ignoreMove = true;
+
                // Add markers and spider legs to map, hidden at our center point.
                // Traverse in ascending order to make sure that inner circleMarkers are on top of further legs. Normal markers are re-ordered by newPosition.
                // The reverse order trick no longer improves performance on modern browsers.
@@ -2136,7 +2266,7 @@ L.MarkerCluster.include({
                        if (m.clusterHide) {
                                m.clusterHide();
                        }
-
+                       
                        // Vectors just get immediately added
                        fg.addLayer(m);
 
@@ -2172,6 +2302,8 @@ L.MarkerCluster.include({
                }
                this.setOpacity(0.3);
 
+               group._ignoreMove = false;
+
                setTimeout(function () {
                        group._animationEnd();
                        group.fire('spiderfied', {
@@ -2191,6 +2323,7 @@ L.MarkerCluster.include({
                        svg = L.Path.SVG,
                        m, i, leg, legPath, legLength, nonAnimatable;
 
+               group._ignoreMove = true;
                group._animationStart();
 
                //Make us visible and bring the child markers back in
@@ -2231,6 +2364,8 @@ L.MarkerCluster.include({
                        }
                }
 
+               group._ignoreMove = false;
+
                setTimeout(function () {
                        //If we have only <= one child left then that marker will be shown on the map so don't remove it!
                        var stillThereChildCount = 0;
@@ -2277,6 +2412,10 @@ L.MarkerClusterGroup.include({
        //The MarkerCluster currently spiderfied (if any)
        _spiderfied: null,
 
+       unspiderfy: function () {
+               this._unspiderfy.apply(this, arguments);
+       },
+
        _spiderfierOnAdd: function () {
                this._map.on('click', this._unspiderfyWrapper, this);
 
@@ -2285,6 +2424,13 @@ L.MarkerClusterGroup.include({
                }
                //Browsers without zoomAnimation or a big zoom don't fire zoomstart
                this._map.on('zoomend', this._noanimationUnspiderfy, this);
+
+               if (!L.Browser.touch) {
+                       this._map.getRenderer(this);
+                       //Needs to happen in the pageload, not after, or animations don't work in webkit
+                       //  http://stackoverflow.com/questions/8455200/svg-animate-with-dynamically-added-elements
+                       //Disable on touch browsers as the animation messes up on a touch zoom and isn't very noticable
+               }
        },
 
        _spiderfierOnRemove: function () {
@@ -2343,7 +2489,7 @@ L.MarkerClusterGroup.include({
                        if (layer.clusterShow) {
                                layer.clusterShow();
                        }
-                       //Position will be fixed up immediately in _animationUnspiderfy
+                               //Position will be fixed up immediately in _animationUnspiderfy
                        if (layer.setZIndexOffset) {
                                layer.setZIndexOffset(0);
                        }
@@ -2418,19 +2564,6 @@ L.MarkerClusterGroup.include({
                }
        },
 
-       /**
-        * Refreshes the icon of all "dirty" visible clusters.
-        * Non-visible "dirty" clusters will be updated when they are added to the map.
-        * @private
-        */
-       _refreshClustersIcons: function () {
-               this._featureGroup.eachLayer(function (c) {
-                       if (c instanceof L.MarkerCluster && c._iconNeedsUpdate) {
-                               c._updateIcon();
-                       }
-               });
-       },
-
        /**
         * Re-draws the icon of the supplied markers.
         * To be used in singleMarkerMode only.
index 2aae5fe..58aa9d4 100755 (executable)
@@ -3,7 +3,7 @@
        -moz-transition: -moz-transform 0.3s ease-out, opacity 0.3s ease-in;
        -o-transition: -o-transform 0.3s ease-out, opacity 0.3s ease-in;
        transition: transform 0.3s ease-out, opacity 0.3s ease-in;
-       }
+}
 
 .leaflet-cluster-spider-leg {
        /* stroke-dashoffset (duration and function) should match with leaflet-marker-icon transform in order to track it exactly */
index 9f48f22..9de3423 100644 (file)
@@ -63,6 +63,7 @@ Clustering (regroupement de points proches) :
 - clusterShowCoverageOnHover = oui   Affiche au survol du cluster le contour de la zone couverte par les points regroupés\r
 - maxClusterRadius = 80              Le rayon maximal (en pixels) qu'un cluster couvrira (80 pixels par defaut)\r
 - clusterSpiderfyOnMaxZoom = oui     Active l'effet d'éclatement pour afficher les points qui se chevauchent\r
+- singleMarkerMode = oui                Utilise les icones de cluster pour tous les points (même ceux qui ne sont pas dans un cluster)\r
 ]\r
 \r
 [(#SET{width,#ENV{width,#ENV{largeur,100%}}})]\r
@@ -74,6 +75,7 @@ Clustering (regroupement de points proches) :
 [(#REM) On utilise la bounding box seulement si le centre n'a pas été donné et si les quatre valeurs de la bounding box sont renseignées\r
     les valeurs par defaut sont "centre +/- 10°", ce qui est naze, mais c'est un cas normalement impossible\r
 ]\r
+#SET{utiliser_bb, ''}\r
 [(#ENV{lat}|ou{#ENV{lon}}|non|et{#ENV{sw_lat}}|et{#ENV{sw_lon}}|et{#ENV{ne_lat}}|et{#ENV{ne_lon}})\r
        #SET{utiliser_bb, oui}\r
        #SET{sw_lat,#ENV{sw_lat,#GET{lat}|moins{10}}}\r
@@ -101,21 +103,21 @@ var jQgisloader;
                                        mapId: '[(#GET{id})]',\r
                                        callback: (typeof(callback_map[(#GET{id})]) === "function") ? callback_map[(#GET{id})] : false,\r
                                        center: [#GET{lat},#GET{lon}],\r
-                                       zoom: [(#ENV{zoom,#CONFIG{gis/zoom,0}})][,\r
-                                       maxZoom: (#ENV{maxZoom})][,\r
-                                       minZoom: (#ENV{minZoom})][,\r
-                                       default_layer: '(#ENV{default_layer})'][,\r
-                                       affiche_layers: (#ENV{affiche_layers}|?{[(#ENV{affiche_layers}|explode{/}|json_encode)],''})],\r
-                                       scrollWheelZoom: [(#ENV{zoom_molette,#ENV{zoom_wheel}}|=={non}|?{false,true})],\r
-                                       zoomControl: [(#ENV{no_control,#ENV{aucun_controle}}|!={oui}|?{true,false})],\r
-                                       fullscreenControl: [(#ENV{fullscreen}|=={oui}|?{true,false})],\r
-                                       scaleControl: [(#ENV{scale}|=={oui}|?{true,false})],\r
-                                       overviewControl:[(#ENV{overview}|=={oui}|?{true,false})],\r
-                                       layersControl: [(#ENV{control_type,#ENV{controle_type}}|=={non}|?{false,true})],\r
+                                       zoom: [(#ENV{zoom,#CONFIG{gis/zoom,0}}|trim)][,\r
+                                       maxZoom: (#ENV{maxZoom}|trim)][,\r
+                                       minZoom: (#ENV{minZoom}|trim)][,\r
+                                       default_layer: '(#ENV{default_layer}|trim)'][,\r
+                                       affiche_layers: (#ENV{affiche_layers}|trim|?{[(#ENV{affiche_layers}|trim|explode{/}|json_encode)],''})],\r
+                                       scrollWheelZoom: [(#ENV{zoom_molette,#ENV{zoom_wheel}}|trim|=={non}|?{false,true})],\r
+                                       zoomControl: [(#ENV{no_control,#ENV{aucun_controle}}|trim|!={oui}|?{true,false})],\r
+                                       fullscreenControl: [(#ENV{fullscreen}|trim|=={oui}|?{true,false})],\r
+                                       scaleControl: [(#ENV{scale}|trim|=={oui}|?{true,false})],\r
+                                       overviewControl:[(#ENV{overview}|trim|=={oui}|?{true,false})],\r
+                                       layersControl: [(#ENV{control_type,#ENV{controle_type}}|trim|=={non}|?{false,true})],\r
                                        layersControlOptions: {\r
-                                               collapsed: [(#ENV{control_type_collapsed,#ENV{control_type_collapsed}}|=={non}|?{false,true})]\r
+                                               collapsed: [(#ENV{control_type_collapsed,#ENV{control_type_collapsed}}|trim|=={non}|?{false,true})]\r
                                        },\r
-                                       noControl: [(#ENV{no_control,#ENV{aucun_controle}}|=={oui}|?{true,false})],\r
+                                       noControl: [(#ENV{no_control,#ENV{aucun_controle}}|trim|=={oui}|?{true,false})],\r
                                        utiliser_bb: [(#GET{utiliser_bb}|?{true,false})][,\r
                                        sw_lat: (#GET{sw_lat})][,\r
                                        ne_lat: (#GET{ne_lat})][,\r
@@ -128,23 +130,24 @@ var jQgisloader;
                                                objets: '(#ENV{objets,#ENV{class}}|trim)'],\r
                                                limit: [(#ENV{limit,#ENV{limite,500}}|trim)],\r
                                                env: [(#ENV*{args,#ENV*}|gis_modele_url_json_env|json_encode)][,\r
-                                               titre: (#ENV{titre}|?{#ENV{titre},''}|json_encode)][,\r
-                                               description: (#ENV{description}|?{#ENV{description},''}|json_encode)][,\r
-                                               icone: (#ENV{icone}|?{#ENV{icone},''}|json_encode)]\r
+                                               titre: (#ENV{titre}|?{#ENV{titre},''}|trim|json_encode)][,\r
+                                               description: (#ENV{description}|?{#ENV{description},''}|trim|json_encode)][,\r
+                                               icone: (#ENV{icone}|?{#ENV{icone},''}|trim|json_encode)]\r
                                        },\r
                                        cluster: [(#ENV{cluster}|=={oui}|?{true,false})],\r
                                        clusterOptions: {\r
                                                disableClusteringAtZoom: [(#ENV{clusterMaxZoom,0})],\r
                                                showCoverageOnHover: [(#ENV{clusterShowCoverageOnHover}|?{true,false})],\r
                                                spiderfyOnMaxZoom: [(#ENV{clusterSpiderfyOnMaxZoom}|?{true,false})],\r
-                                               maxClusterRadius: [(#ENV{maxClusterRadius,80})]\r
+                                               maxClusterRadius: [(#ENV{maxClusterRadius,80})],\r
+                                               singleMarkerMode: [(#ENV{singleMarkerMode}|?{true,false})]\r
                                        },\r
                                        pathStyles: [(#ENV*{path_styles}|json_encode)],\r
-                                       autocenterandzoom: [(#ENV{autocenterandzoom,#ENV{centrer_auto,non}}|=={non}|?{false,true})],\r
+                                       autocenterandzoom: [(#ENV{autocenterandzoom,#ENV{centrer_auto,non}}|trim|=={non}|?{false,true})],\r
                                        openId: [(#ENV{id_a_ouvrir,false})],\r
-                                       localize_visitor: [(#ENV{localize_visitor,#ENV{localiser_visiteur}}|?{true,false})],\r
-                                       localize_visitor_zoom: [(#ENV{localize_visitor_zoom,#ENV{zoom,#CONFIG{gis/zoom,0}}})],\r
-                                       centrer_fichier: [(#ENV{centrer_fichier,oui}|=={oui}|?{true,false})],\r
+                                       localize_visitor: [(#ENV{localize_visitor,#ENV{localiser_visiteur}}|trim|?{true,false})],\r
+                                       localize_visitor_zoom: [(#ENV{localize_visitor_zoom,#ENV{zoom,#CONFIG{gis/zoom,0}}}|trim)],\r
+                                       centrer_fichier: [(#ENV{centrer_fichier,oui}|trim|=={oui}|?{true,false})],\r
                                        kml: [(#ENV{kml,''}|?{[(#ENV{kml}|gis_param_to_array|gis_kml_to_urls|json_encode)],false})],\r
                                        gpx: [(#ENV{gpx,''}|?{[(#ENV{gpx}|gis_param_to_array|gis_kml_to_urls|json_encode)],false})],\r
                                        geojson: [(#ENV{geojson,''}|?{[(#ENV{geojson}|gis_param_to_array|gis_kml_to_urls|json_encode)],false})],\r
index ed83889..165f625 100755 (executable)
 #SET{autocenter,''}\r
 <script type="text/javascript">\r
 /*<![CDATA[*/\r
-(function($){\r
-       var init_map_preview = function() {\r
-               var map_preview;\r
-               var map_preview_container = 'map_preview';\r
-               var marker;\r
-               \r
-               map_preview = new L.Map(map_preview_container);\r
-               \r
-               map_preview.attributionControl.setPrefix('');\r
-\r
-               var base_layer = [(#ENV{layer_defaut}|=={none}|?{"'none'",[new (#EVAL{$GLOBALS\['gis_layers'\]}|table_valeur{[(#ENV{layer_defaut,[(#REM|gis_layer_defaut)]})]/layer})]})];\r
-               if(base_layer != 'none'){\r
-                       map_preview.addLayer(base_layer);\r
+var jQgisloader;\r
+(function (){\r
+       if (typeof jQuery.ajax == "undefined"){ jQuery(init_gis); } else { init_gis(); }\r
+       function init_gis(){\r
+               // Charger le javascript de GIS une seule fois si plusieurs carte\r
+               if (typeof jQgisloader=="undefined"){\r
+                       jQgisloader = jQuery.ajax({url: '[(#PRODUIRE{fond=javascript/gis.js})]', dataType: 'script', cache: true});\r
                }\r
-               \r
-               map_preview.setView(new L.LatLng([(#LAT)],[(#LON)]),[(#ZOOM|sinon{#CONFIG{gis/zoom,0}})]);\r
-
-               [(#REM) On ajoute les points ou le point unique suivant les params ]\r
-               <B_points>\r
-               var data = {\r
-                       "type": "FeatureCollection",\r
-                       "features": [\r
-               <BOUCLE_points(GIS){id_objet}{objet}{","}>\r
-                               {"type": "Feature",\r
-                                       "geometry": {"type": "Point", "coordinates": [#LON, #LAT]},\r
-                                       "id":"#ID_GIS",\r
-                                       "properties": {\r
-                                               "title":[(#TITRE|supprimer_numero|json_encode)],\r
-                                               "description":[(#DESCRIPTIF|json_encode)][\r
-                                               (#LOGO_GIS|gis_icon_properties)]\r
-                                       }\r
-                               }\r
-               </BOUCLE_points>\r
-                       ]\r
-               };\r
-               [(#TOTAL_BOUCLE|>{1}|oui) #SET{autocenter,oui} ]\r
-               </B_points>\r
-               <BOUCLE_point(GIS){id_gis}>\r
-               var data = {\r
-                       "type": "FeatureCollection",\r
-                       "features": [\r
-                               {"type": "Feature",\r
-                                       "geometry": {"type": "Point", "coordinates": [#LON, #LAT]},\r
-                                       "id":"#ID_GIS",\r
-                                       "properties": {\r
-                                               "title":[(#TITRE|supprimer_numero|json_encode)],\r
-                                               "description":[(#DESCRIPTIF|json_encode)][\r
-                                               (#LOGO_GIS|gis_icon_properties)]\r
-                                       }\r
-                               }]\r
-               };\r
-               </BOUCLE_point>\r
-               <//B_points>\r
-               if (data) {\r
-                       var geojson = new L.geoJson('', {\r
-                               onEachFeature: function (feature, layer) {\r
-                                       if (feature.properties && feature.properties.icon){\r
-                                               layer.setIcon(new L.Icon({\r
-                                                       iconUrl: feature.properties.icon,\r
-                                                       iconSize: new L.Point( feature.properties.icon_size\[0\], feature.properties.icon_size\[1\] ),\r
-                                                       iconAnchor: new L.Point( feature.properties.icon_anchor\[0\], feature.properties.icon_anchor\[1\] ),\r
-                                                       popupAnchor: new L.Point( feature.properties.popup_anchor\[0\], feature.properties.popup_anchor\[1\] )\r
-                                               }));\r
-                                       }\r
-                                       if (feature.properties && feature.properties.title){\r
-                                               var popupContent = '<strong>' + feature.properties.title + '</strong>';\r
-                                               if (feature.properties.description)\r
-                                                       popupContent = popupContent + feature.properties.description;\r
-                                               layer.bindPopup(popupContent);\r
-                                       }\r
+               // et initialiser la carte (des que js GIS charge et des que DOM ready)\r
+               jQgisloader.done(function(){\r
+                       jQuery(function(){\r
+                               var map_preview;\r
+                               var map_preview_container = 'map_preview';\r
+                               var marker;\r
+                               \r
+                               map_preview = new L.Map(map_preview_container);\r
+                               \r
+                               map_preview.attributionControl.setPrefix('');\r
+\r
+                               var base_layer = [(#ENV{layer_defaut}|=={none}|?{"'none'",[new (#EVAL{$GLOBALS\['gis_layers'\]}|table_valeur{[(#ENV{layer_defaut,[(#REM|gis_layer_defaut)]})]/layer})]})];\r
+                               if(base_layer != 'none'){\r
+                                       map_preview.addLayer(base_layer);\r
                                }\r
-                       }).addTo(map_preview);\r
-                       geojson.addData(data);\r
-                       [(#GET{autocenter}|oui)\r
-                       if(data.features.length > 1)\r
-                               map_preview.fitBounds(geojson.getBounds());]\r
-               }\r
-               [(#REM) On ajoute les KML attachés à l'objet ]\r
-               <BOUCLE_kml(DOCUMENTS){tous}{objet}{id_objet}{extension=kml}>\r
-               map_preview.addLayer(new L.KML('[(#URL_DOCUMENT|url_absolue)]', {async: true}));\r
-               </BOUCLE_kml>\r
-               [(#REM) On ajoute les GPX attachés à l'objet ]\r
-               <BOUCLE_gpx(DOCUMENTS){tous}{objet}{id_objet}{extension=gpx}>\r
-               map_preview.addLayer(new L.GPX('[(#URL_DOCUMENT|url_absolue)]', {async: true}));\r
-               </BOUCLE_gpx>\r
-       }\r
+                               \r
+                               map_preview.setView(new L.LatLng([(#LAT)],[(#LON)]),[(#ZOOM|sinon{#CONFIG{gis/zoom,0}})]);\r
 \r
-       $(function(){\r
-               jQuery.getScript('[(#PRODUIRE{fond=javascript/gis.js}|compacte)]',function(){\r
-                       init_map_preview();\r
+                               [(#REM) On ajoute les points ou le point unique suivant les params ]\r
+                               <B_points>\r
+                               var data = {\r
+                                       "type": "FeatureCollection",\r
+                                       "features": [\r
+                               <BOUCLE_points(GIS){id_objet}{objet}{","}>\r
+                                               {"type": "Feature",\r
+                                                       "geometry": {"type": "Point", "coordinates": [#LON, #LAT]},\r
+                                                       "id":"#ID_GIS",\r
+                                                       "properties": {\r
+                                                               "title":[(#TITRE|supprimer_numero|json_encode)],\r
+                                                               "description":[(#DESCRIPTIF|json_encode)][\r
+                                                               (#LOGO_GIS|gis_icon_properties)]\r
+                                                       }\r
+                                               }\r
+                               </BOUCLE_points>\r
+                                       ]\r
+                               };\r
+                               [(#TOTAL_BOUCLE|>{1}|oui) #SET{autocenter,oui} ]\r
+                               </B_points>\r
+                               <BOUCLE_point(GIS){id_gis}>\r
+                               var data = {\r
+                                       "type": "FeatureCollection",\r
+                                       "features": [\r
+                                               {"type": "Feature",\r
+                                                       "geometry": {"type": "Point", "coordinates": [#LON, #LAT]},\r
+                                                       "id":"#ID_GIS",\r
+                                                       "properties": {\r
+                                                               "title":[(#TITRE|supprimer_numero|json_encode)],\r
+                                                               "description":[(#DESCRIPTIF|json_encode)][\r
+                                                               (#LOGO_GIS|gis_icon_properties)]\r
+                                                       }\r
+                                               }]\r
+                               };\r
+                               </BOUCLE_point>\r
+                               <//B_points>\r
+                               if (data) {\r
+                                       var geojson = new L.geoJson('', {\r
+                                               onEachFeature: function (feature, layer) {\r
+                                                       if (feature.properties && feature.properties.icon){\r
+                                                               layer.setIcon(new L.Icon({\r
+                                                                       iconUrl: feature.properties.icon,\r
+                                                                       iconSize: new L.Point( feature.properties.icon_size\[0\], feature.properties.icon_size\[1\] ),\r
+                                                                       iconAnchor: new L.Point( feature.properties.icon_anchor\[0\], feature.properties.icon_anchor\[1\] ),\r
+                                                                       popupAnchor: new L.Point( feature.properties.popup_anchor\[0\], feature.properties.popup_anchor\[1\] )\r
+                                                               }));\r
+                                                       }\r
+                                                       if (feature.properties && feature.properties.title){\r
+                                                               var popupContent = '<strong>' + feature.properties.title + '</strong>';\r
+                                                               if (feature.properties.description)\r
+                                                                       popupContent = popupContent + feature.properties.description;\r
+                                                               layer.bindPopup(popupContent);\r
+                                                       }\r
+                                               }\r
+                                       }).addTo(map_preview);\r
+                                       geojson.addData(data);\r
+                                       [(#GET{autocenter}|oui)\r
+                                       if(data.features.length > 1)\r
+                                               map_preview.fitBounds(geojson.getBounds());]\r
+                               }\r
+                               [(#REM) On ajoute les KML attachés à l'objet ]\r
+                               <BOUCLE_kml(DOCUMENTS){tous}{objet}{id_objet}{extension=kml}>\r
+                               map_preview.addLayer(new L.KML('[(#URL_DOCUMENT|url_absolue)]', {async: true}));\r
+                               </BOUCLE_kml>\r
+                               [(#REM) On ajoute les GPX attachés à l'objet ]\r
+                               <BOUCLE_gpx(DOCUMENTS){tous}{objet}{id_objet}{extension=gpx}>\r
+                               map_preview.addLayer(new L.GPX('[(#URL_DOCUMENT|url_absolue)]', {async: true}));\r
+                               </BOUCLE_gpx>\r
+                       });\r
                });\r
-               //onAjaxLoad(init_map_preview(true));\r
-       });\r
-\r
-})(jQuery);\r
+       }\r
+})()\r
 /*]]>*/\r
 </script>\r
 </BOUCLE_gis>\r
index 10ea5a8..cb06e0b 100644 (file)
@@ -1,7 +1,7 @@
 <paquet
        prefix="gis"
        categorie="divers"
-       version="4.41.1"
+       version="4.43.1"
        schema="2.1.0"
        etat="stable"
        compatibilite="[3.0.0;3.1.*]"
@@ -17,6 +17,7 @@
        <auteur lien="http://www.ldd.fr">Les Développements Durables</auteur>
        <credit lien="http://leafletjs.com/">Leaflet</credit>
        <credit lien="https://github.com/shramov/leaflet-plugins">Leaflet plugins</credit>
+       <credit lien="https://gitlab.com/IvanSanchez/Leaflet.GridLayer.GoogleMutant">Leaflet.GridLayer.GoogleMutant</credit>
        <credit lien="https://github.com/leaflet-extras/leaflet-providers">Leaflet providers</credit>
        <credit lien="https://github.com/brunob/leaflet.fullscreen">Leaflet fullscreen</credit>
        <credit lien="https://github.com/Norkart/Leaflet-MiniMap">Leaflet minimap</credit>
index 9d6a4a4..3afdec5 100644 (file)
@@ -1,22 +1,36 @@
 <div class="onglets_simple clearfix">
        <ul>
-               [<li>(#URL_ECRIRE{gis_tous}|parametre_url{afficher,carte}|lien_ou_expose{Carte,#ENV{afficher,carte}|=={carte},ajax})</li>]
-               [<li>(#URL_ECRIRE{gis_tous}|parametre_url{afficher,liste}|lien_ou_expose{Liste,#ENV{afficher,carte}|=={liste},ajax})</li>]
+               [<li>(#URL_ECRIRE{gis_tous}|parametre_url{afficher,carte}|lien_ou_expose{<:gis:onglet_carte:>,#ENV{afficher,carte}|=={carte},ajax})</li>]
+               [<li>(#URL_ECRIRE{gis_tous}|parametre_url{afficher,liste}|lien_ou_expose{<:gis:onglet_liste:>,#ENV{afficher,carte}|=={liste},ajax})</li>]
        </ul>
        [(#FORMULAIRE_RECHERCHE_ECRIRE{#SELF,ajax})]
 </div>
 
-[(#ENV{afficher,carte}|=={carte}|oui)
+<BOUCLE_si_carte(CONDITION){si #ENV{afficher,carte}|=={liste}|non}>
+       #SET{cluster, non}
+       <BOUCLE_limite(GIS){recherche ?}> </BOUCLE_limite>
+       [(#TOTAL_BOUCLE|>{#ENV{limite,500}}|oui)
+               [(#SET{titre,[(#VAL{gis:titre_limite_atteinte}|_T{#ARRAY{limite,#ENV{limite,500}}})]})]
+               [(#BOITE_OUVRIR{[(#GET{titre})],'notice'})]
+               <p>
+                       [(#SET{nouvelle_limite,[(#TOTAL_BOUCLE|plus{100})]})]
+                       [(#SET{url,[(#SELF|parametre_url{limite,#GET{nouvelle_limite}})]})]
+                       <:gis:message_limite_atteinte{url=#GET{url}}:>
+               </p>
+               [(#BOITE_FERMER)]
+       ]
+       [(#TOTAL_BOUCLE|>{500}|et{#ENV{limite,500}|>{500}}|?{#SET{cluster,oui},''})]</B_limite>
        [(#INCLURE{fond=modeles/carte_gis,
                id_carte_gis=_all,
                objets=tous_avec_liens_espace_prive,
-               recherche}
+               recherche,
+               cluster=#GET{cluster},
+               limite}
        )]
-]
-
-[(#ENV{afficher,carte}|=={liste}|oui)
-       [(#INCLURE{fond=prive/objets/liste/gis,env})]
-]
+</BOUCLE_si_carte>
+</B_si_carte>
+[(#INCLURE{fond=prive/objets/liste/gis,env})]
+<//B_si_carte>
 
 [(#AUTORISER{creer,gis})
        [(#URL_ECRIRE{gis_edit,new=oui}|parametre_url{redirect,#URL_ECRIRE{gis_tous}}|icone_verticale{<:gis:editer_gis_nouveau:>,gis,new,right})]
index 8e0b7bc..954e02b 100644 (file)
@@ -1,10 +1,10 @@
 <svn_revision>
 <text_version>
 Origine: file:///home/svn/repository/spip-zone/_plugins_/gis/trunk
-Revision: 99295
-Dernier commit: 2016-08-31 06:04:04 +0200 
+Revision: 103182
+Dernier commit: 2017-03-07 10:19:01 +0100 
 </text_version>
 <origine>file:///home/svn/repository/spip-zone/_plugins_/gis/trunk</origine>
-<revision>99295</revision>
-<commit>2016-08-31 06:04:04 +0200 </commit>
+<revision>103182</revision>
+<commit>2017-03-07 10:19:01 +0100 </commit>
 </svn_revision>
\ No newline at end of file
index 6db244c..ab8623f 100644 (file)
 
        // Les tests
        $essais['table_objet'] = array(
-       array('gis','gis'),
+               array('gis','gis'),
        );
 
        $essais['table_objet_sql'] = array(
-       array('spip_gis','gis'),
+               array('spip_gis','gis'),
        );
 
        $essais['id_table_objet'] = array(
-       array('id_gis','gis'),
+               array('id_gis','gis'),
        );
 
 
        $essais['objet_type'] = array(
-       array('gis','gis'),
+               array('gis','gis'),
        );
 
        // hop ! on y va