This commit is contained in:
humano 2020-04-05 22:03:19 -05:00
parent 589f5628a6
commit 836776c5b1
8 changed files with 444 additions and 119 deletions

306
labmapero.php Normal file
View File

@ -0,0 +1,306 @@
<?php session_start();
if(isset($_REQUEST['debug'])) {ini_set('display_errors', 'On');}
require ('milfs/xajax/xajax.inc.php');
$xajax = new xajax();
//require ('json.lab.php');
require ('milfs/funciones/funciones.php');
require ("milfs/funciones/conex.php");
include ('milfs/librerias/parsedown/Parsedown.php');
//require_once ('includes/markdown.php');
//require ('funciones/convert.php');
$xajax->processRequests();
//if($_REQUEST[id2] =='') {$agregar= $_REQUEST[id];}else {$agregar = $_REQUEST[id2];}
if(isset($_REQUEST['categoria']) AND isset($_REQUEST['buscar'])) {
$cadena_busqueda = "$_REQUEST[buscar]";
$_REQUEST['buscar'] = "$_REQUEST[categoria]:$_REQUEST[buscar]";
}
$formulario_nombre = remplacetas('form_id','id',$_REQUEST[id],'nombre',"","") ;
$formulario_descripcion = remplacetas('form_id','id',$_REQUEST[id],'descripcion',"","") ;
$descripcion_meta = preg_replace("[\n|\r|\n\r|\t]",'', strip_tags($formulario_descripcion[0]));
$agregar_nombre = remplacetas('form_id','id',$agregar,'nombre',"","") ;
$id_empresa = remplacetas('form_id','id',$_REQUEST[id],'id_empresa',"","") ;
$twitter = remplacetas('empresa','id',"$id_empresa[0]",'twitter','',"","") ;
if($twitter[0] =="") {$twitter[0] ="@tupaleCo";}
$logo = remplacetas('empresa','id',"$id_empresa[0]",'imagen','',"","") ;
$razon_social = remplacetas('empresa','id',"$id_empresa[0]",'razon_social','',"","") ;
$campos_formulario = input_campos("$_REQUEST[id]","categoria");
$uri = "$_SERVER[SERVER_NAME]/$_SERVER[REQUEST_URI]";
$background_imagen = buscar_imagen("$_REQUEST[id]","","","$id_empresa");
$plantilla ="mapa";
$categorias = lista_categorias($_REQUEST['id'],'','mapa') ;
$buscador ="
<form action='?id='$_REQUEST[id]' method='get'>
<input type='hidden' id='id' name='id' value='$_REQUEST[id]' >
$campos_formulario'
<div id='div_campos'></div>
<input type='text' id='buscar' name='buscar' class='form-control ' placeholder='Buscar' >
<br>
<input type='submit' class='btn btn-info btn-block ' value='Buscar'>
</form>
<hr>
";
?>
<!DOCTYPE html>
<html lang="en">
<head >
<title><?php echo "$formulario_nombre[0] / $cadena_busqueda" ?> tupale.co</title>
<meta charset="utf-8">
<!-- <meta name="viewport" content="user-scalable=no, width=device-width, maximum-scale=1, initial-scale=1"> -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- <meta name="viewport" content="width=device-width, initial-scale=1"> -->
<meta name="description" content="">
<meta NAME="Language" CONTENT="Spanish">
<meta NAME="Revisit" CONTENT="1 days">
<meta NAME="Distribution" CONTENT="Global">
<meta NAME="Robots" CONTENT="All">
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="<?php echo $twitter[0]; ?>">
<meta name="twitter:creator" content="@qwerty_co">
<meta name="twitter:url" content="<?php echo $uri ; ?>">
<meta name="twitter:title" content="<?php echo "$formulario_nombre[0] / $cadena_busqueda" ?> tupale.co">
<meta name="twitter:description" content=" <?php echo $descripcion_meta; ?>">
<meta name="twitter:image" content="<?php echo "$_SESSION[url]images/secure/?file=full/$background_imagen"; ?>">
<meta property="og:type" content="article">
<meta property="og:title" content="<?php echo "$formulario_nombre[0] / $cadena_busqueda" ?> tupale.co" />
<meta property="og:type" content="website" />
<meta property="og:url" content="<?php echo "$uri"; ?>" />
<meta property="og:image" content="<?php echo "$_SESSION[url]images/secure/?file=full/$background_imagen"; ?>" />
<meta property="og:site_name" content="<?php echo $razon_social[0]; ?>" />
<meta property="og:description" content=" <?php echo $descripcion_meta; ?>" />
<link rel="shortcut icon" href="<?php echo "milfs/images/secure/?file=150/$logo[0]"; ?>">
<?php $xajax->printJavascript("milfs/xajax/"); ?>
<link rel="shortcut icon" href="favicon-152.png">
<link rel="apple-touch-icon-precomposed" href="favicon-152.png">
<link rel="stylesheet" href="librerias/leaflet/leaflet.css" />
<?php
$otro_json = remplacetas('form_parametrizacion','campo',$_REQUEST[id],'descripcion'," tabla='form_id' and opcion = 'json'","","") ;;
//$obj = file_get_contents('https://www.kleper.net/wiki/RutaPazTerritorial.geojson');
$ids = json_decode($otro_json[0]);
foreach ($ids as $clave => $valor) {
if($valor !=""){
$obj=file_get_contents("$valor[0]");
$li .="<script>var geojsonAuxiliar_$clave = $obj ;</script>";
$layer .= "
var geojsonAux_$clave = L.geoJson(geojsonAuxiliar_$clave, {
pointToLayer: function(feature, latlng) {
var smallIcon = new L.Icon({
iconSize: [100, 100],
iconAnchor: [13, 27],
popupAnchor: [1, -24],
/*iconUrl: feature.properties.icon.iconUrl*/
iconUrl: 'https://tupale.co/milfs/images/secure/?file=150/da6d16547658ebc06c5378b30d1ee4bf.png'
});
return L.marker(latlng, {icon: smallIcon});
},
onEachFeature: function(feature, layer) {
var popupText = feature.properties.description
layer.bindPopup(popupText); }
});
";
$add_layer .= "markers.addLayer(geojsonAux_$clave);";
$capas_nombre .="geojsonAux_$clave,";
$capas .= "{
'$clave': geojsonAux_$clave
};";
$overlays ="
var overlays = $capas ";
}
}
echo $li;
?>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link href="librerias/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" href="librerias/leaflet/css/leaflet-sidebar.css" />
<link rel="stylesheet" href="librerias/bootstrap/css/bootstrap.min.css" />
<style>
body {
padding: 0;
margin: 0;
}
html, body, #map {
height: 100%;
}
</style>
</head>
<body onload="">
<!-- optionally define the sidebar content via HTML markup -->
<div id="sidebar" class="leaflet-sidebar collapsed">
<!-- nav tabs -->
<div class="leaflet-sidebar-tabs" onmouseover="sidebar.open('home')";>
<!-- top aligned tabs -->
<ul role="tablist">
<li><a href="#home" role="tab"><i class="fa fa-bars active"></i></a></li>
<li><a href="#search" role="tab"><i class="fa fa-search active"></i></a></li>
</ul>
<!-- bottom aligned tabs -->
<ul role="tablist">
<li><a href="https://tupale.co"><img title='Powered by Tupale.co' alt='http://tupale.co' class='img img-responsive' src='https://tupale.co/images/icons/icon-152x152.png'></a></li>
</ul>
</div>
<!-- panel content -->
<div class="leaflet-sidebar-content">
<div class="leaflet-sidebar-pane" id="home">
<h1 class="leaflet-sidebar-header">
<span id='formulario_titulo_mapa'><?php echo $formulario_nombre[0] ?></span>
<span class="leaflet-sidebar-close"><i class="fa fa-caret-left"></i></span>
</h1>
<hr>
<label id='formulario_descripcion_mapa'><?php echo $formulario_descripcion[0] ?></label>
<center>
<a href='/g<?php echo $_REQUEST[id]; ?>' target='_blank' class="btn btn-default btn-xs"><i class="fa fa-plus-circle" aria-hidden="true"></i> Agregar</a> <br>
<span class="label label-warning">Despues de agregar, recarga el mapa</span>
</center>
<hr>
<?php echo $categorias; ?>
</div>
<div class="leaflet-sidebar-pane" id="search">
<label>Buscar en el Mapa</label>
<?php echo $buscador; ?>
</div>
</div>
</div>
<div id="map"></div>
<script src="librerias/leaflet/leaflet.js" crossorigin=""></script>
<script src="librerias/leaflet/leaflet-providers.js"></script>
<script src="librerias/leaflet/js/leaflet-sidebar.js"></script>
<link rel="stylesheet" href="librerias/leaflet/dist/MarkerCluster.css" />
<link rel="stylesheet" href="librerias/leaflet/dist/MarkerCluster.Default.css" />
<script src="librerias/leaflet/dist/leaflet.markercluster-src.js"></script>
<script src="librerias/jquery/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="milfs/geojson.js.php?id=<?php echo $_REQUEST['id'] ?>&buscar=<?php echo $_REQUEST['buscar'] ?>&item=<?php echo $_REQUEST['item'] ?>"></script>
<script src="https://unpkg.com/leaflet-responsive-popup@0.6.4/leaflet.responsive.popup.js"></script>
<link rel="stylesheet" href="https://unpkg.com/leaflet-responsive-popup@0.6.4/leaflet.responsive.popup.css" />
<script>
// standard leaflet map setup
var map = L.map('map');
// map.setView([51.2, 7], 9);
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: "Map data &copy; OpenStreetMap contributors <a href='https://tupale.co'>Powered by Tupale.co</a>"
}).addTo(map);
var geojson = L.geoJson(geojsonSample, {
pointToLayer: function(feature, latlng) {
var smallIcon = new L.Icon({
iconSize: [50, 50],
iconAnchor: [13, 27],
popupAnchor: [1, -24],
autoPanPadding: [30,30],
iconUrl: feature.properties.icon.iconUrl
});
return L.marker(latlng, {icon: smallIcon });
},
onEachFeature: function(feature, layer) {
layer._leaflet_id = feature.properties.control;
var popupText = L.responsivePopup().setContent(feature.properties.description );
layer.bindPopup(popupText, {
maxWidth: 200
});
layer.bindTooltip(feature.properties.title).openTooltip();
}
});
<?php echo $layer; ?>
// markers.addLayer(geojsonAux);
var markers = L.markerClusterGroup();
// var markers = L.layerGroup();
markers.addLayer(geojson).addTo(map);
<?php echo $add_layer; ?>
map.fitBounds(geojson.getBounds().pad(Math.sqrt(2) /4));
// create the sidebar instance and add it to the map
var sidebar = L.control.sidebar({ container: 'sidebar', autopan: true })
.addTo(map)
.open('home');
function openMarkerPopup(e){
const markerID = e.id;
const marker = markers.getLayer(markerID);
marker.openPopup();
}
// add panels dynamically to the sidebar
sidebar.on('content', function (ev) {
switch (ev.id) {
case 'autopan':
sidebar.options.autopan = true;
break;
default:sidebar.options.autopan = true;
}
});
</script>
<script language="JavaScript">
if (screen.width<1024)
//codigo resolución pequeña
sidebar.close();
else
sidebar.open();
</script>
</body>
</html>

View File

@ -0,0 +1,5 @@
We don't ship the .js files in the git master branch.
They are only present in version tags and in npm.
See how to get the JS files here: https://github.com/Leaflet/Leaflet.markercluster#using-the-plugin
Or how to build them: https://github.com/Leaflet/Leaflet.markercluster#building-testing-and-linting-scripts

View File

@ -1,17 +1,25 @@
/* /*
Leaflet.markercluster, Provides Beautiful Animated Marker Clustering functionality for Leaflet, a JS library for interactive maps. * Leaflet.markercluster 1.4.1+master.37ab9a2,
https://github.com/Leaflet/Leaflet.markercluster * Provides Beautiful Animated Marker Clustering functionality for Leaflet, a JS library for interactive maps.
(c) 2012-2013, Dave Leaver, smartrak * https://github.com/Leaflet/Leaflet.markercluster
*/ * (c) 2012-2017, Dave Leaver, smartrak
(function (window, document, undefined) {/* */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.Leaflet = global.Leaflet || {}, global.Leaflet.markercluster = global.Leaflet.markercluster || {})));
}(this, (function (exports) { 'use strict';
/*
* L.MarkerClusterGroup extends L.FeatureGroup by clustering the markers contained within * L.MarkerClusterGroup extends L.FeatureGroup by clustering the markers contained within
*/ */
L.MarkerClusterGroup = L.FeatureGroup.extend({ var MarkerClusterGroup = L.MarkerClusterGroup = L.FeatureGroup.extend({
options: { options: {
maxClusterRadius: 80, //A cluster will cover at most this many pixels from its center maxClusterRadius: 80, //A cluster will cover at most this many pixels from its center
iconCreateFunction: null, iconCreateFunction: null,
clusterPane: L.Marker.prototype.options.pane,
spiderfyOnMaxZoom: true, spiderfyOnMaxZoom: true,
showCoverageOnHover: true, showCoverageOnHover: true,
@ -420,6 +428,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
//If we aren't on the map (yet), blow away the markers we know of //If we aren't on the map (yet), blow away the markers we know of
if (!this._map) { if (!this._map) {
this._needsClustering = []; this._needsClustering = [];
this._needsRemoving = [];
delete this._gridClusters; delete this._gridClusters;
delete this._gridUnclustered; delete this._gridUnclustered;
} }
@ -677,7 +686,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
_removeFromGridUnclustered: function (marker, z) { _removeFromGridUnclustered: function (marker, z) {
var map = this._map, var map = this._map,
gridUnclustered = this._gridUnclustered, gridUnclustered = this._gridUnclustered,
minZoom = this._map.getMinZoom(); minZoom = Math.floor(this._map.getMinZoom());
for (; z >= minZoom; z--) { for (; z >= minZoom; z--) {
if (!gridUnclustered[z].removeObject(marker, map.project(marker.getLatLng(), z))) { if (!gridUnclustered[z].removeObject(marker, map.project(marker.getLatLng(), z))) {
@ -711,10 +720,11 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
}, },
_childMarkerDragEnd: function (e) { _childMarkerDragEnd: function (e) {
if (e.target.__dragStart) { var dragStart = e.target.__dragStart;
this._moveChild(e.target, e.target.__dragStart, e.target._latlng);
}
delete e.target.__dragStart; delete e.target.__dragStart;
if (dragStart) {
this._moveChild(e.target, dragStart, e.target._latlng);
}
}, },
@ -725,7 +735,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
gridUnclustered = this._gridUnclustered, gridUnclustered = this._gridUnclustered,
fg = this._featureGroup, fg = this._featureGroup,
map = this._map, map = this._map,
minZoom = this._map.getMinZoom(); minZoom = Math.floor(this._map.getMinZoom());
//Remove the marker from distance clusters it might be in //Remove the marker from distance clusters it might be in
if (removeFromDistanceGrid) { if (removeFromDistanceGrid) {
@ -918,7 +928,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
var newBounds = this._getExpandedVisibleBounds(); var newBounds = this._getExpandedVisibleBounds();
this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._zoom, newBounds); this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, Math.floor(this._map.getMinZoom()), this._zoom, newBounds);
this._topClusterLevel._recursivelyAddChildrenToMap(null, Math.round(this._map._zoom), newBounds); this._topClusterLevel._recursivelyAddChildrenToMap(null, Math.round(this._map._zoom), newBounds);
this._currentShownBounds = newBounds; this._currentShownBounds = newBounds;
@ -926,8 +936,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
}, },
_generateInitialClusters: function () { _generateInitialClusters: function () {
var maxZoom = this._map.getMaxZoom(), var maxZoom = Math.ceil(this._map.getMaxZoom()),
minZoom = this._map.getMinZoom(), minZoom = Math.floor(this._map.getMinZoom()),
radius = this.options.maxClusterRadius, radius = this.options.maxClusterRadius,
radiusFn = radius; radiusFn = radius;
@ -938,7 +948,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
radiusFn = function () { return radius; }; radiusFn = function () { return radius; };
} }
if (this.options.disableClusteringAtZoom) { if (this.options.disableClusteringAtZoom !== null) {
maxZoom = this.options.disableClusteringAtZoom - 1; maxZoom = this.options.disableClusteringAtZoom - 1;
} }
this._maxZoom = maxZoom; this._maxZoom = maxZoom;
@ -959,7 +969,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
_addLayer: function (layer, zoom) { _addLayer: function (layer, zoom) {
var gridClusters = this._gridClusters, var gridClusters = this._gridClusters,
gridUnclustered = this._gridUnclustered, gridUnclustered = this._gridUnclustered,
minZoom = this._map.getMinZoom(), minZoom = Math.floor(this._map.getMinZoom()),
markerPoint, z; markerPoint, z;
if (this.options.singleMarkerMode) { if (this.options.singleMarkerMode) {
@ -1058,7 +1068,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
if (this._zoom < mapZoom && this._currentShownBounds.intersects(this._getExpandedVisibleBounds())) { //Zoom in, split if (this._zoom < mapZoom && this._currentShownBounds.intersects(this._getExpandedVisibleBounds())) { //Zoom in, split
this._animationStart(); this._animationStart();
//Remove clusters now off screen //Remove clusters now off screen
this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._zoom, this._getExpandedVisibleBounds()); this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, Math.floor(this._map.getMinZoom()), this._zoom, this._getExpandedVisibleBounds());
this._animationZoomIn(this._zoom, mapZoom); this._animationZoomIn(this._zoom, mapZoom);
@ -1182,14 +1192,14 @@ L.MarkerClusterGroup.include({
//Do nothing... //Do nothing...
}, },
_animationZoomIn: function (previousZoomLevel, newZoomLevel) { _animationZoomIn: function (previousZoomLevel, newZoomLevel) {
this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, previousZoomLevel); this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, Math.floor(this._map.getMinZoom()), previousZoomLevel);
this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds()); this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds());
//We didn't actually animate, but we use this event to mean "clustering animations have finished" //We didn't actually animate, but we use this event to mean "clustering animations have finished"
this.fire('animationend'); this.fire('animationend');
}, },
_animationZoomOut: function (previousZoomLevel, newZoomLevel) { _animationZoomOut: function (previousZoomLevel, newZoomLevel) {
this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, previousZoomLevel); this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, Math.floor(this._map.getMinZoom()), previousZoomLevel);
this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds()); this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds());
//We didn't actually animate, but we use this event to mean "clustering animations have finished" //We didn't actually animate, but we use this event to mean "clustering animations have finished"
@ -1210,7 +1220,7 @@ L.MarkerClusterGroup.include({
_animationZoomIn: function (previousZoomLevel, newZoomLevel) { _animationZoomIn: function (previousZoomLevel, newZoomLevel) {
var bounds = this._getExpandedVisibleBounds(), var bounds = this._getExpandedVisibleBounds(),
fg = this._featureGroup, fg = this._featureGroup,
minZoom = this._map.getMinZoom(), minZoom = Math.floor(this._map.getMinZoom()),
i; i;
this._ignoreMove = true; this._ignoreMove = true;
@ -1281,7 +1291,7 @@ L.MarkerClusterGroup.include({
//Need to add markers for those that weren't on the map before but are now //Need to add markers for those that weren't on the map before but are now
this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds()); this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds());
//Remove markers that were on the map before but won't be now //Remove markers that were on the map before but won't be now
this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, previousZoomLevel, this._getExpandedVisibleBounds()); this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, Math.floor(this._map.getMinZoom()), previousZoomLevel, this._getExpandedVisibleBounds());
}, },
_animationAddLayer: function (layer, newCluster) { _animationAddLayer: function (layer, newCluster) {
@ -1319,10 +1329,10 @@ L.MarkerClusterGroup.include({
// Private methods for animated versions. // Private methods for animated versions.
_animationZoomOutSingle: function (cluster, previousZoomLevel, newZoomLevel) { _animationZoomOutSingle: function (cluster, previousZoomLevel, newZoomLevel) {
var bounds = this._getExpandedVisibleBounds(), var bounds = this._getExpandedVisibleBounds(),
minZoom = this._map.getMinZoom(); minZoom = Math.floor(this._map.getMinZoom());
//Animate all of the markers in the clusters to move to their cluster center point //Animate all of the markers in the clusters to move to their cluster center point
cluster._recursivelyAnimateChildrenInAndAddSelfToMap(bounds, previousZoomLevel + 1, newZoomLevel); cluster._recursivelyAnimateChildrenInAndAddSelfToMap(bounds, minZoom, previousZoomLevel + 1, newZoomLevel);
var me = this; var me = this;
@ -1346,7 +1356,7 @@ L.MarkerClusterGroup.include({
} }
} else { } else {
cluster._recursively(bounds, newZoomLevel, minZoom, function (c) { cluster._recursively(bounds, newZoomLevel, minZoom, function (c) {
c._recursivelyRemoveChildrenFromMap(bounds, previousZoomLevel + 1); c._recursivelyRemoveChildrenFromMap(bounds, minZoom, previousZoomLevel + 1);
}); });
} }
me._animationEnd(); me._animationEnd();
@ -1375,12 +1385,13 @@ L.markerClusterGroup = function (options) {
return new L.MarkerClusterGroup(options); return new L.MarkerClusterGroup(options);
}; };
var MarkerCluster = L.MarkerCluster = L.Marker.extend({
options: L.Icon.prototype.options,
L.MarkerCluster = L.Marker.extend({
initialize: function (group, zoom, a, b) { initialize: function (group, zoom, a, b) {
L.Marker.prototype.initialize.call(this, a ? (a._cLatLng || a.getLatLng()) : new L.LatLng(0, 0), { icon: this }); L.Marker.prototype.initialize.call(this, a ? (a._cLatLng || a.getLatLng()) : new L.LatLng(0, 0),
{ icon: this, pane: group.options.clusterPane });
this._group = group; this._group = group;
this._zoom = zoom; this._zoom = zoom;
@ -1402,7 +1413,7 @@ L.MarkerCluster = L.Marker.extend({
}, },
//Recursively retrieve all child markers of this cluster //Recursively retrieve all child markers of this cluster
getAllChildMarkers: function (storageArray) { getAllChildMarkers: function (storageArray, ignoreDraggedMarker) {
storageArray = storageArray || []; storageArray = storageArray || [];
for (var i = this._childClusters.length - 1; i >= 0; i--) { for (var i = this._childClusters.length - 1; i >= 0; i--) {
@ -1410,6 +1421,9 @@ L.MarkerCluster = L.Marker.extend({
} }
for (var j = this._markers.length - 1; j >= 0; j--) { for (var j = this._markers.length - 1; j >= 0; j--) {
if (ignoreDraggedMarker && this._markers[j].__dragStart) {
continue;
}
storageArray.push(this._markers[j]); storageArray.push(this._markers[j]);
} }
@ -1422,7 +1436,7 @@ L.MarkerCluster = L.Marker.extend({
}, },
//Zoom to the minimum of showing all of the child markers, or the extents of this cluster //Zoom to the minimum of showing all of the child markers, or the extents of this cluster
zoomToBounds: function () { zoomToBounds: function (fitBoundsOptions) {
var childClusters = this._childClusters.slice(), var childClusters = this._childClusters.slice(),
map = this._group._map, map = this._group._map,
boundsZoom = map.getBoundsZoom(this._bounds), boundsZoom = map.getBoundsZoom(this._bounds),
@ -1445,7 +1459,7 @@ L.MarkerCluster = L.Marker.extend({
} else if (boundsZoom <= mapZoom) { //If fitBounds wouldn't zoom us down, zoom us down instead } else if (boundsZoom <= mapZoom) { //If fitBounds wouldn't zoom us down, zoom us down instead
this._group._map.setView(this._latlng, mapZoom + 1); this._group._map.setView(this._latlng, mapZoom + 1);
} else { } else {
this._group._map.fitBounds(this._bounds); this._group._map.fitBounds(this._bounds, fitBoundsOptions);
} }
}, },
@ -1619,8 +1633,8 @@ L.MarkerCluster = L.Marker.extend({
); );
}, },
_recursivelyAnimateChildrenInAndAddSelfToMap: function (bounds, previousZoomLevel, newZoomLevel) { _recursivelyAnimateChildrenInAndAddSelfToMap: function (bounds, mapMinZoom, previousZoomLevel, newZoomLevel) {
this._recursively(bounds, newZoomLevel, this._group._map.getMinZoom(), this._recursively(bounds, newZoomLevel, mapMinZoom,
function (c) { function (c) {
c._recursivelyAnimateChildrenIn(bounds, c._group._map.latLngToLayerPoint(c.getLatLng()).round(), previousZoomLevel); c._recursivelyAnimateChildrenIn(bounds, c._group._map.latLngToLayerPoint(c.getLatLng()).round(), previousZoomLevel);
@ -1628,7 +1642,7 @@ L.MarkerCluster = L.Marker.extend({
//As a hack we only do a animation free zoom on a single level zoom, if someone does multiple levels then we always animate //As a hack we only do a animation free zoom on a single level zoom, if someone does multiple levels then we always animate
if (c._isSingleParent() && previousZoomLevel - 1 === newZoomLevel) { if (c._isSingleParent() && previousZoomLevel - 1 === newZoomLevel) {
c.clusterShow(); c.clusterShow();
c._recursivelyRemoveChildrenFromMap(bounds, previousZoomLevel); //Immediately remove our children as we are replacing them. TODO previousBounds not bounds c._recursivelyRemoveChildrenFromMap(bounds, mapMinZoom, previousZoomLevel); //Immediately remove our children as we are replacing them. TODO previousBounds not bounds
} else { } else {
c.clusterHide(); c.clusterHide();
} }
@ -1707,9 +1721,9 @@ L.MarkerCluster = L.Marker.extend({
}, },
//exceptBounds: If set, don't remove any markers/clusters in it //exceptBounds: If set, don't remove any markers/clusters in it
_recursivelyRemoveChildrenFromMap: function (previousBounds, zoomLevel, exceptBounds) { _recursivelyRemoveChildrenFromMap: function (previousBounds, mapMinZoom, zoomLevel, exceptBounds) {
var m, i; var m, i;
this._recursively(previousBounds, this._group._map.getMinZoom() - 1, zoomLevel - 1, this._recursively(previousBounds, mapMinZoom - 1, zoomLevel - 1,
function (c) { function (c) {
//Remove markers at every level //Remove markers at every level
for (i = c._markers.length - 1; i >= 0; i--) { for (i = c._markers.length - 1; i >= 0; i--) {
@ -1760,6 +1774,9 @@ L.MarkerCluster = L.Marker.extend({
if (zoom < zoomLevelToStart || zoom < zoomLevelToStop) { if (zoom < zoomLevelToStart || zoom < zoomLevelToStop) {
for (i = childClusters.length - 1; i >= 0; i--) { for (i = childClusters.length - 1; i >= 0; i--) {
c = childClusters[i]; c = childClusters[i];
if (c._boundsNeedUpdate) {
c._recalculateBounds();
}
if (boundsToApplyTo.intersects(c._bounds)) { if (boundsToApplyTo.intersects(c._bounds)) {
c._recursively(boundsToApplyTo, zoomLevelToStart, zoomLevelToStop, runAtEveryLevel, runAtBottomLevel); c._recursively(boundsToApplyTo, zoomLevelToStart, zoomLevelToStop, runAtEveryLevel, runAtBottomLevel);
} }
@ -1774,36 +1791,27 @@ L.MarkerCluster = L.Marker.extend({
} }
}); });
/* /*
* Extends L.Marker to include two extra methods: clusterHide and clusterShow. * Extends L.Marker to include two extra methods: clusterHide and clusterShow.
* *
* They work as setOpacity(0) and setOpacity(1) respectively, but * They work as setOpacity(0) and setOpacity(1) respectively, but
* they will remember the marker's opacity when hiding and showing it again. * don't overwrite the options.opacity
* *
*/ */
L.Marker.include({ L.Marker.include({
clusterHide: function () { clusterHide: function () {
this.options.opacityWhenUnclustered = this.options.opacity || 1; var backup = this.options.opacity;
return this.setOpacity(0); this.setOpacity(0);
this.options.opacity = backup;
return this;
}, },
clusterShow: function () { clusterShow: function () {
var ret = this.setOpacity(this.options.opacity || this.options.opacityWhenUnclustered); return this.setOpacity(this.options.opacity);
delete this.options.opacityWhenUnclustered;
return ret;
} }
}); });
L.DistanceGrid = function (cellSize) { L.DistanceGrid = function (cellSize) {
this._cellSize = cellSize; this._cellSize = cellSize;
this._sqCellSize = cellSize * cellSize; this._sqCellSize = cellSize * cellSize;
@ -1897,7 +1905,8 @@ L.DistanceGrid.prototype = {
for (k = 0, len = cell.length; k < len; k++) { for (k = 0, len = cell.length; k < len; k++) {
obj = cell[k]; obj = cell[k];
dist = this._sqDist(objectPoint[L.Util.stamp(obj)], point); dist = this._sqDist(objectPoint[L.Util.stamp(obj)], point);
if (dist < closestDistSq) { if (dist < closestDistSq ||
dist <= closestDistSq && closest === null) {
closestDistSq = dist; closestDistSq = dist;
closest = obj; closest = obj;
} }
@ -1910,7 +1919,8 @@ L.DistanceGrid.prototype = {
}, },
_getCoord: function (x) { _getCoord: function (x) {
return Math.floor(x / this._cellSize); var coord = Math.floor(x / this._cellSize);
return isFinite(coord) ? coord : x;
}, },
_sqDist: function (p, p2) { _sqDist: function (p, p2) {
@ -1920,7 +1930,6 @@ L.DistanceGrid.prototype = {
} }
}; };
/* Copyright (c) 2012 the authors listed at the following URL, and/or /* Copyright (c) 2012 the authors listed at the following URL, and/or
the authors of referenced articles or incorporated external code: the authors of referenced articles or incorporated external code:
http://en.literateprograms.org/Quickhull_(Javascript)?action=history&offset=20120410175256 http://en.literateprograms.org/Quickhull_(Javascript)?action=history&offset=20120410175256
@ -2087,7 +2096,6 @@ L.MarkerCluster.include({
} }
}); });
//This code is 100% based on https://github.com/jawj/OverlappingMarkerSpiderfier-Leaflet //This code is 100% based on https://github.com/jawj/OverlappingMarkerSpiderfier-Leaflet
//Huge thanks to jawj for implementing it first to make my job easy :-) //Huge thanks to jawj for implementing it first to make my job easy :-)
@ -2095,7 +2103,7 @@ L.MarkerCluster.include({
_2PI: Math.PI * 2, _2PI: Math.PI * 2,
_circleFootSeparation: 25, //related to circumference of circle _circleFootSeparation: 25, //related to circumference of circle
_circleStartAngle: Math.PI / 6, _circleStartAngle: 0,
_spiralFootSeparation: 28, //related to size of spiral (experiment!) _spiralFootSeparation: 28, //related to size of spiral (experiment!)
_spiralLengthStart: 11, _spiralLengthStart: 11,
@ -2109,7 +2117,7 @@ L.MarkerCluster.include({
return; return;
} }
var childMarkers = this.getAllChildMarkers(), var childMarkers = this.getAllChildMarkers(null, true),
group = this._group, group = this._group,
map = group._map, map = group._map,
center = map.latLngToLayerPoint(this._latlng), center = map.latLngToLayerPoint(this._latlng),
@ -2147,9 +2155,11 @@ L.MarkerCluster.include({
res = [], res = [],
i, angle; i, angle;
legLength = Math.max(legLength, 35); // Minimum distance to get outside the cluster icon.
res.length = count; res.length = count;
for (i = count - 1; i >= 0; i--) { for (i = 0; i < count; i++) { // Clockwise, like spiral.
angle = this._circleStartAngle + i * angleStep; angle = this._circleStartAngle + i * angleStep;
res[i] = new L.Point(centerPt.x + legLength * Math.cos(angle), centerPt.y + legLength * Math.sin(angle))._round(); res[i] = new L.Point(centerPt.x + legLength * Math.cos(angle), centerPt.y + legLength * Math.sin(angle))._round();
} }
@ -2169,9 +2179,13 @@ L.MarkerCluster.include({
res.length = count; res.length = count;
// Higher index, closer position to cluster center. // Higher index, closer position to cluster center.
for (i = count - 1; i >= 0; i--) { for (i = count; i >= 0; i--) {
angle += separation / legLength + i * 0.0005; // Skip the first position, so that we are already farther from center and we avoid
// being under the default cluster icon (especially important for Circle Markers).
if (i < count) {
res[i] = new L.Point(centerPt.x + legLength * Math.cos(angle), centerPt.y + legLength * Math.sin(angle))._round(); res[i] = new L.Point(centerPt.x + legLength * Math.cos(angle), centerPt.y + legLength * Math.sin(angle))._round();
}
angle += separation / legLength + i * 0.0005;
legLength += lengthFactor / angle; legLength += lengthFactor / angle;
} }
return res; return res;
@ -2181,7 +2195,7 @@ L.MarkerCluster.include({
var group = this._group, var group = this._group,
map = group._map, map = group._map,
fg = group._featureGroup, fg = group._featureGroup,
childMarkers = this.getAllChildMarkers(), childMarkers = this.getAllChildMarkers(null, true),
m, i; m, i;
group._ignoreMove = true; group._ignoreMove = true;
@ -2374,7 +2388,7 @@ L.MarkerCluster.include({
map = group._map, map = group._map,
fg = group._featureGroup, fg = group._featureGroup,
thisLayerPos = zoomDetails ? map._latLngToNewLayerPoint(this._latlng, zoomDetails.zoom, zoomDetails.center) : map.latLngToLayerPoint(this._latlng), thisLayerPos = zoomDetails ? map._latLngToNewLayerPoint(this._latlng, zoomDetails.zoom, zoomDetails.center) : map.latLngToLayerPoint(this._latlng),
childMarkers = this.getAllChildMarkers(), childMarkers = this.getAllChildMarkers(null, true),
svg = L.Path.SVG, svg = L.Path.SVG,
m, i, leg, legPath, legLength, nonAnimatable; m, i, leg, legPath, legLength, nonAnimatable;
@ -2558,7 +2572,6 @@ L.MarkerClusterGroup.include({
} }
}); });
/** /**
* Adds 1 public method to MCG and 1 to L.Marker to facilitate changing * Adds 1 public method to MCG and 1 to L.Marker to facilitate changing
* markers' icon options and refreshing their icon and their parent clusters * markers' icon options and refreshing their icon and their parent clusters
@ -2670,5 +2683,8 @@ L.Marker.include({
} }
}); });
exports.MarkerClusterGroup = MarkerClusterGroup;
exports.MarkerCluster = MarkerCluster;
}(window, document)); })));
//# sourceMappingURL=leaflet.markercluster-src.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
milfs

@ -1 +1 @@
Subproject commit f6c26756eb21de40c2224656caece6749fcaf94a Subproject commit c5d8f1db94cee40d9f5d6eac6f262878beadffef