Git Product home page Git Product logo

ngx-openlayers's Introduction

ngx-openlayers Build StatusJoin the chat at https://gitter.im/ngx-openlayers

Installation

To install this library, run:

npm install ngx-openlayers --save

Example

Here is a "minimal" map example that fetches tiles from OpenStreetMap and center the map in Meylan (France):

in app.module.ts:

...
import { AngularOpenlayersModule } from "ngx-openlayers";
...

@NgModule({
  imports: [
    ...
    AngularOpenlayersModule
  ],
  ...
  bootstrap: [AppComponent]
})
export class AppModule { }

in app.component.html:

<aol-map [width]="'500px'" [height]="'300'">
    <aol-view [zoom]="2">
        <aol-coordinate [x]="5.795122" [y]="45.210225" [srid]="'EPSG:4326'"></aol-coordinate>
    </aol-view>
    <aol-layer-tile>
        <aol-source-osm></aol-source-osm>
    </aol-layer-tile>
</aol-map>

Documentation

The API is documented in documentation

Getting Help

Join us at our Gitter: https://gitter.im/ngx-openlayers

Development

To generate all *.js, *.js.map and *.d.ts files:

npm run ngc

To lint all *.ts files:

npm run lint

Live example (reload on code changes):

npm install -g @angular/cli
cd example
npm install
ng serve

Live example will be viewable at locahost:4200

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request and enjoy! :D

License

MPL-2.0 - Quentin Lampin [email protected] Copyright 2017 Orange

ngx-openlayers's People

Contributors

achimha avatar alienlike avatar aymeric-duchein avatar billfarmakis avatar davinkevin avatar fallenritemonk avatar fttriquet avatar gasperiguillaume avatar greggguru avatar gueuze avatar harelm avatar karomamczi avatar kekel87 avatar lautarobock avatar lmalorgio avatar neonox31 avatar quentin-ol avatar quentinlampin avatar tohruokamoto avatar yakoust avatar ymazzoleni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngx-openlayers's Issues

Missing features

I cant find the way to move the map with the mouse and to zoom in/out dragging mouse wheel.
Are these features availables?

Thanks

bing source

Just wanted to ask if the bing source works for you, as I'm trying to do something similar to what you are doing there with the key string.
But I always get the error: error_handler.js:53Error: No provider for String!
and leaving it away and passing this.key to the super constructor results in an error about not being able to call this before calling the super constructor, which is totally clear.
So if it works for you, please let me know what I'm doing wrong so that i can fix it.

Thanks

Changing Map Co-ordinates

Hello
I was trying to dynamically load lon and lat from two input boxes and draw the map on a div. However with default values I could draw the map. But when I change the input box values the map does not center to the new lon lat values. Due to lack of any good example I am struggling to achieve this. Could you please show us any example. I have gone through the example in the code.

Thanks
Giridhar

Build fail with angular-cli 1.0

I have no problem with angular-cli@beta, but after update to 1.0 I cant bui;d.
Here a repo with a project that reproduce
https://github.com/lautarobock/angular2-openlayers-bug

$ git clone https://github.com/lautarobock/angular2-openlayers-bug.git
$ cd angular2-openlayers-bug
$ npm install
$ ng build

ERROR in C:/Dev/WebDocuments/Field/testWithMap/node_modules/angular2-openlayers/dist/components/map.component.d.ts (1,1): Cannot find type definition file for 'openlayers'.

ERROR in C:/Dev/WebDocuments/Field/testWithMap/node_modules/angular2-openlayers/dist/components/controls/attribution.component.d.ts (1,1): Cannot find type definition file for 'openlayers'.

and more, please see in https://github.com/lautarobock/angular2-openlayers-bug/blob/master/README.md

Exit Full screen keeps map view expanded

Hello. I am using this code, full screen works but when you exit full screen the map div expands and take more space than it used to be before full screen

 <aol-map>
      <aol-view [zoom]="5">
        <aol-coordinate [x]="11.64772" [y]="48.08834" [srid]="'EPSG:4326'"></aol-coordinate>
      </aol-view>
      <aol-interaction-pinchzoom></aol-interaction-pinchzoom><aol-control-zoom></aol-control-zoom>
      <aol-control-fullscreen></aol-control-fullscreen>

      <aol-layer-tile>
        <aol-source-osm></aol-source-osm>
      </aol-layer-tile>
    </aol-map>

No provider for SourceVectorComponent

When i try implementing this code

<aol-map [width]="'100%'">
    <aol-view [zoom]="4.98">
       <aol-coordinate [x]="118.015776" [y]="-2.600029" [srid]="'EPSG:4326'"></aol-coordinate>
    </aol-view>

    <aol-layer-tile>
        <aol-source-osm></aol-source-osm>
    </aol-layer-tile>

    <aol-feature>
        <aol-geometry-point>
            <aol-coordinate [x]="5" [y]="45" [srid]="'EPSG:4326'"></aol-coordinate>
        </aol-geometry-point>
        <aol-style>
            <aol-style-circle [radius]="10">
                <aol-style-stroke [color]="'black'" [width]="2"></aol-style-stroke>
                <aol-style-fill [color]="'green'"></aol-style-fill>
            </aol-style-circle>
        </aol-style>
    </aol-feature>

</aol-map>

i've got this error

No provider for SourceVectorComponent!

Can you guys help me about it?

Thanks

Animation support

This is just one of my ideas, but I think we could discuss about it.

I thought about creating a animation class with all the required inputs that then could be passes to a view in one of the following ways (we could choose one or implement even both):

  • have a default animation as input on a view, which is used used once the x and/or y input change (mainly for re centering the view)
  • have a general animation input on a view (single animation or array) which are fired on change. Not sure if there isn't a better way to achieve something like this, but currently its the only way I can think of.

I personally think the second one should be implemented for sure (maybe not exactly as described but in some way) because it would give a wide range of ways to use (also for re centering the map). The first is not really needed, but would give a easier way to recenter the map without having the create an animation every time.

I'd be pleased to create a PR for this,
so let me know what you think.

Error when upgrading to @angular/cli rc.4

I tried updating my project to cli's rc.4 bet I get the following errors:

ERROR in <PROJECT_PATH>/node_modules/angular2-openlayers/dist/components/map.component.d.ts (3,91): Cannot find module 'openlayers'.)
<PROJECT_PATH>/node_modules/angular2-openlayers/dist/components/map.component.d.ts (1,1): Cannot find type definition file for 'openlayers'.)

ERROR in <PROJECT_PATH>/node_modules/angular2-openlayers/dist/components/controls/attribution.component.d.ts (3,25): Cannot find module 'openlayers'.)
<PROJECT_PATH>/node_modules/angular2-openlayers/dist/components/controls/attribution.component.d.ts (1,1): Cannot find type definition file for 'openlayers'.)
...

This continues for all the modules of the lib I use.
Installing openlayer types (npm install --save-dev @types/openlayers) results in the following error:

ERROR in <PROJECT_PATH>/src/app/challenge/components/world/world.component.ts (111,30): Property 'getId' does not exist on type 'Feature | Feature'.)

no matter if I install version 4.0.1 or 3.20.5.

Reverting to rc.2 (there was no rc.3) fixes the problem!
Any ideas what could be the problem here?

Double viewport issue

Having the following map on my site:

<aol-map id="map">
          <aol-view [zoom]="15">
            <aol-coordinate [x]="location.gpsLong" [y]="location.gpsLat" [srid]="'EPSG:4326'"></aol-coordinate>
          </aol-view>
          <aol-control-zoom></aol-control-zoom>
          <aol-control-scaleline></aol-control-scaleline>
          <aol-control-attribution [collapsible]="false"></aol-control-attribution>
          <aol-interaction-default></aol-interaction-default>
          <aol-layer-tile>
            <aol-source-osm></aol-source-osm>
          </aol-layer-tile>
          <aol-layer-vector>
            <aol-source-vector>
              <aol-feature>
                <aol-geometry-point>
                  <aol-coordinate [x]="location.gpsLong" [y]="location.gpsLat" [srid]="'EPSG:4326'"></aol-coordinate>
                </aol-geometry-point>
                <aol-style>
                  <aol-style-icon [src]="'assets/imgs/flag.svg'" [anchor]="[0, 0]" [scale]="0.3" [anchorOrigin]="'bottom-left'" [imgSize]="[81, 81]">
                  </aol-style-icon>
                </aol-style>
              </aol-feature>
            </aol-source-vector>
          </aol-layer-vector>
        </aol-map>

I have the situation that upon a fresh load of the site everything is perfectly fine, only if I then navigate to a different page and then go back, my map has two view ports:

<aol-map>
    <div style="width: 100%; height: 100%;">
        <div class="ol-viewport" style="position: relative; overflow: hidden; width: 100%; height: 100%; touch-action: none;">
            ...
        </div>
        <div class="ol-viewport" style="position: relative; overflow: hidden; width: 100%; height: 100%; touch-action: none;">
            ...
        </div>
    </div>
    ...
</aol-map>

Is this a bug due to something not being destroyed correctly or am I doing something wrong?

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: AngularOpenlayersModule is not an NgModule

Hi guys, angular 2 beginner here, i tried to use this module and it worked for a while, then beside doing an npm install I didn't do much yet I can't get my project to work anymore. I get the error below.

When i remove "AngularOpenlayersModule " from the imports in the app.module.ts file the project works again but ofc the map doesn't display as the import isn't there.

** NG Live Development Server is running on http://localhost:4200. **
10% building modules 3/3 modules 0 active(node:5716) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: AngularOpenlayersModule is not an NgModule
23% building modules 112/112 modules 0 active

Anyone else got this error?

EDIT:
I just understood how i got the project working.
First, i remove the import of AngularOpenlayersModule in app.module.ts
Then, i start ng serve. The project compiles properly.
Then i add AngularOpenlayersModule in the imports of app.module.ts.
The project recompile properly for some reason, and i can see the map.

EDIT2:
Don't know if this helps in any way but when i use "ng serve --aot" i get this one:
can't resolve module C:/JavaProjects/MovieApp/node_modules/angular2-openlayers/node_modules/@angular/core/src/di/reflective_key.d.ts from C:/JavaProject
s/MovieApp/node_modules/angular2-openlayers/node_modules/@angular/core/src/di/reflective_key.d.ts
(node:7988) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: can't find symbol KeyRegistry exported from module C:/JavaProjects/MovieApp/node_modules/angul
ar2-openlayers/node_modules/@angular/core/src/di/reflective_key.d.ts

I have to admit this is a pretty weird problem and I'm not really sure of its source but since the only thing i change is related to this module, i thought I would ask about it here.

Kind regards

EDIT 3: This problem is recurrent with certain version of angular-cli. Using typescript 2.0.10 and angular-cli beta.24 seems to have done the trick but other errors occurs (something about makeDecorator function calls not supported)

Example code for initialization and setup

Hi,
I went through the documentation from readme.md file. However the examples do not show basic initialization part on the component side. Could it be possible to give a example as how to adopt this in Anguar2 project.
Thanks in advance
Giridhar

Unable to install npm package

C:\MProjects\MGMT\modules\taskmgmt>npm install angular2-openlayers --save
npm ERR! path C:\MProjects\MGMT\modules\taskmgmt\https:\registry.npmjs.org\tapable-\tapable-0.2.6.tgz
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall stat
npm ERR! enoent ENOENT: no such file or directory, stat 'C:\MProjects\MGMT\modules\taskmgmt\https:\registry.npmjs.org\tapable-\tapable-0.2.6.tgz'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\xxxxyyyy\AppData\Roaming\npm-cache_logs\2017-07-12T07_07_21_181Z-debug.log

Creation of a gitter chat

Only the owner of the project can create the gitter chat we talk about earlier today.

You have to join gitter at the following URL : https://gitter.im (with your github credentials)

And to create a room in it with the button Add a room
image

Then choose the angular2-openlayers project. A PR is made by default on the README.md to add the gitter badge in the readme.
image

After that, we will have a simple but powerfull chat dedicated to the project

Thanks ๐Ÿ˜„

/cc @Neonox31 @Yakoust @Yann29

Subscribe to events with Observables

Hi,

I'm currently working on Angular and Openlayers and I found your work very interesting, but I have a question about the implementation you choose (and of course, the need I have ๐Ÿ˜„ )

You choose to expose all the events from OpenLayer through @Output() in every component, but what if I want to subscribe to an event propagated by the <aol-map></aol-map> but I can't access it (because I am in another sibling, parent component or can reach the map by local variable template) ?

It could be useful to have a service which expose those events with an Observable (like BehaviorSubject). This could allow to share the map modification/state to the whole app.

What is your opinion about this ?

ol.control implementation

I started looking into the unfinished control implementations.

There are a few questions. First of all, I don't think you can derive the classes from the OL classes as this breaks the @Input() parameter setting. So I changed it to the instance method used elsewhere. Next, the question is whether to use transclusion with <ng-content>. I couldn't get it to work so I went for this solution which uses the component's DOM element:

@Component({
  selector: 'aol-control-mouseposition',
  template: ``
})
export class ControlMousePositionComponent implements OnInit, OnDestroy {
  instance: control.MousePosition;
  @Input() coordinateFormat: CoordinateFormatType;
  @Input() projection: ProjectionLike;
  target: Element;

  constructor(
    @Host() private map: MapComponent,
    private element: ElementRef
  ) {
  }

  ngOnInit() {
    this.target = this.element.nativeElement;
    // console.log('ol.control.MousePosition init: ', this);
    this.instance = new control.MousePosition(this);
    this.map.instance.addControl(this.instance);
  }

  ngOnDestroy() {
    // console.log('removing aol-control-mouseposition');
    this.map.instance.removeControl(this.instance);
  }
}

In order to style it, you will need the piercing CSS selector ( :host /deep/) which is probably OK. Any thoughts on how to do the controls implementation?

Importing issue

I'm using angular-cli for my project and never had a problem importing this library:

...
import { AngularOpenlayersModule } from 'angular2-openlayers';
...
@NgModule({
  imports: [
    ...,
    AngularOpenlayersModule
]
...

but since angular-cli beta 22 it no longer works. I get the following error:

Error: Unexpected value 'AngularOpenlayersModule' imported by the module '<MODULE_NAME>'

I don't know exactly if this is a problem with angular-cli or with this library, so please have a look at it or let me know if you have no time/idea, then I'll create a issue at the angular-cli repo.

zone.js / change detection issue

I noticed very high CPU usage with VectorTile layers due to constant change detection.

It seems like change detection is triggered by high frequency timers that OL is running which run inside Angular's zone.js context and trigger change detection.

I have to do a more detailed analysis but I believe we have to make sure OL runs outside of Angular's zone and does not get affected by zone.js's monkey patching.

[documentation] Interactions

The documentation is lacking on interactions, especially default interactions, which developers not familiar with Openlayers will want.

We might also add default interactions to the example as it seems to be popular source of issues.

Cannot find Module openlayers

Importing the module like:

...
import { AngularOpenlayersModule } from 'angular2-openlayers';

@NgModule({
  imports: [
    ...,
    AngularOpenlayersModule
  ],
...

result in the following error message:

ERROR in [default] <PROJECT_PATH>/web/node_modules/angular2-openlayers/dist/components/feature.component.d.ts:2:24 
Cannot find module 'openlayers'.

ERROR in [default] <PROJECT_PATH>/node_modules/angular2-openlayers/dist/components/geometry.components.d.ts:2:21 
Cannot find module 'openlayers'.

ERROR in [default] <PROJECT_PATH>/node_modules/angular2-openlayers/dist/components/layer.components.d.ts:2:22 
Cannot find module 'openlayers'.

ERROR in [default] <PROJECT_PATH>/node_modules/angular2-openlayers/dist/components/map.component.d.ts:2:20 
Cannot find module 'openlayers'.

ERROR in [default] <PROJECT_PATH>/node_modules/angular2-openlayers/dist/components/source.components.d.ts:2:23 
Cannot find module 'openlayers'.

ERROR in [default] <PROJECT_PATH>/node_modules/angular2-openlayers/dist/components/view.component.d.ts:2:21 
Cannot find module 'openlayers'.

NPM package name

Hello everyone,

Since Angular has moved to 4.x versions and since we are already those, would it make sense to name the package angular4-openlayers?
To my understanding, this raises a few concerns:

  • same package under 2 different names
  • devs still using angular2 might think this lib is not for them
    Opinions ?

Cannot read property 'prototype' of undefined

Importing the Module leads the following error:

EXCEPTION: Uncaught (in promise): TypeError: Cannot read property 'prototype' of undefined

The error seems to be thrown on the following line of the feature component:

d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());

to be preciser it's line 5 possition 69

Thank you

Minimized object in events

Is possible to get not minimized version of object in events?

Now if I want to listen onMoveEnd event I get an object with not real names of attributes. It has a minified version. Is not easy to use, and in the end the names depends of the minification process

[FEATURE] popup

It would be a really nice feature to have popups. I found this library which could be used and should be easy to implement. I found it on the official size of openlayers Useful 3rd party libraries, so it is somehow supported by openlayers and shouldn't be bad.

Sadly I currently have other priorities to work on so if someone would have a look at it, otherwise I'll implement it once I find time for it.

Move map with mouse or touch

The map doesn't works fine, but it doesn't allow user to control it by mouse or a touch event

as seen here

as the same behavior here for example

GoogleMaps Pan

Code used:

<aol-map>
      <aol-view [zoom]="5">
        <aol-coordinate [x]="5" [y]="45" [srid]="'EPSG:4326'"></aol-coordinate>
      </aol-view>
      <aol-interaction-pinchzoom></aol-interaction-pinchzoom><aol-control-zoom></aol-control-zoom>
      <aol-control-fullscreen></aol-control-fullscreen>

      <aol-layer-tile>
        <aol-source-osm></aol-source-osm>
      </aol-layer-tile>
    </aol-map>

is there any control I need to add to have the behavior specified above?

[Discussion] ol3-cesium

We recently decided that the map on our project should sooner or later have the possibility to not only be flat, but to look like an actual globe. I have done some research and came across ol3-cesium.

Not what I would like to discuss is if it would make sense to implement that into this project, as it is from openlayers to and also uses ol. I think it would be a nice feature, but i don't know exactly how much overweight that is going to be for someone who wont use it and therefor I'm not sure in how far it would fit into this project.

Let me know what you think and if you like the idea I'll sit to it into implementing it into this project instead of into ours directly.

Attribution positioning error

Adding the attribution to the map results in the attribution being positioned totally wrong!

I have a router outlet with a static height of 350px (content overflow auto) and then have a route containing the following:

<div id="wrapper">
   <aol-map [height]="'200px'">
      ...
   </aol-map>
</div>

The wrapper also has a height of 200px, so the map should not be any higher than 200px, which it issn't only that if I add it results in the following:
image

The box represents the container of the router outlet. One can clearly see that the map has it's desired height, but the attribution is in the bottom right of the outlet corner instead of the maps corner.
The strange thing is that it is not in the corner of the wrapper (that was actually what I tried to achieve with the wrapper, otherwise it wouldn't even be needed, but without success)

stretching problem

I found an error that I already had in my project. Let me try to describe it:
I have a page with a toggle able side bar, the rest of the page is filled with the map. Now if i toggle the sidebar the view port of the map gets changed in size, but the page content is stretched.

I fixed this problem before by adding the following to my map page:

ngDoCheck() {
    this.map.updateSize();
  }

I don't know if this is the best, or right solution, but it worked for me, you should have a look at it.

If you have any questions or need more info, just let me know!

Uncaught SyntaxError: Unexpected token import

I'm getting an unexpected token import exception in Chrome due to the following code in index.js:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { components } from './components';

It seems like this started happening with the change to ngc but I'm not really sure.

Module parse failed [example]

I am trying to run the example app on a Windows 7 box. I used the following commands:

npm run ngc
npm install -g [email protected]
cd example
npm install
ng serve

Output of ng serve follows:

$ ng serve
** NG Live Development Server is running on http://localhost:4200. **
4313ms building modules
13ms sealing
1ms optimizing
0ms basic module optimization
106ms module optimization
1ms advanced module optimization
6ms basic chunk optimization
0ms chunk optimization
1ms advanced chunk optimization
0ms module and chunk tree optimization
43ms module reviving
4ms module order optimization
2ms module id optimization
3ms chunk reviving
1ms chunk order optimization
7ms chunk id optimization
43ms hashing
2ms module assets processing
90ms chunk assets processing
3ms additional chunk assets processing
1ms recording
0ms additional asset processing
1075ms chunk asset optimization
66ms asset optimization
29ms emitting
Hash: 15c37587dad06e68f597
Version: webpack 2.1.0-beta.25
Time: 5824ms
            Asset       Size  Chunks             Chunk Names
   main.bundle.js    2.71 MB    0, 2  [emitted]  main
 styles.bundle.js    15.1 kB    1, 2  [emitted]  styles
 inline.bundle.js    5.54 kB       2  [emitted]  inline
  main.bundle.map    2.82 MB    0, 2  [emitted]  main
styles.bundle.map    20.9 kB    1, 2  [emitted]  styles
inline.bundle.map     5.6 kB       2  [emitted]  inline
       index.html  513 bytes          [emitted]

ERROR in ./src/app/ng2-ol
Module parse failed: D:\Projects\angular2-openlayers\example\src\app\ng2-ol Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
| ../../../src/
 @ ./src/app/app.module.ts 14:0-51
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main
Child html-webpack-plugin for "index.html":
         Asset     Size  Chunks       Chunk Names
    index.html  2.85 kB       0
webpack: bundle is now VALID.
[default] Checking started in a separate process...
[default] D:\Projects\angular2-openlayers\example\src\app\app.module.ts:5:41
    Cannot find module './ng2-ol'.
[default] Checking finished with 1 errors

Documentation

Hello,

I would be greatly interested to implementing such a module into my project, but before doing so I would like to know in how far you are thinking to keep this component up to date and continue work on it?

And would it also be possible to create some kind of documentation?

Thanks and Greetings

Async data binding issues

Hello

I am using this markup to draw route and numbered circles in destinations:

> <aol-map [width]="'100%'" [height]="'500px'">
>     <aol-view [zoom]="2">
>         <aol-coordinate [x]="5.795122" [y]="45.210225" [srid]="'EPSG:4326'"></aol-coordinate>
>     </aol-view>
>     <aol-layer-tile>
>         <aol-source-osm></aol-source-osm>
>     </aol-layer-tile>
>     <aol-layer-vector>
>         <aol-source-vector > 
>             <aol-feature>
>                 <aol-geometry-linestring> 
>                     <aol-collection-coordinates [coordinates]="wayPoints" [srid]="'EPSG:4326'">
>                     </aol-collection-coordinates>
>                     <aol-style>
>                         <aol-style-stroke [color]="'red'" [width]="2"></aol-style-stroke>
>                     </aol-style>
>                 </aol-geometry-linestring>
>             </aol-feature>
>             <aol-feature *ngFor="let destination of destinations">
>                 <aol-geometry-point>
>                     <aol-coordinate [x]="destination.lng" [y]="destination.lat" [srid]="'EPSG:4326'"></aol-coordinate>
>                     <aol-style>
>                         <aol-style-text [text]="destination.num"></aol-style-text>
>                         <aol-style-circle [radius]="12" >
>                             <aol-style-stroke [color]="'darkblue'" [width]="2"></aol-style-stroke>
>                             <aol-style-fill [color]="'white'"></aol-style-fill>
>                         </aol-style-circle>
>                     </aol-style>
>                 </aol-geometry-point>
>             </aol-feature>
>         </aol-source-vector>
>     </aol-layer-vector>
> </aol-map>

Route data is loaded async when user clicks button in UI. First run is ok.
When click a button 2nd time then I get 2 issues here:

  1. geometry-linestring is not cleared out when wayPoints is refreshed with new value. Map keeps existing route geometry and starts drawing new geometry from last point
  2. "cannot call method 'forEach' of undefined ..." is thrown for *ngFor="let destination of destinations"

Async data refresh looks like that:

this.distanceService.getDistance().subscribe( d => { .....
....
            this.destinations = destinations;
            this.wayPoints = wayPoints;
});

Any ideas?

Thanks.

AttributionLike for sources

Each ol.source class has an AttributionLike parameter (which can be set separately). I wonder how to implement this best. Doing it as a child component would mean duplicating the attribution and when one author provides several layers, the same copyright would be rendered multiple times.

http://openlayers.org/en/latest/apidoc/ol.html#.AttributionLike

Suggestions? The best solution I've come up with is to let the library user provide the ol.AttributionLike directly as an input parameter to the source components. This means exposing OL3 internals.

capture click event on <aol-feature> or markers

is there a way to capture on click event on a marker on the map. My goal is to be able to show a pop-up once a marker is being clicked on the map. I added (click) on the feature, <aol-geometry-point> and <aol-style-icon> with no luck

This is what I would like to achieve as in the picture here once I click on marker the popup should be displayed

<aol-layer-vector>
    <aol-source-vector>


        <aol-feature *ngFor="let marker of markers; let i = index" [attr.data-index]="i" id="fet{{marker.ID}}" (click)="alert('hi Iam clicked')">

            <aol-geometry-point (click)="alert('hi Iam clicked')">
                <aol-coordinate [x]="marker.x" [y]="marker.y"></aol-coordinate>
            </aol-geometry-point>

            <aol-style>
                <aol-style-icon (click)="alert('hi Iam clicked')" [src]="getIcon(marker.ID)" [anchor]="[0.5, 0.5]" [scale]="0.1" [anchorXUnits]="'fraction'" [anchorYUnits]="'fraction'" [opacity]="1">
                </aol-style-icon>
            </aol-style>

            <!--popup-->
            <aol-overlay>
                <aol-coordinate [x]="marker.x" [y]="marker.y"></aol-coordinate>
                <aol-content>
                    <div class="ol-airport-popup">
                        <div class="ol-airport-popup-content">
                            <h1>{{marker.ID}}</h1>
                        </div>
                    </div>
                </aol-content>
            </aol-overlay>


        </aol-feature>

    </aol-source-vector>
</aol-layer-vector>

Blank map in a fresh angular-cli generated app

Hey,

I've updated angular-cli to 1.0.0-beta.24 and tried created a fresh app using the latest AOT compatible version (0.4.2).
I ran the usual:

ng init
npm install --save angular2-openlayers

then I imported the angular2-openlayers module in app.module.ts:

[...]
import { AngularOpenlayersModule } from 'angular2-openlayers';
[...]
imports: [
[...]
AngularOpenlayersModule
  ],
[...]

and put together this simple example in app.component.html:

<div>
	<aol-map>
		<aol-layer-tile>
			<aol-source-osm></aol-source-osm>
		</aol-layer-tile>
	</aol-map>
</div>

Running ng serve throws a dump of errors:

ERROR in Error encountered resolving symbol values statically. Calling function 'makeParamDecorator', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol Injectable in /path/to/fresh_app/node_modules/angular2-openlayers/node_modules/@angular/core/src/di/metadata.d.ts, [...]

Since it seemed to have something with the angular package in angular2-openlayers/node_modules, I deleted it

rm -rf /path/to/fresh_app/node_modules/angular2-openlayers/node_modules/@angular
```.
```ng serve``` no longer throws errors at me, everything seems to run fine but the map doesn't show up despite logs in the console that tells me components are correctly instantiated.

Any idea why this is happening ?
On a side note, this move to AOT is raising quite a few concerns in angular-cli issues tracker right now.

openlayers css

Would it be possible to somehow import the css file of openlayers into the map component, because at the moment when using this library I have to:

  • install the library (contains ol3 as dependency)
  • install openlayers (to optain css)
  • globally import ol css so that controls have the right style
    by this manner I have openlayers as duplicated dependency, plus the globally import of the css which might be confusing for somebody using this library.

Now my idea would be to somehow import the ol css file in the map component, so that its also shared with all its children, so that importing this library in a project and using it will result in the right styling of all the components without any extra imports. My problem now is that I couldn't find a way to do this until now, so I don't even know if it's even possible, but maybe you know a solution. If so, please implement or let me know how and I'll be happy to help with the implementation

Unable to remove default controlls

Hy,

there is currently no possibility to remove the default controls added to a map or change there options, or at least I didn't find a way to do it.
I found the DefaultControlComponent, but it's inputs do not affect the component in any way! Is there some code missing or am I overseeing something.

Add dist to git

The /dist directory should be part of the git repository. This is good practise with Angular components as it allows using the repo directly via npm and also from applications that do not have a Typescript tool chain.

You can just add to your package.json:

"angular2-openlayers": "https://github.com/quentin-ol/angular2-openlayers"

or your own fork.

Developing

Running npm install on a clean clone of the project results in the following error once reaching prepublish tsc command.
The exact message that is outputted is;

> [email protected] prepublish /home/fallenritemonk/dev/angular2-openlayers
> tsc

src/components/coordinate.component.ts(45,73): error TS2339: Property 'getCode' does not exist on type 'Projection'.
src/components/coordinate.component.ts(94,73): error TS2339: Property 'getCode' does not exist on type 'Projection'.
src/components/feature.component.ts(21,17): error TS2339: Property 'removeFeature' does not exist on type 'SourceVectorComponent'.

Dynamic style components loading

Reviewing #17 I noticed that if I dynamically add a Icon style to a style component, it doesn't get shown, since a subscription is done on ngAfterContentInit. Like so if a icon is added dynamically using ngIf for example, it will never be shown.
At the moment I can think of these solutions:

  • make it clear to the users that a style component always has to be filled with the according sub-style components on its initialization
  • make sub-style component trigger there subscription in the style component (calling some host method on ngInit)
  • remove sub-style components and implement them directly into style component using inputs

I personally would use solution two, as it seems the most reliable and logical one.
The first would be the easiest, but I thing (know from my self) that there are always users who don't read the full documentation and start modifying the example right away, which then might lead to errors that are hard to identify for them. Also not to forget the general lack of documentation at the moment.
I don't like the last because it wouldn't fit into the current style of the library and would make the style component look really ugly and messy for the users.

Let me know what you think.

Problem with instalation

Hello i have this problem when installing and initiation the component

localhost/:3000 Error: Fetch error: 404 Not Found
Instantiating http://localhost:3000/angular2-openlayers
Loading http://localhost:3000/app/mobile-content/mobile-content.module.js
Loading http://localhost:3000/app/app.module.js
Loading http://localhost:3000/app/main.js
Loading app
at fetch.js:37
at ZoneDelegate.invoke (zone.js:391)
at Zone.run (zone.js:141)
at zone.js:818
at ZoneDelegate.invokeTask (zone.js:424)
at Zone.runTask (zone.js:191)
at drainMicroTaskQueue (zone.js:584)

Failed to compile.

<project_folder>/node_modules/angular2-openlayers/dist/components/controls/attribution.component.d.ts (1,1): Cannot find type definition file for 'openlayers'.

Please help!

After installing @types/openlayers it compiles!
Thanks

When bring the SRC code into a project, 404 errors occcur when running in chrome.

Hi,

I am new to angular 2 so this is properly something I have done incorrectly.

I put the code in the SRC folders into the a new project, I installed OpenLayers 3 and I thought I had done all correctly, however when I run the code I get the following error.

zone.js:2019 GET http://localhost:1985/app/angular2-openlayers/components/layers.js 404 (Not Found)

(angular2-openlayers is the SRC version ).

Interesting the file indeed does not exist, there seems to be a problem with sub folders when reading from the index files (components/layers etc).

Any help would be appreciated. :)

M

WMS example

Hello, thanks so much for the wonderful effort

I have 3 questions:

  1. Can you publish the latest release to NPM as the release on NPM is (0.6.5)
  2. Can you provide a WMS example
  3. Do you have a map/layer switcher in plan?

Thanks again ๐Ÿ‘

Source format implementation

I have a semi-working implementation of ol.source.VectorTile which requires the parameter format in its constructor (unfortunately no setFormat available). The format can be something like ol.format.MVT which means we would desire this:

<aol-source-vectortile>
    <aol-format-mvt></aol-format-mvt>
</aol-source-vectortile>

Now this has a chicken and egg problem. In ngOnInit, we create the OL3 objects but at this point the child components are not created yet and also they generally assume they can call the parent.

Any suggestion how to model this case?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.