Skip to content

Commit b5f57b3

Browse files
Clara BelairNeonox31
authored andcommitted
feat(demo): example of marker with svg
1 parent 2e7bda4 commit b5f57b3

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed

src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { SideBySideComponent } from './side-by-side/side-by-side.component';
2222
import { SwipeComponent } from './swipe/swipe.component';
2323
import { OverlayComponent } from './overlay/overlay.component';
2424
import { ColorSelectHoverComponent } from './color-select-hover/color-select-hover.component';
25+
import { MarkerComponent } from './marker/marker.component';
2526

2627
@NgModule({
2728
declarations: [
@@ -41,6 +42,7 @@ import { ColorSelectHoverComponent } from './color-select-hover/color-select-hov
4142
SwipeComponent,
4243
OverlayComponent,
4344
ColorSelectHoverComponent,
45+
MarkerComponent,
4446
],
4547
imports: [BrowserModule, FormsModule, AppRoutingModule, AngularOpenlayersModule, ReactiveFormsModule],
4648
providers: [],

src/app/app.routing.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { SideBySideComponent } from './side-by-side/side-by-side.component';
1515
import { SwipeComponent } from './swipe/swipe.component';
1616
import { OverlayComponent } from './overlay/overlay.component';
1717
import { ColorSelectHoverComponent } from './color-select-hover/color-select-hover.component';
18+
import { MarkerComponent } from './marker/marker.component';
1819

1920
const routes: Routes = [
2021
{ path: '', component: ExamplesListComponent },
@@ -33,6 +34,7 @@ const routes: Routes = [
3334
{ path: 'swipe', component: SwipeComponent },
3435
{ path: 'overlay', component: OverlayComponent },
3536
{ path: 'color-select-hover', component: ColorSelectHoverComponent },
37+
{ path: 'marker', component: MarkerComponent },
3638
{ path: 'cluster', component: ClusterComponent },
3739
{ path: 'raster', component: RasterComponent },
3840
],

src/app/example-list.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ export const examplesList = [
6262
routerLink: 'color-select-hover',
6363
openLayersLink: 'https://openlayers.org/en/latest/examples/vector-layer.html',
6464
},
65+
{
66+
title: 'Marker',
67+
description: 'Display marker with svg on specific point',
68+
routerLink: 'marker',
69+
openLayersLink: 'https://openlayers.org/en/latest/examples/icon-color.html',
70+
},
6571
{
6672
title: 'Cluster',
6773
description: 'Example of using aol-source-cluster. This example shows how to do clustering on point features.',

src/app/marker/marker.component.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
//
4+
5+
@Component({
6+
selector: 'app-display-marker',
7+
template: `
8+
<aol-map #map width="100%" height="100%">
9+
<aol-interaction-default></aol-interaction-default>
10+
<aol-control-defaults></aol-control-defaults>
11+
12+
<aol-view [zoom]="12">
13+
<aol-coordinate [x]="-2.269282" [y]="46.987247" [srid]="'EPSG:4326'"></aol-coordinate>
14+
</aol-view>
15+
16+
<aol-layer-tile [opacity]="1">
17+
<aol-source-osm></aol-source-osm>
18+
</aol-layer-tile>
19+
20+
<aol-layer-vector *ngIf="marker">
21+
<aol-source-vector #markers>
22+
<aol-feature>
23+
<aol-geometry-point>
24+
<aol-coordinate [x]="marker.lon" [y]="marker.lat" [srid]="'EPSG:4326'"></aol-coordinate>
25+
</aol-geometry-point>
26+
<aol-style>
27+
<aol-style-icon
28+
[src]="'assets/marker.svg'"
29+
[anchor]="[0.5, 1]"
30+
[anchorXUnits]="'fraction'" [anchorYUnits]="'fraction'"
31+
[scale]="2"
32+
[anchorOrigin]="'top-left'">
33+
</aol-style-icon>
34+
</aol-style>
35+
</aol-feature>
36+
</aol-source-vector>
37+
</aol-layer-vector>
38+
</aol-map>
39+
`,
40+
})
41+
export class MarkerComponent implements OnInit {
42+
constructor() {}
43+
44+
feature = {
45+
type: 'Feature',
46+
properties: {},
47+
geometry: {
48+
type: 'Polygon',
49+
coordinates: [
50+
[
51+
[-2.3565673828124996, 46.92588289494367],
52+
[-2.1148681640624996, 46.92588289494367],
53+
[-2.1148681640624996, 47.04954010021555],
54+
[-2.3565673828124996, 47.04954010021555],
55+
[-2.3565673828124996, 46.92588289494367],
56+
],
57+
],
58+
},
59+
};
60+
61+
marker = {
62+
lon: -2.264184,
63+
lat: 46.996207,
64+
};
65+
66+
ngOnInit() {}
67+
}

src/assets/marker.svg

Lines changed: 4 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)