1 | <?php |
||
12 | class Map_Field extends Field { |
||
13 | |||
14 | /** |
||
15 | * {@inheritDoc} |
||
16 | */ |
||
17 | protected $default_value = array( |
||
18 | Value_Set::VALUE_PROPERTY => '40.346544,-101.645507', |
||
19 | 'lat' => 40.346544, |
||
20 | 'lng' => -101.645507, |
||
21 | 'zoom' => 10, |
||
22 | 'address' => '', |
||
23 | ); |
||
24 | |||
25 | /** |
||
26 | * {@inheritDoc} |
||
27 | */ |
||
28 | protected $lazyload = true; |
||
29 | |||
30 | /** |
||
31 | * Create a field from a certain type with the specified label. |
||
32 | * |
||
33 | * @param string $type Field type |
||
34 | * @param string $name Field name |
||
35 | * @param string $label Field label |
||
36 | */ |
||
37 | public function __construct( $type, $name, $label ) { |
||
41 | |||
42 | /** |
||
43 | * Enqueue scripts and styles in admin |
||
44 | * Called once per field type |
||
45 | */ |
||
46 | public static function admin_enqueue_scripts() { |
||
52 | |||
53 | /** |
||
54 | * Convert lat and lng to a comma-separated list |
||
55 | */ |
||
56 | protected function lat_lng_to_latlng( $lat, $lng ) { |
||
59 | |||
60 | /** |
||
61 | * Load the field value from an input array based on its name |
||
62 | * |
||
63 | * @param array $input Array of field names and values. |
||
64 | * @return self $this |
||
65 | */ |
||
66 | public function set_value_from_input( $input ) { |
||
93 | |||
94 | /** |
||
95 | * Returns an array that holds the field data, suitable for JSON representation. |
||
96 | * |
||
97 | * @param bool $load Should the value be loaded from the database or use the value from the current instance. |
||
98 | * @return array |
||
99 | */ |
||
100 | public function to_json( $load ) { |
||
116 | |||
117 | /** |
||
118 | * Set the coords and zoom of this field. |
||
119 | * |
||
120 | * @param string $lat Latitude |
||
121 | * @param string $lng Longitude |
||
122 | * @param int $zoom Zoom level |
||
123 | * @return self $this |
||
124 | */ |
||
125 | 1 | public function set_position( $lat, $lng, $zoom ) { |
|
136 | } |
||
137 |