Google maps api 3 如何显示“选择选项”值中的标记?

Google maps api 3 如何显示“选择选项”值中的标记?,google-maps-api-3,option,Google Maps Api 3,Option,代码只在地址变量上工作。 所以在选择选项中,值有多个地址 function geocodeAddress(geocoder, resultsMap) { var address = document.getElementById('Select').value; for(i = 0; i < address.length;i++){ geocoder.geocode({'a

代码只在地址变量上工作。 所以在选择选项中,值有多个地址

function geocodeAddress(geocoder, resultsMap) {   
                var address = document.getElementById('Select').value;   
                 for(i = 0; i < address.length;i++){   
                 geocoder.geocode({'address': address[i]}, function(results, status) {
                            if (status === google.maps.GeocoderStatus.OK) {
                             // resultsMap.setCenter(results[0].geometry.location);


                              var marker = new google.maps.Marker({
                                map: resultsMap,
                                position: results[i].geometry.location
                              });
                              markers.push(marker);
                            } else {
                              alert('Geocode was not successful for the following reason: ' + status);
                            }   
                        });   
                       }
                    }

修改自相关问题:

var地理编码器; var映射; var Geomemarker; var bounds=new google.maps.LatLngBounds; 函数初始化{ map=新建google.maps.map document.getElementByIdmap_画布{ 中心:新google.maps.LatLng37.4419,-122.1419, 缩放:13, mapTypeId:google.maps.mapTypeId.ROADMAP }; geoMarker=新的google.maps.Marker; geoMarker.setPositionmap.getCenter; geoMarker.setMapmap; var txtArray=$location option.eachfunction{ console.log$this.text; geocodeAddress$this.text; }; $location.changefunction{ var addr=$“位置:选定”。文本; console.logaddr; var geocoder=new google.maps.geocoder; 地理编码{ “地址”:地址 },功能结果,状态{ 如果status==google.maps.GeocoderStatus.OK{ 如果结果为[0]。geometry.viewport{ map.fitbundsresults[0].geometry.viewport; }else if结果[0].geometry.bounds{ map.fitBoundsresults[0].geometry.bounds; }否则{ map.setCenterresults[0].geometry.location; } }否则{ alertError地理编码地址:+地址+状态=+状态; } }; }; } google.maps.event.AddDomainListenerWindow,加载,初始化; 函数geocodeAddressaddress{ var geocoder=new google.maps.geocoder; 地理编码{ “地址”:地址 },功能结果,状态{ 如果status==google.maps.GeocoderStatus.OK{ var marker=new google.maps.marker{ 位置:结果[0]。geometry.location, 地图:地图, 标题:地址 }; bounds.extendresults[0].geometry.location; map.fitbundsbounds; }否则{ alertError地理编码地址:+地址+状态=+状态; } }; } html, 身体 地图画布{ 身高:100%; 宽度:100%; 边际:0px; 填充:0px } 纽约州纽约市 新泽西州纽瓦克 宾夕法尼亚州费城
相关问题:相关问题:但当清晰标记不起作用时。markers.pushmarker;这个问题没有明确的标记,你的意思也不清楚。