예제 #1
0
<?php

include_once 'getCoordinates.php';
include_once 'map-utils.php';
if (isset($_POST['choice'])) {
    $choice = $_POST['choice'];
}
$locationsArr = array();
$latArr = array();
$lngArr = array();
foreach ($_POST as $choice) {
    switch ($choice) {
        case 'a':
            //$locations = array("Davao", "Panabo", "Tagum");
            $locations = getLocationsByCat('a');
            $locationsArr = array_merge($locationsArr, $locations);
            foreach ($locations as $loc) {
                $coordinates = getCoordinates($loc);
                $lat[] = $coordinates['lat'];
                $lng[] = $coordinates['lng'];
            }
            break;
        case 'b':
            $locations = array("Cotabato", "Kidapawan", "Digos");
            $locationsArr = array_merge($locationsArr, $locations);
            foreach ($locations as $loc) {
                $coordinates = getCoordinates($loc);
                $lat[] = $coordinates['lat'];
                $lng[] = $coordinates['lng'];
            }
            break;
<?php

include_once 'map-utils.php';
if (isset($_POST['save'])) {
    var_dump($_POST);
    $locationValue = $_POST['location'];
    $locationNumber = $_POST['hidden_location_number'];
    $locationOptionName = $locationNumber . 'cat_' . $_POST['category'];
    if (!get_option($locationOptionName)) {
        add_option($locationOptionName, $locationValue);
    }
}
$categories = array('a', 'b', 'c');
$locations = getAllLocations();
var_dump($locations);
$locationsThisCat = getLocationsByCat('a');
var_dump($locationsThisCat);
$last = count($locations);
$last++;
$locationOptionName = 'location_' . $last . '_';
?>
<div class="wrap">
  <h2>Dynamic Map Marker Input Options</h2>
  <div>
    <form method="post">
<!--      <input type="text" name="sample_input" value="<?php 
echo get_option('sample_input');
?>
"/>-->
        <input type="text" name="location" value=""/>
        <input type="text" name="hidden_location_number" value="<?php