This repository has been archived by the owner on Sep 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(examples): Added the tiles-zoom-changer example by @yagoferrer a…
…s an standalone example. http://tombatossals.github.io/angular-leaflet-directive/examples/tiles-zoom-changer-example.html Added the e2e tests for the tiles attribute too. Discussed here: tombatossals/angular-leaflet-directive#224
- Loading branch information
1 parent
8446fd7
commit 8abe8b4
Showing
4 changed files
with
137 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<!DOCTYPE html> | ||
<html ng-app="demoapp"> | ||
<head> | ||
<script src="http://cdn.leafletjs.com/leaflet-0.7.1/leaflet.js"></script> | ||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script> | ||
<script src="../dist/angular-leaflet-directive.min.js"></script> | ||
|
||
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"> | ||
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.1/leaflet.css" /> | ||
<script> | ||
var app = angular.module("demoapp", ["leaflet-directive"]); | ||
app.controller('DemoZoomLevelController', [ "$scope", function($scope) { | ||
|
||
angular.extend($scope, { | ||
london: { | ||
lat: 51.505, | ||
lng: -0.09, | ||
zoom: 10 | ||
}, | ||
tiles: { | ||
url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" | ||
|
||
} | ||
}); | ||
|
||
$scope.$watch("london.zoom", function(zoom) { | ||
$scope.tiles.url = (zoom > 12) | ||
? "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" | ||
: "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"; | ||
}); | ||
} ]); | ||
</script> | ||
<style> | ||
.angular-leaflet-map { | ||
width: 640px; | ||
height: 400px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<div ng-controller="DemoZoomLevelController"> | ||
|
||
<div class="row"> | ||
<h2>This is a map with dynamic tile change depending on zoom level</h2> | ||
</div> | ||
|
||
<div class="row"> | ||
<p>Current TileLayer Url: {{ tiles.url }}</p> | ||
<p>Current Zoom Level: {{ london.zoom }}</p> | ||
</div> | ||
|
||
<div class="row"> | ||
<leaflet center="london" tiles="tiles"></leaflet> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</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,23 @@ | ||
'use strict'; | ||
|
||
describe('Loading tiles-example.html', function() { | ||
|
||
var ptor, driver; | ||
beforeEach(function() { | ||
ptor = protractor.getInstance(); | ||
browser.get('tiles-example.html'); | ||
driver = ptor.driver; | ||
}); | ||
|
||
it('should update the map tiles if clicked on the tiles changer buttons', function() { | ||
ptor.wait(function() { | ||
return ptor.isElementPresent(by.css('img.leaflet-tile-loaded')); | ||
}); | ||
|
||
expect(ptor.isElementPresent(by.xpath('//img[contains(@src, "http://b.tile.opencyclemap.org")]'))).toBe(true); | ||
|
||
element(by.xpath('//button[text()="OpenStreetMaps"]')).click().then(function() { | ||
expect(ptor.isElementPresent(by.xpath('//img[contains(@src, "http://b.tile.openstreetmap.org")]'))).toBe(true); | ||
}); | ||
}); | ||
}); |
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,34 @@ | ||
'use strict'; | ||
|
||
describe('Loading tiles-zoom-changer-example.html', function() { | ||
|
||
var ptor, driver; | ||
beforeEach(function() { | ||
ptor = protractor.getInstance(); | ||
browser.get('tiles-zoom-changer-example.html'); | ||
driver = ptor.driver; | ||
}); | ||
|
||
it('should update the map tiles if zoom in the map', function() { | ||
ptor.wait(function() { | ||
return ptor.isElementPresent(by.css('img.leaflet-tile-loaded')); | ||
}); | ||
|
||
expect(ptor.isElementPresent(by.xpath('//img[contains(@src, "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/")]'))).toBe(true); | ||
var zoomin = element(by.xpath('.//*[@title="Zoom in"]')); | ||
|
||
zoomin.click().then(function() { | ||
ptor.sleep(300); | ||
zoomin.click().then(function() { | ||
ptor.sleep(300); | ||
zoomin.click().then(function() { | ||
ptor.wait(function() { | ||
return ptor.isElementPresent(by.xpath('//img[contains(@src, "http://a.tile.openstreetmap.org/")]')); | ||
}); | ||
|
||
expect(ptor.isElementPresent(by.xpath('//img[contains(@src, "http://a.tile.openstreetmap.org/")]'))).toBe(true); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |