diff --git a/Block/Adminhtml/System/Coordinate.php b/Block/Adminhtml/System/Coordinate.php new file mode 100644 index 0000000..0ede093 --- /dev/null +++ b/Block/Adminhtml/System/Coordinate.php @@ -0,0 +1,78 @@ +helperData = $helperData; + + parent::__construct($context, $data); + } + + /** + * Render fieldset html + * + * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * + * @return string + */ + public function render(AbstractElement $element) + { + $this->setElement($element); + + return $this->_decorateRowHtml($element, $this->toHtml()); + } +} diff --git a/Block/Map.php b/Block/Map.php new file mode 100644 index 0000000..bdecf76 --- /dev/null +++ b/Block/Map.php @@ -0,0 +1,162 @@ +helperData = $helperData; + + parent::__construct($context, $data); + } + + /** + * Get map API key from system config + * + * @return mixed + */ + public function getMapApi() + { + return $this->helperData->getMapConfig('api_key'); + } + + /** + * Get map Latitude from system config + * + * @return mixed + */ + public function getMapLatitude() + { + return $this->helperData->getMapConfig('location_setting/latitude'); + } + + /** + * Get map Longitude from system config + * + * @return mixed + */ + public function getMapLongitude() + { + return $this->helperData->getMapConfig('location_setting/longitude'); + } + + /** + * Get map Marker Icon Url from system config + * + * @return bool|string + */ + public function getMapMarkerIcon() + { + return $this->helperData->getMarkerUrl(); + } + + /** + * Get map Zoom default value from system config + * + * @return int + */ + public function getMapZoomDefault() + { + return ((int) $this->helperData->getMapConfig('zoom_default')) ?: 20; + } + + /** + * Get map Type from system config + * + * @return string + */ + public function getMapTypeId() + { + return ($this->helperData->getMapConfig('map_type')) ?: 'roadmap'; + } + + /** + * Is draggable map from system config + * + * @return mixed + */ + public function isMapDraggable() + { + return $this->helperData->getMapConfig('allow_drag'); + } + + /** + * Get map Protocol from system config + * + * @return mixed + */ + public function getProtocol() + { + return $this->helperData->getMapConfig('protocol'); + } + + /** + * Get map Embed code from system config + * + * @return mixed + */ + public function getEmbedCode() + { + return $this->helperData->getMapConfig('embed_code'); + } + + /** + * @return false|string + */ + public function getMapTemplate() + { + $mapStyle = $this->helperData->getMapConfig('map_style'); + + return json_encode($this->helperData->getMapTheme($mapStyle)); + } +} diff --git a/Helper/Data.php b/Helper/Data.php new file mode 100644 index 0000000..096dffc --- /dev/null +++ b/Helper/Data.php @@ -0,0 +1,109 @@ +_helperImage = $helperImage; + $this->_mapStyleData = $mapStyleData; + + parent::__construct($context, $objectManager, $storeManager); + } + + /** + * Get map settings system config + * + * @param $code + * @param null $storeId + * + * @return mixed + */ + public function getMapConfig($code, $storeId = null) + { + $code = ($code !== '') ? '/' . $code : ''; + + return $this->getModuleConfig('map_setting' . $code, $storeId); + } + + /** + * Get custom marker icon Url + * + * @return bool|string + */ + public function getMarkerUrl() + { + if ($this->getMapConfig('marker_icon')) { + return $this->_helperImage->getBaseMediaUrl() . '/' . $this->_helperImage->getMediaPath($this->getMapConfig('marker_icon'), 'marker_icon'); + } else { + return ''; + } + } + + /** + * @param $styleName + * + * @return string + */ + public function getMapTheme($styleName) + { + return $this->_mapStyleData->getMapData($styleName); + } +} \ No newline at end of file diff --git a/Helper/Image.php b/Helper/Image.php new file mode 100644 index 0000000..764d5d7 --- /dev/null +++ b/Helper/Image.php @@ -0,0 +1,33 @@ + '[]', + self::STYLE_BLUE_ESSENCE => '[{"featureType":"landscape.natural","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#e0efef"}]},{"featureType":"poi","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"hue":"#1900ff"},{"color":"#c0e8e8"}]},{"featureType":"road","elementType":"geometry","stylers":[{"lightness":100},{"visibility":"simplified"}]},{"featureType":"road","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"transit.line","elementType":"geometry","stylers":[{"visibility":"on"},{"lightness":700}]},{"featureType":"water","elementType":"all","stylers":[{"color":"#7dcdcd"}]}]', + self::STYLE_DARK_GREEN => '[{"featureType":"all","elementType":"all","stylers":[{"visibility":"on"}]},{"featureType":"all","elementType":"labels","stylers":[{"visibility":"off"},{"saturation":"-100"}]},{"featureType":"all","elementType":"labels.text.fill","stylers":[{"saturation":36},{"color":"#000000"},{"lightness":40},{"visibility":"off"}]},{"featureType":"all","elementType":"labels.text.stroke","stylers":[{"visibility":"off"},{"color":"#000000"},{"lightness":16}]},{"featureType":"all","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":17},{"weight":1.2}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"landscape","elementType":"geometry.fill","stylers":[{"color":"#4d6059"}]},{"featureType":"landscape","elementType":"geometry.stroke","stylers":[{"color":"#4d6059"}]},{"featureType":"landscape.natural","elementType":"geometry.fill","stylers":[{"color":"#4d6059"}]},{"featureType":"poi","elementType":"geometry","stylers":[{"lightness":21}]},{"featureType":"poi","elementType":"geometry.fill","stylers":[{"color":"#4d6059"}]},{"featureType":"poi","elementType":"geometry.stroke","stylers":[{"color":"#4d6059"}]},{"featureType":"road","elementType":"geometry","stylers":[{"visibility":"on"},{"color":"#7f8d89"}]},{"featureType":"road","elementType":"geometry.fill","stylers":[{"color":"#7f8d89"}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#7f8d89"},{"lightness":17}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#7f8d89"},{"lightness":29},{"weight":0.2}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":18}]},{"featureType":"road.arterial","elementType":"geometry.fill","stylers":[{"color":"#7f8d89"}]},{"featureType":"road.arterial","elementType":"geometry.stroke","stylers":[{"color":"#7f8d89"}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":16}]},{"featureType":"road.local","elementType":"geometry.fill","stylers":[{"color":"#7f8d89"}]},{"featureType":"road.local","elementType":"geometry.stroke","stylers":[{"color":"#7f8d89"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":19}]},{"featureType":"water","elementType":"all","stylers":[{"color":"#2b3638"},{"visibility":"on"}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#2b3638"},{"lightness":17}]},{"featureType":"water","elementType":"geometry.fill","stylers":[{"color":"#24282b"}]},{"featureType":"water","elementType":"geometry.stroke","stylers":[{"color":"#24282b"}]},{"featureType":"water","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels.text","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels.text.fill","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels.text.stroke","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels.icon","stylers":[{"visibility":"off"}]}]', + self::STYLE_DARK_GREY => '[{"featureType":"all","elementType":"labels.text.fill","stylers":[{"saturation":36},{"color":"#000000"},{"lightness":40}]},{"featureType":"all","elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#000000"},{"lightness":16}]},{"featureType":"all","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":17},{"weight":1.2}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":21}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":17}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":29},{"weight":0.2}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":18}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":16}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":19}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":17}]}]', + self::STYLE_DESERT => '[{"elementType":"labels","stylers":[{"visibility":"off"},{"color":"#f49f53"}]},{"featureType":"landscape","stylers":[{"color":"#f9ddc5"},{"lightness":-7}]},{"featureType":"road","stylers":[{"color":"#813033"},{"lightness":43}]},{"featureType":"poi.business","stylers":[{"color":"#645c20"},{"lightness":38}]},{"featureType":"water","stylers":[{"color":"#1994bf"},{"saturation":-69},{"gamma":0.99},{"lightness":43}]},{"featureType":"road.local","elementType":"geometry.fill","stylers":[{"color":"#f19f53"},{"weight":1.3},{"visibility":"on"},{"lightness":16}]},{"featureType":"poi.business"},{"featureType":"poi.park","stylers":[{"color":"#645c20"},{"lightness":39}]},{"featureType":"poi.school","stylers":[{"color":"#a95521"},{"lightness":35}]},{},{"featureType":"poi.medical","elementType":"geometry.fill","stylers":[{"color":"#813033"},{"lightness":38},{"visibility":"off"}]},{},{},{},{},{},{},{},{},{},{},{},{"elementType":"labels"},{"featureType":"poi.sports_complex","stylers":[{"color":"#9e5916"},{"lightness":32}]},{},{"featureType":"poi.government","stylers":[{"color":"#9e5916"},{"lightness":46}]},{"featureType":"transit.station","stylers":[{"visibility":"off"}]},{"featureType":"transit.line","stylers":[{"color":"#813033"},{"lightness":22}]},{"featureType":"transit","stylers":[{"lightness":38}]},{"featureType":"road.local","elementType":"geometry.stroke","stylers":[{"color":"#f19f53"},{"lightness":-10}]},{},{},{}]', + self::STYLE_LIGHT_BLUE_WATER => '[{"featureType":"administrative","elementType":"labels.text.fill","stylers":[{"color":"#444444"}]},{"featureType":"landscape","elementType":"all","stylers":[{"color":"#f2f2f2"}]},{"featureType":"poi","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"road","elementType":"all","stylers":[{"saturation":-100},{"lightness":45}]},{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"road.arterial","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"all","stylers":[{"color":"#46bcec"},{"visibility":"on"}]}]', + self::STYLE_LIGHT_DREAM => '[{"featureType":"landscape","stylers":[{"hue":"#FFBB00"},{"saturation":43.400000000000006},{"lightness":37.599999999999994},{"gamma":1}]},{"featureType":"road.highway","stylers":[{"hue":"#FFC200"},{"saturation":-61.8},{"lightness":45.599999999999994},{"gamma":1}]},{"featureType":"road.arterial","stylers":[{"hue":"#FF0300"},{"saturation":-100},{"lightness":51.19999999999999},{"gamma":1}]},{"featureType":"road.local","stylers":[{"hue":"#FF0300"},{"saturation":-100},{"lightness":52},{"gamma":1}]},{"featureType":"water","stylers":[{"hue":"#0078FF"},{"saturation":-13.200000000000003},{"lightness":2.4000000000000057},{"gamma":1}]},{"featureType":"poi","stylers":[{"hue":"#00FF6A"},{"saturation":-1.0989010989011234},{"lightness":11.200000000000017},{"gamma":1}]}]', + self::STYLE_LIGHT_GREY => '[{"featureType":"administrative","elementType":"all","stylers":[{"saturation":"-100"}]},{"featureType":"administrative.province","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"landscape","elementType":"all","stylers":[{"saturation":-100},{"lightness":65},{"visibility":"on"}]},{"featureType":"poi","elementType":"all","stylers":[{"saturation":-100},{"lightness":"50"},{"visibility":"simplified"}]},{"featureType":"road","elementType":"all","stylers":[{"saturation":"-100"}]},{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"road.arterial","elementType":"all","stylers":[{"lightness":"30"}]},{"featureType":"road.local","elementType":"all","stylers":[{"lightness":"40"}]},{"featureType":"transit","elementType":"all","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"water","elementType":"geometry","stylers":[{"hue":"#ffff00"},{"lightness":-25},{"saturation":-97}]},{"featureType":"water","elementType":"labels","stylers":[{"lightness":-25},{"saturation":-100}]}]', + self::STYLE_MID_NIGHT => '[{"featureType":"all","elementType":"labels.text.fill","stylers":[{"color":"#ffffff"}]},{"featureType":"all","elementType":"labels.text.stroke","stylers":[{"color":"#000000"},{"lightness":13}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#000000"}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#144b53"},{"lightness":14},{"weight":1.4}]},{"featureType":"landscape","elementType":"all","stylers":[{"color":"#08304b"}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#0c4152"},{"lightness":5}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#000000"}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#0b434f"},{"lightness":25}]},{"featureType":"road.arterial","elementType":"geometry.fill","stylers":[{"color":"#000000"}]},{"featureType":"road.arterial","elementType":"geometry.stroke","stylers":[{"color":"#0b3d51"},{"lightness":16}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#000000"}]},{"featureType":"transit","elementType":"all","stylers":[{"color":"#146474"}]},{"featureType":"water","elementType":"all","stylers":[{"color":"#021019"}]}]', + self::STYLE_NATURE_COLOR => '[{"featureType":"landscape","stylers":[{"hue":"#FFA800"},{"saturation":0},{"lightness":0},{"gamma":1}]},{"featureType":"road.highway","stylers":[{"hue":"#53FF00"},{"saturation":-73},{"lightness":40},{"gamma":1}]},{"featureType":"road.arterial","stylers":[{"hue":"#FBFF00"},{"saturation":0},{"lightness":0},{"gamma":1}]},{"featureType":"road.local","stylers":[{"hue":"#00FFFD"},{"saturation":0},{"lightness":30},{"gamma":1}]},{"featureType":"water","stylers":[{"hue":"#00BFFF"},{"saturation":6},{"lightness":8},{"gamma":1}]},{"featureType":"poi","stylers":[{"hue":"#679714"},{"saturation":33.4},{"lightness":-25.4},{"gamma":1}]}]' + ]; + + /** + * @return array + */ + public function toOptionArray() + { + $options = []; + foreach ($this->toArray() as $value => $label) { + $options[] = [ + 'value' => $value, + 'label' => $label + ]; + } + + return $options; + } + + /** + * Get options in "key-value" format + * + * @return array + */ + public function toArray() + { + return [ + self::STYLE_DEFAULT => __('Default'), + self::STYLE_BLUE_ESSENCE => __('Blue Essence'), + self::STYLE_DARK_GREEN => __('Dark Green'), + self::STYLE_DARK_GREY => __('Dark Grey'), + self::STYLE_DESERT => __('Desert'), + self::STYLE_LIGHT_BLUE_WATER => __('Light Blue Water'), + self::STYLE_LIGHT_DREAM => __('Light Dream'), + self::STYLE_LIGHT_GREY => __('Light Grey'), + self::STYLE_MID_NIGHT => __('Mid Night'), + self::STYLE_NATURE_COLOR => __('Nature Color') + ]; + } + + /** + * @param $style + * + * @return mixed + */ + public function getMapData($style) + { + return self::MAP_DATA[$style]; + } +} diff --git a/Model/Config/Source/System/MapType.php b/Model/Config/Source/System/MapType.php new file mode 100644 index 0000000..6cd4673 --- /dev/null +++ b/Model/Config/Source/System/MapType.php @@ -0,0 +1,67 @@ +toArray() as $value => $label) { + $options[] = [ + 'value' => $value, + 'label' => $label + ]; + } + + return $options; + } + + /** + * Get options in "key-value" format + * + * @return array + */ + public function toArray() + { + return [ + self::TYPE_ROAD_MAP => __('Roadmap'), + self::TYPE_TERRAIN => __('Terrain'), + self::TYPE_SATELLITE => __('Satellite'), + self::TYPE_HYBRID => __('Hybrid') + ]; + } +} diff --git a/Model/Config/Source/System/Position.php b/Model/Config/Source/System/Position.php new file mode 100644 index 0000000..4509a8c --- /dev/null +++ b/Model/Config/Source/System/Position.php @@ -0,0 +1,61 @@ +toArray() as $value => $label) { + $options[] = [ + 'value' => $value, + 'label' => $label + ]; + } + + return $options; + } + + /** + * Get options in "key-value" format + * + * @return array + */ + public function toArray() + { + return [self::POSITION_TOP => __('Top'), self::POSITION_BOTTOM => __('Bottom')]; + } +} diff --git a/Model/Config/Source/System/Protocol.php b/Model/Config/Source/System/Protocol.php new file mode 100644 index 0000000..67aa16f --- /dev/null +++ b/Model/Config/Source/System/Protocol.php @@ -0,0 +1,61 @@ +toArray() as $value => $label) { + $options[] = [ + 'value' => $value, + 'label' => $label + ]; + } + + return $options; + } + + /** + * Get options in "key-value" format + * + * @return array + */ + public function toArray() + { + return [self::API => __('API'), self::EMBED_CODE => __('Embed Code')]; + } +} diff --git a/etc/acl.xml b/etc/acl.xml new file mode 100644 index 0000000..9b41c35 --- /dev/null +++ b/etc/acl.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + diff --git a/etc/adminhtml/menu.xml b/etc/adminhtml/menu.xml new file mode 100644 index 0000000..b68033e --- /dev/null +++ b/etc/adminhtml/menu.xml @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml new file mode 100644 index 0000000..8a56437 --- /dev/null +++ b/etc/adminhtml/system.xml @@ -0,0 +1,133 @@ + + + + +
+ + mageplaza + Mageplaza_GoogleMaps::configuration + + + + + Magento\Config\Model\Config\Source\Yesno + Yes to enable this module]]> + + + + Magento\Config\Model\Config\Source\Yesno + + + + Mageplaza\GoogleMaps\Model\Config\Source\System\Position + + 1 + + + + + + + + Mageplaza\GoogleMaps\Model\Config\Source\System\Protocol + + + + + 1 + + here.]]> + + + + Mageplaza\GoogleMaps\Model\Config\Source\System\MapType + + 1 + + + + + Mageplaza\GoogleMaps\Model\Config\Source\System\MapStyle + + 1 + + + + + Magento\Config\Model\Config\Source\Yesno + + 1 + + Yes to allow dragging the map.]]> + + + + + 1 + + + + + + Mageplaza\GoogleMaps\Model\Config\Backend\Image + mageplaza/google_maps/marker_icon + mageplaza/google_maps/marker_icon + + 1 + + sample icons.]]> + + + + + 2 + + + + + + 1 + + + + + + + + 1 + + Mageplaza\GoogleMaps\Block\Adminhtml\System\Coordinate + + + + required-entry + + + + required-entry + + + +
+
+
diff --git a/etc/config.xml b/etc/config.xml new file mode 100644 index 0000000..6f9692f --- /dev/null +++ b/etc/config.xml @@ -0,0 +1,38 @@ + + + + + + + 1 + 1 + 1 + + + 1 + 0 + 20 + + + + diff --git a/etc/widget.xml b/etc/widget.xml new file mode 100644 index 0000000..fd79289 --- /dev/null +++ b/etc/widget.xml @@ -0,0 +1,43 @@ + + + + + + Mageplaza Google Maps Widget + + + + + + + + + + +