-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ngeo-drawfeature directive and example
- Loading branch information
Showing
37 changed files
with
943 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.