Skip to content

Commit

Permalink
Merge pull request #6 from mageplaza/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
haitv282 committed Jul 31, 2019
2 parents 9bf1621 + 81a6e8b commit 503452b
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 54 deletions.
5 changes: 2 additions & 3 deletions Block/Adminhtml/System/Coordinate.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public function __construct(
Context $context,
Data $helperData,
array $data = []
)
{
) {
$this->helperData = $helperData;

parent::__construct($context, $data);
Expand All @@ -65,7 +64,7 @@ public function __construct(
/**
* Render fieldset html
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @param AbstractElement $element
*
* @return string
*/
Expand Down
7 changes: 3 additions & 4 deletions Block/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ public function __construct(
Context $context,
Data $helperData,
array $data = []
)
{
) {
$this->helperData = $helperData;

parent::__construct($context, $data);
Expand Down Expand Up @@ -107,7 +106,7 @@ public function getMapMarkerIcon()
*/
public function getMapZoomDefault()
{
return ((int)$this->helperData->getMapConfig('zoom_default')) ?: 20;
return ((int) $this->helperData->getMapConfig('zoom_default')) ?: 20;
}

/**
Expand All @@ -117,7 +116,7 @@ public function getMapZoomDefault()
*/
public function getMapTypeId()
{
return ($this->helperData->getMapConfig('map_type')) ?: 'roadmap';
return $this->helperData->getMapConfig('map_type') ?: 'roadmap';
}

/**
Expand Down
18 changes: 10 additions & 8 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
namespace Mageplaza\GoogleMaps\Helper;

use Magento\Framework\App\Helper\Context;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\ObjectManagerInterface;
use Magento\Store\Model\StoreManagerInterface;
use Mageplaza\Core\Helper\AbstractData;
Expand Down Expand Up @@ -60,9 +61,8 @@ public function __construct(
StoreManagerInterface $storeManager,
Image $helperImage,
MapStyle $mapStyleData
)
{
$this->_helperImage = $helperImage;
) {
$this->_helperImage = $helperImage;
$this->_mapStyleData = $mapStyleData;

parent::__construct($context, $objectManager, $storeManager);
Expand All @@ -86,15 +86,17 @@ public function getMapConfig($code, $storeId = null)
/**
* Get custom marker icon Url
*
* @return bool|string
* @return string
* @throws NoSuchEntityException
*/
public function getMarkerUrl()
{
if ($this->getMapConfig('marker_icon')) {
return $this->_helperImage->getBaseMediaUrl() . '/' . $this->_helperImage->getMediaPath($this->getMapConfig('marker_icon'), 'marker_icon');
} else {
return '';
return $this->_helperImage->getBaseMediaUrl() . '/'
. $this->_helperImage->getMediaPath($this->getMapConfig('marker_icon'), 'marker_icon');
}

return '';
}

/**
Expand All @@ -106,4 +108,4 @@ public function getMapTheme($styleName)
{
return $this->_mapStyleData->getMapData($styleName);
}
}
}
2 changes: 1 addition & 1 deletion Model/Config/Source/System/MapStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MapStyle implements ArrayInterface
const STYLE_LIGHT_GREY = 'light-grey';
const STYLE_MID_NIGHT = 'mid-night';
const STYLE_NATURE_COLOR = 'nature-color';
CONST MAP_DATA = [
const MAP_DATA = [
self::STYLE_DEFAULT => '[]',
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"}]}]',
Expand Down
2 changes: 1 addition & 1 deletion USER-GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- User Guide: https://docs.mageplaza.com/google-maps/
- Product page: https://www.mageplaza.com/magento-2-google-maps/
- FAQs: https://www.mageplaza.com/faqs/
- Get Support: https://mageplaza.freshdesk.com/ or [email protected]
- Get Support: https://www.mageplaza.com/contact.html or [email protected]
- Changelog: https://www.mageplaza.com/releases/google-maps/
- License agreement: https://www.mageplaza.com/LICENSE.txt

Expand Down
Binary file modified UserGuide.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "mageplaza/module-google-maps",
"description": "Magento 2 Google Maps Extension",
"require": {
"mageplaza/module-core": "^1.4.0"
"mageplaza/module-core": "^1.4.5"
},
"type": "magento2-module",
"version": "1.0.1",
"version": "1.0.2",
"license": "proprietary",
"authors": [
{
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
</field>
<field id="zoom_default" translate="label comment" type="text" sortOrder="60" showInWebsite="1" showInStore="1" showInDefault="1">
<label>Zoom Default</label>
<validate>validate-zero-or-greater</validate>
<depends>
<field id="protocol">1</field>
</depends>
Expand Down
8 changes: 4 additions & 4 deletions etc/widget.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
-->
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget.xsd">
<widget id="mageplaza_googlemaps_map" class="Mageplaza\GoogleMaps\Block\Map">
<label translate="true">Mageplaza Google Maps</label>
<description translate="true">Mageplaza Google Maps Widget</description>
<label>Mageplaza Google Maps</label>
<description>Mageplaza Google Maps Widget</description>
<parameters>
<parameter name="template" xsi:type="select" required="true" visible="true">
<label translate="true">Template</label>
<label>Template</label>
<options>
<option name="map" value="Mageplaza_GoogleMaps::map.phtml" selected="true">
<label translate="true">Google Map Template</label>
<label>Google Map Template</label>
</option>
</options>
</parameter>
Expand Down
4 changes: 0 additions & 4 deletions i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,3 @@ Address,Address
"GPS Coordinates","GPS Coordinates"
Latitude,Latitude
Longitude,Longitude
"Mageplaza Google Maps","Mageplaza Google Maps"
"Mageplaza Google Maps Widget","Mageplaza Google Maps Widget"
Template,Template
"Google Map Template","Google Map Template"
6 changes: 4 additions & 2 deletions registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
* @license https://www.mageplaza.com/LICENSE.txt
*/

\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
use Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Mageplaza_GoogleMaps',
__DIR__
);
14 changes: 7 additions & 7 deletions view/adminhtml/templates/system/config/coordinate.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ $address = $block->helperData->getMapConfig('location_setting/address');
$btnId = $block->getElement()->getId();
?>
<td id="coordinate-button-label" class="label">
<label for="<?php echo $btnId; ?>_button"></label>
<label for="<?= $btnId ?>_button"></label>
</td>
<td id="coordinate-button-value" class="value">
<button style="margin-bottom: 15px;" id="<?php echo $btnId; ?>_button"
title="<?php echo __("Get GPS coordinates"); ?>"
<button style="margin-bottom: 15px;" id="<?= $btnId ?>_button"
title="<?= __('Get GPS coordinates') ?>"
type="button" class="primary"
role="button" aria-disabled="false">
<span class="ui-button-text">
<span><?php echo __("Get GPS coordinates"); ?></span>
<span><?= __('Get GPS coordinates') ?></span>
</span>
</button>
<div class="mpmessage"></div>
Expand All @@ -42,9 +42,9 @@ $btnId = $block->getElement()->getId();
require([
'jquery',
'mage/translate',
"https://maps.googleapis.com/maps/api/js?key=<?php echo $mapApi ?>"
"https://maps.googleapis.com/maps/api/js?key=<?= $mapApi ?>"
], function ($, $t) {
var buttonCoordinate = $('#<?php echo $btnId; ?>_button');
var buttonCoordinate = $('#<?= $btnId ?>_button');
var message = $('#coordinate-button-value .mpmessage');
var addressEl = $('input#mpgooglemaps_map_setting_location_setting_address');
buttonCoordinate.on('click', function () {
Expand All @@ -53,7 +53,7 @@ $btnId = $block->getElement()->getId();
type: 'GET',
data: {
"address": addressEl.val(),
"key": '<?php echo $mapApi ?>'
"key": '<?= $mapApi ?>'
},
beforeSend: function () {
buttonCoordinate.text($t('Loading...'));
Expand Down
28 changes: 14 additions & 14 deletions view/frontend/templates/map.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@

/** @var \Mageplaza\GoogleMaps\Block\Map $block */
?>
<?php if ($block->getProtocol() == Mageplaza\GoogleMaps\Model\Config\Source\System\Protocol::API): ?>
<?php if ($block->getProtocol() == Mageplaza\GoogleMaps\Model\Config\Source\System\Protocol::API) : ?>
<div class="mpgooglemaps_review_map">
<div class="mpgooglemaps_map" id="mpgooglemaps_map_<?php echo $block->getNameInLayout() ?>"
<div class="mpgooglemaps_map" id="mpgooglemaps_map_<?= $block->getNameInLayout() ?>"
style="height: 550px;width: 100%;margin: 15px 0;">
</div>
</div>
<script>
require([
"https://maps.googleapis.com/maps/api/js?key=<?php echo $block->getMapApi() ?>"
"https://maps.googleapis.com/maps/api/js?key=<?= $block->getMapApi() ?>"
], function () {
var latitude = '<?php echo $block->getMapLatitude() ?>',
longitude = '<?php echo $block->getMapLongitude() ?>';
var isDraggable = <?php echo $block->isMapDraggable() ?>;
var mapStyle = JSON.parse(<?php echo $block->getMapTemplate()?>);
var mapZoomDefault = <?php echo $block->getMapZoomDefault() ?>;
var mapTypeId = '<?php echo $block->getMapTypeId() ?>';
var mapMarkerIcon = '<?php echo $block->getMapMarkerIcon() ?>';
var latitude = '<?= $block->getMapLatitude() ?>',
longitude = '<?= $block->getMapLongitude() ?>';
var isDraggable = <?= $block->isMapDraggable() ?>;
var mapStyle = JSON.parse(<?= $block->getMapTemplate()?>);
var mapZoomDefault = <?= $block->getMapZoomDefault() ?>;
var mapTypeId = '<?= $block->getMapTypeId() ?>';
var mapMarkerIcon = '<?= $block->getMapMarkerIcon() ?>';

function markerMap(latitude, longitude) {
var mapLatLng = new google.maps.LatLng(latitude, longitude);
Expand All @@ -49,7 +49,7 @@
styles: mapStyle
};

var map = new google.maps.Map(document.getElementById("mpgooglemaps_map_<?php echo $block->getNameInLayout() ?>"), mapOptions);
var map = new google.maps.Map(document.getElementById("mpgooglemaps_map_<?= $block->getNameInLayout() ?>"), mapOptions);
var marker = new google.maps.Marker({
draggable: !!(parseInt(isDraggable)),
position: mapLatLng,
Expand All @@ -62,8 +62,8 @@
markerMap(latitude, longitude);
});
</script>
<?php else: ?>
<?php else : ?>
<div class="mpgooglemaps_review_map" style="float: left;width: 100%;margin: 15px 0;">
<?php echo $block->getEmbedCode(); ?>
<?= $block->getEmbedCode() ?>
</div>
<?php endif; ?>
<?php endif; ?>
8 changes: 4 additions & 4 deletions view/frontend/templates/map/position.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

/** @var \Mageplaza\GoogleMaps\Helper\Data $helperData */
/** @var \Magento\Framework\View\Element\Template $block */
$helperData = $this->helper('Mageplaza\GoogleMaps\Helper\Data');
$helperData = $this->helper(\Mageplaza\GoogleMaps\Helper\Data::class);
$position = $helperData->getConfigGeneral('position');
if ($helperData->getConfigGeneral('contact_page') && $position == $block->getData('position')):
echo $block->getLayout()->createBlock('Mageplaza\GoogleMaps\Block\Map')->toHtml();
endif;
if ($helperData->getConfigGeneral('contact_page') && $position == $block->getData('position')) : ?>
<?= $block->getLayout()->createBlock(\Mageplaza\GoogleMaps\Block\Map::class)->toHtml() ?>
<?php endif; ?>

0 comments on commit 503452b

Please sign in to comment.