Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using OpenLayers with Bing maps, I'm trying to load JSON data from a service URL and assign an array of clustering strategies to the resulting layer. There are plenty of examples of using cluster strategies with OpenLayers.Format.GeoJSON loaded via OpenLayers.Protocol.HTTP, but my data is Plain Ol' JSON, not GeoJSON (and I have no control over the format of it).

So using this code, the points load on the map correctly. But I get an error: "Uncaught TypeError: Cannot call method 'read' of null". When I open up the OpenLayers source code to the error-causing line, it's this:{

and indeed, protocol is null.

So my question is: How to use OpenLayers cluster strategies without using a Protocol?

Here's the code I'm using:

map = new OpenLayers.Map("project-map");
osm = new OpenLayers.Layer.Bing({ name: 'street', type: 'Road', key : bingApiKey});
var cp = new OpenLayers.LonLat(0,20).transform(fromProj, toProj);

var pointLayer = new OpenLayers.Layer.Vector("Markers",{
            strategies: [new OpenLayers.Strategy.Fixed(), 
            new OpenLayers.Strategy.Cluster({distance: 25})]

    url: "ServiceHandler.json", 
    success: function(response) {
      var jsonReader = new OpenLayers.Format.JSON();
      var sparkle =;
        $.each(sparkle, function(i,f){
          var point = 
             new OpenLayers.Geometry.Point(f.Long, f.Lat).transform(fromProj, toProj);
          var pointFeature = new OpenLayers.Feature.Vector(point, null, 
          externalGraphic: "http://localhost:8081/Icons/175.png",
          pointRadius: 8
            pointFeature.attributes = f;

share|improve this question
up vote 5 down vote accepted

You get error message by reason of using Fixed strategy. Remove this item from strategies array:

strategies: [new OpenLayers.Strategy.Cluster({distance: 25})]

It is not neccesary use Fixed strategy for manually added features.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.