1 | <?php |
||
3 | class MapExtension extends DataExtension implements Mappable |
||
4 | { |
||
5 | /* |
||
6 | * Template suffix for rendering MapInfoWindow aka map bubble |
||
7 | */ |
||
8 | private static $map_info_window_suffix = '_MapInfoWindow'; |
||
|
|||
9 | |||
10 | private static $db = array( |
||
11 | 'Lat' => 'Decimal(18,15)', |
||
12 | 'Lon' => 'Decimal(18,15)', |
||
13 | 'ZoomLevel' => 'Int', |
||
14 | 'MapPinEdited' => 'Boolean', |
||
15 | ); |
||
16 | |||
17 | public static $has_one = array( |
||
18 | 'MapPinIcon' => 'Image', |
||
19 | ); |
||
20 | |||
21 | public static $defaults = array( |
||
22 | 'Lat' => 0, |
||
23 | 'Lon' => 0, |
||
24 | 'Zoom' => 4, |
||
25 | 'MapPinEdited' => false, |
||
26 | ); |
||
27 | |||
28 | /* |
||
29 | Map editing field |
||
30 | */ |
||
31 | private $mapField = null; |
||
32 | |||
33 | /* |
||
34 | Add a Location tab containing the map |
||
35 | */ |
||
36 | 3 | public function updateCMSFields(FieldList $fields) |
|
53 | |||
54 | 16 | public function getMappableLatitude() |
|
58 | |||
59 | 16 | public function getMappableLongitude() |
|
63 | |||
64 | /** |
||
65 | * Renders the map info window for the DataObject. |
||
66 | * |
||
67 | * Be sure to define a template for that, named by the decorated class suffixed with _MapInfoWindow |
||
68 | * e.g. MyPage_MapInfoWindow |
||
69 | * |
||
70 | * You can change the suffix globally by editing the MapExtension.map_info_window_suffix config val |
||
71 | * |
||
72 | * @return string |
||
73 | */ |
||
74 | 9 | public function getMappableMapContent() |
|
87 | |||
88 | /* |
||
89 | If the marker pin is not at position 0,0 mark the pin as edited. This provides the option of |
||
90 | filtering out (0,0) point which is often irrelevant for plots |
||
91 | */ |
||
92 | 27 | public function onBeforeWrite() |
|
103 | |||
104 | /* |
||
105 | If a user has uploaded a map pin icon display that, otherwise |
||
106 | */ |
||
107 | 15 | public function getMappableMapPin() |
|
122 | |||
123 | /* |
||
124 | Check for non zero coordinates, on the assumption that (0,0) will never be the desired coordinates |
||
125 | */ |
||
126 | 10 | public function HasGeo() |
|
138 | |||
139 | /* |
||
140 | Render a map at the provided lat,lon, zoom from the editing functions, |
||
141 | */ |
||
142 | 2 | public function BasicMap() |
|
160 | |||
161 | 2 | /** |
|
162 | * Access the map editing field for the purpose of adding guide points. |
||
163 | 2 | * |
|
164 | 2 | * @return [LatLongField] instance of location editing field |
|
165 | */ |
||
166 | 2 | public function getMapField() |
|
179 | 3 | ||
180 | 3 | /** |
|
181 | * Template helper, used to decide whether or not to use compressed assets. |
||
182 | 3 | */ |
|
183 | 3 | public function UseCompressedAssets() |
|
187 | } |
||
188 |
This check marks private properties in classes that are never used. Those properties can be removed.