mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-13 12:55:05 +02:00
Address customization
This commit is contained in:
@@ -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"],
|
||||
@@ -38,6 +39,13 @@
|
||||
{
|
||||
"countryCodes": ["tw"],
|
||||
"format": [["postcode", "city", "district"], ["place", "street"], ["housenumber", "floor"]]
|
||||
},
|
||||
{
|
||||
"countryCodes": ["jp"],
|
||||
"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}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+16
-1
@@ -78,24 +78,39 @@ en:
|
||||
# access=*
|
||||
label: Access
|
||||
address:
|
||||
# 'addr:city=*, addr:conscriptionnumber=*, addr:country=*, addr:district=*, addr:floor=*, addr:hamlet=*, addr:housename=*, addr:housenumber=*, addr:place=*, addr:postcode=*, addr:province=*, addr:state=*, addr:street=*, addr:subdistrict=*, addr:suburb=*'
|
||||
# 'addr:city=*, addr:block_number=*, addr:conscriptionnumber=*, addr:country=*, addr:county=*, 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!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/Machi
|
||||
state: State
|
||||
street: Street
|
||||
subdistrict: Subdistrict
|
||||
subdistrict!vn: Ward/Commune/Townlet
|
||||
suburb: Suburb
|
||||
suburb!jp: Ward
|
||||
admin_level:
|
||||
# admin_level=*
|
||||
label: Admin Level
|
||||
|
||||
@@ -80,16 +80,20 @@
|
||||
"type": "address",
|
||||
"keys": [
|
||||
"addr:city",
|
||||
"addr:block_number",
|
||||
"addr:conscriptionnumber",
|
||||
"addr:country",
|
||||
"addr:county",
|
||||
"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",
|
||||
@@ -104,20 +108,35 @@
|
||||
"strings": {
|
||||
"placeholders": {
|
||||
"city": "City",
|
||||
"block_number": "Block Number",
|
||||
"conscriptionnumber": "123",
|
||||
"country": "Country",
|
||||
"county": "County",
|
||||
"district": "District",
|
||||
"floor": "Floor",
|
||||
"hamlet": "Hamlet",
|
||||
"housename": "Housename",
|
||||
"housenumber": "123",
|
||||
"neighbourhood": "Neighbourhood",
|
||||
"place": "Place",
|
||||
"postcode": "Postcode",
|
||||
"province": "Province",
|
||||
"quarter": "Quarter",
|
||||
"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."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2,16 +2,20 @@
|
||||
"type": "address",
|
||||
"keys": [
|
||||
"addr:city",
|
||||
"addr:block_number",
|
||||
"addr:conscriptionnumber",
|
||||
"addr:country",
|
||||
"addr:county",
|
||||
"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",
|
||||
@@ -24,20 +28,35 @@
|
||||
"strings": {
|
||||
"placeholders": {
|
||||
"city": "City",
|
||||
"block_number": "Block Number",
|
||||
"conscriptionnumber": "123",
|
||||
"country": "Country",
|
||||
"county": "County",
|
||||
"district": "District",
|
||||
"floor": "Floor",
|
||||
"hamlet": "Hamlet",
|
||||
"housename": "Housename",
|
||||
"housenumber": "123",
|
||||
"neighbourhood": "Neighbourhood",
|
||||
"place": "Place",
|
||||
"postcode": "Postcode",
|
||||
"province": "Province",
|
||||
"quarter": "Quarter",
|
||||
"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."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+16
-1
@@ -704,20 +704,35 @@
|
||||
"label": "Address",
|
||||
"placeholders": {
|
||||
"city": "City",
|
||||
"block_number": "Block Number",
|
||||
"conscriptionnumber": "123",
|
||||
"country": "Country",
|
||||
"county": "County",
|
||||
"district": "District",
|
||||
"floor": "Floor",
|
||||
"hamlet": "Hamlet",
|
||||
"housename": "Housename",
|
||||
"housenumber": "123",
|
||||
"neighbourhood": "Neighbourhood",
|
||||
"place": "Place",
|
||||
"postcode": "Postcode",
|
||||
"province": "Province",
|
||||
"quarter": "Quarter",
|
||||
"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": {
|
||||
|
||||
@@ -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,19 @@ 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
|
||||
// setup dropdowns for common address tags
|
||||
var addrTags = [
|
||||
if (typeof addressFormat.dropdowns != "undefined") { addrTags = addressFormat.dropdowns; }
|
||||
else { addrTags = [
|
||||
'street', 'city', 'state', 'province', 'district',
|
||||
'subdistrict', 'suburb', 'place', 'postcode'
|
||||
];
|
||||
'subdistrict', 'suburb', 'place', 'postcode']; }
|
||||
|
||||
addrTags.forEach(function(tag) {
|
||||
var nearValues = (tag === 'street') ? getNearStreets
|
||||
|
||||
Reference in New Issue
Block a user