fix for #677 -- making yahoo maps deal with size correctly (safari and general karma fix)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@3843 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -59,10 +59,22 @@ OpenLayers.Layer.Yahoo = OpenLayers.Class(
|
||||
*/
|
||||
loadMapObject:function() {
|
||||
try { //do not crash!
|
||||
this.mapObject = new YMap(this.div, this.type);
|
||||
var size = this.getMapObjectSizeFromOLSize(this.map.getSize());
|
||||
this.mapObject = new YMap(this.div, this.type, size);
|
||||
this.mapObject.disableKeyControls();
|
||||
} catch(e) {}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: onMapResize
|
||||
*
|
||||
*/
|
||||
onMapResize: function() {
|
||||
try {
|
||||
var size = this.getMapObjectSizeFromOLSize(this.map.getSize());
|
||||
this.mapObject.resizeTo(size);
|
||||
} catch(e) {}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
@@ -336,6 +348,21 @@ OpenLayers.Layer.Yahoo = OpenLayers.Class(
|
||||
getMapObjectPixelFromXY: function(x, y) {
|
||||
return new YCoordPoint(x, y);
|
||||
},
|
||||
|
||||
|
||||
// Size
|
||||
|
||||
/**
|
||||
* APIMethod: getMapObjectSizeFromOLSize
|
||||
*
|
||||
* Parameters:
|
||||
* olSize - {<OpenLayers.Size>}
|
||||
*
|
||||
* Return:
|
||||
* {Object} MapObject Size from olSize parameter
|
||||
*/
|
||||
getMapObjectSizeFromOLSize: function(olSize) {
|
||||
return new YSize(olSize.w, olSize.h);
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Layer.Yahoo"
|
||||
});
|
||||
|
||||
120
tests/Layer/test_Yahoo.html
Executable file
120
tests/Layer/test_Yahoo.html
Executable file
@@ -0,0 +1,120 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var layer;
|
||||
|
||||
function test_01_Layer_Yahoo_constructor (t) {
|
||||
t.plan( 4 );
|
||||
|
||||
var tempEventPane = OpenLayers.Layer.EventPane.prototype.initialize;
|
||||
OpenLayers.Layer.EventPane.prototype.initialize = function(name, options) {
|
||||
t.ok(name == g_Name, "EventPane initialize() called with correct name");
|
||||
t.ok(options == g_Options, "EventPane initialize() called with correct options");
|
||||
}
|
||||
|
||||
var tempFixedZoomLevels = OpenLayers.Layer.FixedZoomLevels.prototype.initialize;
|
||||
OpenLayers.Layer.FixedZoomLevels.prototype.initialize = function(name, options) {
|
||||
t.ok(name == g_Name, "FixedZoomLevels initialize() called with correct name");
|
||||
t.ok(options == g_Options, "FixedZoomLevels initialize() called with correct options");
|
||||
}
|
||||
|
||||
|
||||
g_Name = {};
|
||||
g_Options = {};
|
||||
var l = new OpenLayers.Layer.Yahoo(g_Name, g_Options);
|
||||
|
||||
OpenLayers.Layer.EventPane.prototype.initialize = tempEventPane;
|
||||
OpenLayers.Layer.FixedZoomLevels.prototype.initialize = tempFixedZoomLevels;
|
||||
}
|
||||
|
||||
function test_02_Layer_Yahoo_loadMapObject(t) {
|
||||
t.plan(5);
|
||||
|
||||
var temp = YMap;
|
||||
YMap = OpenLayers.Class({
|
||||
initialize: function(div, type, size) {
|
||||
t.ok(div == g_Div, "correct div passed to YMap constructor");
|
||||
t.ok(type == g_Type, "correct type passed to YMap constructor");
|
||||
t.ok(size == g_YMapSize, "correct size passed to YMap constructor");
|
||||
},
|
||||
disableKeyControls: function() {
|
||||
t.ok(true, "disableKeyControls called on map object");
|
||||
}
|
||||
});
|
||||
|
||||
g_Div = {};
|
||||
g_Type = {};
|
||||
g_MapSize = {};
|
||||
g_YMapSize = {};
|
||||
|
||||
var l = new OpenLayers.Layer.Yahoo();
|
||||
l.div = g_Div;
|
||||
l.type = g_Type;
|
||||
l.map = {
|
||||
'getSize': function() {
|
||||
return g_MapSize;
|
||||
}
|
||||
};
|
||||
l.getMapObjectSizeFromOLSize = function(mapSize) {
|
||||
t.ok(mapSize == g_MapSize, "correctly translating map size from ol to YSize");
|
||||
return g_YMapSize;
|
||||
};
|
||||
|
||||
l.loadMapObject();
|
||||
|
||||
YMap = temp;
|
||||
}
|
||||
|
||||
function test_03_Layer_Yahoo_onMapResize(t) {
|
||||
t.plan(2);
|
||||
|
||||
g_MapSize = {};
|
||||
g_YMapSize = {};
|
||||
|
||||
var l = new OpenLayers.Layer.Yahoo();
|
||||
l.mapObject = {
|
||||
'resizeTo': function(size) {
|
||||
t.ok(size == g_YMapSize, "correct YSize passed to reiszeTo on map object");
|
||||
}
|
||||
}
|
||||
l.map = {
|
||||
'getSize': function() {
|
||||
return g_MapSize;
|
||||
}
|
||||
};
|
||||
l.getMapObjectSizeFromOLSize = function(mapSize) {
|
||||
t.ok(mapSize == g_MapSize, "correctly translating map size from ol to YSize");
|
||||
return g_YMapSize;
|
||||
};
|
||||
|
||||
l.onMapResize();
|
||||
}
|
||||
|
||||
function test_04_Layer_Yahoo_getMapObjectSizeFromOLSize(t) {
|
||||
t.plan(2);
|
||||
|
||||
var temp = YSize;
|
||||
YSize = function(w, h) {
|
||||
t.ok(w == g_Size.w, "correct width passed to YSize constructor");
|
||||
t.ok(h == g_Size.h, "correct height passed to YSize constructor");
|
||||
}
|
||||
|
||||
g_Size = {
|
||||
'w': {},
|
||||
'h': {}
|
||||
};
|
||||
|
||||
OpenLayers.Layer.Yahoo.prototype.getMapObjectSizeFromOLSize(g_Size);
|
||||
|
||||
YSize = temp;
|
||||
}
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -51,6 +51,7 @@
|
||||
<li>Layer/test_TMS.html</li>
|
||||
<li>Layer/test_TileCache.html</li>
|
||||
<li>Layer/test_Vector.html</li>
|
||||
<li>Layer/test_Yahoo.html</li>
|
||||
<li>Layer/test_GML.html</li>
|
||||
<li>Layer/test_WrapDateLine.html</li>
|
||||
<li>test_Tile.html</li>
|
||||
|
||||
Reference in New Issue
Block a user