makeArray -> toArray

This commit is contained in:
rlx 2011-02-22 18:52:26 +00:00
commit 4326c307b4
4 changed files with 12598 additions and 11736 deletions

File diff suppressed because it is too large Load diff

View file

@ -63,6 +63,7 @@
<script src="../../build/js/ox.js"></script>
<script src="../../build/js/ox.data.js"></script>
<script src="../../build/js/ox.geo.js"></script>
<script src="../../build/js/ox.map.js"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script>
$(function() {
@ -79,80 +80,71 @@
})
.appendTo($body),
aliases = {
"Ascension Island": "Ascension Island, Saint Helena",
"England": "England, United Kingdom",
'Byelorussian Soviet Socialist Republic': 'Belarus',
"Georgia": "Georgia, Europe",
"Holy See": "Vatican City",
// "Palestine": ["West Bank", "Gaza Strip"],
"Palestine": "West Bank",
"Saint Martin": "Sint Maarten",
"Scotland": "Scotland, United Kingdom",
"Svalbard and Jan Mayen": "Svalbard",
"Wales": "Wales, United Kingdom",
"Yugoslavia": "Serbia"
},
json = {};
///*
$.getJSON("geo.json", function(data) {
json = data;
getPlacemarks($.map(Ox.getCountries(true), function(v) {
return v.code.length == 2 ? v : null;
}));
getPlacemarks(Ox.COUNTRIES);
});
//*/
/*
getPlacemarks($.map(Ox.getCountries(true), function(v) {
return v.code.length == 2 ? v : null;
}));
getPlacemarks(Ox.COUNTRIES);
*/
function getPlacemarks(countries) {
var country = countries.shift();
if (!(country.code in json)) {
console.log(country);
Ox.getPlacemarks(aliases[country.name] || country.name, function(geodata) {
if (!geodata.results) {
if (!geodata.results.length) {
console.log(country.name, geodata.status);
}
geodata = geodata.results[0];
data = {
address: aliases[country.name] || country.name,
geocode: {
address_components: geodata.address_components,
formatted_address: geodata.formatted_address,
geometry: {
location: {},
location_type: geodata.geometry.location_type
} else {
geodata = geodata.results[0];
Ox.print('geodata', geodata)
data = {
address: aliases[country.name] || country.name,
geocode: {
address_components: geodata.address_components,
formatted_address: geodata.formatted_address,
geometry: {
location: {},
location_type: geodata.geometry.location_type
},
types: geodata.types
},
types: geodata.types
},
name: country.name,
time: +new Date()
};
$.each(["lat", "lng"], function(i, crd) {
data.geocode.geometry.location[crd] = parseFloat(
geodata.geometry.location[crd]().toFixed(8)
);
});
$.each(["bounds", "viewport"], function(i, obj) {
if (obj in geodata.geometry) {
data.geocode.geometry[obj] = {};
$.each(["center", "southWest", "northEast"], function(i, pnt) {
data.geocode.geometry[obj][pnt] = {};
$.each(["lat", "lng"], function(i, crd) {
data.geocode.geometry[obj][pnt][crd] = parseFloat(
geodata.geometry[obj][
"get" + pnt[0].toUpperCase() + pnt.substr(1)
]()[crd]().toFixed(8)
);
name: country.name,
time: +new Date()
};
$.each(["lat", "lng"], function(i, crd) {
data.geocode.geometry.location[crd] = parseFloat(
geodata.geometry.location[crd]().toFixed(8)
);
});
$.each(["bounds", "viewport"], function(i, obj) {
if (obj in geodata.geometry) {
data.geocode.geometry[obj] = {};
$.each(["center", "southWest", "northEast"], function(i, pnt) {
data.geocode.geometry[obj][pnt] = {};
$.each(["lat", "lng"], function(i, crd) {
data.geocode.geometry[obj][pnt][crd] = parseFloat(
geodata.geometry[obj][
"get" + pnt[0].toUpperCase() + pnt.substr(1)
]()[crd]().toFixed(8)
);
});
});
});
}
});
json[country.code] = data;
addFlag(country, json[country.code]);
addData(json)
if (country.name != geodata.formatted_address) {
console.log(country.name, geodata.formatted_address, geodata);
}
});
json[country.code] = data;
addFlag(country, json[country.code]);
addData(json)
if (country.name != geodata.formatted_address) {
console.log(country.name, geodata.formatted_address, geodata);
}
if (countries.length) {
setTimeout(function() {
@ -228,8 +220,8 @@
}
$("<img/>")
.attr({
src: "../../tools/flags/png/16/" + (country.flag.indexOf("-") == 2 ?
country.flag.substr(0, 2) + "/" : "") + country.flag + ".png",
src: '/static/oxjs/build/svg/' + country.code + '.' +
(country.flag == 'png' ? 'png' : 'svg'),
title: country.name + " ((" + bounds.southWest.lat + ", " + bounds.southWest.lng + "), (" + bounds.northEast.lat + ", " + bounds.northEast.lng + "))"
})
.addClass("flag")