<!DOCTYPE html>
<html>
<head>
<title>Angular 2.0.0 + TypeScript Starter Kit</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link data-require="bootstrap-css@*" data-semver="4.0.0-alpha.4" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.4/css/bootstrap.min.css" />
<script src="https://unpkg.com/zone.js@0.6.21/dist/zone.js"></script>
<script src="https://unpkg.com/reflect-metadata@0.1.9/Reflect.js"></script>
<script src="https://unpkg.com/systemjs@0.19.41/dist/system.js"></script>
<script src="https://unpkg.com/typescript@2.1.4/lib/typescript.js"></script>
<script src="config.js"></script>
<script>
System.import('app')
.catch(console.error.bind(console));
</script>
</head>
<body>
<my-app>
loading...
</my-app>
</body>
</html>
# Angular 2.0.0 + TypeScript Plunker Starter Kit
I couldn't find this elsewhere, so I created one.
This is a simple Angular 2.0.0 (final) + TypeScript plunker. Fork it.
System.config({
transpiler: 'typescript',
typescriptOptions: {
emitDecoratorMetadata: true
},
map: {
app: "./src",
'@angular/core': 'npm:@angular/core@2.4.1/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common@2.4.1/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler@2.4.1/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser@2.4.1/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic@2.4.1/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http@2.4.1/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router@3.4.1/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms@2.4.1/bundles/forms.umd.js',
'@angular/core/testing': 'npm:@angular/core@2.4.1/bundles/core-testing.umd.js',
'@angular/common/testing': 'npm:@angular/common/bundles@2.4.1/common-testing.umd.js',
'@angular/compiler/testing': 'npm:@angular/compiler@2.4.1/bundles/compiler-testing.umd.js',
'@angular/platform-browser/testing': 'npm:@angular/platform-browser@2.4.1/bundles/platform-browser-testing.umd.js',
'@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic@2.4.1/bundles/platform-browser-dynamic-testing.umd.js',
'@angular/http/testing': 'npm:@angular/http@2.4.1/bundles/http-testing.umd.js',
'@angular/router/testing': 'npm:@angular/router@2.4.1/bundles/router-testing.umd.js',
'rxjs': 'npm:rxjs',
'@agm/core': 'npm:@agm/core/core.umd.js'
},
//packages defines our app package
packages: {
app: {
main: './main.ts',
defaultExtension: 'ts'
},
rxjs: {
defaultExtension: 'js'
}
},
paths: {
'npm:': 'https://unpkg.com/'
}
});
//main entry point
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app';
platformBrowserDynamic().bootstrapModule(AppModule)
import { Component, ElementRef, NgModule, NgZone, OnInit, ViewChild } from '@angular/core';
import { FormControl, FormsModule, ReactiveFormsModule } from "@angular/forms";
import { BrowserModule } from "@angular/platform-browser";
import { AgmCoreModule, MapsAPILoader } from '@agm/core';
@Component({
selector: 'my-app',
styles: [`
agm-map {
height: 300px;
}
`],
template: `
<div class="container">
<h1>Angular 2 + Google Maps polyline </h1>
<agm-map [latitude]="latitude" [longitude]="longitude" [scrollwheel]="false" [zoom]="zoom">
<ng-container>
<agm-polyline *ngFor="let point of polyline;let i = index;" [strokeColor]="point.speed < 50 ? '#2196f3': 'red'">
<agm-polyline-point [latitude]="point.latitude" [longitude]="point.longitude">
</agm-polyline-point>
<ng-container *ngIf="polyline[i+1]">
<agm-polyline-point [latitude]="polyline[i+1].latitude" [longitude]="polyline[i+1].longitude">
</agm-polyline-point>
</ng-container>
</agm-polyline>
</ng-container>
</agm-map>
</div>
`
})
export class App implements OnInit {
public latitude: number;
public longitude: number;
public maxSpeed: number;
public zoom: number;
public polyline: Array<any>;
constructor(
private mapsAPILoader: MapsAPILoader,
private ngZone: NgZone
) {}
ngOnInit() {
//set google maps defaults
this.zoom = 3;
this.maxSpeed = 40;
this.latitude = 21.291;
this.longitude = -122.214;
this.polyline = [
{
latitude: 39.8282,
longitude: -98.5795,
speed: 50
},
{
latitude: 37.772,
longitude: -122.214,
speed: 20
},
{
latitude: 21.291,
longitude: -157.821,
speed: 50
},
{
latitude: -18.142,
longitude: 178.431,
speed: 20
},
{
latitude: -27.467,
longitude: 153.027,
speed: 55
}
]
//set current position
this.setCurrentPosition();
//load Places Autocomplete
this.mapsAPILoader.load().then(() => {
});
}
private setCurrentPosition() {
if ("geolocation" in navigator) {
navigator.geolocation.getCurrentPosition((position) => {
this.latitude = position.coords.latitude;
this.longitude = position.coords.longitude;
this.zoom = 12;
});
}
}
}
@NgModule({
imports: [
AgmCoreModule.forRoot({
libraries: ["places"]
}),
BrowserModule,
FormsModule,
ReactiveFormsModule
],
declarations: [ App ],
bootstrap: [ App ]
})
export class AppModule {}