Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7674783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:48:53+00:00 2026-05-31T16:48:53+00:00

What I need is a way to modify a vector layer representation without downloading

  • 0

What I need is a way to modify a vector layer representation without downloading the data again.
I have defined a GLM vector layer and a function called build_style to colorize their geometries according to some feature. I have an HTML form that calls the function UpdateGlmLayer which is defined in this way:

function UpdateGlmLayer(info_str) {
    var v = info_str.split("|");
    var filter_column = v[0];
    var values = [parseFloat(v[1]), parseFloat(v[2]), parseFloat(v[3])];
    glm.styleMap = build_style(filter_column, values);
    glm.redraw();
};

the GLM layer is defined in this way:

gml_protocol = new OpenLayers.Protocol.HTTP({
    url: "http://localhost:8080/geoserver/ows?service=WFS&version=1.0.0&request=GetFeature&typeName="+info["layer_featurePrefix"]+":"+info["layer_featureType"],
    format: new OpenLayers.Format.GML()
})

glm = new OpenLayers.Layer.Vector(info["layer_name"], {
    strategies: [new OpenLayers.Strategy.BBOX({ratio: 3, resFactor: 1})],
    protocol: gml_protocol,
    styleMap: build_style(info["filter_property"], info["filter_values"]), 
    srsName: info["layer_srsName"],
    projection: new OpenLayers.Projection("EPSG:4326"),
    visibility: true
});

When UpdateGlmLayer is triggered the colors seem to change immediately but after that the system stops for approximately the same time it took to downloaded the data on the initial page load. Nothing can be done during this time. Is there something wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:48:54+00:00Added an answer on May 31, 2026 at 4:48 pm

    The problem is with you setting of the resFactor. I have created two demo maps, one loading some GeoServer GML vectors and restyling them without the resFactor 1 setting and another with the resFactor 1 setting and the second is definitely sending multiple requests. If you set the resfactor to anything above 1 this will not happen.

    No resFactor setting + clicking restyle 3 times gives this result:

    3 Restyle Clicks, 1 data request

    Only 1 data request.

    However, a resFactor setting of 3 + clicking restyle 3 times gives this result:
    3 Restyle Clicks, 4 data requests

    4 data requests.

    This I believe is the behavior you are seeing. This looks like a bug to me as the documentation says what you have done is valid. Looking at the code in the BBOX strategy js file the problem seems to be in the code:

    var ratio = this.resolution / this.layer.map.getResolution();
    invalid = (ratio >= this.resFactor || ratio <= (1 / this.resFactor));
    

    This is running on the .redraw() function to calculate whether it needs to reload the data. Because ratio will always be set to 1 in when you redraw the map (the resolution has not changed so this.resolution === this.layer.map.getResolution() ) then invalid will always be equal to true and therefore the layer reloads.

    resFactor

    {Float} Optional factor used to determine when previously requested
    features are invalid. If set, the resFactor will be compared to the
    resolution of the previous request to the current map resolution. If
    resFactor > (old / new) and 1/resFactor < (old / new). If you set a
    resFactor of 1, data will be requested every time the resolution
    changes. If you set a resFactor of 3, data will be requested if the
    old resolution is 3 times the new, or if the new is 3 times the old.
    If the old bounds do not contain the new bounds new data will always
    be requested (with or without considering resFactor).

    I am doing the restyles in the following manner:

    var style1, style2;
    
    
    style1 = new OpenLayers.Style({
                    strokeColor: "yellow",
                    strokeWidth: 10 });
    
    
    style2 = new OpenLayers.Style({
                    strokeColor: "blue",
                    strokeWidth: 5 });
    
    function restyle1()
    {
        layer.styleMap = style1;
        layer.redraw();
    
    }
    
    function restyle2()
    {
        layer.styleMap = style2;
        layer.redraw();
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm in need of a way to modify an unattend.xml file programmatically. It would
I need a way to easily export and then import data in a MySQL
I need a way to track instances of various classes, without those classes having
Is there a way to modify CakePHP's default layout without needing to make my
Is there a way to modify a UIElement's contents? I have something like this:
Need a way to allow sorting except for last item with in a list.
I need a way to recursively delete a folder and its children. Is there
I need a way to update the month value on a dateTime field in
I need a way to bind POJO objects to an external entity, that could
I need a way to build C++ code from UML diagrams and vice versa.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.