Skip to content

Commit

Permalink
Merge pull request #15 from tanis2000/master
Browse files Browse the repository at this point in the history
Added player position to map
  • Loading branch information
bettse committed Jul 15, 2016
2 parents 07f298b + 060609d commit b5c8a9b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
*.pyc
*.swp
player.json
18 changes: 18 additions & 0 deletions decode.py
Expand Up @@ -155,6 +155,24 @@ def request(context, flow):
except:
print("Missing Request API: %s" % name)

if (key == GET_MAP_OBJECTS):
features = []
props = {
"id": "player",
"marker-symbol": "pitch",
"title": "You",
"marker-size": "large",
"marker-color": "663399",
"type": "player"
}
p = Point((mor.PlayerLng, mor.PlayerLat))
f = Feature(geometry=p, id="player", properties=props)
features.append(f)
fc = FeatureCollection(features)
dump = geojson.dumps(fc, sort_keys=True)
f = open('ui/player.json', 'w')
f.write(dump)

def response(context, flow):
with decoded(flow.response):
if flow.match("~d pgorelease.nianticlabs.com"):
Expand Down
1 change: 1 addition & 0 deletions ui/index.html
Expand Up @@ -32,6 +32,7 @@
<div><input type=checkbox id='wild' checked=true/><label for='wild'>Wild Pokemon</label></div>
<div><input type=checkbox id='catchable' checked=true/><label for='catchable'>Catchable Pokemon</label></div>
<div><input type=checkbox id='nearby' checked=true/><label for='nearby'>Nearby Pokemon</label></div>
<div><input type=checkbox id='player' checked=true/><label for='player'>Player</label></div>

</nav>
<div id='map'></div>
Expand Down
20 changes: 20 additions & 0 deletions ui/index.js
Expand Up @@ -7,6 +7,7 @@ L.tileLayer.provider('OpenStreetMap.Mapnik', {retina: true}).addTo(map);
var filters = document.getElementById('filters');
filters.onclick = function() {
realtime.update();
player.update();
};
var realtime = L.realtime({url: 'get_map_objects.json', type: 'json'}, {
interval: 10 * 1000,
Expand Down Expand Up @@ -34,6 +35,25 @@ realtime.on('update', function(updateEvent) {
}
});


var player = L.realtime({url: 'player.json', type: 'json'}, {
interval: 10 * 1000,
style: function(feature) { return feature.properties; },
pointToLayer: simplestyle,

filter: function(feature) {
if (!loaded) {
return true;
}
var box = document.getElementById(feature.properties.type);
return box == null || box.checked;
},
onEachFeature: function (feature, layer) {
layer.bindPopup(feature.properties.title);
}
}).addTo(map);


//https://gist.github.com/tmcw/3861338
function simplestyle(f, latlon) {
var sizes = {
Expand Down

0 comments on commit b5c8a9b

Please sign in to comment.