the canvas renderer may mess up when rendering external graphics, r=erilem (closes #3264)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11899 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -202,7 +202,7 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
|
||||
* style - {Object}
|
||||
* featureId - {String}
|
||||
*/
|
||||
drawExternalGraphic: function(pt, style, featureId) {
|
||||
drawExternalGraphic: function(geometry, style, featureId) {
|
||||
var img = new Image();
|
||||
|
||||
if (style.graphicTitle) {
|
||||
@@ -218,28 +218,34 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
|
||||
var yOffset = (style.graphicYOffset != undefined) ?
|
||||
style.graphicYOffset : -(0.5 * height);
|
||||
|
||||
var x = pt[0] + xOffset;
|
||||
var y = pt[1] + yOffset;
|
||||
|
||||
var opacity = style.graphicOpacity || style.fillOpacity;
|
||||
|
||||
var onLoad = function() {
|
||||
// TODO: check that we haven't moved
|
||||
var canvas = this.canvas;
|
||||
canvas.globalAlpha = opacity;
|
||||
var factor = OpenLayers.Renderer.Canvas.drawImageScaleFactor ||
|
||||
(OpenLayers.Renderer.Canvas.drawImageScaleFactor =
|
||||
/android 2.1/.test(navigator.userAgent.toLowerCase()) ?
|
||||
// 320 is the screen width of the G1 phone, for which
|
||||
// drawImage works out of the box.
|
||||
320 / window.screen.width : 1
|
||||
if(!this.features[featureId]) {
|
||||
return;
|
||||
}
|
||||
var pt = this.getLocalXY(geometry);
|
||||
var p0 = pt[0];
|
||||
var p1 = pt[1];
|
||||
if(!isNaN(p0) && !isNaN(p1)) {
|
||||
var x = p0 + xOffset;
|
||||
var y = p1 + yOffset;
|
||||
var canvas = this.canvas;
|
||||
canvas.globalAlpha = opacity;
|
||||
var factor = OpenLayers.Renderer.Canvas.drawImageScaleFactor ||
|
||||
(OpenLayers.Renderer.Canvas.drawImageScaleFactor =
|
||||
/android 2.1/.test(navigator.userAgent.toLowerCase()) ?
|
||||
// 320 is the screen width of the G1 phone, for
|
||||
// which drawImage works out of the box.
|
||||
320 / window.screen.width : 1
|
||||
);
|
||||
canvas.drawImage(
|
||||
img, x*factor, y*factor, width*factor, height*factor
|
||||
);
|
||||
canvas.drawImage(
|
||||
img, x*factor, y*factor, width*factor, height*factor
|
||||
);
|
||||
if (this.hitDetection) {
|
||||
this.setHitContextStyle("fill", featureId);
|
||||
this.hitContext.fillRect(x, y, width, height);
|
||||
if (this.hitDetection) {
|
||||
this.setHitContextStyle("fill", featureId);
|
||||
this.hitContext.fillRect(x, y, width, height);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -327,13 +333,13 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
|
||||
*/
|
||||
drawPoint: function(geometry, style, featureId) {
|
||||
if(style.graphic !== false) {
|
||||
var pt = this.getLocalXY(geometry);
|
||||
var p0 = pt[0];
|
||||
var p1 = pt[1];
|
||||
if (!isNaN(p0) && !isNaN(p1)) {
|
||||
if (style.externalGraphic) {
|
||||
this.drawExternalGraphic(pt, style, featureId);
|
||||
} else {
|
||||
if(style.externalGraphic) {
|
||||
this.drawExternalGraphic(geometry, style, featureId);
|
||||
} else {
|
||||
var pt = this.getLocalXY(geometry);
|
||||
var p0 = pt[0];
|
||||
var p1 = pt[1];
|
||||
if(!isNaN(p0) && !isNaN(p1)) {
|
||||
var twoPi = Math.PI*2;
|
||||
var radius = style.pointRadius;
|
||||
if(style.fill !== false) {
|
||||
|
||||
Reference in New Issue
Block a user