@@ -943,4 +943,173 @@ static function allowable_file($ext = '', $mime = false, $file_image = 'file') {
943
943
944
944
return false ;
945
945
}
946
+
947
+ static public function build_icon_data (Array $ type = []) {
948
+
949
+ // Waymark_helper::debug($type);
950
+
951
+ // If Type key not set
952
+ if (!isset ($ type ['type_key ' ])) {
953
+ //Create Type Key
954
+ $ type ['type_key ' ] = self ::make_key ($ type ['marker_title ' ]);
955
+
956
+ }
957
+
958
+ $ icon_data = [
959
+ 'className ' => 'waymark-marker waymark-marker- ' . $ type ['type_key ' ],
960
+ ];
961
+
962
+ //Shape
963
+ if (isset ($ type ['marker_shape ' ]) && isset ($ type ['marker_size ' ])) {
964
+ $ icon_data ['className ' ] .= ' waymark-marker- ' . $ type ['marker_shape ' ];
965
+ $ icon_data ['className ' ] .= ' waymark-marker- ' . $ type ['marker_size ' ];
966
+
967
+ switch ($ type ['marker_shape ' ]) {
968
+ //Markers & Circles
969
+ case 'rectangle ' :
970
+ case 'circle ' :
971
+ case 'marker ' :
972
+ //Size
973
+ switch ($ type ['marker_size ' ]) {
974
+ case 'small ' :
975
+ $ icon_data ['iconSize ' ] = [16 , 16 ];
976
+
977
+ break ;
978
+ case 'medium ' :
979
+ $ icon_data ['iconSize ' ] = [25 , 25 ];
980
+
981
+ break ;
982
+ default :
983
+ case 'large ' :
984
+ $ icon_data ['iconSize ' ] = [32 , 32 ];
985
+
986
+ break ;
987
+ }
988
+
989
+ break ;
990
+ }
991
+
992
+ //Marker only
993
+ if ($ type ['marker_shape ' ] == 'marker ' ) {
994
+ $ icon_data ['iconAnchor ' ] = [
995
+ $ icon_data ['iconSize ' ][0 ] / 2 ,
996
+ $ icon_data ['iconSize ' ][1 ] * 1.25 ,
997
+ ];
998
+ }
999
+ }
1000
+
1001
+ //CSS Styles
1002
+ $ background_css = 'background: ' . self ::get_marker_background ($ type ['marker_colour ' ]) . '; ' ;
1003
+ $ icon_css = 'color: ' . $ type ['icon_colour ' ] . '; ' ;
1004
+
1005
+ //HTML
1006
+ $ icon_data ['html ' ] = '<div class="waymark-marker-background" style=" ' . $ background_css . '"></div> ' ;
1007
+
1008
+ //Classes
1009
+ $ icon_class = 'waymark-marker-icon ' ;
1010
+
1011
+ //Text, HTML or Icon Name
1012
+ switch ($ type ['icon_type ' ]) {
1013
+ //Text
1014
+ case 'text ' :
1015
+ $ icon_class .= ' waymark-icon-text ' ;
1016
+
1017
+ $ icon_data ['html ' ] .= '<div style=" ' . $ icon_css . '" class=" ' . $ icon_class . '"> ' . $ type ['marker_icon ' ] . '</div> ' ;
1018
+
1019
+ break ;
1020
+
1021
+ //HTML
1022
+ case 'html ' :
1023
+ $ icon_class .= ' waymark-icon-html ' ;
1024
+
1025
+ //Decode HTML entities
1026
+ $ icon_html = html_entity_decode ($ type ['marker_icon ' ]);
1027
+
1028
+ $ icon_data ['html ' ] .= '<div class=" ' . $ icon_class . '"> ' . $ icon_html . '</div> ' ;
1029
+
1030
+ break ;
1031
+
1032
+ //Icon Name
1033
+ case 'icon ' :
1034
+ default :
1035
+ $ icon_class .= ' waymark-icon-icon ' ;
1036
+
1037
+ //If Ionic Icons
1038
+ if (strpos ($ type ['marker_icon ' ], 'ion- ' ) === 0 ) {
1039
+ $ icon_class .= ' ion ' ;
1040
+ $ icon_class .= ' ' . $ type ['marker_icon ' ];
1041
+ //Font Awesome
1042
+ } elseif (strpos ($ type ['marker_icon ' ], 'fa- ' ) === 0 ) {
1043
+ $ icon_class .= ' fa ' ;
1044
+ $ icon_class .= ' ' . $ type ['marker_icon ' ];
1045
+ //Default to Ionic
1046
+ } else {
1047
+ $ icon_class .= ' ion ' ;
1048
+ $ icon_class .= ' ion- ' . $ type ['marker_icon ' ];
1049
+ }
1050
+
1051
+ $ icon_data ['html ' ] .= '<i style=" ' . $ icon_css . '" class=" ' . $ icon_class . '"></i> ' ;
1052
+
1053
+ break ;
1054
+ }
1055
+
1056
+ return $ icon_data ;
1057
+ }
1058
+
1059
+ public static function get_marker_background (String $ colour = '' ) {
1060
+ $ old_background_options = [
1061
+ 'red ' ,
1062
+ 'darkred ' ,
1063
+ 'orange ' ,
1064
+ 'green ' ,
1065
+ 'darkgreen ' ,
1066
+ 'blue ' ,
1067
+ 'purple ' ,
1068
+ 'darkpurple ' ,
1069
+ 'cadetblue ' ,
1070
+ 'white ' ,
1071
+ 'black ' ,
1072
+ ];
1073
+
1074
+ //Convert
1075
+ if (in_array ($ colour , $ old_background_options )) {
1076
+ switch ($ colour ) {
1077
+ case 'red ' :
1078
+ return '#da3d20 ' ;
1079
+ break ;
1080
+ case 'darkred ' :
1081
+ return '#a43233 ' ;
1082
+ break ;
1083
+ case 'orange ' :
1084
+ return '#f9960a ' ;
1085
+ break ;
1086
+ case 'green ' :
1087
+ return '#70af00 ' ;
1088
+ break ;
1089
+ case 'darkgreen ' :
1090
+ return '#72820d ' ;
1091
+ break ;
1092
+ case 'blue ' :
1093
+ return '#2aabe1 ' ;
1094
+ break ;
1095
+ case 'purple ' :
1096
+ return '#d553bd ' ;
1097
+ break ;
1098
+ case 'darkpurple ' :
1099
+ return '#5c3a6e ' ;
1100
+ break ;
1101
+ case 'cadetblue ' :
1102
+ return '#416979 ' ;
1103
+ break ;
1104
+ case 'white ' :
1105
+ return '#fbfbfb ' ;
1106
+ break ;
1107
+ case 'black ' :
1108
+ return '#303030 ' ;
1109
+ break ;
1110
+ }
1111
+ }
1112
+
1113
+ return $ colour ;
1114
+ }
946
1115
}
0 commit comments