Hello,

I am building a map that has both point data and linestring data. when I display only points, markercluster works perfectly (a beautiful tool, really). When I add linestring data, however, no data is displayed. The map tiles are still there but no points or lines are shown. I get the error:

"TypeError: e.getLatLng is not a function
Source File: sites/all/libraries/leaflet_markercluster/dist/leaflet.markercluster.js?mhpg56
Line: 6"

Now I know that markercluster would only work for points and not lines, but is there a way to have the magic of markercluster as well as linestring display on the same map?

Any help is greatly appreciated

Comments

Schnitzer’s picture

I have the same problem. For now (until it will fixed) i have added a function to leaflet/leaflet.drupal.js

create_linestring_to_point: function(polyline) {
  var latlng = new L.LatLng(polyline.points[0].lat, polyline.points[0].lon);
  this.bounds.push(latlng);
  return new L.Marker(latlng);
},

at line 210
So i can display at least the points instead of nothing.

Schnitzer’s picture

sorry, i forget the changes in leaflet_markercluster/leaflet_markercluster.drupal.js

i changed the linestring case at line 163 to

            lFeature = Drupal.leaflet.create_linestring_to_point(feature);
rdeboer’s picture

Polygons and clustered pointsIf you keep everything on your system the same, but add the latest 7.x-1.x-dev version of IP Geolocation Views and Maps to the mix, then you can have polygons and point clustering live happily together in the same map.
See screenshots.

You need to apply this simple patch to Leaflet Markercluster: #1995102: Patch to exclude some markers from the clustering process.
Should you not know how to do patches, no problem as the patch is so small you can easily do the edits by hand.

rdeboer’s picture

Title: problems with linestrings » Allow clustering of points in the presence of polygons
Assigned: Unassigned » rdeboer
Status: Active » Patch (to be ported)
StatusFileSize
new1.37 KB

Ok, I've done a little more research on this.

The attached patch takes the patch from #1995102: Patch to exclude some markers from the clustering process one step further and replaces that patch.
The attached patch will work with IP Geolocation Views and Maps, as well as without it.

As above, it will exclude polygons from the clustering process, but will still render them, while applying the clustering to individual markers.

In addition it allows programmers to exclude selected markers, like a visitor marker or some landmark, to be excluded from the clustering process and render these as individual points.

rdeboer’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.