【发布时间】:2014-04-10 11:25:17
【问题描述】:
我很困惑用选项值更改我的自定义图标映射。所以请帮我处理你的cmets。 :D
这是选项值
<select name='type' id='type' onChange='document.getElementById("customicon").value="this.value"'>
<option<?php if($place['type'] == "sekolahremaja") {?> selected="selected"<?php } ?>>Sekolah Remaja</option>
<option<?php if($place['type'] == "jalanremaja") {?> selected="selected"<?php } ?>>Jalan Remaja</option>
<option<?php if($place['type'] == "komunitas") {?> selected="selected"<?php } ?>>Komunitas</option>
<option<?php if($place['type'] == "screening") {?> selected="selected"<?php } ?>>Screening</option>
<option<?php if($place['type'] == "lembaga") {?> selected="selected"<?php } ?>>Lembaga</option>
<option<?php if($place['type'] == "personal") {?> selected="selected"<?php } ?>>Personal</option>
<option<?php if($place['type'] == "foto") {?> selected="selected"<?php } ?>>Foto</option>
</select>
这是我的 javascript 代码
var customicon = {
"sekolahremaja" : "sekolahremaja",
"jalanremaja" : "jalanremaja",
"komunitas" : "komunitas",
"screening" : "screening",
"lembaga" : "lembaga",
"personal" : "personal",
"events" : "events",
};
var markerImage = "../images/icons/"+customicon+".png";
<?php if ($_GET['place_id']){?>
var marker = new google.maps.Marker({
position: new google.maps.LatLng(<?=$place['lat']?>,<?=$place['lng']?>),
map: map,
animation: google.maps.Animation.DROP,
draggable: true,
icon: markerImage
});
【问题讨论】:
-
也许你需要像
var markerImage = "../images/icons/"+customicon[keyOfSelectedOption]+".png";这样的东西,因为customicon 是JSON 数据。无论如何#customicon 是什么? -
#customicon 是我的选项值变量,我不知道是不是错了。我不知道如何使用javascript -_-
标签: javascript php google-maps drop-down-menu options