Switch locations on google map using a dropdown -
i'm new google maps, , have map multiple markers, , want switch between them using dropdown menu.
i'm using code populate dropdown menu markers' title:
// select marker dropdown menu $("select#myselect").change(function(){ gotomarker($(this).val()); }); function makemarkerlist() { var options = ""; $("select#myselect").empty(); (var in markers) { options += "<option value='" + + "'>" + markers[i].map.title + "</option>"; } $("select#myselect").html(options); }
this have far jsfiddle
this shows dropdown menu above map, don't know how markers titles in dropdown menu.
i appreciate help.
thank you.
regarding second problem: original code, shown below, trying pass value of selected item in drop down list panto()
method. however, due way you've set up, value index of markers in markers
array , not latlng
object. passing index panto()
method generates error.
$("select#myselect").change(function(){ //gotomarker($(this).val()); map.panto($(this).val().getposition()); });
to fix that, index , use corresponding marker markers
array:
$("select#myselect").change(function(){ var index = $(this).val(); map.panto(markers[index].position); });
Comments
Post a Comment