New GoogleNG layer using tiles from the v3 API's mapType::getTile method. r=bartvde (closes #3312)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@12000 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="http://maps.google.com/maps/api/js?sensor=false&v=3.5"></script>
|
||||
<script src="../OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
var map, layer;
|
||||
|
||||
function test_constructor(t) {
|
||||
t.plan(2);
|
||||
|
||||
layer = new OpenLayers.Layer.GoogleNG({type: google.maps.MapTypeId.HYBRID});
|
||||
t.ok(layer instanceof OpenLayers.Layer.GoogleNG, "returns OpenLayers.Layer.GoogleNG object" );
|
||||
t.eq(layer.type, google.maps.MapTypeId.HYBRID, "Layer type set");
|
||||
}
|
||||
|
||||
function test_initLayer(t) {
|
||||
t.plan(6);
|
||||
|
||||
map = new OpenLayers.Map("map");
|
||||
var log = {};
|
||||
layer = new OpenLayers.Layer.GoogleNG({
|
||||
numZoomLevels: 10,
|
||||
restrictedMinZoom: 2,
|
||||
initLayer: function() {
|
||||
log[layer.id] = true;
|
||||
OpenLayers.Layer.GoogleNG.prototype.initLayer.apply(this, arguments);
|
||||
}
|
||||
});
|
||||
map.addLayer(layer);
|
||||
map.zoomToMaxExtent();
|
||||
|
||||
var map2 = new OpenLayers.Map("map2");
|
||||
var layer2 = new OpenLayers.Layer.GoogleNG({
|
||||
numZoomLevels: 24,
|
||||
initLayer: function() {
|
||||
log[layer2.id] = true;
|
||||
var origMinZoom = layer2.mapObject.mapTypes[layer2.type].minZoom;
|
||||
// pretend the API reports a minZoom of 1
|
||||
layer2.mapObject.mapTypes[layer2.type].minZoom = 1;
|
||||
OpenLayers.Layer.GoogleNG.prototype.initLayer.apply(this, arguments);
|
||||
layer2.mapObject.mapTypes[layer2.type].minZoom = origMinZoom;
|
||||
}
|
||||
});
|
||||
map2.addLayer(layer2);
|
||||
map2.zoomToMaxExtent();
|
||||
|
||||
t.delay_call(1, function() {
|
||||
t.eq(log[layer.id], true, "initLayer called for 1st layer");
|
||||
t.eq(log[layer2.id], true, "initLayer called for 2nd layer");
|
||||
|
||||
t.eq(layer.numZoomLevels, 10, "numZoomLevels from configuration takes precedence if lower");
|
||||
t.eq(layer2.numZoomLevels, layer2.mapObject.mapTypes[layer2.type].maxZoom+1, "numZoomLevels from API takes precedence if lower");
|
||||
|
||||
t.eq(layer.restrictedMinZoom, 2, "restrictedMinZoom from configuration takes precedence if higher");
|
||||
t.eq(layer2.restrictedMinZoom, 1, "restrictedMinZoom from API takes precedence if higher");
|
||||
|
||||
map.destroy();
|
||||
map2.destroy();
|
||||
});
|
||||
}
|
||||
|
||||
function test_attribution(t) {
|
||||
t.plan(3);
|
||||
|
||||
var log = [];
|
||||
map = new OpenLayers.Map("map");
|
||||
layer = new OpenLayers.Layer.GoogleNG({type: google.maps.MapTypeId.HYBRID});
|
||||
map.addLayer(layer);
|
||||
map.zoomToMaxExtent();
|
||||
|
||||
t.delay_call(1, function() {
|
||||
t.ok(layer.attribution.indexOf('olGoogleAttribution hybrid') !== -1, "Attribution has the correct css class");
|
||||
t.ok(layer.attribution.indexOf('?ll=0,0&z=0&t=h"') != -1, "maps.google.com link has correct parameters");
|
||||
t.ok(layer.attribution.indexOf('¢er=0,0&zoom=0&size=500x550&maptype=hybrid') != -1 , "Attribution has correct map data link");
|
||||
map.destroy();
|
||||
});
|
||||
}
|
||||
|
||||
function test_clone(t) {
|
||||
t.plan(2);
|
||||
|
||||
var clone;
|
||||
|
||||
layer = new OpenLayers.Layer.GoogleNG({type: google.maps.MapTypeId.HYBRID});
|
||||
clone = layer.clone();
|
||||
t.ok(clone instanceof OpenLayers.Layer.GoogleNG, "clone is a Layer.GoogleNG instance");
|
||||
t.eq(clone.type, google.maps.MapTypeId.HYBRID, "with the correct map type");
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width:500px;height:550px"></div>
|
||||
<div id="map2" style="width:500px;height:550px"></div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user