#Create your own map with OpenStreetMap
This is some note of me playing with OpenStreetMap and creating an Android app that renders the map drawn.
##Draw a map
###Get GPS trace
If you want to draw your own map, OpenStreetMap
<!doctype html> | |
<style> | |
.trail { /* className for the trail elements */ | |
position: absolute; | |
height: 6px; width: 6px; | |
border-radius: 3px; | |
background: teal; | |
} | |
body { |
var playerSprites = document.createElement("img"); | |
var extraCanvas = document.createElement("canvas"); | |
var extraCx = extraCanvas.getContext("2d"); | |
playerSprites.src = "img/player.png"; | |
playerSprites.addEventListener("load", function(event) { | |
var width = playerSprites.width; | |
var height = playerSprites.height; | |
extraCx.scale(-1, 1); | |
extraCx.translate(-width, 0); |
//Ref: | |
//https://developers.google.com/web/fundamentals/getting-started/primers/promises | |
function requestAuthor(type) { | |
return new Promise(function(resolve, reject) { | |
var req = new XMLHttpRequest(); | |
req.open("GET", "http://eloquentjavascript.net/author", true); | |
req.setRequestHeader("accept", type); | |
req.onload = function() { | |
if(req.status == 200) { |
function all(promises) { | |
return new Promise(function(success, fail) { | |
// Your code here. | |
function promiseThen(i) { | |
return promises[i].then(function(res) { | |
//we should return the res here. | |
//push into results here won't work, since | |
//promises here settles at different time | |
//and elements in results will be out of order. | |
return res; |
//http://www.geeksforgeeks.org/sorted-array-to-balanced-bst/ | |
//is the better solution(return created node, instead of a separated | |
//insert operation). | |
//Note here int mid = (int)Math.floor(n / 2); is used to get the middle | |
//node instead of int mid = (start + end) / 2;, resulting right middle | |
//node is selected when there is even number of nodes in the array. | |
import java.util.*; | |
import java.lang.*; | |
import java.io.*; |
#Create your own map with OpenStreetMap
This is some note of me playing with OpenStreetMap and creating an Android app that renders the map drawn.
##Draw a map
###Get GPS trace
If you want to draw your own map, OpenStreetMap