Skip to content

Commit

Permalink
Merge pull request #50 from mejackreed/add-example-by-url
Browse files Browse the repository at this point in the history
add an embedable version
  • Loading branch information
mejackreed authored Oct 14, 2016
2 parents 086d702 + 476f755 commit a6128f6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
15 changes: 15 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="//cdn.leafletjs.com/leaflet-0.7.5/leaflet.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<script src="//cdn.leafletjs.com/leaflet-0.7.5/leaflet.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="../leaflet-iiif.js"></script>
</head>
<body>
<div id="map">
</div>
<script src="index.js"></script>
</body>
</html>
16 changes: 16 additions & 0 deletions examples/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var map;

map = L.map('map', {
center: [0, 0],
crs: L.CRS.Simple,
zoom: 0
});

var url = window.location.search.replace('?url=', '')

// http://stackoverflow.com/a/18222306
var urlregex = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/;

if (urlregex.test(url)) {
layer = L.tileLayer.iiif(url, {}).addTo(map);
}

0 comments on commit a6128f6

Please sign in to comment.