ol-mapbox-style
Advanced tools
Comparing version 3.4.0 to 3.5.0
@@ -440,5 +440,3 @@ /* | ||
if (layer) { | ||
layer.setZIndex(i); | ||
layer.set('mapbox-source', glSourceId); | ||
layer.set('mapbox-layers', layerIds); | ||
} | ||
@@ -621,2 +619,3 @@ } | ||
layer.set('mapbox-layers', layerIds); | ||
if (map.getLayers().getArray().indexOf(layer) === -1) { | ||
@@ -623,0 +622,0 @@ map.addLayer(layer); |
{ | ||
"name": "ol-mapbox-style", | ||
"version": "3.4.0", | ||
"version": "3.5.0", | ||
"description": "Create OpenLayers maps from Mapbox Style objects", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -421,2 +421,3 @@ /* | ||
let text = null; | ||
let placementAngle = 0; | ||
let icon, iconImg, skipLabel; | ||
@@ -440,3 +441,24 @@ if ((type == 1 || type == 2) && 'icon-image' in layout) { | ||
//FIXME Do not hard-code a size of 150 | ||
styleGeom = new Point(geom.getFlatMidpoint()); | ||
const midpoint = geom.getFlatMidpoint(); | ||
styleGeom = new Point(midpoint); | ||
const placement = getValue(layer, 'layout', 'symbol-placement'); | ||
if (placement === 'line') { | ||
const stride = geom.getStride(); | ||
const coordinates = geom.getFlatCoordinates(); | ||
for (let i = 0, ii = coordinates.length - stride; i < ii; i += stride) { | ||
const x1 = coordinates[i]; | ||
const y1 = coordinates[i + 1]; | ||
const x2 = coordinates[i + stride]; | ||
const y2 = coordinates[i + stride + 1]; | ||
const minX = Math.min(x1, x2); | ||
const minY = Math.min(y1, y2); | ||
const maxX = Math.max(x1, x2); | ||
const maxY = Math.max(y1, y2); | ||
if (midpoint[0] >= minX && midpoint[0] <= maxX && | ||
midpoint[1] >= minY && midpoint[1] <= maxY) { | ||
placementAngle = Math.atan2(y1 - y2, x2 - x1); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
@@ -497,2 +519,3 @@ } | ||
offset: [spriteImageData.x, spriteImageData.y], | ||
rotateWithView: getValue(layer, 'layout', 'icon-rotation-alignment') === 'map', | ||
scale: iconSize / spriteImageData.pixelRatio | ||
@@ -502,3 +525,3 @@ }); | ||
} | ||
iconImg.setRotation(deg2rad(getValue(layer, 'layout', 'icon-rotate', zoom, f))); | ||
iconImg.setRotation(placementAngle + deg2rad(getValue(layer, 'layout', 'icon-rotate', zoom, f))); | ||
iconImg.setOpacity(getValue(layer, 'paint', 'icon-opacity', zoom, f)); | ||
@@ -505,0 +528,0 @@ style.setImage(iconImg); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6358128
39011