-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
52 lines (45 loc) · 1.74 KB
/
script.js
File metadata and controls
52 lines (45 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var data,
response,
httpRequest,
trondheimsfjorden = [63.493641, 10.539794];
map = L.map('map').setView([40.712216,-74.22655], 11);
var imageUrl = 'http://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg',
imageBounds = [[40.712216, -74.22655], [40.773941, -74.12544]];
L.tileLayer('http://{s}.tiles.mapbox.com/v3/kproj6.jgi4fhgo/{z}/{x}/{y}.png', {
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>'
}).addTo(map);
//http request to get JSON
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE 8 and older
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
// function to handle request
httpRequest.onreadystatechange = function(){
if (httpRequest.readyState === 4) {
console.log('the response is received');
if (httpRequest.status === 200) {
response = httpRequest.responseText;
data = JSON.parse(response);
} else {
alert('There was a problem with the request.');
}
} else {
console.log('server not ready for http request');
}
};
//get json
httpRequest.open('GET', 'http://localhost:8080/salinity.json', false);
//send request
httpRequest.send(null);
//draw a circle funciton
var drawCircle = function (startPointX, startPointY, offsetX, offsetY) {
var circle = L.circle([startPointX + (offsetX * 0.0001),
startPointY + (offsetY * 0.0001)], 1, {
color: 'red',
fillColor: '#f03',
fillOpacity: 0.5
}).addTo(map);
}
var imgO = L.imageOverlay(imageUrl, imageBounds);
L.imageOverlay(imageUrl, imageBounds).addTo(map);