I have following problem. My webpack is bundling files from node_modules. How can I prevent him from doing that? He is doing that, because i import files from node_modules in main.ts, but i have to do this. What am i doing wrong?
main.ts
import { NgModule } from '#angular/core';
import { platformBrowserDynamic } from '#angular/platform-browser-dynamic';
import { BrowserModule } from '#angular/platform-browser';
import { AppComponent } from './app/app.component';
#NgModule({
imports: [ BrowserModule ],
exports: [],
declarations: [AppComponent],
providers: [],
})
export class AppModule { }
platformBrowserDynamic().bootstrapModule(AppModule);
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es2015", "dom"],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
webpack.config.json
var webpack = require('webpack');
module.exports = {
entry : __dirname + '/src/main.ts',
output: {
path: __dirname + '/dist',
filename: 'app.bundle.js'
},
module: {
rules: [
{
test: /\.ts$/,
loader: 'ts-loader'
}
]
},
resolve: {
extensions: ['.js','.ts']
}
};
package.json
{
"name": "angular2",
"version": "1.0.0",
"scripts": {
"start": "webpack --progress"
},
"dependencies": {
"#angular/common": "~2.4.0",
"#angular/compiler": "~2.4.0",
"#angular/core": "~2.4.0",
"#angular/forms": "~2.4.0",
"#angular/http": "~2.4.0",
"#angular/platform-browser": "~2.4.0",
"#angular/platform-browser-dynamic": "~2.4.0",
"#angular/router": "~3.4.0",
"core-js": "^2.4.1",
"rxjs": "5.0.1",
"zone.js": "^0.7.4"
},
"devDependencies": {
"ts-loader": "^2.0.2",
"typescript": "^2.2.1",
"typings": "^2.1.0",
"webpack": "^2.3.0"
}
}
Test for .js files and exclude node modules in your loaders, example for using javascript(react) with babel-loader:
{
test: /.js?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: [
'es2015', 'react', 'stage-0',
],
}
},
In your main.js file you can just do import Module from 'module' where 'module' is the name of your component. Webpack will bundle it if you refer to it like that.
Example if I want to include React: import React from 'react' - no relative paths needed.
Related
I am having problems to setup karma with Angular 5.2.0 (without Cli)
The Angular application is working, but the problem is with karma, when I try to run the test i get this ERROR:
karma start
Hash: ccc4545dd1d9416a823b
Version: webpack 3.10.0
Time: 58ms
webpack: Compiled successfully.
13 01 2018 15:34:59.123:WARN [karma]: No captured browser, open http://localhost:9876/
13 01 2018 15:34:59.134:INFO [karma]: Karma v2.0.0 server started at http://0.0.0.0:9876/
13 01 2018 15:34:59.136:INFO [launcher]: Launching browser Chrome with unlimited concurrency
13 01 2018 15:34:59.147:INFO [launcher]: Starting browser Chrome
13 01 2018 15:35:00.726:INFO [Chrome 63.0.3239 (Windows 10 0.0.0)]: Connected on socket 37NRWsbdgw5x2CTBAAAA with id 42149942
Chrome 63.0.3239 (Windows 10 0.0.0) ERROR
{
"message": "Uncaught SyntaxError: Unexpected token {\nat src/app/app.component.spec.ts:2:8\n\nSyntaxError: Unexpected token {",
"str": "Uncaught SyntaxError: Unexpected token {\nat src/app/app.component.spec.ts:2:8\n\nSyntaxError: Unexpected token {"
}
First I got that ERROR with video/mp2t so I added the MIME fix. And now I got the above ERROR. It seems that karma is not resolving the TS or something, because I have tested the .spec.ts file with just one import and still get the same error.
app.component.spec.ts
import { TestBed, async } from '#angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
}).compileComponents();
}));
it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it('should display the header text "Welcome to Momentz4Ever"', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to Momentz4Ever');
}));
});
tsconfig.ts
{
"compileOnSave": false,
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": false,
"sourceMap": true,
"baseUrl": "src",
"outDir": "./dist",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"typeRoots": [
"node_modules/#types"
],
"lib": [
"es2016",
"dom"
],
"types": [
"node",
"jasmine"
]
},
"awesomeTypeScriptLoaderOptions": {
"useWebpackText": true
}
}
webpack.config.ts
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { ContextReplacementPlugin } = require('webpack');
module.exports = {
entry: {
main: './src/index.ts'
},
output: {
path: path.join(__dirname, "../dist/"),
filename: "[name].bundle.js",
},
resolve: {
extensions: ['.js', '.ts', '.html']
},
devServer: {
contentBase: path.join(__dirname, "../dist/"),
port: 9000
},
devtool: 'inline-source-map',
module: {
loaders: [
{ test: /.ts$/, use: ['awesome-typescript-loader', 'angular2-template-loader'] },
{ test: /.html$/, use: 'raw-loader' }
]
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/index.html",
filename: "index.html",
showErrors: true,
title: "Webpack App",
path: path.join(__dirname, "../dist/"),
hash: true
}),
new ContextReplacementPlugin(
/\#angular(\\|\/)core(\\|\/)esm5/,
path.resolve(__dirname, 'src')
)
]
}
karma.conf.ts
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
files: [
{ pattern: './src/app/app.component.spec.ts' }
],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-webpack'),
require('karma-sourcemap-loader'),
],
preprocessors: {
'./src/test.ts': ['webpack', 'sourcemap']
},
mime: {
'text/x-typescript': ['ts','tsx']
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
concurrency: Infinity
})
}
package.json
{
"name": "",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "karma start",
"build": "webpack-dev-server --config webpack.config.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"#angular/common": "^5.2.0",
"#angular/compiler": "^5.2.0",
"#angular/core": "^5.2.0",
"#angular/forms": "^5.2.0",
"#angular/http": "^5.2.0",
"#angular/platform-browser": "^5.2.0",
"#angular/platform-browser-dynamic": "^5.2.0",
"#angular/router": "^5.2.0",
"core-js": "^2.5.3",
"rxjs": "^5.5.6",
"zone.js": "^0.8.20"
},
"devDependencies": {
"#types/jasmine": "^2.8.4",
"#types/node": "^9.3.0",
"angular2-template-loader": "^0.6.2",
"awesome-typescript-loader": "^3.4.1",
"css-loader": "^0.28.8",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.6",
"html-webpack-plugin": "^2.30.1",
"jasmine": "^2.8.0",
"jasmine-core": "^2.8.0",
"karma": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.1.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-typescript": "^3.0.9",
"karma-webpack": "^2.0.9",
"node-sass": "^4.7.2",
"raw-loader": "^0.5.1",
"sass-loader": "^6.0.6",
"style-loader": "^0.19.1",
"ts-loader": "^3.2.0",
"tslint": "^5.9.1",
"typescript": "^2.6.2",
"url-loader": "^0.6.2",
"webpack": "^3.10.0",
"webpack-dev-server": "^2.10.1"
}
}
I'm coding a Typescript application. In This application I'ld read some json file with the function d3.json, but the code doesn't work. The error is this:
SyntaxError: Unexpected token T in JSON at position 0
at JSON.parse ()
at Object. (d3-request.node.js:176)
at respond (d3-request.node.js:39)
at exports.XMLHttpRequest.onload.xhr.onreadystatechange (d3-request.node.js:30)
at exports.XMLHttpRequest.dispatchEvent (XMLHttpRequest.js:591)
at setState (XMLHttpRequest.js:610)
at exports.XMLHttpRequest.handleError (XMLHttpRequest.js:532)
at module.exports.errorHandler (XMLHttpRequest.js:459)
at module.exports.EventEmitter.emit (events.js:81)
at request.js:142
The code is this:
export async function setSelectConfiguration(
filenameJson: string, storeData: (str: string) => void, element: JQuery,
listenerFunction:(e: JQueryEventObject) => void) {
await d3.json("filename2.json", function(error, data) {
if(error) {
console.log(error);
} else {
console.log(data);
storeData(data.toString())
}
});
element.on("change", listenerFunction);
}
The json is this:
{
"files": [
{
"name": "time_sensitive_test.json",
"type": "user",
"owner": "Master",
"data_type": "linear data",
"description": "Utenti master (Enrica) periodo 20/05/2014-16/10/2014",
"ids_description": "accesso risorse",
"ods_description": "chat/forum",
"bds_description": "login/logout"
}
]}
the gulpfile.js:
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var tsify = require('tsify');
var sourcemaps = require('gulp-sourcemaps');
var buffer = require('vinyl-buffer');
var paths = {
pages: ['src/*.html']
};
gulp.task('copyHtml', function () {
return gulp.src(paths.pages)
.pipe(gulp.dest('dist'));
});
gulp.task('default', ['copyHtml'], function () {
return browserify({
basedir: '.',
debug: true,
entries: ['src/main.ts'],
cache: {},
packageCache: {}
})
.plugin(tsify)
.transform('babelify', {
presets: ['env','stage-0'],
extensions: ['.ts'],
plugins: ['transform-runtime','transform-async-to-generator']
})
.bundle()
.pipe(source('project.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'));
});
the package.json:
{
"name": "project",
"version": "1.0.0",
"description": " Project",
"main": "./dist/project.js",
"directories": {
"example": "example"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": " ... "
},
"author": " ",
"license": "ISC",
"bugs": {
"url": "... "
},
"homepage": "...",
"devDependencies": {
"#types/d3": "^4.10.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-0": "^6.24.1",
"babelify": "^8.0.0",
"browserify": "^14.5.0",
"gulp": "^3.9.1",
"gulp-sourcemaps": "^2.6.3",
"gulp-typescript": "^3.2.3",
"gulp-uglify": "^3.0.0",
"gulp-util": "^3.0.8",
"tsify": "^3.0.4",
"typescript": "^2.6.2",
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0",
"watchify": "^3.9.0"
},
"dependencies": {
"#types/node": "^8.5.7",
"babel-polyfill": "^6.26.0",
"babel-runtime": "^6.26.0",
"d3": "^4.12.2",
"webpack": "^3.10.0"
}
}
the tsconfig.json:
{
"files": [
...
],
"compilerOptions": {
"module": "commonjs",
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"noImplicitAny": true,
"target": "es2015",
"lib": ["es2015", "es2016", "dom", "es2017", "es6", "es5"],
"experimentalAsyncFunctions": true,
"typeRoots": [
"./node_modules/#types"
]
},
"exclude": [
"node_modules",
"dist"
]
}
the webpack.config.json:
module.exports = {
context: __dirname + '/src',
entry: ['babel-polyfill', './main.ts'],
output: {
path: 'dist',
filename: 'project.js'
},
module: {
loaders: [
{
test: /\.js/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015']
}
}
]
}
};
I ran the code compiled outside the IDE, but the error appeared equally; so it should not be some strange fault of the IDE.
I've tried to read the file with in a pure javascript app and all works fine; so the problem is not to be found in the files.
What could be the problem? for example: does it need any special modules or configurations?
I have a React project with SASS using Webpack, my project compiles successfully, but does not represent the CSS effect in the HTML page in the browser. I compile it with webpack-dev-server command.
I have the following webpack.config.js:
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: {
main: './src/scripts/main.js'
},
output: {
filename: './dist/scripts/[name].js'
},
devtool: 'source-map',
module: {
loaders: [{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015']
}
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('css-loader!sass-loader')
}
]
},
plugins: [
new ExtractTextPlugin('dist/styles/main.css', {
allChunks: true
})
]
}
and following main.js:
import React from 'react';
import ReactDOM from 'react-dom';
import style from '../styles/main.scss';
ReactDOM.render(<h1 class="title">Hello World</h1>, document.getElementById('example'));
main.scss:
.example {
h1 {
color: green;
}
}
and this is the devDependcies section:
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.5",
"extract-text-webpack-plugin": "^3.0.0",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-hot-loader": "^1.3.1",
"sass-loader": "^6.0.6",
"style-loader": "^0.18.2",
"webpack": "^3.1.0",
"webpack-dev-server": "^2.7.1"
}
I want focus to be set on my <ion-input> as I enter the page
This is my typescript code:
import { Component, Input, ViewChild,ElementRef,Renderer } from '#angular/core';
import { NavController, PopoverController, NavParams, ViewController, ModalController } from 'ionic-angular';
#Component({
selector: 'page-comments',
templateUrl: 'comments.html'
})
export class CommentsParentPage {
#ViewChild('input') myInput;
constructor(public navCtrl: NavController,private renderer: Renderer,
private elementRef: ElementRef, public modalCtrl: ModalController) {
}
ionViewLoaded() {
setTimeout(() => {
let element = this.elementRef.nativeElement.querySelector('input');
this.renderer.invokeElementMethod(element, 'focus', []);
},150);
}
}
And this is what i have done with my html file:
<ion-item>
<ion-input set-focuser type="text" placeholder="Write Your Comments" [(ngModel)]="addComment"></ion-input>
</ion-item>
Whenever I enter this page of my application, I would like the keyboard to be opened and focus to be set on ion-input
My config.xml includes:
<preference name="KeyboardDisplayRequiresUserAction" value="false" />
package.json
{
"name": "sample app",
"author": "",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"#angular/common": "2.2.1",
"#angular/compiler": "2.2.1",
"#angular/compiler-cli": "2.2.1",
"#angular/core": "2.2.1",
"#angular/forms": "2.2.1",
"#angular/http": "2.2.1",
"#angular/platform-browser": "2.2.1",
"#angular/platform-browser-dynamic": "2.2.1",
"#angular/platform-server": "2.2.1",
"#ionic-native/core": "^3.4.4",
"#ionic-native/keyboard": "^3.4.4",
"#ionic/cloud-angular": "^0.10.0",
"#ionic/storage": "1.1.7",
"angular2-moment": "^1.1.0",
"google-libphonenumber": "^2.0.14",
"ionic-angular": "2.0.0-rc.4",
"ionic-gallery-modal": "0.0.7",
"ionic-native": "2.2.11",
"ionicons": "3.0.0",
"rxjs": "5.0.0-beta.12",
"zone.js": "0.6.26"
},
"devDependencies": {
"#ionic/app-scripts": "1.0.0",
"typescript": "2.0.9"
},
"cordovaPlugins": [
"ionic-plugin-keyboard",
"cordova-plugin-whitelist",
"cordova-plugin-console",
"cordova-plugin-statusbar",
"cordova-plugin-device",
"cordova-plugin-splashscreen",
"cordova-sqlite-storage",
"cordova-plugin-x-toast",
"cordova-plugin-camera",
"cordova-plugin-compat",
"cordova-plugin-image-picker",
"cordova.plugins.diagnostic",
{
"id": "phonegap-plugin-push",
"locator": "phonegap-plugin-push",
"variables": {
"SENDER_ID": "461076790064"
}
},
"cordova-plugin-contacts",
"ionic-plugin-deploy",
"cordova-plugin-x-socialsharing",
{
"locator": "https://github.com/napolitano/cordova-plugin-intent",
"id": "com.napolitano.cordova.plugin.intent"
},
"cordova-plugin-screen-orientation",
"cordova-plugin-file",
"cordova-plugin-file-transfer"
],
"cordovaPlatforms": [
{
"platform": "android",
"version": "",
"locator": "android"
}
],
"description": "ionic2: An Ionic project"
}
use ngAfterViewChecked:
See plnkr here
import { Component, Input, ViewChild,ElementRef,Renderer, AfterViewChecked,ChangeDetectorRef } from '#angular/core';
import { NavController, PopoverController, NavParams, ViewController, ModalController } from 'ionic-angular';
#Component({
selector: 'page-comments',
templateUrl: 'comments.html'
})
export class CommentsParentPage implements AfterViewChecked {
#ViewChild('input') myInput;
needsFocus: boolean;
constructor(public navCtrl: NavController,private renderer: Renderer,
private elementRef: ElementRef, public modalCtrl: ModalController,
private _changeDetectionRef: ChangeDetectorRef) {
}
ionViewDidEnter() {
this.needsFocus = true;
}
public ngAfterViewChecked(): void {
if (this.needsFocus) {
this.needsFocus = false;
this.myInput.setFocus();
this._changeDetectionRef.detectChanges();
}
}
You can do it using Directive as shown below.Hope code is self-explanatory.If you have any issue please comment below.
Play with Git Repo code.
You can View this on Ionic View: Id = F5F367AE
Note: Just tap My Page.
set-focuser.ts
import { Directive, Renderer, ElementRef } from '#angular/core';
import { Keyboard } from '#ionic-native/keyboard';
#Directive({
selector: '[set-focuser]' // Attribute selector
})
export class SetFocuser {
constructor(private renderer: Renderer, private elementRef: ElementRef, public keyboard: Keyboard) {
}
ngAfterViewInit() {
const element = this.elementRef.nativeElement.querySelector('input');
// to delay
setTimeout(() => {
this.renderer.invokeElementMethod(element, 'focus', []);
this.keyboard.show();
}, 500);
}
}
.html
<ion-input set-focuser type="text"></ion-input>
app.module.ts
import { SetFocuser } from "../components/set-focuser/set-focuser";
#NgModule({
declarations: [
SetFocuser,
],
Issues on your package.json
You have to remove "ionic-native": "2.2.11", module.
Use "#ionic/app-scripts": "1.1.4", instead of "#ionic/app-scripts": "1.0.0",
After the above changes run npm i
This is the official package.json file.
I know this is an old topic, but I faced a similar issue (in my case there was an error: 'setFocus is not a function'. My solution may help someone in the future (Ionic v5).
In this case I generated a component instead of a page, so I didn't have a module.ts file for the component. I had to add the component to the parent page's declarations.
declarations: [
MyModalComponent
]
Then in the component's typescript file, added the following lines and it worked as intended:
#ViewChild('myInputsReference', {static: false}) inputEl: IonInput;
ionViewDidEnter() {
this.setFocusOnInput();
}
setFocusOnInput() {
setTimeout(_ => { this.inputEl.setFocus()}, 200);
}
You can try simple method.
<div ng-init="getfocus()">
<ion-input id="myAnchor" type="text" placeholder="Write Your Comments"/>
</div>
In js file call a function with ng-init
function getfocus() {
document.getElementById("myAnchor").focus();
}
Hope this code will help you.if you get any error please comment.
The problem is that I don't see any map and the error appears when subscribe runs. Does anyone know how to help me?
I tryied some ways btu they don't work
google-maps-into-ionic-2 or google maps from ionic native
Html:
<button (click)="getMapresults()"></button>
<ion-content>
<div id="mapid"></div>
</ion-content>
Trypescript:
import {Component, ViewChild, OnInit, NgZone} from '#angular/core';
import {NavController, Platform} from 'ionic-angular';
import {
Geolocation, GoogleMap, GoogleMapsEvent, GoogleMapsMarker, GoogleMapsMarkerOptions,
CameraPosition, GoogleMapsLatLng
} from "ionic-native";
import {Observable} from "rxjs/Rx";
private gMap: GoogleMap;
location: {lat: number, lng: number};
constructor(public navCtrl: NavController,
public platform:Platform
) {}
getMapresults() {
this.platform.ready().then(()=>{
console.log('Platform ready!');
this.gMap = new GoogleMap('mapid');
this.gMap.on(GoogleMapsEvent.MAP_READY)
.subscribe(()=>{
console.log('Map!');
});
}
Error:
Uncaught (in promise): [object Object]
package.json:
{
"name": "ionic-hello-world",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"#angular/common": "^2.1.1",
"#angular/compiler": "^2.1.1",
"#angular/compiler-cli": "2.1.1",
"#angular/core": "^2.1.1",
"#angular/forms": "2.1.1",
"#angular/http": "2.1.1",
"#angular/platform-browser": "^2.1.1",
"#angular/platform-browser-dynamic": "^2.1.1",
"#angular/platform-server": "^2.1.1",
"#ionic/storage": "1.1.6",
"angular2-google-maps": "^0.16.0",
"ionic-angular": "2.0.0-rc.3",
"ionic-native": "2.2.3",
"ionicons": "3.0.0",
"rxjs": "5.0.0-beta.12",
"zone.js": "0.6.26"
},
"devDependencies": {
"#ionic/app-scripts": "0.0.45",
"typescript": "2.0.6"
},
"cordovaPlugins": [
"cordova-plugin-whitelist",
"cordova-plugin-console",
"cordova-plugin-statusbar",
"cordova-plugin-device",
"cordova-plugin-splashscreen",
"ionic-plugin-keyboard"
],
"cordovaPlatforms": [
"ios",
{
"platform": "ios",
"version": "",
"locator": "ios"
}
],
"description": "firstMobApp: An Ionic project"
}
There are few problems in your code. You need to send some parameters to Google map API in order to load google maps.
import { Component } from '#angular/core';
import { NavController, Platform } from 'ionic-angular';
import { GoogleMap, GoogleMapsEvent, GoogleMapsLatLng } from 'ionic-native';
#Component({
selector: 'home-page',
templateUrl: 'home.html'
})
export class HomePage {
map: GoogleMap;
constructor(public navCtrl: NavController, public platform: Platform) {
platform.ready().then(() => {
this.loadMap();
});
}
loadMap(){
let location = new GoogleMapsLatLng(-34.9290,138.6010);
this.map = new GoogleMap('map', {
'backgroundColor': 'white',
'controls': {
'compass': true,
'myLocationButton': true,
'indoorPicker': true,
'zoom': true
},
'gestures': {
'scroll': true,
'tilt': true,
'rotate': true,
'zoom': true
},
'camera': {
'latLng': location,
'tilt': 30,
'zoom': 15,
'bearing': 50
}
});
this.map.on(GoogleMapsEvent.MAP_READY).subscribe(() => {
console.log('Map is ready!');
});
}
}