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 | * Create a field from a certain type with the specified label. |
||
27 | * |
||
28 | * @param string $type Field type |
||
29 | * @param string $name Field name |
||
30 | * @param string $label Field label |
||
31 | */ |
||
32 | public function __construct( $type, $name, $label ) { |
||
36 | |||
37 | /** |
||
38 | * Enqueue scripts and styles in admin |
||
39 | * Called once per field type |
||
40 | */ |
||
41 | public static function admin_enqueue_scripts() { |
||
47 | |||
48 | /** |
||
49 | * Convert lat and lng to a comma-separated list |
||
50 | */ |
||
51 | protected function lat_lng_to_latlng( $lat, $lng ) { |
||
54 | |||
55 | /** |
||
56 | * Load the field value from an input array based on its name |
||
57 | * |
||
58 | * @param array $input Array of field names and values. |
||
59 | * @return self $this |
||
60 | */ |
||
61 | public function set_value_from_input( $input ) { |
||
88 | |||
89 | /** |
||
90 | * Returns an array that holds the field data, suitable for JSON representation. |
||
91 | * |
||
92 | * @param bool $load Should the value be loaded from the database or use the value from the current instance. |
||
93 | * @return array |
||
94 | */ |
||
95 | public function to_json( $load ) { |
||
112 | |||
113 | /** |
||
114 | * Set the coords and zoom of this field. |
||
115 | * |
||
116 | * @param string $lat Latitude |
||
117 | * @param string $lng Longitude |
||
118 | * @param int $zoom Zoom level |
||
119 | * @return $this |
||
120 | */ |
||
121 | 1 | public function set_position( $lat, $lng, $zoom ) { |
|
132 | } |
||
133 |