diff --git a/data/address-formats.json b/data/address-formats.json index 418fd7defe..2e8d164e30 100644 --- a/data/address-formats.json +++ b/data/address-formats.json @@ -25,7 +25,8 @@ }, { "countryCodes": ["vn"], - "format": [["housenumber", "street"], ["subdistrict"], ["district"], ["city"], ["province", "postcode"]] + "format": [["housenumber", "street"], ["subdistrict"], ["district"], ["city"], ["province", "postcode"]], + "customPlaceholders": ["subdistrict", "district", "city"] }, { "countryCodes": ["us"], @@ -41,7 +42,10 @@ }, { "countryCodes": ["jp"], - "format": [["postcode", "province", "county"], ["city", "suburb", "quarter"], ["neighbourhood", "block_number", "housenumber"]] + "format": [["postcode", "province", "county"], ["city", "suburb"], ["quarter", "neighbourhood"], ["block_number", "housenumber"]], + "customPlaceholders": ["province", "county", "city", "suburb", "quarter", "neighbourhood", "block_number", "housenumber"], + "dropdowns": ["postcode", "province", "county", "city", "suburb", "quarter", "neighbourhood", "block_number"], + "widths": {"postcode": 0.3, "province": 0.35, "county": 0.35, "city": 0.65, "suburb": 0.35, "quarter": 0.5, "neighbourhood": 0.5, "block_number": 0.5} } ] } diff --git a/data/presets.yaml b/data/presets.yaml index 267cd107d1..1443287059 100644 --- a/data/presets.yaml +++ b/data/presets.yaml @@ -81,25 +81,41 @@ en: # 'addr:block_number=*, addr:city=*, addr:conscriptionnumber=*, addr:county=*, addr:country=*, addr:district=*, addr:floor=*, addr:hamlet=*, addr:housename=*, addr:housenumber=*, addr:neighbourhood=*, addr:place=*, addr:postcode=*, addr:province=*, addr:quarter=*, addr:state=*, addr:street=*, addr:subdistrict=*, addr:suburb=*' label: Address placeholders: - block_number: Block number + block_number: Block Number + block_number!jp: Block No. city: City + city!jp: City/Town/Village/Tokyo Special Ward + city!vn: City/Town conscriptionnumber: '123' country: Country county: County + county!jp: District district: District + district!vn: Arrondissement/Town/District floor: Floor hamlet: Hamlet housename: Housename housenumber: '123' + housenumber!jp: Building No./Lot No. neighbourhood: Neighbourhood + neighbourhood!jp: Chōme/Aza/Koaza place: Place postcode: Postcode province: Province + province!jp: Prefecture quarter: Quarter + quarter!jp: Ōaza/Mach + neighbourhood: Neighbourhood + place: Place + postcode: Postcode + province: Province + quarter: Quarte state: State street: Street subdistrict: Subdistrict + subdistrict!vn: Ward/Commune/Townlet suburb: Suburb + suburb!jp: Ward admin_level: # admin_level=* label: Admin Level diff --git a/data/presets/fields.json b/data/presets/fields.json index b270f1d05e..62054fbee8 100644 --- a/data/presets/fields.json +++ b/data/presets/fields.json @@ -81,9 +81,11 @@ "keys": [ "addr:block_number", "addr:city", + "addr:block_number", "addr:conscriptionnumber", "addr:county", "addr:country", + "addr:county", "addr:district", "addr:floor", "addr:hamlet", @@ -109,9 +111,11 @@ "placeholders": { "block_number": "Block number", "city": "City", + "block_number": "Block Number", "conscriptionnumber": "123", "county": "County", "country": "Country", + "county": "County", "district": "District", "floor": "Floor", "hamlet": "Hamlet", @@ -125,7 +129,18 @@ "state": "State", "street": "Street", "subdistrict": "Subdistrict", - "suburb": "Suburb" + "suburb": "Suburb", + "subdistrict!vn": "Ward/Commune/Townlet", + "district!vn": "Arrondissement/Town/District", + "city!vn": "City/Town", + "province!jp": "Prefecture", + "county!jp": "District", + "city!jp": "City/Town/Village/Tokyo Special Ward", + "suburb!jp": "Ward", + "quarter!jp": "Ōaza/Machi", + "neighbourhood!jp": "Chōme/Aza/Koaza", + "block_number!jp": "Block No.", + "housenumber!jp": "Building No./Lot No." } } }, diff --git a/data/presets/fields/address.json b/data/presets/fields/address.json index ff1e5f5056..d8ad9ab399 100644 --- a/data/presets/fields/address.json +++ b/data/presets/fields/address.json @@ -3,9 +3,11 @@ "keys": [ "addr:block_number", "addr:city", + "addr:block_number", "addr:conscriptionnumber", "addr:county", "addr:country", + "addr:county", "addr:district", "addr:floor", "addr:hamlet", @@ -29,9 +31,11 @@ "placeholders": { "block_number": "Block number", "city": "City", + "block_number": "Block Number", "conscriptionnumber": "123", "county": "County", "country": "Country", + "county": "County", "district": "District", "floor": "Floor", "hamlet": "Hamlet", @@ -45,7 +49,18 @@ "state": "State", "street": "Street", "subdistrict": "Subdistrict", - "suburb": "Suburb" + "suburb": "Suburb", + "subdistrict!vn": "Ward/Commune/Townlet", + "district!vn": "Arrondissement/Town/District", + "city!vn": "City/Town", + "province!jp": "Prefecture", + "county!jp": "District", + "city!jp": "City/Town/Village/Tokyo Special Ward", + "suburb!jp": "Ward", + "quarter!jp": "Ōaza/Machi", + "neighbourhood!jp": "Chōme/Aza/Koaza", + "block_number!jp": "Block No.", + "housenumber!jp": "Building No./Lot No." } } } diff --git a/dist/locales/en.json b/dist/locales/en.json index 3c1bfe0614..39685c92ef 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -782,9 +782,11 @@ "placeholders": { "block_number": "Block number", "city": "City", + "block_number": "Block Number", "conscriptionnumber": "123", "county": "County", "country": "Country", + "county": "County", "district": "District", "floor": "Floor", "hamlet": "Hamlet", @@ -798,7 +800,18 @@ "state": "State", "street": "Street", "subdistrict": "Subdistrict", - "suburb": "Suburb" + "suburb": "Suburb", + "subdistrict!vn": "Ward/Commune/Townlet", + "district!vn": "Arrondissement/Town/District", + "city!vn": "City/Town", + "province!jp": "Prefecture", + "county!jp": "District", + "city!jp": "City/Town/Village/Tokyo Special Ward", + "suburb!jp": "Ward", + "quarter!jp": "Ōaza/Machi", + "neighbourhood!jp": "Chōme/Aza/Koaza", + "block_number!jp": "Block No.", + "housenumber!jp": "Building No./Lot No." } }, "admin_level": { diff --git a/modules/ui/fields/address.js b/modules/ui/fields/address.js index c3eb7f4f2d..4baea37603 100644 --- a/modules/ui/fields/address.js +++ b/modules/ui/fields/address.js @@ -19,17 +19,10 @@ export function uiFieldAddress(field, context) { nominatim = services.nominatim, wrap = d3.select(null), isInitialized = false, + widths, + addrTags, entity; - var widths = { - housenumber: 1/3, - street: 2/3, - city: 2/3, - state: 1/4, - postcode: 1/3 - }; - - function getNearStreets() { var extent = entity.extent(context.graph()), l = extent.center(), @@ -98,7 +91,6 @@ export function uiFieldAddress(field, context) { } } - function getNearValues(key) { var extent = entity.extent(context.graph()), l = extent.center(), @@ -130,6 +122,9 @@ export function uiFieldAddress(field, context) { return a && a.countryCodes && _.includes(a.countryCodes, countryCode); }) || _.first(dataAddressFormats); + if (typeof addressFormat.widths !== 'undefined') { widths = addressFormat.widths; } + else { widths = {housenumber: 1/3, street: 2/3, city: 2/3, state: 1/4, postcode: 1/3}; } + function row(r) { // Normalize widths. var total = _.reduce(r, function(sum, field) { @@ -154,16 +149,21 @@ export function uiFieldAddress(field, context) { .enter() .append('input') .property('type', 'text') - .attr('placeholder', function (d) { return field.t('placeholders.' + d.id); }) + .attr('placeholder', function (d) { + var countryInserter = ''; + if (addressFormat.customPlaceholders.indexOf(d.id) !== -1) { countryInserter = '!' + countryCode; } + return field.t('placeholders.' + d.id + countryInserter); }) .attr('class', function (d) { return 'addr-' + d.id; }) .style('width', function (d) { return d.width * 100 + '%'; }); // Update - var addrTags = [ + // setup dropdowns for common address tags + if (typeof addressFormat.dropdowns !== 'undefined') { addrTags = addressFormat.dropdowns; } + else { addrTags = [ 'city', 'county', 'country', 'district', 'hamlet', 'neighbourhood', 'place', 'postcode', 'province', 'quarter', 'state', 'street', 'subdistrict', 'suburb' - ]; + ]; } // If fields exist for any of these tags, create dropdowns to pick nearby values.. addrTags.forEach(function(tag) {