[OpenLayers-Users] Re: Marker Problem when having too much data
: Help
Greg Allensworth
gregor at greeninfo.org
Tue Jul 19 18:03:37 EDT 2011
> But the problem is i'm nooby to
> OpenLayers (started coding a week back). Could you please provide me with
> any relevant examples for using the "pagination of the points"
Sorry, I don't have any such examples offhand. But, the solution I
suggest isn't centered on OpenLayers, but general JavaScript.
* Set up your search service (the URL that returns JSON) to accept a
parameter indicating which results it should send. For instance, have it
accept a &page= parameter which tells it to output records 1-99,
100-199, 200-299, and so on. This is the real catch: if you don't
control that search/JSON thing, you may be out of luck here. Make sure
this step is working first.
* Make a variable that stores what "page" you're showing, and some
buttons to change that value.
var page = 1;
function nextPage() { page += 1; layer.refresh(); }
function prevPage() { page -= 1; layer.refresh(); }
<input type="button" value="" onClick="nextPage()" />
<input type="button" value="" onClick="prevPage()" />
* Have your JSON loader specify this page number:
url: "/path/to/json/search.php",
params: { page:page }
So it would make URLs like this:
/path/to/json/search.php?page=10
And there you should go, a client that asks for only 100 records at a
time but can tell the server which "page" it wants, and a server smart
enough to do that.
--
Greg Allensworth
Web GIS Developer, GreenInfo Network
BS A+ Network+ Security+ Linux+ Server+
More information about the Users
mailing list