Removing Fluster2 Clusters - google-maps-markers

I'm using GMap API v3 and Fluster2 to create a map with clustered markers on it. Everything is fine with adding markers and have them show up as clusters depending on the zoom level.
However, I am having a problem when it's time to clear all the markers so that I can add new ones (based on user input).
while(overlays[0]){
overlays.pop().setMap(null);
}
I am using the following code to clear the markers, unfortunately, it only affects the markers (overlays) that are not found within a cluster at the selected zoom level.
Does anyone know how I can remove all markers from the map, meaning all current markers (overlays) showing at the current zoom level AND all other markers found within clusters.

I've decided to simply create a new map and get rid of the old one.

Related

Fabric.js doesn't maintain group when exporting/importing JSON

So I have another issue with Fabric.js that's once again probably down to my own ignorance.
Imagine using free draw to scribble some line paths on to a canvas. When finished, we disable free draw and at this point I want to take all the objects drawn and group them in to a single entity.
I've created a fiddle here that shows the grouping stage.
var grp=new fabric.Group();
canvas.getObjects().map(function(o){
if(o.type=="path"){
o.hasControls=o.hasBorders=false;
grp.addWithUpdate(o);
//canvas.clear(); // this seems to break grouping
}
});
canvas.add(grp);
canvas._activeObject = null;
canvas.setActiveGroup(grp.setCoords()).renderAll();
This appears to work well enough (even if the paths themselves appear to darken once the group has been created).
I now want to export this to JSON, save at a DB, and in the future reload and replicate the whole layout.
In the fiddle above I reproduce this sort of behaviour by first saving the canvas to JSON after the group has been created, and then attempt to reload it.
As you'll see, the reload itself works fine and the positioning is good but the item that was previously grouped has been loaded in to it's constituent parts, rather than being maintained as a group.
Am I doing something dumb here?
Thanks for any help!

Network node highlighting with Crossfilter

I have a graph with a network and a few histograms.
For the network, each node has a few properties with continuous value. The histograms are for node properties. Is there an easy way to highlight the node in the network, when users brush the histogram? Could I bind a dimension of the network data to the node class attribute "selectednode"?
I have checked dc.js, but it seems not support network graph.
Thanks
Crossfilter isn't really built for highlighting, as filtering will remove the data outside the filter from the view of other dimensions and groups. It sounds like you don't want unselected network nodes to disappear, but rather want nodes with property values falling within the selection to be highlighted. I'd build either your histogram or your network directly based on unfiltered data (not based on the Crossfilter) and then whenever the brush event happens, re-render the network nodes, checking the current brush extent against the property values.
How about two crossfilters built from the same records? The filtering one (cfFilt) would work as expected with dimensions for everything that can be filtered. The highlighting filter (cfHigh) would have one dimension (based on a record id or an identity function, d=>d) that is filtered by inclusion in cfFilt.groupAll(), plus dimensions that filter anything that can be highlighted. (cfFilt().groupAll().reduce() will need to return records, not counts. I can say how in comments if anyone needs to know.)
So cfHigh.groupAll() returns the records that pass through all the filtering and all the highlighting.
An interesting (and otherwise hard to achieve) consequence of this approach is that if you highlight something, then a filter makes that thing disappear, and then that filter is removed and the thing comes back, it will stay highlighted as long as nothing came along to change the highlighting filter in the meantime.

Set a country background to my Google Geomap

A few days ago I've explored geomaps and, however, it turned out to be easy to change the properties of the elements.
But I have two questions:
I'd like to add rivers and forests on the maps. So Ive considered to set a background image instead of the geomaps figure. But I can't find a way to get this one fixed. Is there a way to set a background picture for a country or region?
How can I change the shape of the "bubbles" when you select a city e.g. "London"? I'd like to change it to a square.
Thanks in advance for your help!
Unfortunately what you're looking for is not available in geocharts in their current implementation.
Using a background image is possible in the sense that you can use CSS to make all shapes in the map transparent, and use a background image in the div to make it appear as if the little circles are being drawn on a map with forest and rivers, but you will run in to two big hurdles:
Your map will need to be identical in size/layout to the Google Maps SVG
If Google ever changes the SVG they use (or the view/projection they use) you will need to edit yours too
This isn't ideal, obviously. You could work around it by creating custom javascript to write rivers and forests on your map, but that is going to be a huge headache (especially if you are using multiple maps/views).
As for the circles, you can't change them to squares without hacking the actual SVG in the background with javascript. While this is definitely possible (if you're really good with SVG/Javascript), it again isn't using any of the fancy features of geocharts, and is more just a custom solution that will have to be updated if/when google updates their API.
Rather than doing it that way, you may want to look in to the same implementation on google maps itself. That will allow you to use custom markers, draw custom shapes, etc. with a lot more flexibility (and a much more stable API).

Google Maps V3 MarkerCluster plugin by polygon coordinate boundaries

I'm having trouble figuring out how to implement markercluster v3 in my map. I am able to get it to work, but am trying to cluster the markers based on specific neighborhoods and regions. I have created a layer on my map from a kml file that is seperated into several neighborhoods and I'd like the map markers to "cluster" by the neighborhood that they're located in. I tried messing with
http://jsfromhell.com/math/is-point-in-poly#example-header
but have had no luck...
Another question led me to figure out that I should use this method:
containsLocation(point:LatLng, polygon:Polygon)
Has anyone been able to achieve this?
Here's an example of a site that does it:
apartmentlist.com
Thanks for any help!

Change icon of markercluster depending on marker type inside the cluster

I have a map with markers of at this time two different types: photos and blog posts. I would like to use a clustering system, preferably MarkerClusterer.
Is there a way to change the marker icon dynamically, or in other words, depending on what kinds of marker (photos or posts) are inside the cluster? For example, if the cluster only consists of photos, I would like to display some sort of camera icon, if there are only posts inside the cluster, I might want to display a letter. And if all types of markers are inside the cluster, I would like to use some sort of combined icon.
Can I somehow insert this check where I assign the URL of the icon in MarkerStyleOptions?
A bonus would be to also display the amount of markers of each type in the icon, i.e. two numbers.
Does anyone see a way to do this without having to change the source code?
I guess the simplest option is to keep each marker type in a seperate clusters ...
You must create a different array of marker for each group that you created. And try to create a MarkerCluster for each one.

Resources