Skip to content

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
meetar committed Sep 26, 2015
1 parent 8fdfee9 commit b4667b7
Show file tree
Hide file tree
Showing 14 changed files with 1,042 additions and 1 deletion.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Mapzen

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
# bendy-map
A bit Inception, and bit Here&There.

A map made with [Tangram](http://github.com/tangrams/tangram).

Live demo: http://meetar.github.io/bendy-map

### To run locally:

Start a web server in the repo's directory:

python -m SimpleHTTPServer 8000

If that doesn't work, try:

python -m http.server 8000

Then navigate to: [http://localhost:8000](http://localhost:8000)
65 changes: 65 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<!doctype html>
<!--
Tangram: real-time WebGL rendering for OpenStreetMap
http://github.com/tangrams/tangram
http://mapzen.com
-->
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Tangram</title>

<link rel="stylesheet" href="lib/leaflet/leaflet.css" />

<style>
body {
margin: 0px;
border: 0px;
padding: 0px;
}

#map {
background: rgba(0, 0, 0, 0);
height: 100%;
width: 100%;
position: absolute;
}
</style>
</head>

<body>
<div id="map"></div>

<!-- 3rd party libraries -->
<script src="lib/leaflet/leaflet.js"></script>
<!-- bog-standard leaflet URL hash -->
<script src="lib/leaflet-hash.js"></script>
<!-- End of 3rd party libraries -->

<!-- Main tangram library -->
<script src="https://mapzen.com/tangram/tangram.min.js"></script>

<!-- Demo module -->
<script src="main.js"></script>

<!-- Adding a script block to post message to the parent container (think iframed demos) -->
<script type="text/javascript">
window.addEventListener("hashchange",function(){parent.postMessage(window.location.hash, "*")});
</script>

<!-- Mapzen map UI -->
<script src='//s3.amazonaws.com/assets-staging.mapzen.com/ui/mapzen-ui.min.js'></script>
<script>
MPZN.bug({
name: 'Tangram',
link: 'https://mapzen.com/projects/tangram',
tweet: 'Inception map made with @Tangramjs from @mapzen',
repo: 'https://github.com/meetar/bendy-map/'
});
</script>

</body>
</html>
82 changes: 82 additions & 0 deletions lib/dat.gui.min.js

Large diffs are not rendered by default.

124 changes: 124 additions & 0 deletions lib/leaflet-hash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
(function(window) {

L.Hash = function(map) {

if (map) {
this.init(map);
}
};

L.Hash.parseHash = function(hash) {
if(hash.indexOf('#') === 0) {
hash = hash.substr(1);
}
var args = hash.split("/");
if (args.length == 3) {
var zoom = parseInt(args[0], 10),
lat = parseFloat(args[1]),
lon = parseFloat(args[2]);
if (isNaN(zoom) || isNaN(lat) || isNaN(lon)) {
return false;
} else {
return {
center: new L.LatLng(lat, lon),
zoom: zoom
};
}
} else {
return false;
}
};

L.Hash.formatHash = function(map) {
var center = map.getCenter(),
zoom = map.getZoom(),
precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));

// cap zoom at 5 digits for beauty
return "#" + [parseFloat(zoom.toFixed(5)),
center.lat.toFixed(precision),
center.lng.toFixed(precision)
].join("/");
},

L.Hash.prototype = {
map: null,
lastHash: null,

parseHash: L.Hash.parseHash,
formatHash: L.Hash.formatHash,

init: function(map) {
this.map = map;

// reset the hash
this.lastHash = null;

if (!this.isListening) {
this.startListening();
}
},

removeFrom: function(map) {
if (this.changeTimeout) {
clearTimeout(this.changeTimeout);
}

if (this.isListening) {
this.stopListening();
}

this.map = null;
},

// defer hash change updates every changeDefer milliseconds
changeDefer: 250,
changeTimeout: null,
onMapMove: function() {
// bail if we're moving the map (updating from a hash),
// or if the map is not yet loaded
if (this.movingMap || !this.map._loaded) {
return false;
}

var hash = this.formatHash(this.map);
if (this.lastHash != hash) {
this.lastHash = hash;
}
if (!this.changeTimeout) {
var that = this;
this.changeTimeout = setTimeout(function() {

// update the hash
window.location.replace(hash);

that.changeTimeout = null;
}, this.changeDefer);
}
},

movingMap: false,

isListening: false,
startListening: function() {
this.map.on("moveend", this.onMapMove, this);

this.isListening = true;
},

stopListening: function() {
this.map.off("moveend", this.onMapMove, this);

this.isListening = false;
}
};
L.hash = function(map) {
return new L.Hash(map);
};
L.Map.prototype.addHash = function() {
this._hash = L.hash(this);
};
L.Map.prototype.removeHash = function() {
this._hash.removeFrom();
};
})(window);
Binary file added lib/leaflet/images/layers-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/leaflet/images/layers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/leaflet/images/marker-icon-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/leaflet/images/marker-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/leaflet/images/marker-shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b4667b7

Please sign in to comment.