Merge branch 'master' of github.com:openlayers/openlayers into proj
This commit is contained in:
@@ -57,6 +57,8 @@ OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, {
|
||||
* set to true or to an object. If set to an object this
|
||||
* object will be passed to the {<OpenLayers.Kinetic>}
|
||||
* constructor. Defaults to false.
|
||||
* If you set this property, you should ensure that
|
||||
* OpenLayers/Kinetic.js is included in your build config
|
||||
*/
|
||||
enableKinetic: false,
|
||||
|
||||
|
||||
@@ -414,11 +414,13 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {
|
||||
* labelAlign - {String} Label alignment. This specifies the insertion point relative to the text. It is a string
|
||||
* composed of two characters. The first character is for the horizontal alignment, the second for the vertical
|
||||
* alignment. Valid values for horizontal alignment: "l"=left, "c"=center, "r"=right. Valid values for vertical
|
||||
* alignment: "t"=top, "m"=middle, "b"=bottom. Example values: "lt", "cm", "rb".
|
||||
* alignment: "t"=top, "m"=middle, "b"=bottom. Example values: "lt", "cm", "rb". Default is "cm".
|
||||
* labelXOffset - {Number} Pixel offset along the positive x axis for displacing the label. Not supported by the canvas renderer.
|
||||
* labelYOffset - {Number} Pixel offset along the positive y axis for displacing the label. Not supported by the canvas renderer.
|
||||
* labelSelect - {Boolean} If set to true, labels will be selectable using SelectFeature or similar controls.
|
||||
* Default is false.
|
||||
* labelOutlineColor - {String} The color of the label outline. Default is 'white'. Only supported by the canvas & SVG renderers.
|
||||
* labelOutlineWidth - {Number} The width of the label outline. Default is 3, set to 0 or null to disable. Only supported by the canvas & SVG renderers.
|
||||
* fontColor - {String} The font color for the label, to be provided like CSS.
|
||||
* fontOpacity - {Number} Opacity (0-1) for the label
|
||||
* fontFamily - {String} The font family for the label, to be provided like in CSS.
|
||||
@@ -445,7 +447,11 @@ OpenLayers.Feature.Vector.style = {
|
||||
hoverPointRadius: 1,
|
||||
hoverPointUnit: "%",
|
||||
pointerEvents: "visiblePainted",
|
||||
cursor: "inherit"
|
||||
cursor: "inherit",
|
||||
fontColor: "#000000",
|
||||
labelAlign: "cm",
|
||||
labelOutlineColor: "white",
|
||||
labelOutlineWidth: 3
|
||||
},
|
||||
'select': {
|
||||
fillColor: "blue",
|
||||
@@ -464,7 +470,12 @@ OpenLayers.Feature.Vector.style = {
|
||||
hoverPointRadius: 1,
|
||||
hoverPointUnit: "%",
|
||||
pointerEvents: "visiblePainted",
|
||||
cursor: "pointer"
|
||||
cursor: "pointer",
|
||||
fontColor: "#000000",
|
||||
labelAlign: "cm",
|
||||
labelOutlineColor: "white",
|
||||
labelOutlineWidth: 3
|
||||
|
||||
},
|
||||
'temporary': {
|
||||
fillColor: "#66cccc",
|
||||
@@ -483,7 +494,12 @@ OpenLayers.Feature.Vector.style = {
|
||||
hoverPointRadius: 1,
|
||||
hoverPointUnit: "%",
|
||||
pointerEvents: "visiblePainted",
|
||||
cursor: "inherit"
|
||||
cursor: "inherit",
|
||||
fontColor: "#000000",
|
||||
labelAlign: "cm",
|
||||
labelOutlineColor: "white",
|
||||
labelOutlineWidth: 3
|
||||
|
||||
},
|
||||
'delete': {
|
||||
display: "none"
|
||||
|
||||
@@ -294,7 +294,7 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class(
|
||||
var px = approx(point.x, digs);
|
||||
var py = approx(point.y, digs);
|
||||
function getX(y, x1, y1, x2, y2) {
|
||||
return (((x1 - x2) * y) + ((x2 * y1) - (x1 * y2))) / (y1 - y2);
|
||||
return (y - y2) * ((x2 - x1) / (y2 - y1)) + x2;
|
||||
}
|
||||
var numSeg = this.components.length - 1;
|
||||
var start, end, x1, y1, x2, y2, cx, cy;
|
||||
|
||||
91
lib/OpenLayers/Layer/OSM.js
Normal file
91
lib/OpenLayers/Layer/OSM.js
Normal file
@@ -0,0 +1,91 @@
|
||||
/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Layer/XYZ.js
|
||||
* @requires OpenLayers/Layer/SphericalMercator.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Layer.OSM
|
||||
* This layer allows accessing OpenStreetMap tiles. By default the OpenStreetMap
|
||||
* hosted tile.openstreetmap.org Mapnik tileset is used. If you wish to use
|
||||
* tiles@home / osmarender layer instead, you need to provide a different
|
||||
* URL to the constructor. Here's an example for tiles@home:
|
||||
*
|
||||
* (code)
|
||||
* new OpenLayers.Layer.OSM("t@h",
|
||||
* "http://tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png");
|
||||
* (end)
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Layer.XYZ>
|
||||
*/
|
||||
OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
|
||||
|
||||
/**
|
||||
* APIProperty: name
|
||||
* {String} The layer name. Defaults to "OpenStreetMap" if the first
|
||||
* argument to the constructor is null or undefined.
|
||||
*/
|
||||
name: "OpenStreetMap",
|
||||
|
||||
/**
|
||||
* APIProperty: url
|
||||
* {String} The tileset URL scheme. Defaults to
|
||||
* : http://tile.openstreetmap.org/${z}/${x}/${y}.png
|
||||
* (the official OSM tileset) if the second argument to the constructor
|
||||
* is null or undefined. To use another tileset you can have something
|
||||
* like this:
|
||||
* (start code)
|
||||
* new OpenLayers.Layer.OSM("t@h",
|
||||
* "http://tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png");
|
||||
* (end)
|
||||
*/
|
||||
url: 'http://tile.openstreetmap.org/${z}/${x}/${y}.png',
|
||||
|
||||
/**
|
||||
* Property: attribution
|
||||
* {String} The layer attribution.
|
||||
*/
|
||||
attribution: "Data CC-By-SA by <a href='http://openstreetmap.org/'>OpenStreetMap</a>",
|
||||
|
||||
/**
|
||||
* Property: sphericalMercator
|
||||
* {Boolean}
|
||||
*/
|
||||
sphericalMercator: true,
|
||||
|
||||
/**
|
||||
* Property: wrapDateLine
|
||||
* {Boolean}
|
||||
*/
|
||||
wrapDateLine: true,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Layer.OSM
|
||||
*
|
||||
* Parameters:
|
||||
* name - {String} The layer name.
|
||||
* url - {String} The tileset URL scheme.
|
||||
* options - {Object} Configuration options for the layer. Any inherited
|
||||
* layer option can be set in this object (e.g.
|
||||
* <OpenLayers.Layer.Grid.buffer>).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Method: clone
|
||||
*/
|
||||
clone: function(obj) {
|
||||
if (obj == null) {
|
||||
obj = new OpenLayers.Layer.OSM(
|
||||
this.name, this.url, this.getOptions());
|
||||
}
|
||||
obj = OpenLayers.Layer.XYZ.prototype.clone.apply(this, [obj]);
|
||||
return obj;
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Layer.OSM"
|
||||
});
|
||||
@@ -183,37 +183,3 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
|
||||
CLASS_NAME: "OpenLayers.Layer.XYZ"
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Layer.OSM
|
||||
* A class to access OpenStreetMap tiles. By default, uses the OpenStreetMap
|
||||
* hosted tile.openstreetmap.org 'Mapnik' tileset. If you wish to use
|
||||
* tiles@home / osmarender layer instead, you can pass a layer like:
|
||||
*
|
||||
* (code)
|
||||
* new OpenLayers.Layer.OSM("t@h",
|
||||
* "http://tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png");
|
||||
* (end)
|
||||
*
|
||||
* This layer defaults to Spherical Mercator.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Layer.XYZ>
|
||||
*/
|
||||
OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
|
||||
name: "OpenStreetMap",
|
||||
attribution: "Data CC-By-SA by <a href='http://openstreetmap.org/'>OpenStreetMap</a>",
|
||||
sphericalMercator: true,
|
||||
url: 'http://tile.openstreetmap.org/${z}/${x}/${y}.png',
|
||||
clone: function(obj) {
|
||||
if (obj == null) {
|
||||
obj = new OpenLayers.Layer.OSM(
|
||||
this.name, this.url, this.getOptions());
|
||||
}
|
||||
obj = OpenLayers.Layer.XYZ.prototype.clone.apply(this, [obj]);
|
||||
return obj;
|
||||
},
|
||||
wrapDateLine: true,
|
||||
CLASS_NAME: "OpenLayers.Layer.OSM"
|
||||
});
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* TODO: remove this dependency in 3.0
|
||||
* @requires OpenLayers/Format/QueryStringFilter.js
|
||||
* if application uses the query string, for example, for BBOX parameters,
|
||||
* OpenLayers/Format/QueryStringFilter.js should be included in the build config file
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
* @requires OpenLayers/Format/GeoJSON.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* if application uses the query string, for example, for BBOX parameters,
|
||||
* OpenLayers/Format/QueryStringFilter.js should be included in the build config file
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Protocol.Script
|
||||
* A basic Script protocol for vector layers. Create a new instance with the
|
||||
|
||||
@@ -525,10 +525,6 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
|
||||
* style - {Object}
|
||||
*/
|
||||
drawText: function(location, style) {
|
||||
style = OpenLayers.Util.extend({
|
||||
fontColor: "#000000",
|
||||
labelAlign: "cm"
|
||||
}, style);
|
||||
var pt = this.getLocalXY(location);
|
||||
|
||||
this.setCanvasStyle("reset");
|
||||
@@ -560,6 +556,13 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
|
||||
this.canvas.measureText('xx').width;
|
||||
pt[1] += lineHeight*vfactor*(numRows-1);
|
||||
for (var i = 0; i < numRows; i++) {
|
||||
if (style.labelOutlineWidth) {
|
||||
this.canvas.save();
|
||||
this.canvas.strokeStyle = style.labelOutlineColor;
|
||||
this.canvas.lineWidth = style.labelOutlineWidth;
|
||||
this.canvas.strokeText(labelRows[i], pt[0], pt[1] + (lineHeight*i) + 1);
|
||||
this.canvas.restore();
|
||||
}
|
||||
this.canvas.fillText(labelRows[i], pt[0], pt[1] + (lineHeight*i));
|
||||
}
|
||||
} else if (this.canvas.mozDrawText) {
|
||||
|
||||
@@ -415,6 +415,12 @@ OpenLayers.Renderer.Elements = OpenLayers.Class(OpenLayers.Renderer, {
|
||||
*/
|
||||
LABEL_ID_SUFFIX: "_label",
|
||||
|
||||
/**
|
||||
* Constant: LABEL_OUTLINE_SUFFIX
|
||||
* {String}
|
||||
*/
|
||||
LABEL_OUTLINE_SUFFIX: "_outline",
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Renderer.Elements
|
||||
*
|
||||
@@ -879,6 +885,10 @@ OpenLayers.Renderer.Elements = OpenLayers.Class(OpenLayers.Renderer, {
|
||||
if (label) {
|
||||
this.textRoot.removeChild(label);
|
||||
}
|
||||
var outline = document.getElementById(featureId + this.LABEL_OUTLINE_SUFFIX);
|
||||
if (outline) {
|
||||
this.textRoot.removeChild(outline);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -643,12 +643,25 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
* location - {<OpenLayers.Geometry.Point>}
|
||||
*/
|
||||
drawText: function(featureId, style, location) {
|
||||
var drawOutline = (!!style.labelOutlineWidth);
|
||||
// First draw text in halo color and size and overlay the
|
||||
// normal text afterwards
|
||||
if (drawOutline) {
|
||||
var outlineStyle = OpenLayers.Util.extend({}, style);
|
||||
outlineStyle.fontColor = outlineStyle.labelOutlineColor;
|
||||
outlineStyle.fontStrokeColor = outlineStyle.labelOutlineColor;
|
||||
outlineStyle.fontStrokeWidth = style.labelOutlineWidth;
|
||||
delete outlineStyle.labelOutlineWidth;
|
||||
this.drawText(featureId, outlineStyle, location);
|
||||
}
|
||||
|
||||
var resolution = this.getResolution();
|
||||
|
||||
var x = ((location.x - this.featureDx) / resolution + this.left);
|
||||
var y = (location.y / resolution - this.top);
|
||||
|
||||
var label = this.nodeFactory(featureId + this.LABEL_ID_SUFFIX, "text");
|
||||
var suffix = (drawOutline)?this.LABEL_OUTLINE_SUFFIX:this.LABEL_ID_SUFFIX;
|
||||
label = this.nodeFactory(featureId + suffix, "text");
|
||||
|
||||
label.setAttributeNS(null, "x", x);
|
||||
label.setAttributeNS(null, "y", -y);
|
||||
@@ -656,6 +669,12 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
if (style.fontColor) {
|
||||
label.setAttributeNS(null, "fill", style.fontColor);
|
||||
}
|
||||
if (style.fontStrokeColor) {
|
||||
label.setAttributeNS(null, "stroke", style.fontStrokeColor);
|
||||
}
|
||||
if (style.fontStrokeWidth) {
|
||||
label.setAttributeNS(null, "stroke-width", style.fontStrokeWidth);
|
||||
}
|
||||
if (style.fontOpacity) {
|
||||
label.setAttributeNS(null, "opacity", style.fontOpacity);
|
||||
}
|
||||
@@ -677,7 +696,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
} else {
|
||||
label.setAttributeNS(null, "pointer-events", "none");
|
||||
}
|
||||
var align = style.labelAlign || "cm";
|
||||
var align = style.labelAlign;
|
||||
label.setAttributeNS(null, "text-anchor",
|
||||
OpenLayers.Renderer.SVG.LABEL_ALIGN[align[0]] || "middle");
|
||||
|
||||
@@ -692,7 +711,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
label.removeChild(label.lastChild);
|
||||
}
|
||||
for (var i = 0; i < numRows; i++) {
|
||||
var tspan = this.nodeFactory(featureId + this.LABEL_ID_SUFFIX + "_tspan_" + i, "tspan");
|
||||
var tspan = this.nodeFactory(featureId + suffix + "_tspan_" + i, "tspan");
|
||||
if (style.labelSelect === true) {
|
||||
tspan._featureId = featureId;
|
||||
tspan._geometry = location;
|
||||
|
||||
@@ -584,7 +584,7 @@ OpenLayers.Renderer.SVG2 = OpenLayers.Class(OpenLayers.Renderer.NG, {
|
||||
} else {
|
||||
text.setAttributeNS(null, "pointer-events", "none");
|
||||
}
|
||||
var align = style.labelAlign || "cm";
|
||||
var align = style.labelAlign;
|
||||
text.setAttributeNS(null, "text-anchor",
|
||||
OpenLayers.Renderer.SVG2.LABEL_ALIGN[align[0]] || "middle");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user