Skip to content

AngularJS directive to embed an interact with maps managed by the OpenLayers library

License

Notifications You must be signed in to change notification settings

cse-t-kutsuna/angular-openlayers-directive

 
 

Repository files navigation

angular-openlayers-directive

Work in progress.

AngularJS directive for the OpenLayers (version 3) Javascript Library. This software allows you to embed maps managed by openlayers on your AnguarJS or OpenLayers project. It's a good starting point to learn the Openlayers API too.

Let's start with some basic examples. Look at the source code of the example to see all the code you need to embed a similar interactive map on our page.

You can take a look at the current documentation go get a more detailed explanation of how it works and what you can accomplish with this directive:

Quick start: How to use it

First of all, load AngularJS and Openlayers(V3) in your HTML.

After that, you must include the openlayers-directive dependency on your angular module:

var app = angular.module("demoapp", ["openlayers-directive"]);

After that, you can change the default values of the directive (if you want) on your angular controller. For example, you can change the tiles source of the main layer, or the maxzoom on the map. You can see all the customizable default options in the documentation.

angular.extend($scope, {
    defaults: {
        layers: {
            main: {
                source: {
                    type; "OSM",
                    url: "http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png",
                }
            }
        },
        maxZoom: 14
    }
});

If you want to set the start of the map to a precise position, you can define the "center" property of the scope (lat, lng, zoom). It will be updated interacting on the scope and on the OpenLayers map in two-way binding. Example:

angular.extend($scope, {
    center: {
        lat: 51.505,
        lon: -0.09,
        zoom: 8
    }
});

Finally, you must include the markup directive on your HTML page, like this:

<openlayers ol-center="center" height="480px" width="640px"></openlayers>

About

AngularJS directive to embed an interact with maps managed by the OpenLayers library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 98.2%
  • CSS 1.8%