lcbrq/magento2-googlemap

一个用于Google Map嵌入的Magento 2模块

安装: 860

依赖: 0

建议: 0

安全: 0

星标: 9

关注者: 8

分支: 3

开放问题: 1

类型:magento2-module

1.0.2 2017-10-25 14:17 UTC

This package is not auto-updated.

Last update: 2024-09-29 01:49:24 UTC


README

用法

声明

<block class="LCB\GoogleMap\Block\Render" name="map" as="map" template="map.phtml"/>

在您的布局xml中

以及在您的模板文件中的 <?php echo $this->getChildHtml('map'); ?>

contact_index_index.xml的示例

<referenceContainer name="content" htmlClass="row contact-page" htmlTag="div">
    <block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml">
        <block class="LCB\GoogleMap\Block\Render" name="map" as="map" template="map.phtml"/>
    </block>
</referenceContainer>

配置

Magento2 Google Maps configuration

您也可以在任何页面上使用以下语法

<div id="map"></div>
<script type="text/javascript">// <![CDATA[
    var apiKey = '<GOOGLE_MAPS_API_KEY>';
    require([
        'LCB_GoogleMap/js/map'
    ], function (map) {
        map.render(
                document.getElementById('map'),
                latitude,
                longitude,
                zoom
                );
    });
    // ]]>
</script>

已知问题

缺少地图宽度和高度。请在您的样式表中添加

#map {
    min-width: 640px;
    min-height: 320px;
}