-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
executable file
·28 lines (21 loc) · 815 Bytes
/
test.php
File metadata and controls
executable file
·28 lines (21 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
require_once('ssgeocoder.php');
$ssgeocoder = new ssgeocoder();
// Fetch an array of features
$places = Array('Ironwood, MI, USA','Sacramento, MG, Brazil','Provo','Lostlandneverfoundcity');
$features = $ssgeocoder->geocode($places);
// Geocode a single place
$singlePlace = 'Vienna, Austria';
$feature = $ssgeocoder->geocode($singlePlace);
// Combine the single feature with the others
$features[$singlePlace] = $feature;
// Put the features into a GeoJSON array and convert to JSON
// Note that the $features array is actually a hash, and we just want the values
// piece of that since json_encode will make it an object if we include
// the keys
$geojson = Array(
'type' => 'FeatureCollection',
'features' => array_values($features)
);
$jsonString = json_encode($geojson);
print $jsonString;