Skip to content

Commit 059b91c

Browse files
committed
Fixed Floorplans, function placed right in code.
1 parent 264a042 commit 059b91c

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

app/assets/javascripts/locations.js

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -78,31 +78,7 @@ require(["lib/models", "lib/tools", "lib/leaflet/leaflet", "lib/msg", "lib/astat
7878
img.src = geojson[i].floorplans[j];
7979
img.onload = handleLoad;
8080

81-
function handleLoad(response) {
82-
83-
$('#floorplans-wrap').append('<div id="floorplan-div-' + i + + j + '" class="floorplan-divs" style="margin-bottom: 1em;"></div>');
84-
85-
// Get accurate measurements from that.
86-
var nw = img.width;
87-
var nh = img.height;
88-
89-
console.log(nw+' '+nh+' '+img.src);
90-
var floor = L.map('floorplan-div-' + i + j, {
91-
crs: L.CRS.Simple,
92-
minZoom: 0
93-
});
94-
95-
if(nh>nw){
96-
$('#floorplan-div-'+i+j).height($('#floorplan-div-'+i+j).width());
97-
$('#floorplan-div-'+i+j).width(nw/nh*$('#floorplan-div-'+i+j).height());
98-
}else{
99-
$('#floorplan-div-'+i+j).height(nh/nw*$('#floorplan-div-'+i+j).width());
100-
}
101-
102-
var bounds = [[0, 0], [$('#floorplan-div-'+i+j).height(), $('#floorplan-div-'+i+j).width()]];
103-
var image = L.imageOverlay(img.src, bounds).addTo(floor);
104-
floor.fitBounds(bounds);
105-
}
81+
10682
//possible to incorporate rooms with coordinates just as above,
10783
//just be sure to use right coordinate system (cf. leaflet page)
10884
//and mapping probably needed for room number vs. location
@@ -113,6 +89,32 @@ require(["lib/models", "lib/tools", "lib/leaflet/leaflet", "lib/msg", "lib/astat
11389
//add addresses as text
11490
//self.geoContent(texts);
11591

92+
function handleLoad(response) {
93+
94+
$('#floorplans-wrap').append('<div id="floorplan-div-' + i + + j + '" class="floorplan-divs" style="margin-bottom: 1em;"></div>');
95+
96+
// Get accurate measurements from that.
97+
var nw = img.width;
98+
var nh = img.height;
99+
100+
console.log(nw+' '+nh+' '+img.src);
101+
var floor = L.map('floorplan-div-' + i + j, {
102+
crs: L.CRS.Simple,
103+
minZoom: 0
104+
});
105+
106+
if(nh>nw){
107+
$('#floorplan-div-'+i+j).height($('#floorplan-div-'+i+j).width());
108+
$('#floorplan-div-'+i+j).width(nw/nh*$('#floorplan-div-'+i+j).height());
109+
}else{
110+
$('#floorplan-div-'+i+j).height(nh/nw*$('#floorplan-div-'+i+j).width());
111+
}
112+
113+
var bounds = [[0, 0], [$('#floorplan-div-'+i+j).height(), $('#floorplan-div-'+i+j).width()]];
114+
var image = L.imageOverlay(img.src, bounds).addTo(floor);
115+
floor.fitBounds(bounds);
116+
}
117+
116118
}
117119
}
118120

0 commit comments

Comments
 (0)