0

I'm using open layers to draw the world map and below is the code. Basically there's a JSON file which contains the coordinates of all countries which will be read by OpenLayers and the fill color (which will be dynamic and it can be any color) of each country is got from the DB through a separate AJAX call (single call will get the color for all countries).

It works fine in Firefox and Chrome but in IE 7 and 8, it takes a very long time to draw the map. Please let me know how to improve the performance..

Code:

Layer creation:

var vecLayer = new OpenLayers.Layer.Vector("vector", {
                      rendererOptions: { zIndexing: true },
                      styleMap: new OpenLayers.StyleMap({
                          'default': allCountryStyle,
                          "select": new OpenLayers.Style({
                              strokeWidth: 3,
                              strokeColor: "#000000",
                              graphicZIndex: 2
                          })
                      }
                      ),
                      protocol: new OpenLayers.Protocol.HTTP({
                          url: url,
                          format: new OpenLayers.Format.GeoJSON()
                      }),
                      strategies: [new OpenLayers.Strategy.Fixed()]
                  });

Fill Color:

var allCountryTemplate = {
                          cursor: "pointer",
                          fillOpacity: 1,
                          fillColor: "${getAllCountryColor}",
                          pointRadius: 5,
                          strokeWidth: 1,
                          strokeOpacity: 0.2,
                          strokeColor: "black",
                          graphicName: "triangle"
                  };

Please let me know if you need any further information

  • realizing how late this comment is to the question...browsers behave differently depending on a plethora of factors....need to see entire markup before making any decisions... – albert Feb 17 '17 at 4:42
  • Are you getting any errors in console ? – Shiko Feb 17 '17 at 7:14
1

Using a Fixed strategy means that the entire layer loads all at once, which can cause trouble with some browsers if the layer has a large number of features. A BoundingBox strategy might be better, but this might not be an option with a GeoJSON protocol. In that case try changing to WFS. (Of course, if your map starts at the minimum zoom, the strategy won't make any difference.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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