Skip to content

Instantly share code, notes, and snippets.

@richgcook
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save richgcook/f0f1d0973c8badf27164 to your computer and use it in GitHub Desktop.

Select an option

Save richgcook/f0f1d0973c8badf27164 to your computer and use it in GitHub Desktop.
Processwire JSON example
<?php
$projects = $pages->find('template=project-detail, sort=sort');
$projects_array = array();
foreach ($projects as $project) {
$title = $project->title;
$summary = $project->project_summary;
$long = $project->project_location_marker_long;
$lat = $project->project_location_marker_lat;
$projects_array[] = array(
'type' => 'Feature',
'geometry' => array(
'type' => 'Point',
'coordinates' => [$long,$lat]
),
'properties' => array(
'title' => $title,
'description' => $summary,
'marker-color' => '#ffff00',
'marker-size' => 'large',
'marker-symbol' => 'monument',
),
);
}
$projects_json = json_encode($projects_array, true);
?>
<script>
var geojson = <?php echo $projects_json; ?>
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment