Merge branch 'upstream-master' into deprecated.js
This commit is contained in:
@@ -50,21 +50,20 @@
|
|||||||
|
|
||||||
style.addRules([rule, elseRule]);
|
style.addRules([rule, elseRule]);
|
||||||
|
|
||||||
// Create a GML layer with GeoRSS format and a style map.
|
// Create a Vector layer with GeoRSS format and a style map.
|
||||||
markerLayer = new OpenLayers.Layer.GML("Some images from Flickr",
|
markerLayer = new OpenLayers.Layer.Vector("Some images from Flickr", {
|
||||||
"xml/georss-flickr.xml", {
|
protocol: new OpenLayers.Protocol.HTTP({
|
||||||
format: OpenLayers.Format.GeoRSS,
|
url: "xml/georss-flickr.xml",
|
||||||
formatOptions: {
|
format: new OpenLayers.Format.GeoRSS({
|
||||||
// adds the thumbnail attribute to the feature
|
// adds the thumbnail attribute to the feature
|
||||||
createFeatureFromItem: function(item) {
|
createFeatureFromItem: function(item) {
|
||||||
var feature = OpenLayers.Format.GeoRSS.prototype
|
var feature = OpenLayers.Format.GeoRSS.prototype.createFeatureFromItem.apply(this, arguments);
|
||||||
.createFeatureFromItem.apply(this, arguments);
|
feature.attributes.thumbnail = this.getElementsByTagNameNS(item, "*", "thumbnail")[0].getAttribute("url");
|
||||||
feature.attributes.thumbnail =
|
|
||||||
this.getElementsByTagNameNS(
|
|
||||||
item, "*", "thumbnail")[0].getAttribute("url");
|
|
||||||
return feature;
|
return feature;
|
||||||
}
|
}
|
||||||
},
|
})
|
||||||
|
}),
|
||||||
|
strategies: [new OpenLayers.Strategy.Fixed()],
|
||||||
// Giving the style map keys for "default" and "select"
|
// Giving the style map keys for "default" and "select"
|
||||||
// rendering intent, to make the image larger when selected
|
// rendering intent, to make the image larger when selected
|
||||||
styleMap: new OpenLayers.StyleMap({
|
styleMap: new OpenLayers.StyleMap({
|
||||||
|
|||||||
@@ -20,7 +20,13 @@
|
|||||||
"http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
|
"http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
|
||||||
map.addLayer(layer);
|
map.addLayer(layer);
|
||||||
map.zoomToExtent(new OpenLayers.Bounds(-3.922119,44.335327,4.866943,49.553833));
|
map.zoomToExtent(new OpenLayers.Bounds(-3.922119,44.335327,4.866943,49.553833));
|
||||||
map.addLayer(new OpenLayers.Layer.GML("GML", "gml/polygon.xml"));
|
map.addLayer(new OpenLayers.Layer.Vector("GML", {
|
||||||
|
protocol: new OpenLayers.Protocol.HTTP({
|
||||||
|
url: "gml/polygon.xml",
|
||||||
|
format: new OpenLayers.Format.GML()
|
||||||
|
}),
|
||||||
|
strategies: [new OpenLayers.Strategy.Fixed()]
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ OpenLayers.Control = OpenLayers.Class({
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: allowSelection
|
* Property: allowSelection
|
||||||
* {Boolean} By deafault, controls do not allow selection, because
|
* {Boolean} By default, controls do not allow selection, because
|
||||||
* it may interfere with map dragging. If this is true, OpenLayers
|
* it may interfere with map dragging. If this is true, OpenLayers
|
||||||
* will not prevent selection of the control.
|
* will not prevent selection of the control.
|
||||||
* Default is false.
|
* Default is false.
|
||||||
|
|||||||
@@ -1702,6 +1702,30 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: adjustZoom
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* zoom - {Number} The zoom level to adjust
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* {Integer} Adjusted zoom level that shows a map not wider than its
|
||||||
|
* <baseLayer>'s maxExtent.
|
||||||
|
*/
|
||||||
|
adjustZoom: function(zoom) {
|
||||||
|
var resolution, resolutions = this.baseLayer.resolutions,
|
||||||
|
maxResolution = this.getMaxExtent().getWidth() / this.getSize().w;
|
||||||
|
if (this.getResolutionForZoom(zoom) > maxResolution) {
|
||||||
|
for (var i=zoom|0, ii=resolutions.length; i<ii; ++i) {
|
||||||
|
if (resolutions[i] <= maxResolution) {
|
||||||
|
zoom = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return zoom;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: moveTo
|
* Method: moveTo
|
||||||
*
|
*
|
||||||
@@ -1723,6 +1747,9 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
zoom = Math.round(zoom);
|
zoom = Math.round(zoom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this.baseLayer.wrapDateLine) {
|
||||||
|
zoom = this.adjustZoom(zoom);
|
||||||
|
}
|
||||||
// dragging is false by default
|
// dragging is false by default
|
||||||
var dragging = options.dragging || this.dragging;
|
var dragging = options.dragging || this.dragging;
|
||||||
// forceZoomChange is false by default
|
// forceZoomChange is false by default
|
||||||
|
|||||||
@@ -131,7 +131,7 @@
|
|||||||
|
|
||||||
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
|
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
|
||||||
layer = new OpenLayers.Layer.WMS(name, url, params, {'wrapDateLine':true,encodeBBOX:true, buffer: 2});
|
layer = new OpenLayers.Layer.WMS(name, url, params, {'wrapDateLine':true,encodeBBOX:true, buffer: 2});
|
||||||
var m = new OpenLayers.Map('map');
|
var m = new OpenLayers.Map('map', {adjustZoom: function(z) {return z;}});
|
||||||
m.addLayer(layer);
|
m.addLayer(layer);
|
||||||
m.zoomToMaxExtent();
|
m.zoomToMaxExtent();
|
||||||
t.eq(layer.grid[3][0].url, "http://octo.metacarta.com/cgi-bin/mapserv?MAP=%2Fmapdata%2Fvmap_wms.map&LAYERS=basic&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=0%2C-90%2C180%2C90&WIDTH=256&HEIGHT=256", "cell [3][0] is wrapped around the world.");
|
t.eq(layer.grid[3][0].url, "http://octo.metacarta.com/cgi-bin/mapserv?MAP=%2Fmapdata%2Fvmap_wms.map&LAYERS=basic&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=0%2C-90%2C180%2C90&WIDTH=256&HEIGHT=256", "cell [3][0] is wrapped around the world.");
|
||||||
@@ -147,7 +147,7 @@
|
|||||||
"http://www.openlayers.org/world/index.php",
|
"http://www.openlayers.org/world/index.php",
|
||||||
{g: "satellite", map: "world"},
|
{g: "satellite", map: "world"},
|
||||||
{wrapDateLine: true, buffer: 2} );
|
{wrapDateLine: true, buffer: 2} );
|
||||||
var m = new OpenLayers.Map('map');
|
var m = new OpenLayers.Map('map', {adjustZoom: function(z) {return z;}});
|
||||||
m.addLayer(layer);
|
m.addLayer(layer);
|
||||||
m.zoomToMaxExtent();
|
m.zoomToMaxExtent();
|
||||||
t.eq(layer.grid[0][0].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=-1280&l=0&s=221471921.25", "grid[0][0] kamap is okay");
|
t.eq(layer.grid[0][0].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=-1280&l=0&s=221471921.25", "grid[0][0] kamap is okay");
|
||||||
@@ -165,7 +165,7 @@
|
|||||||
"prov_bound,fedlimit,rail,road,popplace",
|
"prov_bound,fedlimit,rail,road,popplace",
|
||||||
transparent: "true", format: "image/png"},
|
transparent: "true", format: "image/png"},
|
||||||
{wrapDateLine: true, reproject: false,encodeBBOX:true, buffer:2});
|
{wrapDateLine: true, reproject: false,encodeBBOX:true, buffer:2});
|
||||||
var m = new OpenLayers.Map('map');
|
var m = new OpenLayers.Map('map', {adjustZoom: function(z) {return z;}});
|
||||||
m.addLayers([baselayer,layer]);
|
m.addLayers([baselayer,layer]);
|
||||||
m.zoomToMaxExtent();
|
m.zoomToMaxExtent();
|
||||||
t.eq(layer.grid[0][0].url, "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?LAYERS=bathymetry%2Cland_fn%2Cpark%2Cdrain_fn%2Cdrainage%2Cprov_bound%2Cfedlimit%2Crail%2Croad%2Cpopplace&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=0%2C450%2C180%2C630&WIDTH=256&HEIGHT=256", "grid[0][0] wms overlay is okay");
|
t.eq(layer.grid[0][0].url, "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?LAYERS=bathymetry%2Cland_fn%2Cpark%2Cdrain_fn%2Cdrainage%2Cprov_bound%2Cfedlimit%2Crail%2Croad%2Cpopplace&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=0%2C450%2C180%2C630&WIDTH=256&HEIGHT=256", "grid[0][0] wms overlay is okay");
|
||||||
|
|||||||
@@ -1967,6 +1967,23 @@
|
|||||||
t.eq(map.layerContainerDiv.style.top, '0px', 'layer container top correct');
|
t.eq(map.layerContainerDiv.style.top, '0px', 'layer container top correct');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_adjustZoom(t) {
|
||||||
|
t.plan(3);
|
||||||
|
var map = new OpenLayers.Map({
|
||||||
|
div: 'map',
|
||||||
|
layers: [
|
||||||
|
new OpenLayers.Layer('name', {
|
||||||
|
isBaseLayer: true,
|
||||||
|
wrapDateLine: true
|
||||||
|
})
|
||||||
|
]
|
||||||
|
});
|
||||||
|
map.zoomToMaxExtent();
|
||||||
|
t.ok(map.getResolution() <= map.getMaxExtent().getWidth() / map.getSize().w, "wrapDateLine map not wider than world");
|
||||||
|
|
||||||
|
t.eq(map.adjustZoom(9), 9, "valid zoom maintained");
|
||||||
|
t.eq(map.adjustZoom(1), 2, "zoom adjusted to not exceed world width");
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -16,7 +16,13 @@
|
|||||||
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
|
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
|
||||||
map.addLayer(layer);
|
map.addLayer(layer);
|
||||||
map.zoomToExtent(new OpenLayers.Bounds(-94.617035,33.010025,-89.645401,36.492752));
|
map.zoomToExtent(new OpenLayers.Bounds(-94.617035,33.010025,-89.645401,36.492752));
|
||||||
map.addLayer(new OpenLayers.Layer.GML("GML", "arkansas.rss", {format: OpenLayers.Format.GeoRSS}));
|
map.addLayer(new OpenLayers.Layer.Vector("arkansas", {
|
||||||
|
protocol: new OpenLayers.Protocol.HTTP({
|
||||||
|
url: "arkansas.rss",
|
||||||
|
format: new OpenLayers.Format.GeoRSS()
|
||||||
|
}),
|
||||||
|
strategies: [new OpenLayers.Strategy.Fixed()]
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
Reference in New Issue
Block a user