Skip to content

New examples rework & Viewer #697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ Status](https://coveralls.io/repos/realtymaps/angular-leaflet-directive/badge.pn
Library. This software aims to easily embed maps managed by leaflet on your
[Leaflet](http://leaflet.cloudmade.com) project.

See some basic examples:
You can browse all the examples added by the community to learn about the directive and its possibilities here:

http://tombatossals.github.io/angular-leaflet-directive/examples/0000-viewer.html

Or you can see some examples directly:

* [Basic example](http://tombatossals.github.io/angular-leaflet-directive/examples/simple-example.html)
* [Center example](http://tombatossals.github.io/angular-leaflet-directive/examples/center-example.html)
Expand Down
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
},
"devDependencies": {
"jquery": "*",
"bootstrap": "*",
"semantic-ui": "*",
"prism": "*",
"angular-route": "1.3.x",
"angular-animate": "1.3.x",
"angular-mocks": "1.3.x",
Expand Down
80 changes: 80 additions & 0 deletions examples/0000-viewer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<title>Angular Leaflet Directive: Examples viewer</title>

<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Open+Sans:300italic,400,300,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="../bower_components/semantic-ui/dist/semantic.min.css">
<link rel="stylesheet" type="text/css" href="../bower_components/prism/themes/prism.css">
<link rel="stylesheet" type="text/css" href="../bower_components/leaflet/dist/leaflet.css">
<link rel="stylesheet" href="../bower_components/Leaflet.label/dist/leaflet.label.css" />
<link rel="stylesheet" href="../bower_components/leaflet.draw/dist/leaflet.draw.css" />
<link rel="stylesheet" href="../bower_components/leaflet.markercluster/dist/MarkerCluster.css" />
<link rel="stylesheet" href="../bower_components/leaflet.markercluster/dist/MarkerCluster.Default.css" />
<link rel="stylesheet" type="text/css" href="css/viewer.css">
<link rel="stylesheet" type="text/css" href="http://cloud.github.com/downloads/lafeber/world-flags-sprite/flags32.css" />
<link rel="stylesheet" href="../bower_components/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="../bower_components/Leaflet.awesome-markers/dist/leaflet.awesome-markers.css">
<link rel="stylesheet" href="../bower_components/Leaflet.ExtraMarkers/src/leaflet.extra-markers.css">


<script src="http://maps.google.com/maps/api/js?v=3&sensor=false"></script>
<script src="../bower_components/leaflet/dist/leaflet.js"></script>
<script src="../bower_components/proj4/dist/proj4.js"></script>
<script src="../bower_components/proj4leaflet/src/proj4leaflet.js"></script>
<script src="../bower_components/leaflet-plugins/layer/tile/Google.js"></script>
<script src="../bower_components/esri-leaflet/dist/esri-leaflet.js"></script>
<script src="../bower_components/webgl-heatmap-leaflet/js/webgl-heatmap.js"></script>
<script src="../bower_components/webgl-heatmap-leaflet/js/webgl-heatmap-leaflet.js"></script>
<script src="../bower_components/Leaflet.utfgrid/dist/leaflet.utfgrid.js"></script>
<script src="../bower_components/Leaflet.label/dist/leaflet.label.js"></script>
<script src="../bower_components/leaflet-plugins/layer/tile/Bing.js"></script>
<script src="../bower_components/leaflet.draw/dist/leaflet.draw.js"></script>
<script src="../bower_components/leaflet-plugins/layer/Marker.Rotate.js"></script>
<script src="../bower_components/leaflet.markercluster/dist/leaflet.markercluster.js"></script>
<script src="../bower_components/Leaflet.PolylineDecorator/leaflet.polylineDecorator.min.js"></script>
<script src="../bower_components/Leaflet.awesome-markers/dist/leaflet.awesome-markers.js"></script>
<script src="../bower_components/Leaflet.MakiMarkers/Leaflet.MakiMarkers.js"></script>
<script src="../bower_components/Leaflet.ExtraMarkers/src/leaflet.extra-markers.js"></script>

<script src="../bower_components/jquery/dist/jquery.min.js"></script>

<script src="../bower_components/prism/prism.js"></script>
<script src="../bower_components/semantic-ui/dist/semantic.min.js"></script>
<script src="../bower_components/angular/angular.min.js"></script>
<script src="../bower_components/angular-route/angular-route.min.js"></script>
<script src="../dist/angular-leaflet-directive.min.js"></script>
<script src="js/viewer.js"></script>
<script src="js/controllers.js"></script>
</head>

<body ng-app="webapp" ng-controller="MainController">
<div class="ui divided equal height padded grid leftside">
<div class="seven wide middle column">
<a class="ui right floated blue launch button" href="http://github.com/tombatossals/angular-leaflet-directive">
<i class="social github icon"></i> Github
</a>

<h2 class="ui header"><a href="http://tombatossals.github.io/angular-leaflet-directive">angular-leaflet-directive</a></h2>
<div class="ui tabular filter menu">
<a class="item" ng-repeat="s in sections" ng-class="{ active: s.active }" ng-click="setActiveSection(s.id)" ng-bind="s.name"></a>
</div>
<div class="ui selection list">
<a class="item" ng-class="{ active: example.id === e.id }" ng-href="#{{ e.id }}" ng-repeat="e in getExamplesFromActiveSection()">
<i class="map marker icon"></i>
<div class="content">
<div ng-bind="($index +1) + '. ' + e.title"></div>
</div>
</a>
</div>
</div>
<div class="nine wide right column rightside">
<ng-view></ng-view>
</div>
</div>
</body>

</html>
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
<link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" />
<script>
var app = angular.module("demoapp", ['leaflet-directive']);
app.controller("DemoController", [ "$scope", function($scope) {
app.controller("BasicFirstController", [ "$scope", function($scope) {
// Nothing here!
}]);
</script>
</head>
<body ng-controller="DemoController">
<leaflet width="640px" height="480px"></leaflet>

<body ng-controller="BasicFirstController">
<leaflet width="100%" height="480px"></leaflet>
<h1>First steps, basic example</h1>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" />
<script>
var app = angular.module('demoapp', ['leaflet-directive']);
app.controller('DemoController', [ '$scope', function($scope) {
app.controller('BasicCenterController', [ '$scope', function($scope) {
angular.extend($scope, {
london: {
lat: 51.505,
Expand All @@ -24,13 +24,13 @@
}
</style>
</head>
<body ng-controller="DemoController">
<h1>Center map example</h1>
<form>
Latitude : <input type="number" step="any" ng-model="london.lat" />
Longitude : <input type="number" step="any" ng-model="london.lng" />
Zoom : <input type="number" step="any" ng-model="london.zoom" />
</form>
<leaflet center="london" width="640" height="400"></leaflet>
<body ng-controller="BasicCenterController">
<leaflet center="london" width="100%" height="480px"></leaflet>
<h1>Center map example</h1>
<ul>
<li><input type="number" step="any" ng-model="london.lat" /> Latitude</li>
<li><input type="number" step="any" ng-model="london.lng" /> Longitude</li>
<li><input type="number" step="any" ng-model="london.zoom" /> Zoom</li>
</ul>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<!DOCTYPE html>
<html ng-app="demoapp">
<head>
<link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" />
<script src="../bower_components/angular/angular.min.js"></script>
<script src="../bower_components/angular-route/angular-route.min.js"></script>
<script src="../bower_components/leaflet/dist/leaflet.js"></script>
<script src="../dist/angular-leaflet-directive.min.js"></script>
<link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" />
<meta charset="UTF-8">
<script>
var app = angular.module('demoapp', ['leaflet-directive']);
app.controller('DemoController', [ '$scope', function($scope) {
app.controller('BasicCenterAutodiscoverController', [ '$scope', function($scope) {
angular.extend($scope, {
center: {
autoDiscover: true
Expand All @@ -24,14 +22,16 @@
}
</style>
</head>
<body ng-controller="DemoController">
<body ng-controller="BasicCenterAutodiscoverController">
<leaflet center="center" width="100%" height="480px"></leaflet>
<h1>Center autodiscover example</h1>
<form>
Latitude : <input type="number" step="any" ng-model="center.lat" />
Longitude : <input type="number" step="any" ng-model="center.lng" />
Zoom : <input type="number" step="any" ng-model="center.zoom" />
<button ng-click="center.autoDiscover=true">Discover position</button>
</form>
<leaflet center="center" width="640" height="400"></leaflet>
<ul>
<li><input type="number" step="any" ng-model="center.lat" /> Latitude</li>
<li><input type="number" step="any" ng-model="center.lng" /> Longitude</li>
<li><input type="number" step="any" ng-model="center.zoom" /> Zoom</li>
</ul>

<button ng-click="center.autoDiscover=true">Discover position</button>

</body>
</html>
53 changes: 53 additions & 0 deletions examples/0103-basic-center-url-hash-example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html ng-app="demoapp">
<head>
<script src="../bower_components/angular/angular.min.js"></script>
<script src="../bower_components/leaflet/dist/leaflet.js"></script>
<script src="../dist/angular-leaflet-directive.min.js"></script>
<link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" />
<script>
var app = angular.module('demoapp', ['leaflet-directive']);
app.controller('BasicCenterUrlHashController', [ '$scope', '$location', function($scope, $location) {
angular.extend($scope, {
london: {
lat: 51.505,
lng: -0.09,
zoom: 4
}
});
$scope.$on("centerUrlHash", function(event, centerHash) {
console.log("url", centerHash);
$location.search({ c: centerHash });
});

$scope.changeLocation = function(centerHash) {
$location.search({ c: centerHash });
}

}]);
</script>
<style>
input {
width: 120px;
margin-right: 10px;
}
</style>
</head>
<body ng-controller="BasicCenterUrlHashController">
<leaflet center="london" url-hash-center="yes" width="100%" height="480px"></leaflet>
<h1>Center map with URL synchronization example</h1>
<p>This demo syncs the map center position with the URL, and viceversa, using the <strong>center-url-params</strong> property.</p>
<ul>
<li><input type="number" step="any" ng-model="london.lat" /> Latitude</li>
<li><input type="number" step="any" ng-model="london.lng" /> Longitude</li>
<li><input type="number" step="any" ng-model="london.zoom" /> Zoom</li>
</ul>
<h2>Direct locations</h2>
<ul>
<li><a href="" ng-click="changeLocation('36.8899:-121.8008:12')">Watsonville</a>
<li><a href="" ng-click="changeLocation('34.0078:-118.8060:14')">Malibu</a>
<li><a href="" ng-click="changeLocation('33.7717:-117.9458:12')">Garden Grove</a>
<li><a href="" ng-click="changeLocation('32.5290:-117.0442:13')">Tijuana</a>
</ul>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" />
<script>
var app = angular.module("demoapp", ["leaflet-directive"]);
app.controller('DemoController', [ '$scope', function($scope) {
app.controller('BasicCustomParametersController', [ '$scope', function($scope) {
angular.extend($scope, {
london: {
lat: 51.505,
Expand All @@ -27,14 +27,9 @@
});
}]);
</script>
<style>
.angular-leaflet-map {
width: 640px;
height: 400px;
}
</style>
</head>
<body ng-controller="DemoController">
<leaflet center="london" defaults="defaults"></leaflet>
<body ng-controller="BasicCustomParametersController">
<leaflet center="london" defaults="defaults" width="100%" height="480px"></leaflet>
<h1>Using custom default parameters</h1>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" />
<script>
var app = angular.module("demoapp", ["leaflet-directive"]);
app.controller("DemoController", [ "$scope", "leafletData", "leafletBoundsHelpers", function($scope, leafletData, leafletBoundsHelpers) {
app.controller("BasicBoundsController", [ "$scope", "leafletData", "leafletBoundsHelpers", function($scope, leafletData, leafletBoundsHelpers) {

var bounds = leafletBoundsHelpers.createBoundsFromArray([
[ 51.508742458803326, -0.087890625 ],
Expand All @@ -22,14 +22,9 @@

}]);
</script>
<style>
input {
width: 120px;
margin-right: 10px;
}
</style>
</head>
<body ng-controller="DemoController">
<body ng-controller="BasicBoundsController">
<leaflet bounds="bounds" center="center" width="100%" height="480px"></leaflet>
<h1>Map bounds example</h1>
<h2>South west</h2>
<form>
Expand All @@ -42,6 +37,5 @@ <h2>North east</h2>
Lat : <input type="number" step="any" ng-model="bounds.northEast.lat" />
Lng : <input type="number" step="any" ng-model="bounds.northEast.lng" />
</form>
<leaflet bounds="bounds" center="center" width="640" height="400"></leaflet>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" />
<script>
var app = angular.module("demoapp", ["leaflet-directive"]);
app.controller("DemoController", [ "$scope", "leafletData", function($scope, leafletData) {
app.controller("BasicMaxBoundsController", [ "$scope", "leafletData", function($scope, leafletData) {
$scope.regions = {
london: {
northEast: {
Expand Down Expand Up @@ -42,27 +42,23 @@
};

angular.extend($scope, {
maxbounds: {}
maxbounds: $scope.regions.london
});

} ]);
</script>
<style>
.angular-leaflet-map {
width: 640px;
height: 400px;
}
</style>
</head>
<body ng-controller="DemoController">
<body ng-controller="BasicMaxBoundsController">
<leaflet maxbounds="maxbounds" width="100%" height="480px"></leaflet>
<h1>Setting MaxBounds in a map</h1>
<p>With <strong>maxbounds</strong> the map visualization is limited to a defined zone. Try to pan on these regions to see how it works.</p>
<form>
<button ng-click="maxbounds=regions.london">London region</button>
<button ng-click="maxbounds=regions.lisbon">Lisbon region</button>
<button ng-click="maxbounds=regions.warszawa">Warszawa region</button>
<button ng-click="maxbounds={}">Unset maxbounds</button>
</form>

<leaflet maxbounds="maxbounds"></leaflet>
<p ng-show="maxbounds.northEast" class="result">Maxbounds: NE(lat: {{ maxbounds.northEast.lat }}, lng: {{ maxbounds.northEast.lng }}) SW(lat: {{ maxbounds.southWest.lat }}, lng: {{ maxbounds.southWest.lng }})</p>
</body>
</html>
Loading