Comments (4)
Hi, just for me to understand:
- After a tile has been served, an identical /GetMap request is triggered
- 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.
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.
Yes, the above looks like what I had in mind.
from ol2.
Thanks for the suggestions, finally I found the source of error in another code part.
from ol2.
Related Issues (20)
- Maps do not pan in Chrome 55 or Microsoft Edge HOT 2
- implement openlayers with bing offline server
- Featureclick eventListeners randomly not work on chrome 51 HOT 1
- Get OpenLayers from packagist
- Clojure Compiler Link is dead
- Scroll bar does not show in Popup.FramedCloud in mobile devices (OL 2.13.1) HOT 3
- Need to add set style feature to Google Layer HOT 1
- OpenStreetMap newly redirecting tile URLs. Problem on safari HOT 1
- Incorrect Web Mercator transforms with newest versions of proj4js
- Map extent is increased after setting base layer
- How to Convert Circle Polygon Geometry to Line in openlayers 2 HOT 1
- Snapping another layer point with Create Circle Polygon in Openlayers 2
- how to show a arrow feature by some longitude
- Ping (ICMP) send during Layer/Map request
- Image getting stretched in Image layer
- How to Change style of point feature to polygon?
- Open source License obligations of openlayers-2.13.1 HOT 3
- Responsible disclosure policy
- Dev.openlayers.org is gone HOT 10
- Google Map Layers not rendering anymore HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ol2.