Skip to content

Commit

Permalink
avoid protype conflicts with other libs
Browse files Browse the repository at this point in the history
  • Loading branch information
ianjennings committed May 7, 2016
1 parent 1aea245 commit 447fd56
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 19 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eon-map",
"version": "0.2.10",
"version": "0.2.11",
"homepage": "https://github.com/pubnub/eon-map",
"authors": [
"Ian Jennings <ian@meetjennings.com>"
Expand Down
4 changes: 2 additions & 2 deletions examples/custom_keys.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
}
</style>

<script type="text/javascript" src="http://pubnub.github.io/eon/v/eon/0.0.9/eon.js"></script>
<link type="text/css" rel="stylesheet" href="http://pubnub.github.io/eon/v/eon/0.0.9/eon.css"/>
<script type="text/javascript" src="http://pubnub.github.io/eon/v/eon/0.0.10/eon.js"></script>
<link type="text/css" rel="stylesheet" href="http://pubnub.github.io/eon/v/eon/0.0.10/eon.css"/>

</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions examples/distributed.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
}
</style>

<script type="text/javascript" src="http://pubnub.github.io/eon/v/eon/0.0.9/eon.js"></script>
<link type="text/css" rel="stylesheet" href="http://pubnub.github.io/eon/v/eon/0.0.9/eon.css"/>
<script type="text/javascript" src="http://pubnub.github.io/eon/v/eon/0.0.10/eon.js"></script>
<link type="text/css" rel="stylesheet" href="http://pubnub.github.io/eon/v/eon/0.0.10/eon.css"/>

</head>
<body>
Expand Down
81 changes: 81 additions & 0 deletions examples/local_files.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>EON Maps</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<style>
body {
margin: 0;
padding: 0;
}
#map {
position:absolute;
top:0;
bottom:0;
width:100%;
}
</style>

<script type="text/javascript" src="../bower_components/pubnub/web/pubnub.min.js"></script>
<script type="text/javascript" src="../bower_components/subsub/subsub.js"></script>
<script type="text/javascript" src="../lib/pubnub-mapbox.js"></script>
<script type="text/javascript" src="../pubnub-mapbox.js"></script>

<link type="text/css" rel="stylesheet" href="http://pubnub.github.io/eon/v/eon/0.0.10/eon.css"/>

</head>
<body>
<div id='map'></div>
<script>
function getNonZeroRandomNumber(){
var random = Math.floor(Math.random()*199) - 99;
if(random==0) return getNonZeroRandomNumber();
return random;
}
</script>
<script>
var channel = 'pubnub-mapbox' + getNonZeroRandomNumber();

eon.map({
id: 'map',
mb_token: 'pk.eyJ1IjoiaWFuamVubmluZ3MiLCJhIjoiZExwb0p5WSJ9.XLi48h-NOyJOCJuu1-h-Jg',
mb_id: 'ianjennings.l896mh2e',
channel: channel,
connect: connect,
options: {
zoomAnimation: false,
},
});

function connect() {

var point = {
latlng: [37.370375, -97.756138]
};

var pn = PUBNUB.init({
publish_key: 'demo'
});

setInterval(function(){

var new_point = JSON.parse(JSON.stringify(point));

new_point.latlng = [
new_point.latlng[0] + (getNonZeroRandomNumber() * 0.1),
new_point.latlng[1] + (getNonZeroRandomNumber() * 0.2)
];

pn.publish({
channel: channel,
message: [new_point]
});

}, 1000);

};

</script>
</body>
</html>
10 changes: 8 additions & 2 deletions examples/transform.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@
}
</style>

<script type="text/javascript" src="http://pubnub.github.io/eon/v/eon/0.0.9/eon.js"></script>
<link type="text/css" rel="stylesheet" href="http://pubnub.github.io/eon/v/eon/0.0.9/eon.css"/>


<script type="text/javascript" src="../bower_components/pubnub/web/pubnub.min.js"></script>
<script type="text/javascript" src="../bower_components/subsub/subsub.js"></script>
<script type="text/javascript" src="../lib/mapbox.js"></script>
<script type="text/javascript" src="../pubnub-mapbox.js"></script>
<link type="text/css" rel="stylesheet" href="http://pubnub.github.io/eon/v/eon/0.0.10/eon.css"/>

</head>
<body>
Expand Down Expand Up @@ -50,6 +55,7 @@
return a;
}
});

</script>
</body>
</html>
28 changes: 16 additions & 12 deletions pubnub-mapbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,26 @@ window.eon.m = {
clog('Markers:', 'Updating');

for(var key in seed) {

if(!self.markers.hasOwnProperty(key)) {

var data = seed[key].data || {};
if(seed.hasOwnProperty(key)) {

self.markers[key]= options.marker(seed[key].latlng, seed[key].data);
self.markers[key].addTo(self.map);
if(!self.markers[key]) {

} else {
var data = seed[key].data || {};

self.markers[key]= options.marker(seed[key].latlng, seed[key].data);
self.markers[key].addTo(self.map);

if(animate) {
clog('Markers:', 'Animating');
self.animate(key, seed[key].latlng);
} else {
clog('Markers:', 'Updating');
self.updateMarker(key, seed[key].latlng);

if(animate) {
clog('Markers:', 'Animating');
self.animate(key, seed[key].latlng);
} else {
clog('Markers:', 'Updating');
self.updateMarker(key, seed[key].latlng);
}

}

}
Expand Down Expand Up @@ -156,7 +160,7 @@ window.eon.m = {

for(var index in self.markers) {

if(typeof self.animations[index] !== 'undefined') {
if(self.markers.hasOwnProperty(index) && typeof self.animations[index] !== 'undefined') {

s.position = self.animations[index].start;

Expand Down

0 comments on commit 447fd56

Please sign in to comment.