Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/proxy.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ allowedHosts = ['www.openlayers.org', 'openlayers.org',
'www.openstreetmap.org', 'sample.azavea.com',
'v2.suite.opengeo.org', 'v-swe.uni-muenster.de:8080',
'vmap0.tiles.osgeo.org', 'www.openrouteservice.org',
'maps.wien.gv.at']
'maps.wien.gv.at','msgsoc.mapgears.com']

method = os.environ["REQUEST_METHOD"]

Expand Down
2 changes: 1 addition & 1 deletion examples/utfgrid_twogrids.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var controls = {
}),
move_both: new OpenLayers.Control.UTFGrid({
callback: callback,
layers: null, // same as all map.layers
layers: [population,bioregions],
handlerMode: "move"
})
};
Expand Down
113 changes: 113 additions & 0 deletions examples/utfgridwms.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
var lon = 0;
var lat = 40;
var zoom = 4;
var control, callback;
OpenLayers.ProxyHost = "./proxy.cgi?url=";

init = function(){
var map = new OpenLayers.Map( 'map' );
var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://msgsoc.mapgears.com/cgi-bin/mapserv.cgi?map=/home/fdesjarlais/nemapfile/nemapfile.map&", {layers: 'basic,points'}, {isBaseLayer:true, singleTile:true} );
map.addLayer(layer);
var layer2 = new OpenLayers.Layer.UTFGridWMS( "Utfgrid",
"http://msgsoc.mapgears.com/cgi-bin/mapserv.cgi?map=/home/fdesjarlais/nemapfile/nemapfile.map&", {layers: 'basic'}, {utfgridResolution: 4, singleTile:true} );
map.addLayer(layer2);
var layer3 = new OpenLayers.Layer.UTFGridWMS( "Utfgrid",
"http://msgsoc.mapgears.com/cgi-bin/mapserv.cgi?map=/home/fdesjarlais/nemapfile/nemapfile.map&", {layers: 'points'}, {utfgridResolution: 4, singleTile:true} );
map.addLayer(layer3);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
map.addControls([new OpenLayers.Control.Scale(), new OpenLayers.Control.MousePosition()]);

callback = function(infoLookup) {
var msg = "";
if (infoLookup) {
var layer, info;
for (var idx in infoLookup) {
layer = map.layers[idx];
info = infoLookup[idx];
if (info && info.data) {
msg += "Feature ID: " + info.id + "<br>";
for (var key in info.data) {
msg += key + ": " + info.data[key] + "<br>";
}
}
}
}
document.getElementById("attrs").innerHTML = msg;
};

var controls = {
move_country: new OpenLayers.Control.UTFGrid({
callback: callback,
layers: [layer2],
handlerMode: "move"
}),
move_city: new OpenLayers.Control.UTFGrid({
callback: callback,
layers: [layer3],
handlerMode: "move"
}),
move_both: new OpenLayers.Control.UTFGrid({
callback: callback,
layers: [layer2,layer3], // same as all map.layers
handlerMode: "move"
})
};
for (var key in controls) {
map.addControl(controls[key]);
}

toggleControl = function(el) {
for (var c in controls) {
controls[c].deactivate();
}
controls[el.value].activate();
}
toggleControl({value: "move_country"});
}
</script>
</head>
<body onload="init()">
<h1 id="title">OpenLayers UTFGridWMS Demo</h1>

<div id="tags">
wms, layer, singletile
</div>
<p id="shortdesc">
This page demonstrates the use of the OpenLayers UTFGridWMS.
</p>

<div id="map" class="smallmap"></div>
<ul id="controlToggle">
<li>
<input type="radio" name="type" value="move_country" id="moveHandler"
onclick="toggleControl(this);" checked="checked" />
<label for="moveHandler">View country</label>
</li>
<li>
<input type="radio" name="type" value="move_city" id="hoverHandler"
onclick="toggleControl(this);" />
<label for="hoverHandler">View cities</label>
</li>
<li>
<input type="radio" name="type" value="move_both" id="clickHandler"
onclick="toggleControl(this);" />
<label for="clickHandler">View both</label>
</li>
</ul>
<div id="docs">
<p><strong id="attrs">&nbsp;</strong></p>
<p> This exemple demostrates the use of UTFGridWMS. It allows high interaction maps with WMS. It can be used with the same functionalities that UTFGrid has.</p>
</div>
</body>
</html>
1 change: 1 addition & 0 deletions lib/OpenLayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
"OpenLayers/Layer/Boxes.js",
"OpenLayers/Layer/XYZ.js",
"OpenLayers/Layer/UTFGrid.js",
"OpenLayers/Layer/UTFGridWMS.js",
"OpenLayers/Layer/OSM.js",
"OpenLayers/Layer/Bing.js",
"OpenLayers/Layer/TMS.js",
Expand Down
2 changes: 1 addition & 1 deletion lib/OpenLayers/Control/UTFGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ OpenLayers.Control.UTFGrid = OpenLayers.Class(OpenLayers.Control, {
var layer;
for (var i=candidates.length-1; i>=0; --i) {
layer = candidates[i];
if (layer instanceof OpenLayers.Layer.UTFGrid ) {
if (layer instanceof OpenLayers.Layer.UTFGrid || OpenLayers.Layer.UTFGridWMS) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this isn't doing what you expect it to be doing.

I'd go with

if (layer instanceof OpenLayers.Layer.UTFGrid ||
    layer instanceof OpenLayers.Layer.UTFGridWMS) {
// ...
}

layers.push(layer);
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/OpenLayers/Layer/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,9 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
this.grid[0] = [];
}

// store the resolution of the grid
this.gridResolution = this.getServerResolution();

var tile = this.grid[0][0];
if (!tile) {
tile = this.addTile(tileBounds, px);
Expand All @@ -870,9 +873,6 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {

//remove all but our single tile
this.removeExcessTiles(1,1);

// store the resolution of the grid
this.gridResolution = this.getServerResolution();
},

/**
Expand Down
Loading