【问题标题】:api yandex maps on different pages of wordpress siteapi yandex 在 wordpress 网站的不同页面上映射
【发布时间】:2017-12-08 13:01:03
【问题描述】:

我在 wordpress 站点中有 4 个页面,我需要在其中包含 api yandex 地图。所以我创建了 4 个脚本,它们可以工作。我在页脚中包含了脚本标签:

        <!-- Yandex map scripts -->
    <script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="application/javascript"></script>
    <script src="/wp-content/themes/bla" type="application/javascript"></script>
    <script src="/wp-content/themes/blabla" type="application/javascript"></script>
    <script src="/wp-content/themes/blablabla" type="application/javascript"></script>
    <script src="/wp-content/themes/blablablabla" type="application/javascript"></script>

所有脚本都有不同的 div 块 ID,不同的变量名。 但是当我把我的 div 放在 4 页内时,只有第一个脚本在工作,在这个例子中,我只会在包含这个脚本的页面上看到地图

<script src="/wp-content/themes/bla" type="application/javascript"></script>

其他页面将为空白。

在浏览器中看起来像this,所以脚本不起作用

如果我在 1 个页面上加载所有 4 个地图,它就可以工作。但我希望每个地图都在某个页面上。

我应该怎么做才能让事情顺利进行?

【问题讨论】:

    标签: javascript php wordpress yandex-maps


    【解决方案1】:

    问题解决了。 我想我们每次都必须加载 yandex json。

    <!-- Yandex map scripts --> <script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script> <script src="/wp-content/themes/bbbb" type="application/javascript"></script> <script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script> <script src="/wp-content/themes/b" type="application/javascript"></script> <script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script> <script src="/wp-content/themes/bbb" type="application/javascript"></script> <script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script> <script src="/wp-content/themes/bb" type="application/javascript"></script> <script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>

    【讨论】:

      猜你喜欢
      • 2011-05-06
      • 2018-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-26
      • 2011-10-07
      • 2023-01-19
      • 1970-01-01
      相关资源
      最近更新 更多