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 | static $has_one = array( |
||
18 | 'MapPinIcon' => 'Image' |
||
19 | ); |
||
20 | |||
21 | static $defaults = array ( |
||
22 | 'Lat' =>0, |
||
23 | 'Lon' => 0, |
||
24 | 'Zoom' => 4, |
||
25 | 'MapPinEdited' => false |
||
26 | ); |
||
27 | |||
28 | |||
29 | /* |
||
30 | Add a Location tab containing the map |
||
31 | */ |
||
32 | public function updateCMSFields(FieldList $fields) { |
||
48 | |||
49 | |||
50 | public function getMappableLatitude() { |
||
53 | |||
54 | public function getMappableLongitude() { |
||
57 | |||
58 | |||
59 | /** |
||
60 | * Renders the map info window for the DataObject. |
||
61 | * |
||
62 | * Be sure to define a template for that, named by the decorated class suffixed with _MapInfoWindow |
||
63 | * e.g. MyPage_MapInfoWindow |
||
64 | * |
||
65 | * You can change the suffix globally by editing the MapExtension.map_info_window_suffix config val |
||
66 | * |
||
67 | * @return string |
||
68 | */ |
||
69 | public function getMappableMapContent() { |
||
80 | |||
81 | |||
82 | /* |
||
83 | If the marker pin is not at position 0,0 mark the pin as edited. This provides the option of |
||
84 | filtering out (0,0) point which is often irrelevant for plots |
||
85 | */ |
||
86 | public function onBeforeWrite() { |
||
96 | |||
97 | |||
98 | /* |
||
99 | If a user has uploaded a map pin icon display that, otherwise |
||
100 | */ |
||
101 | public function getMappableMapPin() { |
||
115 | |||
116 | |||
117 | /* |
||
118 | Check for non zero coordinates, on the assumption that (0,0) will never be the desired coordinates |
||
119 | */ |
||
120 | public function HasGeo() { |
||
142 | |||
143 | |||
144 | /* |
||
145 | Render a map at the provided lat,lon, zoom from the editing functions, |
||
146 | */ |
||
147 | public function BasicMap() { |
||
197 | |||
198 | |||
199 | /** |
||
200 | * Access the map editing field for the purpose of adding guide points |
||
201 | * @return [LatLongField] instance of location editing field |
||
202 | */ |
||
203 | public function getMapField() { |
||
214 | |||
215 | |||
216 | /** |
||
217 | * Template helper, used to decide whether or not to use compressed assets |
||
218 | */ |
||
219 | public function UseCompressedAssets() { |
||
222 | } |
||
223 |
This check marks private properties in classes that are never used. Those properties can be removed.