All Projects → Viglino → ol-ext-angular

Viglino / ol-ext-angular

Licence: MIT license
Using Openlayers (ol) and ol-ext with Angular 7

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to ol-ext-angular

Ngeo
Library combining OpenLayers and AngularJS
Stars: ✭ 122 (+212.82%)
Mutual labels:  openlayers
Wind Layer
🎏 🚀 wind-layer | a openlayers && amap && bmap && leaflet && mapbox-gl extension to windjs
Stars: ✭ 188 (+382.05%)
Mutual labels:  openlayers
hslayers-ng
User interface and map building extensions for OpenLayers
Stars: ✭ 29 (-25.64%)
Mutual labels:  openlayers
Ngx Openlayers
Angular2+ components for Openlayers 4.x
Stars: ✭ 131 (+235.9%)
Mutual labels:  openlayers
Ol Geocoder
Geocoder Nominatim for OpenLayers
Stars: ✭ 158 (+305.13%)
Mutual labels:  openlayers
React Geo
A set of geo related modules to use in combination with React, Ant Design and OpenLayers.
Stars: ✭ 220 (+464.1%)
Mutual labels:  openlayers
Mangol
Maps created with Angular & OpenLayers using Material design
Stars: ✭ 92 (+135.9%)
Mutual labels:  openlayers
dicom-microscopy-viewer
Web-based DICOM slide microscopy viewer library
Stars: ✭ 70 (+79.49%)
Mutual labels:  openlayers
React Openlayers
OpenLayer React Components
Stars: ✭ 169 (+333.33%)
Mutual labels:  openlayers
geostyler-openlayers-parser
GeoStyler Style Parser implementation for OpenLayers styles
Stars: ✭ 26 (-33.33%)
Mutual labels:  openlayers
Data Visualization
Data visualization demos, mainly geographic data.
Stars: ✭ 137 (+251.28%)
Mutual labels:  openlayers
Ol Contextmenu
Custom Context Menu for OpenLayers
Stars: ✭ 141 (+261.54%)
Mutual labels:  openlayers
Ol3echarts
🌏 📊 ol3Echarts | a openlayers extension to echarts
Stars: ✭ 229 (+487.18%)
Mutual labels:  openlayers
Lizmap Web Client
Transfer a QGIS project on a server, Lizmap is providing the web interface to browse it
Stars: ✭ 130 (+233.33%)
Mutual labels:  openlayers
covid-19
Open source web map for tracking COVID-19 global cases
Stars: ✭ 23 (-41.03%)
Mutual labels:  openlayers
Geoext3
A JavaScript framework that combines the GIS functionality of OpenLayers with all features of the ExtJS library
Stars: ✭ 121 (+210.26%)
Mutual labels:  openlayers
Mf Geoadmin3
map.geo.admin.ch source code
Stars: ✭ 215 (+451.28%)
Mutual labels:  openlayers
olturf
A Turf toolbar for OpenLayers.
Stars: ✭ 30 (-23.08%)
Mutual labels:  openlayers
rlayers
React Component Library for OpenLayers
Stars: ✭ 98 (+151.28%)
Mutual labels:  openlayers
Mapstore2
Modern webmapping with OpenLayers, Leaflet and React
Stars: ✭ 251 (+543.59%)
Mutual labels:  openlayers

  ol-ext + Angular

This project is an example to use Openlayers and ol-ext with Angular 7.

It is by no means a complete app but you should find mecanisms to handle an Openlayers map using Angular, with interactions and controls to customize for your own.

Goal

The goal of this example is to create a map as simple as that:

<app-map id="map">
  <!-- Add a layers -->
  <app-layer layer="OSM" opacity=.5 visibility=true></app-layer>
  <app-layer layer="watermark" visibility=false></app-layer>
  <!-- Add interactions -->
  <app-interaction1></app-interaction1>
  <app-interaction2></app-interaction2>
  <!-- Add a controls inside the map -->
  <app-control1></app-control1>
  <app-control2></app-control2>
</app-map>

As controls can be set outside the map (using the target option) we also want to have this option too.

<app-map id="map">
  <!-- Add a layers -->
  <app-layer layer="OSM" opacity=.5 visibility=true></app-layer>
  <!-- Add a controls inside the map -->
  <app-control1></app-control1>
</app-map>

<!-- Add control outside -->
<app-control2 mapId="map"></app-control2>

We also want to create more than one map:

<app-map id="map">
  <!-- Add a layers -->
  <app-layer layer="OSM" opacity=.5 visibility=true></app-layer>
</app-map>

<app-map id="map2">
  <!-- Add a layers -->
  <app-layer layer="watermark"></app-layer>
</app-map>

Mecanisms

MapService and MapidService

The map is implemented as a service to let you access it in other components.

Getting a map

You just have to declare the service in your constructor to access the map:

constructor(private mapService: MapService) { }

Then to retrieve the map you want, use the getMap method:

// Default map (id=map)
const map = mapService.getMap();
// another map (id=map1)
const map1 = mapService.getMap('map1');

The parameter is the id of the map you want to get. If you just have one map you can use the default value (map).

Getting the current map

The MapidService let you handle the current map's id. It is used by the map component to register a new map id (mapServe.setId()). It's not a root service and each map has its own one, thus each component defined inside a map component can access the current map id using the getId() method of the service.

This id is registered by the root MapComponent (using the setId()method).

Customizing the map

Feel free to modify the createMap() method of the MapService to handle the default map.
The MapComponent let you define the map itself. Use the ngOnInit() method to customize the map (set zoom, etc.).

Creating new map components (controls, layers, interactions...)

This example comes with a set of components for each Openlayers map features: controls, interactions, layer...
Just copy the .ts file to create a new one to use in your app.

You first have to declare the services in your constructor:

  constructor(
    private mapService: MapService,
    @Host()
    private mapidService: MapidService
  ) { }

Then in ngOnInit, get the current map like this:

  ngOnInit() {
    // Get the current map
    const map: OlMap = this.mapService.getMap(this.mapidService);
    // Add component to the map
  }

To let the control be set inside or outside the map you also need to get the target ElementRef. In this case the MapidService is optional (as it comes inside a MapComponent it is not defined when set outside a map). Look at the ControlComponent for more informations.

Example

The example defines:

  • 2 maps
  • a set of layers define using a component propertie
  • an interaction to synchonize the maps together
  • a control inside the map (Bookmark contol)
  • a control outside the map (MousePosition).

Build

This project was generated with Angular CLI version 7.1.4.

Install

Run npm install to install node modules and start developping.

Development server

Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Run ng build to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI README.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].