Skip to content

Commit e97690c

Browse files
committed
Fixed empty map and invalid font (on Firefox) issues
Signed-off-by: Ko Nagase <[email protected]>
1 parent ca8c7fe commit e97690c

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

assets/javascripts/app.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ var App = (function ($, publ) {
8888
);
8989
}
9090

91+
// Fix FireFox unloaded font issue
92+
publ.reloadFontSymbol();
93+
9194
// TODO: this is only necessary because setting the initial form value
9295
// through the template causes encoding problems
9396
publ.updateForm(features);
@@ -183,6 +186,10 @@ var App = (function ($, publ) {
183186
})
184187
})
185188
});
189+
// Fix empty map issue
190+
map.once('postrender', function(event) {
191+
publ.zoomToExtent(true);
192+
});
186193

187194
// Add Toolbar
188195
toolbar = new ol.control.Bar();
@@ -1005,6 +1012,38 @@ var App = (function ($, publ) {
10051012
return url;
10061013
};
10071014

1015+
publ.reloadFontSymbol = function () {
1016+
if ('fonts' in document) {
1017+
document.fonts.addEventListener('loadingdone', function(e) {
1018+
var loaded = false;
1019+
e.fontfaces.forEach(function(f) {
1020+
if (f.family === '"mcr-icons"' || f.family === '"fontmaki"') {
1021+
loaded = true;
1022+
}
1023+
});
1024+
if (loaded) {
1025+
maps.forEach(function(m) {
1026+
var layers = m.getLayers();
1027+
layers.forEach(function(layer) {
1028+
if (layer.type === "VECTOR" &&
1029+
layer.getKeys().indexOf("title") >= 0 &&
1030+
layer.get("title") === "Features") {
1031+
var features = layer.getSource().getFeatures();
1032+
if (features.length >= 0) {
1033+
var geom = features[0].getGeometry();
1034+
if (geom.getType() == "Point") {
1035+
console.log("Reloading Features layer");
1036+
layer.changed();
1037+
}
1038+
}
1039+
}
1040+
});
1041+
});
1042+
}
1043+
});
1044+
}
1045+
};
1046+
10081047
function getCookie(cname) {
10091048
var name = cname + "=";
10101049
var ca = document.cookie.split(';');

0 commit comments

Comments
 (0)