0
私はWordpressを使用しており、GMapsを使用して複数のマーカーで自分のサイトにマップを表示するのに成功しています。残念ながら、私は自分のサイトの関連する投稿にハイパーリンクされた「ロケーション名」を持っていたいと思っていました。しかし、何らかの理由で、マップ全体をクラッシュさせることなく、情報ウィンドウにハイパーリンクを追加することはできません。GMapを使用したInfowindowへのハイパーリンクの追加
以下は機能するコードです。strip_tags();
機能を削除するとマップは表示されなくなります。私はそれがあまりにも多くの"
を持っていることに関連していると推測しているが、私はそれを働かせる方法を理解できない。
$str = '';
foreach($loop as $p){
//get the meta and taxonomy data
$name = strip_tags(get_the_term_list($p, "mountains"));
$wtr_long = get_post_meta($p,"wtr_longitude",true);
$wtr_lat = get_post_meta($p,"wtr_latitude",true);
//Add to Array
$map_string .= '{latitude: "' . $wtr_lat . '", longitude: "' . $wtr_long . '", html: "' . $name .'"},~!~';
//$map_string .= '{latitude: "' . $wtr_lat . '", longitude: "' . $wtr_long . '", html: "name"},~!~';
}
//Remove last three "~!~" characters from the string not to have one too many arrays when exploding
$clean_map_string = substr($map_string, 0, -3);
//Now I can use explode on ~!~ to get arrays with my string
$map_array = explode('~!~', $clean_map_string);
?>
<!--Map implementation-->
<div id="map" style="width:880px; height: 600px; background-color:grey;"></div>
<script type="text/JavaScript">
$("#map").gMap({
scrollwheel: false,
maptype: G_PHYSICAL_MAP,
markers: [
<?php
$i = 0;
$length = count($map_array)-1;
//Inserts all the markers
foreach($map_array as $value){
if($i != $length){
echo $value;
}
else {
echo str_replace("},", "}],", $value);
}
$i++;
}
?>
popup: false,
zoom: 2 });
</script>
助けてください@ Dr.Molle。 それは魅力のように機能します!変数の経度と緯度を入れ替えました。これは、おそらく私がやらなければならない最も簡単な修正でした。 – WouterB
ああ、申し訳ありませんが、上記のとおりです –