2017-12-08 2 views
0

私は4つのページをWordPressのサイトで用意しています。だから、私は4つのスクリプトを作った。api yandexは、ワードプレスサイトの別のページにマップします。

 <!-- 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があります。 しかし、ときに私は、最初のスクリプトが動作して、この例では、私が唯一

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

他のページが空白になります。このスクリプトを含むページ上の地図が表示されます、4ページ内の私のdivを置きます。

のブラウザでは、thisのように見えるので、私はそれが働いている1ページのすべての4つのマップをロードした場合、スクリプトは

が機能していません。しかし、私は特定のページ上の各マップをしたい。

私は物事をうまく動かすために何をすべきですか?

答えて

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>

関連する問題