私は仕事をしているウェブページに、そのサイトの連絡先情報を含むラベルとともに、サイトにマークが付けられたGoogleマップを持っています。ボストンやニューヨークのような密集地域では、単一のラベルに複数のサイトの連絡先情報があります。私が抱えている問題は、すべてのサイトの連絡先情報を以下のような単一のテキスト行に入れると、これを正しく機能させることしかできないということです。jsを複数の行に分割する
var labelBoston = [
new GInfoWindowTab("Center", "<b>Beth Israel Deaconess Medical Center</b><br>Jon Doe, MD<br>Harvard Medical School<br>address line here<br>Boston, MA 02215<br>Phone: xxx-xxx-xxxx<br>Fax: xxx-xxx-xxxx<br><a href='mailto:[email protected]'>[email protected]</a><br><br><b>Boston Medical Center</b><br>Jane Doe, Study Coordinator<br>Dept. of Obstetrics-Gynecology<br>address line here<br>100th Floor<br>Boston, MA 02118<br>Phone: xxx-xxx-xxxx<br><a href='mailto:[email protected]'>[email protected]</a>"),
];
これは機能しますが、維持するのは非常に苦労します。特に5つ以上のサイトがある他の都市では、私はこれを次のようなものに分割したいと考えています。
var labelBoston = [
new GInfoWindowTab("Center", "
<b>Beth Israel Deaconess Medical Center</b><br>Jon Doe, MD<br>Harvard Medical School<br>address line here
<br>Boston, MA 02215<br>Phone: xxx-xxx-xxxx<br>Fax: xxx-xxx-xxxx
<br><a href='mailto:[email protected]'>[email protected]</a>
<br><br>
<b>Boston Medical Center</b><br>Jane Doe, Study Coordinator
<br>Dept. of Obstetrics-Gynecology<br>address line here
<br>100th Floor<br>Boston, MA 02118<br>Phone: xxx-xxx-xxxx
<br><a href='mailto:[email protected]'>[email protected]</a>"),
];
この情報を管理することは、より管理しやすいものです。しかし、私が単数のテキスト行に行ったバリエーションは、すべてを完全に破壊します。誰かが私に解決策を見つけるのを助けることができるか?
、だろう、最後に1つの大きな文字列に連結するだけです。たとえば、 'Harvard Medical School'は' var school = 'Harvard Medical School
; 'とすることができます。この方法では、文字列の異なるビットを単独で維持するのは簡単です。 –
HTMLをHTMLファイルに格納し、JavaScriptでハードコードするのではなく、ajaxでロードすることをお勧めします。 –