Commit 15439f57 authored by Adrien Pavie's avatar Adrien Pavie
Browse files

Fixed various bugs (closes #56)

parent 59cdc229
......@@ -43,13 +43,21 @@ Flickr.OSM_TAG_RGX = /^(osm:)(node|way|relation)$/;
* @param fail The function to call back if an error occurs
*/
Flickr.prototype.get = function(bbox, success, fail) {
bbox = L.latLngBounds(bbox.getSouthWest().wrap(), bbox.getNorthEast().wrap());
var url = this._url + 'method=flickr.photos.search&api_key=' + this._key + '&bbox=' + bbox.toBBoxString() + '&machine_tags=osm:&has_geo=1&extras=machine_tags,url_c,date_taken,owner_name&format=json&nojsoncallback=1';
$.ajax({
url: url,
async: true,
dataType: 'json',
success: function(d) { success(Flickr._simpleResult(d)); }
success: function(d) {
if(!d || d.stat != "ok" || d.photos == undefined || d.photos.photo == undefined) {
fail();
}
else {
success(Flickr._simpleResult(d));
}
}
}).fail(fail);
};
......@@ -61,10 +69,6 @@ Flickr.prototype.get = function(bbox, success, fail) {
Flickr._simpleResult = function(data) {
var result = {};
if(data.stat != "ok" || data.photos == undefined || data.photos.photo == undefined) {
throw new Error("ctrl.provider.picture.Flickr.invalidData");
}
var photos = data.photos.photo;
var photo, machineTags, machineTag, mtKey, mtValue, osmType, osmId;
......
......@@ -122,6 +122,14 @@ var Main = function(divId, mode, config, rulesets, newNoteService, searchService
zoomControl: false,
maxZoom: this.config.map.maxZoom
});
//Wrap coordinates
this.map.on("load moveend", function() {
if(this.map.getCenter().lng < -180 || this.map.getCenter().lng > 180) {
this.map.setView(this.map.getCenter().wrap());
}
}.bind(this));
this.map.attributionControl.setPrefix('<img src="img/favicon.png" /> <a href="http://openlevelup.net">OpenLevelUp!</a>');
this.layersManager = new MapLayersManager(this.map);
var hash = new L.Hash(this.map);
......@@ -539,7 +547,7 @@ var Main = function(divId, mode, config, rulesets, newNoteService, searchService
//Choose first level to show
var firstLvl = (o.levels.indexOf(0) >= 0) ? 0 : o.levels[0];
if(this.options.level != undefined) {
if(this.options.level != undefined && o.levels.indexOf(this.options.level) >= 0) {
firstLvl = this.options.level;
this.options.level = undefined;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment