Marker Clustering - Fusion Table Layer - Google Maps v3
Asked Answered
D

4

6

Is there a way to get marker clustering (ie makerclusterer) to work with a Fusion Table layer? It seems that you have to assign markers to markerclusterer yet when using a fusion table layer, Google is handling the markers/infowindows? Still trying to figure this fusion table thing out.

Basically looking for a way to cluster large amounts of markers being provided via a Fusion Table

Duple answered 26/7, 2011 at 19:3 Comment(0)
S
0

Fusion Tables allows you to view thousands of points at once by using server side rendering (from the google servers). Marker Clusterer solves the problem by building a set of clusters from nearest points (from the clients browser). I wouldn't necessarily use them both at the same time, but it might work for your use case it's up to you.

You can read more information about how they work here:

http://code.google.com/apis/maps/articles/toomanymarkers.html

If you really wanted too you could use the Fusion Tables API to feed the data from Fusion Tables to the Marker Clusterer.

Hope this helps.

Swearingen answered 27/7, 2011 at 9:39 Comment(0)
L
5

Fusion Table Layers render an additional png image for each tile that gets overlaid on top of the map tile, containing the data points for that tile, this is the server side rendering part. So it's multiple data points per tile that contains data points.

MapsIt.png map tile with data points already positioned on the layer

Generating your own markers from data, which is necessary for MarkerClusterer, doesn't overlay an image per tile, it creates an individual Marker on the map for each data point and overlays a sprite image on to that.

Marker Sprite image used for each data point

Based on this, it is not possible to use MarkerClusterer and a FusionTablesLayer.

Leandraleandre answered 26/10, 2011 at 20:40 Comment(6)
Ran across this post researching this for myself. Thought I'd leave a comment that yes, it is possible according to Google Fusion Tables Team. [groups.google.com/d/msg/fusion-tables-users-group/eW-der8-diM/…Twentyfour
@Twentyfour There's a big difference between doing it on a FusionTablesLayer and using the data from a Fusion Table like the post you mentioned references. It is possible to do it using data from a Fusion Table, it is still not possible to do it using a FusionTablesLayer which is rendered server-side. They would have to create a Layer of the grouped items at each zoom level on the server side.Leandraleandre
@Twentyfour your link appears to be broken. Do you have an alternate one?Organicism
@Organicism I just tested the URL. It worked. It should bring you to the Google Fusion Table API Users Group. Failing that search for Multiple Items with same geolocation do not display in the Google groups forum.Twentyfour
@Twentyfour I just noticed that there is a bracket being appended at the end of the url when I click it. It does work once I remove that bracket. Cheers and thanks.Organicism
I couldn't edit. Apparently there is only a 5 minute window. Here is the URL again. groups.google.com/d/msg/fusion-tables-users-group/eW-der8-diM/…Twentyfour
U
5

This is my own code. I was trying the technique in the earlier link but it didn't work for me. So this is how i did it.

First i queried the fusion table with the regular chart api query

function initialize() {
    mapMain = new google.maps.Map(document.getElementById('map-canvas'), {
        center: new google.maps.LatLng(37.4, -100.1),
        zoom: 3,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });
    mc = new MarkerClusterer(mapMain);
    var queryText = encodeURIComponent("select wikipedia_article, xy from "+tableid);
    var query = new google.visualization.Query("https://www.google.com/fusiontables/gvizdata?tq="+queryText);
    query.send(handleQueryResponse);
}

Next, in my handleQueryResponse, I dynamically created markers and added it to the Mapclusterer

function handleQueryResponse(response){
     dataTable = response.getDataTable();

    for(var i=0; i< dataTable.getNumberOfRows();i++){           
        var hrefval = dataTable.getValue(i,0).toString();

        var arr = dataTable.getValue(i,1).toString().split(" ");            
        var latlng = new google.maps.LatLng(arr[0], arr[1]);

        var marker = new google.maps.Marker({
            position: latlng,
            map:mapMain
        });
        fn = markerClick(i, marker);
        google.maps.event.addListener(marker,'click', fn);          
        markers.push(marker);
    }
    mc.addMarkers(markers);
}

In this case, the main map, the array of markers (mc in the code below) are global variables. You can see the full working example here.

Unshroud answered 10/11, 2011 at 3:49 Comment(6)
Could you summarize what they've done on that site so that your answer isn't subject to link rot?Wadley
This is interesting, I would like to do the same with KML markers loaded in FusionTableLayer. Do you have any example?Gerrit
I did this long time back, haven't done any google maps based work since then.Unshroud
you wrote any server side code to generate data for markers?Benedicite
No, I just populated a fusion table with the data in this particular case.Unshroud
in the case if we do not have locations of points and they are geocoded by fusion table, is there any way to create markers ?Pentheam
S
1

I don't think you will get it work with a fusion table. IMO the fusion table is lacking the support for a spatial index. A si helps reduce the 2d complexity to a 1d complexity. It's uses in a lot of applications like heatmaps, treemaps, post code search, maps application. You want to look for Nick's hilbert curve spatial index quadtree blog.

Submaxillary answered 26/7, 2011 at 20:53 Comment(0)
S
0

Fusion Tables allows you to view thousands of points at once by using server side rendering (from the google servers). Marker Clusterer solves the problem by building a set of clusters from nearest points (from the clients browser). I wouldn't necessarily use them both at the same time, but it might work for your use case it's up to you.

You can read more information about how they work here:

http://code.google.com/apis/maps/articles/toomanymarkers.html

If you really wanted too you could use the Fusion Tables API to feed the data from Fusion Tables to the Marker Clusterer.

Hope this helps.

Swearingen answered 27/7, 2011 at 9:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.