tibormarias 0 Newbie Poster

Dear Readers!

I would like to ask your kind help about showing just the selected markers in Google Maps API V3.

I have a HTML select ->

<select onchange="appartments()" id="selectField">
<option value="appartment1">Choose one appartment...</option>
<option value="appartment2">1052 Budapest, Galamb u. 3.</option>
<option value="appartment3">1052 Budapest, Régi posta u. 11.</option>
<option value="appartment4">1052 Budapest, Régi posta u. 14.</option>
<option value="appartment5">1051 Budapest, Vörösmarty tér 2.</option>
<option value="appartment6">1066 Budapest, Ó u. 5.</option>
</select>

I have the API V3 and the markers ->

function appartments() {
    var get_id = document.getElementById('selectField');
    console.log(get_id);
    var result = get_id.options[get_id.selectedIndex].value;
    }

IF ELSE HERE!   
var marker = new google.maps.Marker();
marker.setPosition(new google.maps.LatLng(47.5037832, 19.0575725));
marker.setMap(map);

var marker = new google.maps.Marker();
marker.setPosition(new google.maps.LatLng(47.4947063,19.0527723));
marker.setMap(map);

var marker = new google.maps.Marker();
marker.setPosition(new google.maps.LatLng(47.4968459,19.0505202));
marker.setMap(map);


var marker = new google.maps.Marker();
marker.setPosition(new google.maps.LatLng(47.494265,19.0516276));
marker.setMap(map);


var marker = new google.maps.Marker();
marker.setPosition(new google.maps.LatLng(47.4933959,19.0515483));
marker.setMap(map);

}

I would like to get the marker which is selected in HTML select, for example ->

if (result = appartment1) {

var marker...

} else if (result = appartment2) {

var marker..

} blablabla

Could anybody help me giving me a simple way for solving this?

Thanks a lot in advance,

Tibor