diff --git a/src/ol/geom/polygon.js b/src/ol/geom/polygon.js index d256ea0951..77df7e0259 100644 --- a/src/ol/geom/polygon.js +++ b/src/ol/geom/polygon.js @@ -136,10 +136,11 @@ ol.geom.Polygon.prototype.containsCoordinate = function(coordinate) { /** - * Calculates a label point that is guaranteed to be inside the polygon. - * @return {ol.Coordinate} The label point. + * Calculates a point that is guaranteed to lie in the interior of the polygon. + * Inspired by JTS's com.vividsolutions.jts.geom.Geometry#getInteriorPoint. + * @return {ol.Coordinate} A point which is in the interior of the polygon. */ -ol.geom.Polygon.prototype.getLabelPoint = function() { +ol.geom.Polygon.prototype.getInteriorPoint = function() { if (goog.isNull(this.labelPoint_)) { var center = ol.extent.getCenter(this.getBounds()), resultY = center[1], diff --git a/src/ol/renderer/canvas/canvasvectorrenderer.js b/src/ol/renderer/canvas/canvasvectorrenderer.js index 25bde2f6ad..9bf610e33a 100644 --- a/src/ol/renderer/canvas/canvasvectorrenderer.js +++ b/src/ol/renderer/canvas/canvasvectorrenderer.js @@ -445,7 +445,7 @@ ol.renderer.canvas.VectorRenderer.getLabelVectors = function(geometry) { return [[geometry.get(0), geometry.get(1), 0]]; } if (type == ol.geom.GeometryType.POLYGON) { - var coordinates = geometry.getLabelPoint(); + var coordinates = geometry.getInteriorPoint(); return [[coordinates[0], coordinates[1], 0]]; } throw new Error('Label rendering not implemented for geometry type: ' +