2 header("Content-Type: application/json; charset=UTF-8");
3 header("Access-Control-Allow-Origin: *");
5 $aFilteredPlaces = array();
6 foreach($aSearchResults as $iResNum => $aPointDetails)
9 'place_id'=>$aPointDetails['place_id'],
10 'licence'=>"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.",
13 $sOSMType = ($aPointDetails['osm_type'] == 'N'?'node':($aPointDetails['osm_type'] == 'W'?'way':($aPointDetails['osm_type'] == 'R'?'relation':'')));
16 $aPlace['osm_type'] = $sOSMType;
17 $aPlace['osm_id'] = $aPointDetails['osm_id'];
20 if (isset($aPointDetails['aBoundingBox']))
22 $aPlace['boundingbox'] = array(
23 $aPointDetails['aBoundingBox'][0],
24 $aPointDetails['aBoundingBox'][1],
25 $aPointDetails['aBoundingBox'][2],
26 $aPointDetails['aBoundingBox'][3]);
28 if (isset($aPointDetails['aPolyPoints']) && $bShowPolygons)
30 $aPlace['polygonpoints'] = $aPointDetails['aPolyPoints'];
34 if (isset($aPointDetails['zoom']))
36 $aPlace['zoom'] = $aPointDetails['zoom'];
39 $aPlace['lat'] = $aPointDetails['lat'];
40 $aPlace['lon'] = $aPointDetails['lon'];
41 $aPlace['display_name'] = $aPointDetails['name'];
43 $aPlace['class'] = $aPointDetails['class'];
44 $aPlace['type'] = $aPointDetails['type'];
45 if ($aPointDetails['icon'])
47 $aPlace['icon'] = $aPointDetails['icon'];
50 if (isset($aPointDetails['address']))
52 $aPlace['address'] = $aPointDetails['address'];
55 $aFilteredPlaces[] = $aPlace;
58 if (isset($_GET['json_callback']) && preg_match('/^[-A-Za-z0-9:_.]+$/',$_GET['json_callback']))
60 echo $_GET['json_callback'].'('.javascript_renderData($aFilteredPlaces).')';
64 echo javascript_renderData($aFilteredPlaces);