diff --git a/js/main.js b/js/main.js
index 5e42f0f..35efbe2 100644
--- a/js/main.js
+++ b/js/main.js
@@ -476,10 +476,12 @@ var zoomControl = L.control.zoom({
map.on('locationerror', onLocationError);
map.on('moveend', nominatimQuery);
- map.on('popupopen', function() {
+ map.on('popupopen', function(e) {
var href=$("#plusone-div").data("href");
var size=$("#plusone-div").data("size");
- gapi.plusone.render("plusone-div",{'size':size,'href':href});
+ //gapi.plusone.render("plusone-div",{'size':size,'href':href});
+ // we make sure that a proper address is displayed
+ e.popup._source.el.fetchAddress();
});
n=true;
var href=$("#main-plus").data("href");
diff --git a/js/poi.js b/js/poi.js
index fc83394..13bfe8b 100644
--- a/js/poi.js
+++ b/js/poi.js
@@ -152,8 +152,10 @@ POI.prototype.getInfoBox = function(){
//name
content+='
';
//addr
- content+=''+((this.element.tags.hasOwnProperty("addr:city")) ? this.element.tags["addr:city"]+', ' : "")+((this.element.tags.hasOwnProperty("addr:street")) ? this.element.tags["addr:street"]+', ' : "")+((this.element.tags.hasOwnProperty("addr:housenumber")) ? this.element.tags["addr:housenumber"]+', ' : "")+'';
-
+ if(this.element.tags.hasOwnProperty("addr:housenumber") && this.element.tags.hasOwnProperty("addr:street"))
+ content+=''+((this.element.tags.hasOwnProperty("addr:city")) ? this.element.tags["addr:city"]+', ' : "")+this.element.tags["addr:street"]+', ' +this.element.tags["addr:housenumber"]+'';
+ else
+ content+=''+lang_loading+'
';
//net
content+='';
content += this.__genItems({tag:['contact:email','email'],icon:'glyphicon glyphicon-envelope',href:'mailto:'});
@@ -284,3 +286,46 @@ POI.prototype.updateShadow = function (now){
return false;
return true;
};
+
+/*
+ Determine the address of a POI, if it is unknown
+*/
+POI.prototype.fetchAddress = function(){
+ var typeTable = {"node":"N","way":"W","relation":"R"};
+ var addressDiv = this.element.type+this.element.id;
+ // if the address has not been determined yet
+ if($("#"+addressDiv).html() == lang_loading)
+ {
+ var requestData;
+ if(this.element.tags.hasOwnProperty("addr:housenumber"))
+ {
+ if(this.element.type)
+ requestData = {osm_type:typeTable[this.element.type],osm_id:this.element.id};
+ else
+ // way objects have no key type, no idea why
+ requestData = {osm_type:this.element.id[0].toUpperCase(),osm_id:this.element.id.substr(1)};
+ }
+ else
+ requestData = {lon:this.element.lon,lat:this.element.lat};
+
+ $.ajax({
+ url: 'nominatim_reverse_proxy.php',
+ dataType: "json",
+ data: requestData,
+ number : this.element.tags["addr:housenumber"],
+ addressDiv : addressDiv,
+ success: function(nominatim){
+ var wayName = nominatim.address.road;
+ if(!wayName)wayName = nominatim.address.pedestrian;
+ if(!wayName)wayName = nominatim.address.footway;
+ var cityName = nominatim.address.city;
+ if(!cityName)cityName = nominatim.address.town;
+ if(!cityName)cityName = nominatim.address.village;
+ var displayedAddress = cityName?cityName:"";
+ displayedAddress += (wayName?", "+wayName:"");
+ displayedAddress += (this.number?", "+this.number:"");
+ $("#"+this.addressDiv).html(''+displayedAddress+'');
+ }
+ });
+ }
+};
diff --git a/nominatim_reverse_proxy.php b/nominatim_reverse_proxy.php
new file mode 100644
index 0000000..ee11e33
--- /dev/null
+++ b/nominatim_reverse_proxy.php
@@ -0,0 +1,6 @@
+
\ No newline at end of file