Skip to content

Commit

Permalink
basic file structure
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmtech committed Mar 8, 2017
1 parent 17955f2 commit 126fd27
Show file tree
Hide file tree
Showing 294 changed files with 3,824 additions and 1,073 deletions.
6 changes: 6 additions & 0 deletions demos/browser/basic/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

function startDemo() {
var browser = Melown.MapBrowser("map-div", {
map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json"
});
}
14 changes: 14 additions & 0 deletions demos/browser/basic/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<head>
<title>Vadstena Map Viewer</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../../build/melown-v1.css" />
<script type="text/javascript" src="../../build/melown-v1.js"></script>
<script type="text/javascript" src="./demo.js"></script>
</head>

<body style = "padding: 0; margin: 0;" onload="startDemo()">
<div id="map-div" style="width:100%; height:100%;">
</div>
</body>
</html>
File renamed without changes
38 changes: 38 additions & 0 deletions demos/browser/flights/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

var browser = null;
var ui = null;
var list = null;

function startDemo() {
browser = Melown.MapBrowser("map-div", {
map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json",
position : [ "obj", 1683559, 6604129, "float", 0, -13, -58, 0, 3764, 90 ]
});

ui = browser.getUI();
var panel = ui.addControl("destination-panel",
'<form id="panel">' +
'<input type="radio" name="destination" value="a"> Destination A<br>' +
'<input type="radio" name="destination" value="b"> Destination B<br>' +
'<input type="radio" name="destination" value="c"> Destination C' +
'</form>');

list = panel.getElement("panel");
list.on("change", onFlyToNewDestination);
}

function onFlyToNewDestination() {
switch (list.getElement().elements["destination"].value) {
case "a":
browser.flyTo([ "obj", 1683559, 6604129, "float", 0, -13, -58, 0, 1764, 90 ]);
break;

case "b":
browser.flyTo([ "obj", 1679084, 6607401, "float", 0, -17, -57, 0, 1158, 90 ]);
break;

case "c":
browser.flyTo([ "obj", 1694920, 6608430, "float", 0, -24, -76, 0, 2049, 90 ]);
break;
}
}
29 changes: 29 additions & 0 deletions demos/browser/flights/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<html>
<head>
<title>Vadstena Map Viewer</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../../build/melown-v1.css" />
<script type="text/javascript" src="../../build/melown-v1.js"></script>
<script type="text/javascript" src="./demo.js"></script>


<style>
#panel {
font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
position: absolute;
right: 30px;
bottom: 30px;
background-color: #eee;
padding: 10px 20px;
border-radius: 5px;
border: solid 1px #000;
}
</style>

</head>

<body style = "padding: 0; margin: 0;" onload="startDemo()">
<div id="map-div" style="width:100%; height:100%;">
</div>
</body>
</html>
Binary file added demos/browser/flights/skydome.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions demos/browser/hit-surface/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@

var browser = null;
var pointTexture = null;
var clickCoords = null;

function startDemo() {
browser = Melown.MapBrowser("map-div", {
map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json",
position : [ "obj", 1683559, 6604129, "float", 0, -13, -58, 0, 964, 90 ]
});

//callback once is map config loaded
browser.on("map-loaded", onMapLoaded);

//add mouse down callback
browser.getMapElement().on('mousedown', onMouseDown);

loadTexture();
}

function loadTexture() {
//load icon used for displaing hit point
var pointImage = Melown.Http.imageFactory(
"http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png",
(function(){
pointTexture = browser.getRenderer().createTexture({ "source": pointImage });
}).bind(this)
);
}


function onMapLoaded() {
//add render slots
//render slots are called during map render
browser.addRenderSlot("custom-points", onDrawPoints, true);
browser.moveRenderSlotAfter("after-map-render", "custom-points");
}

function onMouseDown(event) {
if (event.getMouseButton() == "left") {
var coords = event.getMouseCoords();

//get hit coords with fixed height
clickCoords = browser.getHitCoords(coords[0], coords[1], "fixed");

//force map redraw to display hit point
browser.redraw();
}
}

function onDrawPoints(renderChannel) {
if (renderChannel == "hit") {
return; //do render points in to the hit texture
}

if (clickCoords) { //draw hit point
var renderer = browser.getRenderer();

//conver hit coords to canvas coords
coords = browser.convertCoordsFromNavToCanvas(clickCoords, "fixed");

renderer.drawImage({
"rect" : [coords[0]-12, coords[1]-12, 24, 24],
"texture" : pointTexture,
"color" : [255,0,0,255],
"depth" : coords[2],
"depth-test" : false,
"blend" : true
});
}
};



14 changes: 14 additions & 0 deletions demos/browser/hit-surface/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<head>
<title>Vadstena Map Viewer</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../../build/melown-v1.css" />
<script type="text/javascript" src="../../build/melown-v1.js"></script>
<script type="text/javascript" src="./demo.js"></script>
</head>

<body style = "padding: 0; margin: 0;" onload="startDemo()">
<div id="map-div" style="width:100%; height:100%;">
</div>
</body>
</html>
Binary file added demos/browser/hit-surface/skydome.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions demos/browser/lines-and-images/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

var browser = null;

function startDemo() {
browser = Melown.MapBrowser("map-div", {
map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json",
position : [ "obj", 1683559, 6604129, "float", 0, -13, -58, 0, 1764, 90 ]
});

browser.on("map-loaded", onMapLoaded);
loadImage();
}

var demoTexture = null;

function loadImage() {
var demoImage = Melown.Http.imageFactory(
"http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png",
(function(){
demoTexture = browser.getRenderer().createTexture({ "source": demoImage });
}));
}

function onMapLoaded() {
browser.addRenderSlot("custom-render", onCustomRender, true);
browser.moveRenderSlotAfter("after-map-render", "map");
};

function onCustomRender() {
if (demoTexture) {
var renderer = browser.getRenderer();
var coords = browser.convertCoordsFromNavToCanvas([1683559, 6604129, 0], "float");

var totalPoints = 32;
var points = new Array(totalPoints);
var p = [1683559, 6604129, 0];
var scale = [400, 100];

for (var i = 0; i < totalPoints; i++) {
points[i] = browser.convertCoordsFromNavToCanvas(
[p[0] + (i / totalPoints) * scale[0],
p[1] + Math.sin(2 * Math.PI * (i / totalPoints)) * scale[1],
p[2]], "float");
}

renderer.drawLineString({
"points" : points,
"size" : 2.0,
"color" : [255,0,255,255],
"depth-test" : false,
"blend" : false
});


renderer.drawImage({
"rect" : [coords[0]-12, coords[1]-12, 24, 24],
"texture" : demoTexture,
"color" : [255,0,255,255],
"depth" : coords[2],
"depth-test" : false,
"blend" : true
});

}
}



14 changes: 14 additions & 0 deletions demos/browser/lines-and-images/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<head>
<title>Vadstena Map Viewer</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../../build/melown-v1.css" />
<script type="text/javascript" src="../../build/melown-v1.js"></script>
<script type="text/javascript" src="./demo.js"></script>
</head>

<body style = "padding: 0; margin: 0;" onload="startDemo()">
<div id="map-div" style="width:100%; height:100%;">
</div>
</body>
</html>
Binary file added demos/browser/lines-and-images/skydome.jpg
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 126fd27

Please sign in to comment.