Skip to content

Commit

Permalink
Add ngeo-drawfeature directive and example
Browse files Browse the repository at this point in the history
  • Loading branch information
adube committed Apr 11, 2016
1 parent 187ae6c commit c86fb68
Show file tree
Hide file tree
Showing 37 changed files with 943 additions and 21 deletions.
24 changes: 12 additions & 12 deletions contribs/gmf/src/directives/partials/featurestyle.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</div>

<div class="form-group"
ng-if="fsCtrl.type !== 'text'">
ng-if="fsCtrl.type !== 'Text'">
<div class="col-xs-12">
<span
class="gmf-featurestyle-measure">
Expand All @@ -29,7 +29,7 @@
</div>

<div
ng-if="fsCtrl.type === 'point'"
ng-if="fsCtrl.type === 'Point'"
class="form-group">
<label class="control-label col-xs-4">{{'Size' | translate}}</label>
<div class="col-xs-8">
Expand All @@ -45,7 +45,7 @@
</div>

<div
ng-if="fsCtrl.type === 'text'"
ng-if="fsCtrl.type === 'Text'"
class="form-group">
<label class="control-label col-xs-4">{{'Size' | translate}}</label>
<div class="col-xs-8">
Expand All @@ -61,7 +61,7 @@
</div>

<div
ng-if="fsCtrl.type === 'circle' || fsCtrl.type === 'linestring' || fsCtrl.type === 'polygon' || fsCtrl.type === 'rectangle'"
ng-if="fsCtrl.type === 'Circle' || fsCtrl.type === 'LineString' || fsCtrl.type === 'Polygon' || fsCtrl.type === 'Rectangle'"
class="form-group">
<label class="control-label col-xs-4">{{'Stroke' | translate}}</label>
<div class="col-xs-8">
Expand All @@ -77,7 +77,7 @@
</div>

<div
ng-if="fsCtrl.type === 'circle' || fsCtrl.type === 'polygon' || fsCtrl.type === 'rectangle'"
ng-if="fsCtrl.type === 'Circle' || fsCtrl.type === 'Polygon' || fsCtrl.type === 'Rectangle'"
class="form-group">
<label class="control-label col-xs-4">{{'Opacity' | translate}}</label>
<div class="col-xs-8">
Expand All @@ -93,7 +93,7 @@
</div>

<div
ng-if="fsCtrl.type === 'text'"
ng-if="fsCtrl.type === 'Text'"
class="form-group">
<label class="control-label col-xs-4">{{'Angle' | translate}}</label>
<div class="col-xs-8">
Expand All @@ -109,7 +109,7 @@
</div>

<div
ng-if="fsCtrl.type !== 'text'"
ng-if="fsCtrl.type !== 'Text'"
class="form-group">
<div class="col-xs-12">
<input
Expand All @@ -121,19 +121,19 @@
ng-switch="fsCtrl.type"
for="gmf-featurestyle-showmeasure"
class="control-label">
<span ng-switch-when="circle">
<span ng-switch-when="Circle">
{{'Display surface' | translate}}
</span>
<span ng-switch-when="polygon">
<span ng-switch-when="Polygon">
{{'Display surface' | translate}}
</span>
<span ng-switch-when="rectangle">
<span ng-switch-when="Rectangle">
{{'Display surface' | translate}}
</span>
<span ng-switch-when="linestring">
<span ng-switch-when="LineString">
{{'Display length' | translate}}
</span>
<span ng-switch-when="point">
<span ng-switch-when="Point">
{{'Display coordinates' | translate}}
</span>
</label>
Expand Down
1 change: 1 addition & 0 deletions contribs/gmf/src/directives/partials/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
<span class="clear-button ng-hide"
ng-hide="!ctrl.clearButton || ctrl.input_value == ''"
ng-click="ctrl.onClearButton()"></span>
<input data-ng-model="color" data-ng-change="ctrl.setStyleColor(color)"></input>
</div>
1 change: 1 addition & 0 deletions examples/animation.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<p>Use the <em>Open sidebar!</em> to open the sidebar and change the width of the map.</p>
<p id="desc">This example shows how to animate the resizing of a map without distortions of the map during the animation. This uses the <code><a href="../apidoc/ngeo.resizemapDirective.html" title="Read our documentation">ngeoResizemap</a></code> directive.</p>
<script src="../node_modules/angular/angular.js"></script>
<script src="../node_modules/angular-gettext/dist/angular-gettext.js"></script>
<script src="/@?main=animation.js"></script>
<script src="default.js"></script>
<script src="../utils/watchwatchers.js"></script>
Expand Down
1 change: 1 addition & 0 deletions examples/backgroundlayer.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
</div> <!-- container -->

<script src="../node_modules/angular/angular.js"></script>
<script src="../node_modules/angular-gettext/dist/angular-gettext.js"></script>
<script src="/@?main=backgroundlayer.js"></script>
<script src="default.js"></script>
<script src="../utils/watchwatchers.js"></script>
Expand Down
1 change: 1 addition & 0 deletions examples/backgroundlayerdropdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
</div>
<script src="../node_modules/jquery/dist/jquery.js"></script>
<script src="../node_modules/angular/angular.js"></script>
<script src="../node_modules/angular-gettext/dist/angular-gettext.js"></script>
<script src="../node_modules/bootstrap/dist/js/bootstrap.js"></script>
<script src="/@?main=backgroundlayerdropdown.js"></script>
<script src="default.js"></script>
Expand Down
1 change: 1 addition & 0 deletions examples/colorpicker.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<p id="desc">This example shows how to write an application-specific directive (<code>app-colorpicker</code>) based on <code>ngeo-colorpicker</code>to create a color picker.</p>
</div>
<script src="../node_modules/angular/angular.js"></script>
<script src="../node_modules/angular-gettext/dist/angular-gettext.js"></script>
<script src="/@?main=colorpicker.js"></script>
<script src="default.js"></script>
<script src="../utils/watchwatchers.js"></script>
Expand Down
1 change: 1 addition & 0 deletions examples/control.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
Mouse position: <div id="mouse-position" ngeo-control="ctrl.control" ngeo-control-map="ctrl.map"></div>
<p id="desc">This example shows how to use the <code><a href="../apidoc/ngeo.controlDirective.html" title="Read our documentation">ngeo-control</a></code> directive to insert an OpenLayers control in the page.</p>
<script src="../node_modules/angular/angular.js"></script>
<script src="../node_modules/angular-gettext/dist/angular-gettext.js"></script>
<script src="/@?main=control.js"></script>
<script src="default.js"></script>
<script src="../utils/watchwatchers.js"></script>
Expand Down
146 changes: 146 additions & 0 deletions examples/drawfeature.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<!DOCTYPE html>
<html ng-app='app'>
<head>
<title>Draw Feature Example</title>
<meta charset="utf-8">
<meta name="viewport"
content="initial-scale=1.0, user-scalable=no, width=device-width">
<meta name="mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="../node_modules/openlayers/css/ol.css" type="text/css">
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.css" type="text/css">

<style>
#map {
width: 600px;
height: 400px;
}
ngeo-drawfeature {
margin: 10px 0;
}
.ngeo-drawfeature-circle:before {
content: 'Circle'
}
.ngeo-drawfeature-linestring:before {
content: 'LineString'
}
.ngeo-drawfeature-point:before {
content: 'Point'
}
.ngeo-drawfeature-polygon:before {
content: 'Polygon'
}
.ngeo-drawfeature-rectangle:before {
content: 'Rectangle'
}
.ngeo-drawfeature-text:before {
content: 'Text'
}
.tooltip {
position: relative;
background: rgba(0, 0, 0, 0.5);
border-radius: 4px;
color: white;
padding: 4px 8px;
opacity: 0.7;
white-space: nowrap;
}
.tooltip-measure {
opacity: 1;
font-weight: bold;
}
.tooltip-static {
display: none;
}
.tooltip-measure:before,
.tooltip-static:before {
border-top: 6px solid rgba(0, 0, 0, 0.5);
border-right: 6px solid transparent;
border-left: 6px solid transparent;
content: "";
position: absolute;
bottom: -6px;
margin-left: -7px;
left: 50%;
}
.tooltip-static:before {
border-top-color: #ffcc33;
}
</style>
</head>
<body ng-controller="MainController as ctrl">
<div id="map" ngeo-map="ctrl.map"></div>

<ngeo-drawfeature
ngeo-btn-group
class="btn-group"
ngeo-drawfeature-active="ctrl.drawActive"
ngeo-drawfeature-map="ctrl.map">
<a
href
translate
ngeo-btn
ngeo-drawpoint
class="btn btn-default ngeo-drawfeature-point"
ng-class="{active: dfCtrl.drawPoint.active}"
ng-model="dfCtrl.drawPoint.active"></a>
<a
href
translate
ngeo-btn
ngeo-measurelength
class="btn btn-default ngeo-drawfeature-linestring"
ng-class="{active: dfCtrl.measureLength.active}"
ng-model="dfCtrl.measureLength.active"></a>
<a
href
translate
ngeo-btn
ngeo-measurearea
class="btn btn-default ngeo-drawfeature-polygon"
ng-class="{active: dfCtrl.measureArea.active}"
ng-model="dfCtrl.measureArea.active"></a>
<a
href
translate
ngeo-btn
ngeo-measureazimut
class="btn btn-default ngeo-drawfeature-circle"
ng-class="{active: dfCtrl.measureAzimut.active}"
ng-model="dfCtrl.measureAzimut.active"></a>
<a
href
translate
ngeo-btn
ngeo-drawrectangle
class="btn btn-default ngeo-drawfeature-rectangle"
ng-class="{active: dfCtrl.drawRectangle.active}"
ng-model="dfCtrl.drawRectangle.active"></a>
<a
href
translate
ngeo-btn
ngeo-drawtext
class="btn btn-default ngeo-drawfeature-text"
ng-class="{active: dfCtrl.drawText.active}"
ng-model="dfCtrl.drawText.active"></a>
</ngeo-drawfeature>

<input type="checkbox"
ng-model="ctrl.dummyActive" /> Dummy

<p id="desc">
This example shows how to use the <code>ngeo-drawfeature</code>
directive to draw vector features on the map.
</p>

<script src="../node_modules/jquery/dist/jquery.js"></script>
<script src="../node_modules/angular/angular.js"></script>
<script src="../node_modules/angular-animate/angular-animate.js"></script>
<script src="../node_modules/angular-touch/angular-touch.js"></script>
<script src="../node_modules/bootstrap/dist/js/bootstrap.js"></script>
<script src="../node_modules/angular-gettext/dist/angular-gettext.js"></script>
<script src="/@?main=drawfeature.js"></script>
<script src="default.js"></script>
<script src="../utils/watchwatchers.js"></script>
</body>
</html>
81 changes: 81 additions & 0 deletions examples/drawfeature.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
goog.provide('drawfeature');

goog.require('ngeo.Features');
goog.require('ngeo.ToolActivate');
goog.require('ngeo.ToolActivateMgr');
goog.require('ngeo.drawfeatureDirective');
goog.require('ngeo.mapDirective');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.layer.Tile');
goog.require('ol.source.OSM');


/** @const **/
var app = {};


/** @type {!angular.Module} **/
app.module = angular.module('app', ['ngeo']);


/**
* @param {!angular.Scope} $scope Angular scope.
* @param {ol.Collection.<ol.Feature>} ngeoFeatures Collection of features.
* @param {ngeo.ToolActivateMgr} ngeoToolActivateMgr Ngeo ToolActivate manager
* service.
* @constructor
*/
app.MainController = function($scope, ngeoFeatures, ngeoToolActivateMgr) {

/**
* @type {!angular.Scope}
* @private
*/
this.scope_ = $scope;

var vector = new ol.layer.Vector({
source: new ol.source.Vector({
wrapX: false,
features: ngeoFeatures
})
});

/**
* @type {ol.Map}
* @export
*/
this.map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
}),
vector
],
view: new ol.View({
center: [0, 0],
zoom: 3
})
});

/**
* @type {boolean}
* @export
*/
this.drawActive = false;

var drawToolActivate = new ngeo.ToolActivate(this, 'drawActive');
ngeoToolActivateMgr.registerTool('mapTools', drawToolActivate, false);

/**
* @type {boolean}
* @export
*/
this.dummyActive = true;

var dummyToolActivate = new ngeo.ToolActivate(this, 'dummyActive');
ngeoToolActivateMgr.registerTool('mapTools', dummyToolActivate, true);
};


app.module.controller('MainController', app.MainController);
1 change: 1 addition & 0 deletions examples/geolocation.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
</p>
<p id="desc">This example shows how to use the <code><a href="../apidoc/ngeo.DecorateGeolocation.html" title="Read our documentation">ngeoDecorateGeolocation</a></code> service to bind the <code>Geolocation</code>'s <code>tracking</code> value to an input checkbox.</p>
<script src="../node_modules/angular/angular.js"></script>
<script src="../node_modules/angular-gettext/dist/angular-gettext.js"></script>
<script src="/@?main=geolocation.js"></script>
<script src="default.js"></script>
<script src="../utils/watchwatchers.js"></script>
Expand Down
1 change: 1 addition & 0 deletions examples/importfeatures.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<p id="desc">This example shows how to use the <code><a href="../apidoc/ngeo.filereaderDirective.html" title="Read our documentation">ngeo-filereader</a></code> directive to import features from a KML file read from the user's file system.</p>
<p>You can download and use the <a href="http://openlayers.org/en/master/examples/data/kml/2012-02-10.kml">2012-02-10.kml file</a> from the OpenLayers examples for testing.</p>
<script src="../node_modules/angular/angular.js"></script>
<script src="../node_modules/angular-gettext/dist/angular-gettext.js"></script>
<script src="/@?main=importfeatures.js"></script>
<script src="default.js"></script>
<script src="../utils/watchwatchers.js"></script>
Expand Down
1 change: 1 addition & 0 deletions examples/interactionbtngroup.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<div ng-show="ctrl.showInfo" ng-cloak class="alert alert-success" role="alert"><b>ngeo-btn</b> directive works also outside <b>ngeo-btn-group</b> one</div>
<p id="desc">This example shows how to use the <code><a href="../apidoc/ngeo.btngroupDirective.html" title="Read our documentation">ngeo-btn-group</a></code> and <code><a href="../apidoc/ngeo.btnDirective.html" title="Read our documentation">ngeo-btn</a></code> directives to activate/deactivate OpenLayers interactions in a toggle group.</p>
<script src="../node_modules/angular/angular.js"></script>
<script src="../node_modules/angular-gettext/dist/angular-gettext.js"></script>
<script src="/@?main=interactionbtngroup.js"></script>
<script src="default.js"></script>
<script src="../utils/watchwatchers.js"></script>
Expand Down
1 change: 1 addition & 0 deletions examples/interactiontoggle.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
</p>
<p id="desc">This examples shows how to use <code><a href="../apidoc/ngeo.DecorateInteraction.html" title="Read our documentation">ngeoDecorateInteraction</a></code> to activate/deactivate an interaction through <code>ng-model</code>.</p>
<script src="../node_modules/angular/angular.js"></script>
<script src="../node_modules/angular-gettext/dist/angular-gettext.js"></script>
<script src="/@?main=interactiontoggle.js"></script>
<script src="default.js"></script>
<script src="../utils/watchwatchers.js"></script>
Expand Down

0 comments on commit c86fb68

Please sign in to comment.