Google Mas如何根据点击点位置画圆,然后可以删除这个圆 求回复!!!!和代码Google地图
解决方案 »
- js字符串分割求教
- js有指针方法怎么调用?
- 【分享】看看最近你上过哪些网站!
- 请教个页面加载时脚本的问题
- 如何在新窗体中打开
- JS如何取GRIDVIEW当前行某一列的值
- 用table 实现datagrid功能 跟踪日记
- 在javascript中怎样才可以判断上传文件的大小啊?急等~~~~
- 大哥,大姐~~~哭求~"编写刻度"问题~
- jqgrid配置列为select的时候,设置 editoptions中dataurl,服务器如何返回数据?
- 谁能给我入门级的JS项目实例代码大全
- 求指教:java swing / javascript 实现两文本文件的内容对比(类似svn 的“show changes"功能)
<html><head>
<title>JavaScript SVG Animation</title>
<body onload="init(); doAnim();"> <!-- init() sets up the animation, doAnim() actually does the animation. -->
<svg width="800px" height="800px" >
<circle onclick=" this.parentNode.removeChild(this)" r="10" cx="100" cy="100" style="fill:green"/>
<circle onclick="this.parentNode.removeChild(this)" r="10" cx="200" cy="200" style="fill:red"/>
</svg>
</body>
</html>
也可以参考这两个帖子:
添加圆: http://stackoverflow.com/questions/15111403/google-maps-api-v3-change-circle-radius-by-click-event
删除圆: http://stackoverflow.com/questions/6539215/google-maps-v3-clearing-a-circle-made-from-polylines-off-the-map
<html>
<head>
<div id="map"></div>
<style media="screen, projection" type="text/css">
#map {
width: 800px;
height: 400px;
}</style>
<script type="text/javascript">
function removeCircles() {
if (circles) {
for (var idx = 0; idx < circles.length; idx++) {
circles[idx].setMap(null);
}
}
if (ers) {
for (var idx = 0; idx < ers.length; idx++) {
ers[idx].setMap(null);
}
}
}
</script>
</head>
<body>
<div>
<input type="button" value="Remove all Circles" onclick="removeCircles();" />
</div>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script><script type="text/javascript">
var circle, map, pre_radius;
function initialize() {
pre_radius = '60000'; var mapCenter = new google.maps.LatLng(40, -74); map = new google.maps.Map(document.getElementById('map'), {
'zoom': 7,
'center': mapCenter,
'mapTypeId': google.maps.MapTypeId.ROADMAP
}); // Add click event listenecal
calcRadius(60000);
}; var circles = new Array();
var ers = new Array();
function calcRadius(radiusVal) {
pre_radius = radiusVal;
google.maps.event.addListener(map, "click", function (e) { var image = new google.maps.MarkerImage(
'http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png',
new google.maps.Size(40, 35),
new google.maps.Point(0, 0),
new google.maps.Point(20, 30)
); var shadow = new google.maps.MarkerImage(
'http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png',
new google.maps.Size(62, 35),
new google.maps.Point(0, 0),
new google.maps.Point(0, 35)
); var er = new google.maps.Marker({
draggable: true,
raiseOnDrag: false,
icon: image,
map: map,
position: e.latLng
}); circle = new google.maps.Circle({
map: map,
radius: pre_radius,
fillColor: '#AA0000'
}); console.log(circle); circle.bindTo('center', er, 'position'); circles[circles.length] = circle;
ers[ers.length] = er;
});
} google.maps.event.addDomListener(window, 'load', initialize);
</script>
</body>
</html>
<html>
<head>
<div id="map"></div>
<style media="screen, projection" type="text/css">
#map {
width: 800px;
height: 400px;
}</style>
<script type="text/javascript">
function removeCircles() {
if (circles) {
for (var idx = 0; idx < circles.length; idx++) {
circles[idx].setMap(null);
}
}
}
</script>
</head>
<body>
<div>
<input type="button" value="Remove all Circles" onclick="removeCircles();" />
</div>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script><script type="text/javascript">
var circle, map, pre_radius;
var circles = new Array();
function initialize() {
pre_radius = '60000'; var mapCenter = new google.maps.LatLng(40, -74); map = new google.maps.Map(document.getElementById('map'), {
'zoom': 7,
'center': mapCenter,
'mapTypeId': google.maps.MapTypeId.ROADMAP
}); calcRadius(60000);
} function calcRadius(radiusVal) {
pre_radius = radiusVal;
google.maps.event.addListener(map, "click", function (e) { circle = new google.maps.Circle({
map: map,
radius: pre_radius,
fillColor: '#AA0000',
center: e.latLng
}); console.log(circle); circles[circles.length] = circle;
});
} google.maps.event.addDomListener(window, 'load', initialize);
</script>
</body>
</html>