Rendering test for an icon
This commit is contained in:
BIN
rendering/cases/icon-symbol/expected.png
Normal file
BIN
rendering/cases/icon-symbol/expected.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
22
rendering/cases/icon-symbol/index.html
Normal file
22
rendering/cases/icon-symbol/index.html
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
html, body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
#map {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="map"></div>
|
||||||
|
<script src="main.js"></script>
|
||||||
|
</body>
|
||||||
|
</script>
|
||||||
|
</html>
|
||||||
44
rendering/cases/icon-symbol/main.js
Normal file
44
rendering/cases/icon-symbol/main.js
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import Map from '../../../src/ol/Map.js';
|
||||||
|
import View from '../../../src/ol/View.js';
|
||||||
|
import {Vector as VectorLayer, Tile as TileLayer} from '../../../src/ol/layer.js';
|
||||||
|
import {Vector as VectorSource, OSM} from '../../../src/ol/source.js';
|
||||||
|
import Point from '../../../src/ol/geom/Point.js';
|
||||||
|
import Feature from '../../../src/ol/Feature.js';
|
||||||
|
import {fromLonLat} from '../../../src/ol/proj.js';
|
||||||
|
import {Style, Icon} from '../../../src/ol/style.js';
|
||||||
|
|
||||||
|
const center = fromLonLat([8.6, 50.1]);
|
||||||
|
|
||||||
|
new Map({
|
||||||
|
layers: [
|
||||||
|
new TileLayer({
|
||||||
|
source: new OSM()
|
||||||
|
}),
|
||||||
|
new VectorLayer({
|
||||||
|
style: function() {
|
||||||
|
return new Style({
|
||||||
|
image: new Icon({
|
||||||
|
src: '/data/icon.png',
|
||||||
|
anchor: [0.5, 46],
|
||||||
|
anchorXUnits: 'fraction',
|
||||||
|
anchorYUnits: 'pixels'
|
||||||
|
})
|
||||||
|
});
|
||||||
|
},
|
||||||
|
source: new VectorSource({
|
||||||
|
features: [
|
||||||
|
new Feature(
|
||||||
|
new Point(center)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
})
|
||||||
|
})
|
||||||
|
],
|
||||||
|
target: 'map',
|
||||||
|
view: new View({
|
||||||
|
center: center,
|
||||||
|
zoom: 3
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
render();
|
||||||
BIN
rendering/data/icon.png
Normal file
BIN
rendering/data/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 KiB |
@@ -66,14 +66,6 @@ describe('ol.rendering.style.Icon', function() {
|
|||||||
img.src = src;
|
img.src = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
it('tests the canvas renderer', function(done) {
|
|
||||||
createMap('canvas');
|
|
||||||
createFeatures('rendering/ol/data/icon.png', imgInfo, function() {
|
|
||||||
expectResemble(map, 'rendering/ol/style/expected/icon-canvas.png',
|
|
||||||
IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('scales svg correctly in the canvas renderer', function(done) {
|
it('scales svg correctly in the canvas renderer', function(done) {
|
||||||
createMap('canvas', 512, 512);
|
createMap('canvas', 512, 512);
|
||||||
createFeatures('rendering/ol/data/me0.svg', {
|
createFeatures('rendering/ol/data/me0.svg', {
|
||||||
|
|||||||
Reference in New Issue
Block a user