I want to draw a custom rectangle which is resizable and draggable with a close button and which is formed with the bounds returned by the query in the database.
Thanks
I want to draw a custom rectangle which is resizable and draggable with a close button and which is formed with the bounds returned by the query in the database.
Thanks
这是一个可调整大小和可拖动的矩形。一点点搜索和一些尝试会给你你需要的东西。
function initialize() {
var myOptions = {
center: new google.maps.LatLng(44.5452, -78.5389),
zoom: 9,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map_canvas'),
myOptions);
var bounds = new google.maps.LatLngBounds(
new google.maps.LatLng(44.490, -78.649),
new google.maps.LatLng(44.599, -78.443)
);
var rectangle = new google.maps.Rectangle({
bounds: bounds,
editable: true
});
rectangle.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
希望这可以帮助!
我认为您唯一需要添加的是矩形选项中的“可拖动:真”。
所以,应该是这样的;
var rectangle = new google.maps.Rectangle({
bounds: bounds,
editable: true,
draggable: true
});
这将使矩形可调整大小和可拖动。同样在页面正文中创建一个按钮。
<body >
<button onclick="remove()">Close</button>
</body>
在删除函数中,您可以编写代码以连接到数据库。您必须在 initialize() 之外声明边界才能访问它。此链接可能会帮助您了解如何连接谷歌地图和 MySQL。https://developers.google.com/maps/articles/phpsqlajax_v3