3 $aFilteredPlaces = array();
4 foreach ($aSearchResults as $iResNum => $aPointDetails) {
12 if (isset($aPointDetails['place_id'])) $aPlace['properties']['geocoding']['place_id'] = $aPointDetails['place_id'];
13 $sOSMType = formatOSMType($aPointDetails['osm_type']);
15 $aPlace['properties']['geocoding']['osm_type'] = $sOSMType;
16 $aPlace['properties']['geocoding']['osm_id'] = $aPointDetails['osm_id'];
19 $aPlace['properties']['geocoding']['type'] = $aPointDetails['type'];
21 $aPlace['properties']['geocoding']['label'] = $aPointDetails['langaddress'];
23 $aPlace['properties']['geocoding']['name'] = $aPointDetails['placename'];
25 if (isset($aPointDetails['address'])) {
26 $aFieldMappings = array(
27 'house_number' => 'housenumber',
29 'locality' => 'locality',
30 'postcode' => 'postcode',
32 'district' => 'district',
35 'country' => 'country'
38 $aAddrNames = $aPointDetails['address']->getAddressNames();
39 foreach ($aFieldMappings as $sFrom => $sTo) {
40 if (isset($aAddrNames[$sFrom])) {
41 $aPlace['properties']['geocoding'][$sTo] = $aAddrNames[$sFrom];
45 $aPlace['properties']['geocoding']['admin']
46 = $aPointDetails['address']->getAdminLevels();
49 if (isset($aPointDetails['asgeojson'])) {
50 $aPlace['geometry'] = json_decode($aPointDetails['asgeojson']);
52 $aPlace['geometry'] = array(
54 'coordinates' => array(
55 (float) $aPointDetails['lon'],
56 (float) $aPointDetails['lat']
60 $aFilteredPlaces[] = $aPlace;
64 javascript_renderData(array(
65 'type' => 'FeatureCollection',
68 'attribution' => 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
72 'features' => $aFilteredPlaces