Skip to content

Commit

Permalink
Merge pull request #370 from yagajs/polygon-example
Browse files Browse the repository at this point in the history
Add an example for the polygon directive
  • Loading branch information
OpenSteveMap committed Mar 30, 2018
2 parents 3a8a8bc + 9243e22 commit 369742d
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ <h4>Vector-Layer</h4>
<li class="list-group-item"><a href="./circle-marker-directive">Circle-Marker-Directive</a></li>
<li class="list-group-item"><a href="./marker-directive">Marker-Directive</a></li>
<li class="list-group-item"><a href="./rectangle-directive">Rectangle-Directive</a></li>
<li class="list-group-item"><a href="./polygon-directive">Polygon-Directive</a></li>
<li class="list-group-item"><a href="./geojson-directive">GeoJSON-Directive</a></li>
</ul>

Expand Down
20 changes: 20 additions & 0 deletions examples/polygon-directive/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>YAGA | leaflet-ng2 | Polygon-Directive Example</title>
<script src="bundle.js"></script>
<link rel="stylesheet" href="../../node_modules/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="../../node_modules/bootstrap/dist/css/bootstrap-theme.min.css" />
<link rel="stylesheet" href="../../node_modules/font-awesome/css/font-awesome.min.css" />
<link rel="stylesheet" href="../../node_modules/leaflet/dist/leaflet.css" />
<link rel="stylesheet" href="../default.css" />
<style>
</style>
</head>
<body>
<app></app>

</body>
</html>
161 changes: 161 additions & 0 deletions examples/polygon-directive/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
// Shims
import 'reflect-metadata';
import 'zone.js';

import { YagaModule } from '../../lib/index'; // @yaga/leflet-ng2

import { Component, PlatformRef } from '@angular/core';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { ExampleAppComponentBlueprint, IExampleProperties } from '../app-component-blueprint';
import { ExamplePropertiesModule, PROPERTIES_WRAPPER } from '../property.component';

const platform: PlatformRef = platformBrowserDynamic();

/* tslint:disable:max-line-length */
const template: string = `
<example-header [title]="'Polygon-Directive'"></example-header>
<div class="container">
<div class="map">
<yaga-map>
<yaga-polygon
(click)="handleEvent('click', $event);"
(dblclick)="handleEvent('dblclick', $event);"
(mousedown)="handleEvent('mousedown', $event);"
(mouseup)="handleEvent('mouseup', $event);"
(mouseover)="handleEvent('mouseover', $event);"
(mouseout)="handleEvent('mouseout', $event);"
(mousemove)="handleEvent('mousemove', $event);"
(contextmenu)="handleEvent('contextmenu', $event);"
(keypress)="handleEvent('keypress', $event);"
(preclick)="handleEvent('preclick', $event);"
[(display)]="getDuplexPropertyByName('display').value"
[(geoJSON)]="getDuplexPropertyByName('geoJSON').value"
[(stroke)]="getDuplexPropertyByName('stroke').value"
[(color)]="getDuplexPropertyByName('color').value"
[(weight)]="getDuplexPropertyByName('weight').value"
[(opacity)]="getDuplexPropertyByName('opacity').value"
[(lineCap)]="getDuplexPropertyByName('lineCap').value"
[(lineJoin)]="getDuplexPropertyByName('lineJoin').value"
[(dashArray)]="getDuplexPropertyByName('dashArray').value"
[(dashOffset)]="getDuplexPropertyByName('dashOffset').value"
[(fill)]="getDuplexPropertyByName('fill').value"
[(fillColor)]="getDuplexPropertyByName('fillColor').value"
[(fillOpacity)]="getDuplexPropertyByName('fillOpacity').value"
[(fillRule)]="getDuplexPropertyByName('fillRule').value"
[(className)]="getDuplexPropertyByName('className').value"
[interactive]="getInputPropertyByName('interactive').value"
[smoothFactor]="getInputPropertyByName('smoothFactor').value"
[noClip]="getInputPropertyByName('noClip').value"
>
<yaga-tooltip>{{ getInputPropertyByName('tooltip directive').value }}</yaga-tooltip>
<yaga-popup>{{ getInputPropertyByName('popup directive').value }}</yaga-popup>
</yaga-polygon>
<yaga-tile-layer [url]="'http://a.tile.openstreetmap.org/{z}/{x}/{y}.png'"></yaga-tile-layer>
</yaga-map>
</div>
${ PROPERTIES_WRAPPER }
</div><!-- /.container -->
<example-footer></example-footer>
`;
/* tslint:enable */

@Component({
selector: 'app',
template,
})
export class AppComponent extends ExampleAppComponentBlueprint {
public properties: IExampleProperties = {
duplex: [
{
name: 'geoJSON',
type: 'geojson',
value: {
geometry: {
coordinates: [
[
[19.335937499999996, 31.353636941500987],
[-3.1640625, 43.32517767999296],
[-22.148437499999996, 11.867350911459308],
[18.984375, -39.09596293630548],
[57.30468749999999, 10.487811882056695],
[41.1328125, 43.58039085560784],
[19.335937499999996, 31.353636941500987],
],
],
type: 'Polygon',
},
},
},
{name: 'display', value: true, type: 'checkbox' },
{name: 'stroke', value: true, type: 'checkbox' },
{name: 'color', value: '#900', type: 'text' },
{name: 'weight', value: 5, type: 'number' },
{name: 'opacity', value: 0.3, type: 'relative'},
{
additional: { states: ['butt', 'round', 'square', 'inherit']},
name: 'lineCap',
type: 'select',
value: 'inherit',
},
{
additional: { states: ['miter', 'round', 'bevel', 'inherit']},
name: 'lineJoin',
type: 'select',
value: 'inherit',
},
{name: 'dashArray', value: '15, 3', type: 'text' },
{name: 'dashOffset', value: '12px', type: 'text' },
{name: 'fill', value: true, type: 'checkbox'},
{name: 'fillColor', value: '#f99', type: 'text' },
{name: 'fillOpacity', value: 0.6, type: 'relative' },
{
additional: { states: ['nonzero', 'evenodd', 'inherit']},
name: 'fillRule',
type: 'select',
value: 'inherit',
},
{name: 'className', value: '', type: 'text' },
// {name: 'tooltipOpened', value: true, type: 'checkbox' },
// {name: 'popupOpened', value: false, type: 'checkbox' }
{name: 'tooltip directive', value: 'Tooltip content', type: 'text' },
{name: 'popup directive', value: 'Popup content', type: 'text' },
],
input: [
{name: 'interactive', value: true, type: 'checkbox' },
{name: 'smoothFactor', value: 10, type: 'number' },
{name: 'noClip', value: true, type: 'checkbox' },
{name: 'tooltip directive', value: 'This is the tooltip content', type: 'text' },
{name: 'popup directive', value: 'This is the popup content', type: 'text' },
],
output: [
{name: 'click', value: '', type: 'event' },
{name: 'dblclick', value: '', type: 'event' },
{name: 'mousedown', value: '', type: 'event' },
{name: 'mouseup', value: '', type: 'event' },
{name: 'mouseover', value: '', type: 'event' },
{name: 'mouseout', value: '', type: 'event' },
{name: 'mousemove', value: '', type: 'event' },
{name: 'contextmenu', value: '', type: 'event' },
{name: 'keypress', value: '', type: 'event' },
{name: 'preclick', value: '', type: 'event' },
],
};
}

/* tslint:disable:max-classes-per-file */
@NgModule({
bootstrap: [ AppComponent ],
declarations: [ AppComponent ],
imports: [ BrowserModule, FormsModule, YagaModule, ExamplePropertiesModule ],
})
export class AppModule { }

document.addEventListener('DOMContentLoaded', () => {
platform.bootstrapModule(AppModule);
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test": "npm run lint && npm run transpile && istanbul cover _mocha -- -- test/*.js",
"browser-test": "npm run transpile; browserify test/index.js -o browser-test/bundle.js",
"doc": "typedoc --out ./typedoc/ --mode file ts/",
"build-examples": "set -x && npm run transpile && cd examples && tsc; browserify rectangle-directive/index.js -o rectangle-directive/bundle.js && browserify tooltip-directive/index.js -o tooltip-directive/bundle.js && browserify popup-directive/index.js -o popup-directive/bundle.js && browserify geojson-directive/index.js -o geojson-directive/bundle.js && browserify tile-layer-directive/index.js -o tile-layer-directive/bundle.js && browserify wms-layer-directive/index.js -o wms-layer-directive/bundle.js && browserify map-component/index.js -o map-component/bundle.js && browserify zoom-control-directive/index.js -o zoom-control-directive/bundle.js && browserify layers-control-directive/index.js -o layers-control-directive/bundle.js && browserify scale-control-directive/index.js -o scale-control-directive/bundle.js && browserify attribution-control-directive/index.js -o attribution-control-directive/bundle.js && browserify circle-marker-directive/index.js -o circle-marker-directive/bundle.js && browserify image-overlay-directive/index.js -o image-overlay-directive/bundle.js && browserify icon-directive/index.js -o icon-directive/bundle.js && browserify div-icon-directive/index.js -o div-icon-directive/bundle.js && browserify passau/index.js -o passau/bundle.js && browserify circle-directive/index.js -o circle-directive/bundle.js && browserify marker-directive/index.js -o marker-directive/bundle.js && browserify floor-plan/index.js -o floor-plan/bundle.js"
"build-examples": "set -x && npm run transpile && cd examples && tsc; browserify polygon-directive/index.js -o polygon-directive/bundle.js && browserify rectangle-directive/index.js -o rectangle-directive/bundle.js && browserify tooltip-directive/index.js -o tooltip-directive/bundle.js && browserify popup-directive/index.js -o popup-directive/bundle.js && browserify geojson-directive/index.js -o geojson-directive/bundle.js && browserify tile-layer-directive/index.js -o tile-layer-directive/bundle.js && browserify wms-layer-directive/index.js -o wms-layer-directive/bundle.js && browserify map-component/index.js -o map-component/bundle.js && browserify zoom-control-directive/index.js -o zoom-control-directive/bundle.js && browserify layers-control-directive/index.js -o layers-control-directive/bundle.js && browserify scale-control-directive/index.js -o scale-control-directive/bundle.js && browserify attribution-control-directive/index.js -o attribution-control-directive/bundle.js && browserify circle-marker-directive/index.js -o circle-marker-directive/bundle.js && browserify image-overlay-directive/index.js -o image-overlay-directive/bundle.js && browserify icon-directive/index.js -o icon-directive/bundle.js && browserify div-icon-directive/index.js -o div-icon-directive/bundle.js && browserify passau/index.js -o passau/bundle.js && browserify circle-directive/index.js -o circle-directive/bundle.js && browserify marker-directive/index.js -o marker-directive/bundle.js && browserify floor-plan/index.js -o floor-plan/bundle.js"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 369742d

Please sign in to comment.