diff options
| author | Code WvS <code-wvs@quantentunnel.de> | 2015-02-08 15:24:05 +0100 |
|---|---|---|
| committer | Code WvS <code-wvs@quantentunnel.de> | 2015-02-08 15:24:05 +0100 |
| commit | c71147a2fccf5d6ebd8a1eabd41e10b134248070 (patch) | |
| tree | 225bed731052a5884bfe3bc3e2d5790997e26c22 | |
| parent | 79437a6ab81112438373a6010030ef504ffd5deb (diff) | |
| download | snap-yow-c71147a2fccf5d6ebd8a1eabd41e10b134248070.tar.gz snap-yow-c71147a2fccf5d6ebd8a1eabd41e10b134248070.zip | |
improve initial world loading; prepare conversion of sprites to "persons"
| -rw-r--r-- | objects.js | 20 | ||||
| -rwxr-xr-x | snap.html | 40 |
2 files changed, 42 insertions, 18 deletions
@@ -215,6 +215,7 @@ SpriteMorph.prototype.initBlocks = function () { defaults: [null, 12] }, addMarker: { + dev: true, type: 'command', category: 'map', spec: 'add a marker to %l' @@ -1358,6 +1359,16 @@ SpriteMorph.prototype.init = function (globals) { this.isDraggable = true; this.isDown = false; + // Snap! - YOW code + this.icon = L.icon({ + iconUrl: 'images/marker-icon.png', + iconRetinaUrl: 'images/marker-icon-2x.png', + shadowUrl: 'images/marker-shadow.png' + }); + this.geoposition = window.map.getCenter(); + this.marker = L.marker(this.geoposition, {icon: this.icon, title: this.name}); + this.marker.addTo(window.map); + this.heading = 90; this.changed(); this.drawNew(); @@ -1724,7 +1735,10 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push(block('reportLocation')); blocks.push(block('focusMap')); - blocks.push(block('addMarker')); + + //if (this.world().isDevMode) { + blocks.push(block('addMarker')); + //} } /* else if (cat === 'motion') { @@ -4910,7 +4924,9 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push(block('reportLocation')); blocks.push(block('focusMap')); - blocks.push(block('addMarker')); + if (this.world().isDevMode) { + blocks.push(block('addMarker')); + } } /* else if (cat === 'motion') { @@ -21,35 +21,43 @@ <script type="text/javascript" src="locale.js"></script> <script type="text/javascript" src="cloud.js"></script> <script type="text/javascript" src="sha512.js"></script> - <script type="text/javascript"> - var world; - window.onload = function () { - world = new WorldMorph(document.getElementById('world')); - world.worldCanvas.focus(); - new IDE_Morph().openIn(world); - setInterval(loop, 10); - }; - function loop() { - world.doOneCycle(); - } - </script> </head> <body style="margin: 0;"> <canvas id="world" tabindex="1" style="position: absolute;"></canvas> <div id="map" style="position: absolute; width: 480px; height: 360px;" /> <!-- set initial size to 480x360 or the map will not load properly --> <script type="text/javascript"> - var map, layer; + var world, map, layer; + + function loop() { + world.doOneCycle(); + } + + function setGlobalPosition (e) { + window.geoposition = e.latlng; + } + + function startYOW (e) { + map.on('locationfound', setGlobalPosition); + map.locate({watch: true, enableHighAccuracy: true}); + + new OSMBuildings(map).load(); + + world = new WorldMorph(document.getElementById('world')); + world.worldCanvas.focus(); + new IDE_Morph().openIn(world); + setInterval(loop, 10); + } + window.map = map; window.layer = layer; map = L.map('map'); - map.locate({setView: true, maxZoom: 16}); + map.on('locationfound', startYOW); + map.locate({setView: true}); layer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' }).addTo(map); - - new OSMBuildings(map).load(); </script> </body> </html> |
