简体   繁体   English

api yandex映射在wordpress网站的不同页面上

[英]api yandex maps on different pages of wordpress site

I have 4 pages in wordpress site where i need to inculde api yandex maps. 我在Wordpress网站上有4个页面,需要在其中插入api yandex地图。 So i created 4 scripts, which works. 所以我创建了4个脚本,可以正常工作。 I included script tags in my footer: 我在页脚中包含了脚本标签:

        <!-- 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>

All scripts have different ids for div blocks, different variable names. 所有脚本的div块都有不同的ID,变量名也不同。 But when i put my divs inside 4 pages, only the first script is working, in this example i will see map only on the page that contains this script 但是,当我将div放在4页内时,只有第一个脚本有效,在此示例中,我只会在包含此脚本的页面上看到map

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

Other pages will be blank. 其他页面将为空白。

In browser it looks like this , so script is not working 在浏览器中看起来像这样 ,因此脚本不起作用

If i load all 4 maps on 1 page it is working. 如果我在一页上加载所有4张地图,它将正常工作。 But i want each map on certain page. 但是我希望每张地图都在特定页面上。

What should i do to get things work? 我应该怎么做才能使工作正常?

Problem solved. 问题解决了。 I guess we have to load yandex json every time. 我猜我们每次都要加载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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM