ここにうまく機能するフォーム要素があります:
<input id="addreessinput1" style="width:20%" value="Enter Address"/>
<input id="showaddress1" type="button" value="Show Tech Home" style="width:10%"/>
これにより、以下の JavaScript コードが正常に起動されます。アドレス入力1を変更すると
<select name="addreessinput1" style="width:20%">
<option value="my address">my address</option>
</select>
$("#showaddress1").click(geoCode1);
クリックから変更への変更を効果なしに変更してみました。私は何を間違っていますか?
function geoCode1(){
var address = $("#addreessinput1").val();
geocoder = new google.maps.Geocoder();
if(geocoder){
geocoder.geocode( { 'address': address }, function(results, status) { // status is empty
if (status == google.maps.GeocoderStatus.OK) {
$("#lnf").css("display","none");
var mposition = new google.maps.LatLng(results[0].geometry.location.lat(),results[0].geometry.location.lng());
var image = new google.maps.MarkerImage('beachflag.png',
new google.maps.Size(20, 32),
new google.maps.Point(0,0),
new google.maps.Point(0, 32));
var shadow = new google.maps.MarkerImage('beachflag_shadow.png',
new google.maps.Size(37, 32),
new google.maps.Point(0,0),
new google.maps.Point(0, 32));
var shape = {
coord: [1, 1, 1, 20, 18, 20, 18 , 1],
type: 'poly'
};
if(mapa.addressmarker){
mapa.addressmarker.setMap(null);
mapa.bounds = new google.maps.LatLngBounds();
mapa.map.fitBounds(mapa.bounds);
}
mapa.addressmarker = new google.maps.Marker({
position: mposition,
map:mapa.map,
title:address,
icon:image,
shadow:shadow,
shape:shape
});
mapa.bounds.extend(mposition);
mapa.map.fitBounds(mapa.bounds);
}
else if(status == google.maps.GeocoderStatus.ZERO_RESULTS){
mapa.addressmarker.setMap(null);
$("#lnf").css("display","block");
}
});
}
}
$(document).ready(function(){
$("#date1" ).datetimepicker({
inline: true,
dateFormat: "yy-mm-dd",
timeFormat: "HH:mm",
pickerTimeFormat: "HH:mm"
});
$("#date2" ).datetimepicker({
inline: true,
dateFormat: "yy-mm-dd",
timeFormat: "HH:mm",
pickerTimeFormat: "HH:mm",
hour: 23,
minute: 59
});
var mapOptions = {center: new google.maps.LatLng(26.549473, -81.847920),
zoom: mapa.zoom,
mapTypeId: google.maps.MapTypeId.HYBRID
};
mapa.map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
$("#user_id").change(getUserMarkers);
$("#markerslist").change(upMarker);
$("#getmarkers").click(getUserMarkers);
$("#showaddress").click(geoCode);
$("#showaddress1").click(geoCode1);
});
トニー