<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Locus </title>
<style type="text/css">
html
{
height: 100%;
}
body
{
height: 100%;
margin: 0px;
padding: 0px;
}
#map_canvas
{
height: 100%;
}
</style>
<script type="text/javascript" src="http://ditu.google.com/maps?file=api&v=2&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA&hl=zh-CN""></script>
<script type="text/javascript">
var map;
var radius=100;
var mycircle;
function initialize() {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(39.88023492849342, 110.225830078125), 5);
map.addControl(new GMapTypeControl());
map.addControl(new GLargeMapControl());
map.enableScrollWheelZoom();
// DrawCircle(new GLatLng(39.88023492849342, 110.225830078125),100);
GEvent.addListener(map,"click",function(e, point){
DrawCircle(point,radius);
//labelMarker(point);
});
GEvent.addListener(mycircle,"click",function(){
//map.removeOverlay(mycircle);
alert("asdfasdf");
});
}
function DrawCircle(latlng,radius){
var d2r = Math.PI/180;
var r2d = 180/Math.PI;
var Clat = (radius/3963)*r2d;
var Clng = Clat/Math.cos(latlng.lat()*d2r);
var Cpoints = [];
for (var i=0; i < 33; i++)
{
var theta = Math.PI * (i/16);
Cy = latlng.lat() + (Clat * Math.sin(theta));
Cx = latlng.lng() + (Clng * Math.cos(theta));
var P = new GPoint(Cx,Cy);
Cpoints.push(P);
}
mycircle = new GPolygon(Cpoints,"#0000ff",1,0.5,"#0000ff",0.5);
map.addOverlay(mycircle);
}
/*
var marker;
function labelMarker(point){
google.maps.LabelMarker = function(latlng, options)
{
this.latlng = latlng;
this.labelText = options.labelText || '';
this.labelClass = options.labelClass || 'writeb';
this.labelOffset = options.labelOffset || new google.maps.Size(8, -33);
options.icon = options.icon || getTextIcon();
google.maps.Marker.apply(this, arguments);
}
google.maps.LabelMarker.prototype = new google.maps.Marker(new google.maps.LatLng(0, 0));
google.maps.LabelMarker.prototype.initialize = function(map)
{
google.maps.Marker.prototype.initialize.call(this, map);
var label = document.createElement('div');
label.className = this.labelClass;
label.innerHTML = this.labelText;
label.style.position = 'absolute';
label.style.width = '7px';
label.style.color="Red";
map.getPane(G_MAP_MARKER_PANE).appendChild(label);
this.map = map;
this.label = label;
}
google.maps.LabelMarker.prototype.redraw = function(force)
{
google.maps.Marker.prototype.redraw.call(this, map);
if(!force)
{
return;
}
var point = this.map.fromLatLngToDivPixel(this.latlng);
var z = google.maps.Overlay.getZIndex(this.latlng.lat());
this.label.style.left = (point.x + this.labelOffset.width) + 'px';
this.label.style.top = (point.y + this.labelOffset.height) + 'px';
this.label.style.zIndex = z + 1;
}
google.maps.LabelMarker.prototype.remove = function()
{
this.label.parentNode.removeChild(this.label);
this.label = null;
google.maps.Marker.prototype.remove.call(this);
}
var n= "半径: "+radius;//在这里接收要显示的信息,文字要用双引号""
function getTextIcon()
{
var icon = new google.maps.Icon();
icon.image = "";
icon.iconSize = new GSize(70,70 );
icon.iconAnchor = new GPoint(0, 40);
icon.infoWindowAnchor = new GPoint(5, 1);
return icon;
}
marker = new google.maps.LabelMarker(point, { labelText:n});//在这加入n
map.addOverlay(marker);
}
*/
</script>
</head>
<body οnlοad="initialize()" οnunlοad="GUnload()">
<div id="map_canvas" style="width: 90%; height: 90%; ">
</div>
</body>
</html>
<html>
<head>
<title>Locus </title>
<style type="text/css">
html
{
height: 100%;
}
body
{
height: 100%;
margin: 0px;
padding: 0px;
}
#map_canvas
{
height: 100%;
}
</style>
<script type="text/javascript" src="http://ditu.google.com/maps?file=api&v=2&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA&hl=zh-CN""></script>
<script type="text/javascript">
var map;
var radius=100;
var mycircle;
function initialize() {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(39.88023492849342, 110.225830078125), 5);
map.addControl(new GMapTypeControl());
map.addControl(new GLargeMapControl());
map.enableScrollWheelZoom();
// DrawCircle(new GLatLng(39.88023492849342, 110.225830078125),100);
GEvent.addListener(map,"click",function(e, point){
DrawCircle(point,radius);
//labelMarker(point);
});
GEvent.addListener(mycircle,"click",function(){
//map.removeOverlay(mycircle);
alert("asdfasdf");
});
}
function DrawCircle(latlng,radius){
var d2r = Math.PI/180;
var r2d = 180/Math.PI;
var Clat = (radius/3963)*r2d;
var Clng = Clat/Math.cos(latlng.lat()*d2r);
var Cpoints = [];
for (var i=0; i < 33; i++)
{
var theta = Math.PI * (i/16);
Cy = latlng.lat() + (Clat * Math.sin(theta));
Cx = latlng.lng() + (Clng * Math.cos(theta));
var P = new GPoint(Cx,Cy);
Cpoints.push(P);
}
mycircle = new GPolygon(Cpoints,"#0000ff",1,0.5,"#0000ff",0.5);
map.addOverlay(mycircle);
}
/*
var marker;
function labelMarker(point){
google.maps.LabelMarker = function(latlng, options)
{
this.latlng = latlng;
this.labelText = options.labelText || '';
this.labelClass = options.labelClass || 'writeb';
this.labelOffset = options.labelOffset || new google.maps.Size(8, -33);
options.icon = options.icon || getTextIcon();
google.maps.Marker.apply(this, arguments);
}
google.maps.LabelMarker.prototype = new google.maps.Marker(new google.maps.LatLng(0, 0));
google.maps.LabelMarker.prototype.initialize = function(map)
{
google.maps.Marker.prototype.initialize.call(this, map);
var label = document.createElement('div');
label.className = this.labelClass;
label.innerHTML = this.labelText;
label.style.position = 'absolute';
label.style.width = '7px';
label.style.color="Red";
map.getPane(G_MAP_MARKER_PANE).appendChild(label);
this.map = map;
this.label = label;
}
google.maps.LabelMarker.prototype.redraw = function(force)
{
google.maps.Marker.prototype.redraw.call(this, map);
if(!force)
{
return;
}
var point = this.map.fromLatLngToDivPixel(this.latlng);
var z = google.maps.Overlay.getZIndex(this.latlng.lat());
this.label.style.left = (point.x + this.labelOffset.width) + 'px';
this.label.style.top = (point.y + this.labelOffset.height) + 'px';
this.label.style.zIndex = z + 1;
}
google.maps.LabelMarker.prototype.remove = function()
{
this.label.parentNode.removeChild(this.label);
this.label = null;
google.maps.Marker.prototype.remove.call(this);
}
var n= "半径: "+radius;//在这里接收要显示的信息,文字要用双引号""
function getTextIcon()
{
var icon = new google.maps.Icon();
icon.image = "";
icon.iconSize = new GSize(70,70 );
icon.iconAnchor = new GPoint(0, 40);
icon.infoWindowAnchor = new GPoint(5, 1);
return icon;
}
marker = new google.maps.LabelMarker(point, { labelText:n});//在这加入n
map.addOverlay(marker);
}
*/
</script>
</head>
<body οnlοad="initialize()" οnunlοad="GUnload()">
<div id="map_canvas" style="width: 90%; height: 90%; ">
</div>
</body>
</html>