Giter VIP home page Giter VIP logo

Comments (3)

ramiassi avatar ramiassi commented on June 2, 2024 1

You can basically import all from openlayers like this:

import * as ol from 'openlayers';

Then you can use the OpenLayers native api. For example to transform the coordinates given by the onClick event to lat long:

onMapClick(event: ol.MapBrowserEvent) {
    const coords = ol.proj.toLonLat(event.coordinate);
    console.log('map click: ', coords);
  }

from ngx-openlayers.

sudmann avatar sudmann commented on June 2, 2024

You need to import AngularOpenlayersModule from the npm package and then import it in your desired NgModule.

Could look something like this:

import { AngularOpenlayersModule } from 'ngx-openlayers';

@NgModule({
  imports: [AngularOpenlayersModule]
  // other props left out for simplicity
})
export class AppModule {}

Now the components are usable within scope of the AppModule. Consult the documentation or the demo project on how to use the components.

P.s. I agree that importing the api could be better documented. It also would be nice if the lib did support automatic setup with ng add.

Edit: Whoops, seems like I've misinterpreted your question. Sorry. I think you could still use the native ol api.
The corrdinate "format" is set via the [srid] propertys.

from ngx-openlayers.

Helveg avatar Helveg commented on June 2, 2024

Ok, do you have a snippet for using the native ol api in an Angular project? I'm fuzzy on modules, typings, precise import mechanics, ... Do I have to install another package for the ol api?

from ngx-openlayers.

Related Issues (20)

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.