Giter Club home page Giter Club logo

Comments (4)

ahocevar avatar ahocevar commented on July 21, 2024

Hi, just for me to understand:

  1. After a tile has been served, an identical /GetMap request is triggered
  2. While the /GetMap request for tile 1 is processed on the server, an identical request is triggered

Are you saying that OpenLayers triggers a 2nd request for the same tile on its own, or just that if the user requests the same map extent again, a new request is sent? If the former, then we have a bug somewhere in OpenLayers. If the latter, then I don't expect any efforts in client-side cache management of asynchronous requests, since the only layer type that currently uses asynchronous tile loading is Layer.ArcIMS, and ArcIMS was deprecated by ESRI.

The only future use of asynchronous tile requests in OpenLayers I can think of is offline storage, which might help you as well. Other than that, your solution for problem 1 sounds reasonable, and for problem 2 you could have a cache of pending requests by bounds and reassign the callback if a request for the same bounds is pending.

Please close this ticket if the information provided here was helpful. If, on the other hand, your proprietary map service is a commonly used one, provide more information about that service and turn this ticket into a feature request for creating a layer type for that service. This feature could then become at least an add-in.

from ol2.

fbuchinger avatar fbuchinger commented on July 21, 2024

thanks for the quick reply!

seems that OpenLayers triggers the request from time to time, I will try to track that down and open a new ticket for the exact cause (maybe the fault is on my side by making bad use of the API).
Anyhow I like to safeguard my layer against unneeded requests, so that it behaves gracefully even in non-optimal configurations.
Just for clarification: by "reassign the callback if a request for the same bounds is pending" you mean something like:

 //getURLasync layer of subclassed grid method, `tileCache` and `pendingRequests` are object properties.
 getURLasync: function (bounds, scope, prop, callback) {
      bounds = this.adjustBounds(bounds);
      var requestParams = this.getMyMapRequestParams(bounds, this.map.getSize());
      var reqQueryString = $.param(requestParams);
      var self = this;

      //check if there is a pending request for the same extent
      //and reassign the callback if necessary
      if (this.pendingRequests[reqQueryString]) {
          callback = self.pendingRequests[reqQueryString];
      }

      //check if there is already a completed tile request for the same extent
      else if (self.tileCache[reqQueryString]) {
          scope[prop] = self.tileCache[reqQueryString];
          callback.apply(scope);
      }

      //issue a new get request
      else {
          self.pendingRequests[reqQueryString] = callback;
          jQuery.get(this.methodPath, requestParams, function (response) {
              var mapData = self.parseMapResponse(response);
              scope[prop] = mapData.url;
              callback.apply(scope);
              //fill tilecache object
              self.tileCache[reqQueryString] = mapData.url;
              //delete pending request
              delete self.pendingRequests[reqQueryString]; 
          });
      }
  }

from ol2.

ahocevar avatar ahocevar commented on July 21, 2024

Yes, the above looks like what I had in mind.

from ol2.

fbuchinger avatar fbuchinger commented on July 21, 2024

Thanks for the suggestions, finally I found the source of error in another code part.

from ol2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.