我有以下代码,
<script type="text/javascript">
var map;
$(document).ready(function() {
initialize();
$("#menu").on("click", ".panTo", function() {
var laLatLng = new google.maps.LatLng(4.6747035,-74.0575514); /My question
map.panTo(laLatLng);
var marker = new google.maps.Circle({
strokeColor: "#8ada55",
fillColor: "#bcff8f",
strokeOpacity: 0.8,
strokeWeight: 2,
fillOpacity: 0.5,
map: map,
center: laLatLng,
radius:300
});
});
});
function initialize() {
var myOptions = {
zoom: 15,
center: new google.maps.LatLng(4.5980556,-74.0758333),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);;
}
</script>
<div id="map_canvas" style="width: 650px; height:400px"></div>
<div id="menu">
<label>Location 1</label>
<input type="button" class="panTo" value="4.6747035,-74.0575514" />
<br /><br />
</div>
我的问题是如何在 Javascript 代码中设置来自输入值的值。?
正好在这一行:LatLng(4.6747035,-74.0575514);
因为我会有很多地址,有按钮,所以当有人点击按钮时,LatLng 必须更新。