2010-12-15 23:14:59 +08:00
|
|
|
(function() {
|
2011-01-13 18:17:50 +08:00
|
|
|
//TODO replace script list with the one from ../buid/deps.js
|
2013-01-31 04:01:32 +08:00
|
|
|
function getFiles() {
|
|
|
|
var memo = {},
|
|
|
|
comps;
|
|
|
|
|
|
|
|
function addFiles(srcs) {
|
|
|
|
for (var j = 0, len = srcs.length; j < len; j++) {
|
|
|
|
memo[srcs[j]] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i in deps) {
|
|
|
|
addFiles(deps[i].src);
|
|
|
|
}
|
|
|
|
var files = [];
|
|
|
|
|
|
|
|
for (var src in memo) {
|
|
|
|
files.push('src/' + src);
|
|
|
|
}
|
|
|
|
|
|
|
|
return files;
|
|
|
|
}
|
|
|
|
var scripts = getFiles();
|
|
|
|
|
2011-06-02 22:07:56 +08:00
|
|
|
function getSrcUrl() {
|
|
|
|
var scripts = document.getElementsByTagName('script');
|
|
|
|
for (var i = 0; i < scripts.length; i++) {
|
|
|
|
var src = scripts[i].src;
|
|
|
|
if (src) {
|
|
|
|
var res = src.match(/^(.*)leaflet-include\.js$/);
|
2011-06-03 16:45:07 +08:00
|
|
|
if (res) {
|
2013-01-31 04:01:32 +08:00
|
|
|
return res[1] + '../';
|
2011-06-02 22:07:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-12-14 19:12:54 +08:00
|
|
|
|
2011-06-02 22:07:56 +08:00
|
|
|
var path = getSrcUrl();
|
2012-05-16 20:34:36 +08:00
|
|
|
for (var i = 0; i < scripts.length; i++) {
|
2012-05-10 22:03:50 +08:00
|
|
|
document.writeln("<script src='" + path + scripts[i] + "'></script>");
|
2010-12-15 23:14:59 +08:00
|
|
|
}
|
2012-08-07 23:43:52 +08:00
|
|
|
document.writeln('<script defer>L.Icon.Default.imagePath = "' + path + '../dist/images";</script>');
|
2011-06-20 16:15:53 +08:00
|
|
|
})();
|
2011-08-11 19:30:46 +08:00
|
|
|
|
|
|
|
function getRandomLatLng(map) {
|
|
|
|
var bounds = map.getBounds(),
|
|
|
|
southWest = bounds.getSouthWest(),
|
|
|
|
northEast = bounds.getNorthEast(),
|
|
|
|
lngSpan = northEast.lng - southWest.lng,
|
|
|
|
latSpan = northEast.lat - southWest.lat;
|
2011-12-14 19:12:54 +08:00
|
|
|
|
2011-08-11 19:30:46 +08:00
|
|
|
return new L.LatLng(
|
|
|
|
southWest.lat + latSpan * Math.random(),
|
|
|
|
southWest.lng + lngSpan * Math.random());
|
2011-12-14 19:12:54 +08:00
|
|
|
}
|
2012-11-14 19:37:25 +08:00
|
|
|
|
|
|
|
function logEvent(e) {
|
|
|
|
console.log(e.type);
|
|
|
|
}
|