Google maps 谷歌地图API V3:基于搜索if/else创建标记HTML
我在这里设置了商店定位器: lat、lng、姓名、地址、csz和电话信息存储在mySQL数据库中。如果输入邮政编码13165,定位器将正常工作。但是,我需要限制邮政编码的范围以显示一个标记,并显示邮政编码66000到69999范围内的标记html。这部分实际上是使用函数searchLocations部分将地图居中,但我需要函数createMarkerlatlng、name、address、csz、phone和函数createOptionname、distance、num部分的帮助 当前,如果使用邮政编码67501,地图将居中,但不显示任何标记。我需要它在一个特定的位置放置一个标记,并将Company Name Inc,123 Main St,Anywhere KS 67501555-555-1234作为标记HTML。如果在66000到69999范围内使用zip,则该标记将是静态的 如果这是一个更简单的解决方案,我也可以在数据库方面做一些事情 感谢您的帮助 以下是我遇到问题的3个部分:Google maps 谷歌地图API V3:基于搜索if/else创建标记HTML,google-maps,google-maps-api-3,google-geocoding-api,Google Maps,Google Maps Api 3,Google Geocoding Api,我在这里设置了商店定位器: lat、lng、姓名、地址、csz和电话信息存储在mySQL数据库中。如果输入邮政编码13165,定位器将正常工作。但是,我需要限制邮政编码的范围以显示一个标记,并显示邮政编码66000到69999范围内的标记html。这部分实际上是使用函数searchLocations部分将地图居中,但我需要函数createMarkerlatlng、name、address、csz、phone和函数createOptionname、distance、num部分的帮助 当前,如果使用
function searchLocations() {
var address = document.getElementById("addressInput").value;
var mylatlng = new google.maps.LatLng(37.928552, -97.898658);
var geocoder = new google.maps.Geocoder();
if (address >= 66000 && address <= 69999) {
map.setCenter(mylatlng);
map.setZoom(10); }
else {
geocoder.geocode({address: address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
searchLocationsNear(results[0].geometry.location); }
else {
alert(address + ' not found');
}
});
}}
function createMarker(latlng, name, address, csz, phone) {
var html = "<font face = 'arial'>" + "<b>" + name + "</b> <br/>" + address + "<br/>" + csz + "<br/>" + phone + "</font>";
var marker = new google.maps.Marker({
map: map,
position: latlng
});
google.maps.event.addListener(marker, 'click', function() {
infoWindow.setContent(html);
infoWindow.open(map, marker);
});
markers.push(marker);
}
function createOption(name, distance, num) {
var option = document.createElement("option");
option.value = num;
option.innerHTML = name + "(" + distance.toFixed(1) + ")";
locationSelect.appendChild(option);
}
你能把问题代码的关键部分添加到你的问题中,并且对你的问题更具体一点吗?