如何更改地理完整地图实例的选项,例如,如果单击#center按钮,则将zoomControl更改为true。
<!DOCTYPE html>
<html>
<head>
<title>$.geocomplete()</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<form>
<input id="geocomplete" type="text" placeholder="Type in an address" size="90" />
<input id="find" type="button" value="find" />
</form>
<div class="map_canvas"></div>
Call:
<button id="search">.geocomplete("find", "NYC")</button>
<button id="center">.geocomplete("map").setCenter()</button>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="../jquery.geocomplete.js"></script>
<script src="logger.js"></script>
<script>
$(function(){
$("#geocomplete").geocomplete({
map: ".map_canvas",
mapOptions: {
zoom: 10,
zoomControl: false,
},
});
$("#search").click(function(){
$("#geocomplete").geocomplete("find", "NYC");
});
$("#center").click(function(){
var map = $("#geocomplete").geocomplete("map"),
center = new google.maps.LatLng(10, 0);
map.setCenter(center);
map.setZoom(3);
});
});
</script>
</body>
</html>