source: trunk/src/map/inc/suggestions.php@ 7841

Last change on this file since 7841 was 7822, checked in by janveeden, 15 years ago

Added commenting in suggestions.php. Clicking on a node from a list now also displays the nodeinfo.

File size: 1.8 KB
Line 
1<?php
2require_once("../../config.php");
3require_once($config['root']."/map/inc/kmlHandler.php");
4/*
5 * Get the array containing all the nodes
6 */
7$markers = get_node_array($config['kml_file']);
8
9
10$suggested_markers = array();
11
12/*
13 * Get the value that has been sent in the url, if theres no value in the url, the value will be nothing.
14 */
15if(isset($_GET['value']))
16{
17 $typed_value = $_GET['value'];
18}
19else
20{
21 $typed_value = "";
22}
23
24/*
25 * Fill the markernames array with all the names from markers we have on the map.
26 */
27foreach($markers as $marker)
28{
29 $markernames[] = (string)$marker['name'];
30}
31
32/*
33 * If the typed value is equal to the first part of a node name, the nodename is inserted into the $suggested_markers array
34 */
35if (strlen($typed_value) > 0)
36{
37 for($i=0; $i<count($markernames); $i++)
38 {
39 $hint= "";
40 if (strtolower($typed_value)==strtolower(substr($markernames[$i],0,strlen($typed_value))))
41 {
42 $suggested_markers[]=$markernames[$i];
43 }
44 }
45}
46
47/*
48 * If there are no suggested markers, check if there is something that has been typed.
49 * If so there are no suggestions found.
50 * Else there has been nothing typed, so we show all the markers we have.
51 */
52if ($suggested_markers == null)
53{
54 if (strlen($typed_value) > 0)
55 {
56 $suggested_markers[] = "Geen suggesties";
57 }
58 else
59 {
60 $suggested_markers = $markernames;
61 }
62}
63
64/*
65 * Make a list with all the suggested markers we have.
66 * onchange we call the goToMarker function in nodemapWL.js and set the constructor with the value of the selected option.
67 */
68echo "<select multiple onchange='goToMarker(this.options[this.selectedIndex].text)'>";
69foreach($suggested_markers as $name)
70{
71 $name = (string)$name;
72 echo "<option value='{$name}' >{$name}</option>";
73}
74echo "</select>";
75
76?>
77
78
79
Note: See TracBrowser for help on using the repository browser.