Comments (8)
From @mathiasmuller4sh on July 10, 2014 15:10
Hi,
I'am working on the same problem.
I've made a little hack in the index.html and it seems to do the tricks.
EDIT: Now, need to add a listener to remove cluster on geojson layer remove
<script src="lib/js/leaflet/dist/leaflet.js" type="text/javascript"></script>
<script src="lib/js/leaflet.markercluster/dist/leaflet.markercluster.js" type="text/javascript"></script>
<script>
L.GeoJSON = L.GeoJSON.extend({
addTo: function(map) {
var markers = new L.MarkerClusterGroup({
spiderfyOnMaxZoom: false,
showCoverageOnHover: false,
zoomToBoundsOnClick: false,
disableClusteringAtZoom: 19
});
map.addLayer(markers);
markers.addLayer(this);
return this;
}
});
L.geoJson = function (geojson, options) {
return new L.GeoJSON(geojson, options);
};
</script>
from ui-leaflet.
From @mathiasmuller4sh on July 11, 2014 10:28
Complete hack with remove listener.
I use this code in my angular controller
L.GeoJSON = L.GeoJSON.extend({
addTo: function(map) {
var self = this;
map.addLayer(this.markers);
var parentRemove = L.GeoJSON.prototype.onRemove;
L.GeoJSON.prototype.onRemove = function (map) {
self.markers.removeLayer(self);
delete self.markers;
parentRemove(map);
};
return this;
}
});
L.geoJson = function (geojson, options) {
var geoJSON = new L.GeoJSON(geojson, options);
var markers = new L.MarkerClusterGroup({
spiderfyOnMaxZoom: false,
showCoverageOnHover: true,
zoomToBoundsOnClick: true,
disableClusteringAtZoom: 18
});
markers.setGeoJSON = function(data) {
geoJSON.setGeoJSON(data);
};
markers.addLayer(geoJSON);
geoJSON.markers = markers;
return markers;
};
from ui-leaflet.
From @stefan2k on October 27, 2014 13:33
Nice workaround!
from ui-leaflet.
From @briankostar on May 14, 2015 21:16
this saved me some time! thanks
from ui-leaflet.
👍
from ui-leaflet.
Someone want to work on flushing this out into the geojson directive?
from ui-leaflet.
From @briankostar on May 14, 2015 21:36
I'm still learning, but I'll take a crack at it this weekend.
from ui-leaflet.
From @mahmoudmy on June 17, 2015 15:1
Very useful, thanks!
from ui-leaflet.
Related Issues (20)
- leafletData.getDirectiveControls
- Dynamically add data to geoJSONShape HOT 1
- Migration to Angular 4 HOT 1
- Changin markers on scope, the model is different HOT 2
- Markers not showing in second (or more) maps HOT 4
- Travis CI seems to be broken HOT 1
- Add Custom Styles To Google Maps
- layercontrol - More than 1 map on the DOM
- IE 11: US Map mouse over highlighting beside state(s)
- <Security Issue> Slack token need to be encrypted
- Fitbounds and markercluster zoom issue
- Marker in not updating its position on the map, when its value is updated
- Nor working in angular 1.6.4 HOT 2
- Popup closes when changing marker icon
- ui-leaflet analog for bindLabel functionality? HOT 1
- Could anyone propagate this commit to the 2.0.x tag version?
- MBTiles
- Disable auto center adjust after change marker coordinates programmatically
- Is this project still active ?
- Issue with Clickable Marker Content
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ui-leaflet.