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