我有这部分代码。我想放置标记,当文本框中的文本发生变化时 - 它与函数 changeValue() 一起使用 - 获取新地址。
然后,我想在地址变量发生变化时放置这个标记。怎么办?
我尝试使用下面的代码,但出现此错误:
Error: ReferenceError: changeValue is not defined
出了什么问题?
(...)
<asp:TextBox Style="width: 300px;" runat="server" ID="tbStreet" onchange="changeValue()"></asp:TextBox>
(...) // more 5 textboxes
<script type='text/javascript'>
(...) // 2 long string arrays.
var address;
function mapaStart() {
var wspolrzedne = new google.maps.LatLng(52.22105994970536, 19.22609921875007);
var opcjeMapy = {
zoom: 5,
center: wspolrzedne,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("mapka"), opcjeMapy);
function changeValue() {
var ulica;
var miasto;
var woj1;
var panstwo1;
ulica = document.getElementById("<%=tbStreet.ClientID%>").value;
miasto = document.getElementById("<%=tbCity.ClientID%>").value;
woj1 = woj[document.getElementById("<%=ddlProvince.ClientID%>").value];
panstwo1 = panstwa[document.getElementById("<%=ddlCountry.ClientID%>").value];
address = panstwo1 + ", " + woj1 + ", " + miasto + ", " + ulica;
alert(address);
}
var geokoder = new google.maps.Geocoder();
map.setCenter(address.geometry.location);
var marker = new google.maps.Marker(
{
map: map,
position: address.geometry.location,
}
);
}
</script>