9 个解决方案
#1
我刚做了一套基于GMap.NET 的东东,有什么不明白的可以问,代码是项目里边的,不能给你!
#2
我只是要找个例子研究一下 要说问题就多了 一堆 你可以把你的给我一部分研究一下吗
#3
给你一个 我做的画圆 里面有详细注释
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0044)http://maps.forum.nu/gm_driving_radius.html -->
<HTML xmlns="http://www.w3.org/1999/xhtml" xmlns:v =
"urn:schemas-microsoft-com:vml"><HEAD><TITLE>Google Maps</TITLE>
<META content="text/html; charset=iso-8859-1" http-equiv=content-type>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<SCRIPT>
var scriptTag = '<' + 'script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAM2yl1mX_7cDIg07mHXKQOhQnF99Ky5e4pKKTdf7-jr0ehRH-oBQqZCOcBo_dv2kR9Bq5cHhhVm3nRw">'+'<'+'/script>';
document.write(scriptTag);
</SCRIPT>
<SCRIPT src="MStatusControl.js" charset='utf-8'></SCRIPT>
<SCRIPT type=text/javascript>
//<![CDATA[
var map;
var container;
var zoom = 15;
var centerPoint = new GLatLng(34.762,113.636);
var dirObj = new GDirections();
var centerMarker;
var circleMarkers = Array();
var circlePoints = Array();
var drivePolyPoints = Array();
var searchPolygon,drivePolygon;
var distToDrive = 30; // miles
var pointInterval = 30;
GEvent.addListener(dirObj, "load", onDirectionsLoad);
GEvent.addListener(dirObj, "error", onDirectionsError);
var baseIcon = new GIcon();
baseIcon.shadow = "http://www.google.cn/mapfiles/shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);
var redIcon8 = (new GIcon(baseIcon, "/images/redSquare_8.png", null, ""));
function load() {
if (GBrowserIsCompatible()) {
container = document.getElementById("mapDiv");
map = new GMap2(container, {draggableCursor:"crosshair"});
map.addMapType(G_PHYSICAL_MAP)//将新地图类型添加到地图中。
map.setCenter(centerPoint, zoom, G_NORMAL_MAP );//按指定的中心设置地图视图。也可以同时设置缩放级别和地图类型。地图类型必须是地图已知的类型。请参见构造函数和方法 addMapType()。必须在构造后先调用此方法,才能设置地图的初始状态。在调用此函数之前调用对新构造的 GMap2 对象执行的操作,这是错误的。
map.addControl(new GScaleControl());//添加比例尺控件
map.addControl(new GLargeMapControl());//大号平移和缩放控件 位置为左上角
map.addControl(new GMapTypeControl());//地图类型控件 可选平面图 卫星图 混合地图
var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(0, -80));//此类描述了地图视图中控件的位置。它由相对于控件所在位置的角和确定此位置的偏移量组成
map.addControl(new MStatusControl({position:pos}));
map.enableContinuousZoom();//启用选择浏览器的连续平滑缩放(默认情况下禁用)。
map.enableScrollWheelZoom(); //启用使用鼠标滚轮缩放。注意:默认情况下禁用滚轮缩放。
GEvent.addListener(map, "click", mapClick);//GEvent.addListener(source:Object, event:String, handler:Function) GEventListener 为源对象的自定义事件注册事件处理程序。返回一个可用于最终注销处理程序的句柄。可使用源对象的 this 集合调用事件处理程序。
}
}
function mapClick(ov,pt) {
alert(ov);
alert(pt);
map.clearOverlays();//clearOverlays() 无 删除所有地图上的标注,并触发clearoverlays事件.
circleMarkers = Array();
if (!centerMarker) {
centerMarker = new GMarker(pt);//GMarker 标记地图上的位置。它实现 GOverlay 接口,因此可使用 GMap2.addOverlay() 方法添加到地图中。
}
else {
map.removeOverlay(centerMarker);//当使用 removeOverlay() 方法删除单个叠加层时会触发此事件。删除的叠加层会作为参数 overlay 传递到事件处理程序中。从地图中删除叠加层。尝试删除不在地图上的叠加层是错误的。如果调用成功,会触发 removeoverlay 事件。
centerMarker.setPoint(pt);
}
map.addOverlay(centerMarker);//将叠加层添加到地图中,并触发 addoverlay 事件。
searchPoints = getCirclePoints(pt,distToDrive);//调用getCirclePoints
drivePolyPoints = Array();
getDirections();
}
function getCirclePoints(center,radius){
var circlePoints = Array();
var searchPoints = Array();
with (Math) {
var rLat = (radius/39630.189) * (180/PI); // miles
var rLng = rLat/cos(center.lat() * (PI/180));
for (var a = 0 ; a < 361 ; a++ ) {
var aRad = a*(PI/180);
var x = center.lng() + (rLng * cos(aRad));
var y = center.lat() + (rLat * sin(aRad));
var point = new GLatLng(parseFloat(y),parseFloat(x),true);//GLatLng(lat:Number, lng:Number, unbounded?:Boolean) 注意纬度和经度的顺序。如果 unbounded 标记为 true,则将使用传递的数字,否则纬度会限定在 -90 度和 +90 度之间,而经度会限定在 -180 度和 +180 度之间。
circlePoints.push(point);
if (a % pointInterval ==0) {
searchPoints.push(point);//push 方法
//将新元素添加到一个数组中,并返回数组的新长度值。
//arrayObj.push([item1 [item2 [. . . [itemN ]]]])
// 参数
// arrayObj
// 必选项。一个 Array 对象。
// item, item2,. . . itemN
//可选项。该 Array 的新元素。
}
}
}
searchPolygon = new GPolygon(circlePoints, '#0000ff', 1, 1, '#0000ff', 0.2);//GPolygon(latlngs:GLatLng[], strokeColor?:String, strokeWeight?:Number, strokeOpacity?:Number, fillColor?:Number, fillOpacity?:Number, opts?:GPolygonOptions) 根据顶点数组创建多边形。colors 是一个字符串,包含十六进制数字、HTML 样式的颜色,如 #RRGGBB。weight 是以像素为单位的线宽度。opacities 为 0 到 1 之间的数字。该线条平滑且半透明。
map.addOverlay(searchPolygon);//将叠加层添加到地图中,并触发 addoverlay 事件。
map.setCenter(searchPolygon.getBounds().getCenter(),map.getBoundsZoomLevel(searchPolygon.getBounds()));
//setCenter(center:GLatLng, zoom?:Number, type?:GMapType) None 按指定的中心设置地图视图。也可以同时设置缩放级别和地图类型。地图类型必须是地图已知的类型。请参见构造函数和方法 addMapType()。必须在构造后先调用此方法,才能设置地图的初始状态。在调用此函数之前调用对新构造的 GMap2 对象执行的操作,这是错误的。
//getCenter() GLatLng 返回地图视图中心点的地理坐标。
//getBounds() GLatLngBounds 返回地图视图的可视矩形区域(以地理坐标表示)。
//getBoundsZoomLevel(bounds:GLatLngBounds) Number 返回指定矩形区域在地图视图中的缩放级别。缩放级别要按当前选中的地图类型计算。如果还未选择地图类型,将使用地图类型列表中列出的第一个类型。
return searchPoints;
}
// 创建信息窗口显示对应给定索引的字母的标记
function createMarker(point, index) {
// Create a lettered icon for this point using our icon class
var letter = String.fromCharCode("A".charCodeAt(0) + index);
var letteredIcon = new GIcon(baseIcon);
letteredIcon.image = "http://www.google.cn/mapfiles/marker" + letter + ".png";
// 设置 GMarkerOptions 对象
markerOptions = { icon:letteredIcon };
var marker = new GMarker(point, markerOptions);
GEvent.addListener(marker, "mouseover", function() {
marker.openInfoWindowHtml("标记 <b>"+point+"</b>");
});
return marker;
}
function getDirections() {
if (!searchPoints.length) {
return;
}
var from = centerMarker.getLatLng().lat() + ' ' + centerMarker.getLatLng().lng();
var to = searchPoints[0].lat() + ' ' + searchPoints[0].lng();
var loadStr = 'from: ' + from + ' to: ' + to;
dirObj.load(loadStr,{getPolyline:true,getSteps:true});
var latlng = new GLatLng(searchPoints[0].lat(),
searchPoints[0].lng());
map.addOverlay(createMarker(latlng, 1));
searchPoints.shift();
}
function onDirectionsLoad() {
var status = dirObj.getStatus();
var bounds = dirObj.getBounds();
var distance = parseInt(dirObj.getDistance().meters / 1609);
var duration = parseFloat(dirObj.getDuration().seconds / 3600).toFixed(2);
var polyline = dirObj.getPolyline();
getDirections();
}
function onDirectionsError() {
GLog.write('Error: ' + dirObj.getStatus().code);
getDirections();
}
function unload() {
GUnload();
}
//]]>
</SCRIPT>
<META name=GENERATOR content="MSHTML 8.00.6001.18999"></HEAD>
<BODY>
<CENTER>
<TABLE cellSpacing=5 cellPadding=10>
<TBODY>
<TR>
<TD vAlign=top>
<DIV style="WIDTH: 800px; HEIGHT: 500px" id=mapDiv></DIV></TD>
</TR></TBODY></TABLE></CENTER>
<SCRIPT>
window.onload = load;
window.onunload = unload;
</SCRIPT>
</BODY></HTML>
#4
GMap.NET 官网上有例子,你下载了看看就行了,有基于WinForm和WPF两种的(主要区别是客户端技术不一样),底层代码都一样.
#5
function MStatusControl(MOptions) {
MOptions = MOptions ? MOptions : {};
this.DMS = MOptions.DMS ? MOptions.DMS : false;
this.background = MOptions.background ? MOptions.background : '#eeeeee';
this.foreground = MOptions.foreground ? MOptions.foreground : '#000000';
this.vertical = MOptions.vertical ? MOptions.vertical : false;
this.position = MOptions.position ? MOptions.position : new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(0, 45));
this.parent = MOptions.container ? MOptions.container : null;
}
MStatusControl.prototype = new GControl(true,true);
MStatusControl.prototype.initialize = function(map) {
// REMOVE - REMOVE - REMOVE - REMOVE - REMOVE - REMOVE - REMOVE - REMOVE - REMOVE - REMOVE
// Remove this block after saving the file to your server
if (window.location.host != 'maps.forum.nu') {
alert('Please do not hotlink this script.\n Save this file to your own server instead and remove this message.');
// return;
}
// END Remove
// END REMOVE - END REMOVE - END REMOVE - END REMOVE - END REMOVE - END REMOVE - END REMOVE
var globalThis_3456 = this;
this.map = map;
this.projection = this.map.getCurrentMapType().getProjection();
this.container = document.createElement('div');
if (!this.vertical) {
var w = this.map.getContainer().clientWidth - 2;
this.container.style.width = w + 'px';
}
this.container.style.backgroundColor = this.background;
this.container.style.border = '1px solid gray';
var innerDiv = document.createElement('div');
this.container.appendChild(innerDiv);
var crDiv = document.createElement('div');
this.container.appendChild(crDiv);
crDiv.innerHTML = 'Marcelo Montagna©2008 - <a style="color: #aaaaaa;" href="http://maps.forum.nu" target="_blank">http://maps.forum.nu</a>';
crDiv.style.padding = '2px';
crDiv.style.marginTop = '2px';
crDiv.style.textAlign = 'right';
crDiv.style.color = '#aaaaaa';
crDiv.style.backgroundColor = '#eeeeee';
crDiv.style.font = 'normal 10px verdana';
var oTable = document.createElement('table');
oTable.setAttribute('cellSpacing','0');
oTable.setAttribute('cellPadding','0');
if (!this.vertical) {
oTable.style.width = '100%';
}
innerDiv.appendChild(oTable);
var oTableBody = document.createElement('tbody');
oTable.appendChild(oTableBody);
if (this.vertical) {
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.centerDisplay = document.createElement('td');
this.setStyleValue(this.centerDisplay);
// this.centerDisplay.style.width = iWidth + 'px';
oRow.appendChild(this.centerDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.zDisplay = document.createElement('td');
this.setStyleValue(this.zDisplay);
oRow.appendChild(this.zDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.swDisplay = document.createElement('td');
this.setStyleValue(this.swDisplay);
oRow.appendChild(this.swDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.neDisplay = document.createElement('td');
this.setStyleValue(this.neDisplay);
oRow.appendChild(this.neDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.mouseDisplay = document.createElement('td');
this.setStyleValue(this.mouseDisplay);
// this.mouseDisplay.style.width = iWidth + 'px';
oRow.appendChild(this.mouseDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.mousePxDisplay = document.createElement('td');
this.setStyleValue(this.mousePxDisplay);
oRow.appendChild(this.mousePxDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.mouseTileDisplay = document.createElement('td');
this.setStyleValue(this.mouseTileDisplay);
oRow.appendChild(this.mouseTileDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.clickDisplay = document.createElement('td');
this.setStyleValue(this.clickDisplay);
oRow.appendChild(this.clickDisplay);
//-------------------------
}
else {
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.centerDisplay = document.createElement('td');
this.setStyleValue(this.centerDisplay);
// this.centerDisplay.style.width = iWidth + 'px';
oRow.appendChild(this.centerDisplay);
this.mouseDisplay = document.createElement('td');
this.setStyleValue(this.mouseDisplay);
// this.mouseDisplay.style.width = iWidth + 'px';
oRow.appendChild(this.mouseDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.swDisplay = document.createElement('td');
this.setStyleValue(this.swDisplay);
oRow.appendChild(this.swDisplay);
this.mousePxDisplay = document.createElement('td');
this.setStyleValue(this.mousePxDisplay);
oRow.appendChild(this.mousePxDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.neDisplay = document.createElement('td');
this.setStyleValue(this.neDisplay);
oRow.appendChild(this.neDisplay);
this.mouseTileDisplay = document.createElement('td');
this.setStyleValue(this.mouseTileDisplay);
oRow.appendChild(this.mouseTileDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.zDisplay = document.createElement('td');
this.setStyleValue(this.zDisplay);
oRow.appendChild(this.zDisplay);
this.clickDisplay = document.createElement('td');
this.setStyleValue(this.clickDisplay);
oRow.appendChild(this.clickDisplay);
//-------------------------
}
#6
this.mouseDisplay.innerHTML = 'Mouse LatLon: '
this.mousePxDisplay.innerHTML = 'Mouse Px: '
this.mouseTileDisplay.innerHTML = 'Mouse Tile: '
this.clickDisplay.innerHTML = 'Mouse Click: '
if (this.parent) {
this.parent.appendChild(container);
}
else {
this.map.getContainer().appendChild(this.container);
}
GEvent.addListener(this.map, "click", function(ol,pt){globalThis_3456.MMapClick(pt)});
GEvent.addListener(this.map, "moveend", function(){globalThis_3456.MMoveEnd()});
GEvent.addListener(this.map, "zoomend", function(){globalThis_3456.MZoomEnd()});
GEvent.addListener(this.map, "mousemove", function(pt){globalThis_3456.MMouseMove(pt)});
this.MMapClick = function (pt) {
var point = pt ? pt : null;
if (point) {
if (this.DMS) {
this.clickDisplay.innerHTML = 'Mouse Click: ' + this.degToDms(point.lat()) + ', ' + this.degToDms(point.lng());
}
else {
this.clickDisplay.innerHTML = 'Mouse Click: ' + point.lat().toFixed(6) + ', ' + point.lng().toFixed(6);
}
}
}
this.MMoveEnd = function() {
this.MUpdateStatus();
}
this.MZoomEnd = function() {
this.MUpdateStatus();
}
this.MMouseMove = function(mousePt) {
var zoom = this.map.getZoom();
var mousePx = this.projection.fromLatLngToPixel(mousePt, zoom);
if (this.DMS) {
this.mouseDisplay.innerHTML = 'Mouse LatLon: ' + this.degToDms(mousePt.lat()) + ', ' + this.degToDms(mousePt.lng());
}
else {
this.mouseDisplay.innerHTML = 'Mouse LatLon: ' + mousePt.lat().toFixed(6) + ', ' + mousePt.lng().toFixed(6);
}
this.mousePxDisplay.innerHTML = 'Mouse Px: ' + mousePx.x + ', ' + mousePx.y;
this.mouseTileDisplay.innerHTML = 'Mouse Tile: ' + Math.floor(mousePx.x / 256) + ', ' + Math.floor(mousePx.y / 256);
}
this.MUpdateStatus = function() {
var center = this.map.getCenter();
var zoom = this.map.getZoom();
var bounds = this.map.getBounds();
var SW = bounds.getSouthWest();
var NE = bounds.getNorthEast();
if (this.DMS) {
this.centerDisplay.innerHTML = 'Map Center: ' + this.degToDms(center.lat()) + ', ' + this.degToDms(center.lng());
this.swDisplay.innerHTML = 'Map SW: ' + this.degToDms(SW.lat()) + ', ' + this.degToDms(SW.lng());
this.neDisplay.innerHTML = 'Map NE: ' + this.degToDms(NE.lat()) + ', ' + this.degToDms(NE.lng());
this.zDisplay.innerHTML = 'Map Zoom: ' + zoom;
}
else {
this.centerDisplay.innerHTML = 'Map Center: ' + center.lat().toFixed(6) + ', ' + center.lng().toFixed(6);
this.swDisplay.innerHTML = 'Map SW: ' + SW.lat().toFixed(6) + ', ' + SW.lng().toFixed(6);
this.neDisplay.innerHTML = 'Map NE: ' + NE.lat().toFixed(6) + ', ' + NE.lng().toFixed(6);
this.zDisplay.innerHTML = 'Map Zoom: ' + zoom;
}
}
this.MUpdateStatus();
return this.container;
}
MStatusControl.prototype.degToDms = function(dec) {
var deg = Math.floor(Math.abs(dec));
var min = Math.floor((Math.abs(dec)-deg)*60);
var sec = (Math.round((((Math.abs(dec) - deg) - (min/60)) * 60 * 60) * 100) / 100 ) ;
var len = String(deg).length
deg = Array(3 + 1 - len).join('0') + deg;
var len = String(min).length
min = Array(2 + 1 - len).join('0') + min;
var len = String(sec).length
sec = Array(5 + 1 - len).join('0') + sec;
deg = dec < 0 ? '-' + deg : deg;
var dms = deg + '° ' + min + '\' ' + sec + '"';
return dms;
}
MStatusControl.prototype.getDefaultPosition = function() {
return this.position;
}
////////////////////////////
MStatusControl.prototype.setStyleValue = function(obj) {
obj.style.padding = '0px';
obj.style.paddingRight = '2px';
obj.style.paddingLeft = '2px';
obj.style.textAlign = 'left';
obj.style.color = this.foreground;
obj.style.backgroundColor = this.background;
obj.style.font = 'normal 12px courier new';
obj.style.lineHeight = '14px'
obj.setAttribute('noWrap','true');
if (!this.vertical) {
obj.style.width = '50%'
}
}
MStatusControl.prototype.show = function () {
this.container.style.display = '';
}
MStatusControl.prototype.hide = function () {
this.container.style.display = 'none';
}
MStatusControl.prototype.toggle = function () {
this.container.style.display = this.container.style.display == '' ? 'none' : '';
}
//////////// END MStatusControl /////////////////
this.mousePxDisplay.innerHTML = 'Mouse Px: '
this.mouseTileDisplay.innerHTML = 'Mouse Tile: '
this.clickDisplay.innerHTML = 'Mouse Click: '
if (this.parent) {
this.parent.appendChild(container);
}
else {
this.map.getContainer().appendChild(this.container);
}
GEvent.addListener(this.map, "click", function(ol,pt){globalThis_3456.MMapClick(pt)});
GEvent.addListener(this.map, "moveend", function(){globalThis_3456.MMoveEnd()});
GEvent.addListener(this.map, "zoomend", function(){globalThis_3456.MZoomEnd()});
GEvent.addListener(this.map, "mousemove", function(pt){globalThis_3456.MMouseMove(pt)});
this.MMapClick = function (pt) {
var point = pt ? pt : null;
if (point) {
if (this.DMS) {
this.clickDisplay.innerHTML = 'Mouse Click: ' + this.degToDms(point.lat()) + ', ' + this.degToDms(point.lng());
}
else {
this.clickDisplay.innerHTML = 'Mouse Click: ' + point.lat().toFixed(6) + ', ' + point.lng().toFixed(6);
}
}
}
this.MMoveEnd = function() {
this.MUpdateStatus();
}
this.MZoomEnd = function() {
this.MUpdateStatus();
}
this.MMouseMove = function(mousePt) {
var zoom = this.map.getZoom();
var mousePx = this.projection.fromLatLngToPixel(mousePt, zoom);
if (this.DMS) {
this.mouseDisplay.innerHTML = 'Mouse LatLon: ' + this.degToDms(mousePt.lat()) + ', ' + this.degToDms(mousePt.lng());
}
else {
this.mouseDisplay.innerHTML = 'Mouse LatLon: ' + mousePt.lat().toFixed(6) + ', ' + mousePt.lng().toFixed(6);
}
this.mousePxDisplay.innerHTML = 'Mouse Px: ' + mousePx.x + ', ' + mousePx.y;
this.mouseTileDisplay.innerHTML = 'Mouse Tile: ' + Math.floor(mousePx.x / 256) + ', ' + Math.floor(mousePx.y / 256);
}
this.MUpdateStatus = function() {
var center = this.map.getCenter();
var zoom = this.map.getZoom();
var bounds = this.map.getBounds();
var SW = bounds.getSouthWest();
var NE = bounds.getNorthEast();
if (this.DMS) {
this.centerDisplay.innerHTML = 'Map Center: ' + this.degToDms(center.lat()) + ', ' + this.degToDms(center.lng());
this.swDisplay.innerHTML = 'Map SW: ' + this.degToDms(SW.lat()) + ', ' + this.degToDms(SW.lng());
this.neDisplay.innerHTML = 'Map NE: ' + this.degToDms(NE.lat()) + ', ' + this.degToDms(NE.lng());
this.zDisplay.innerHTML = 'Map Zoom: ' + zoom;
}
else {
this.centerDisplay.innerHTML = 'Map Center: ' + center.lat().toFixed(6) + ', ' + center.lng().toFixed(6);
this.swDisplay.innerHTML = 'Map SW: ' + SW.lat().toFixed(6) + ', ' + SW.lng().toFixed(6);
this.neDisplay.innerHTML = 'Map NE: ' + NE.lat().toFixed(6) + ', ' + NE.lng().toFixed(6);
this.zDisplay.innerHTML = 'Map Zoom: ' + zoom;
}
}
this.MUpdateStatus();
return this.container;
}
MStatusControl.prototype.degToDms = function(dec) {
var deg = Math.floor(Math.abs(dec));
var min = Math.floor((Math.abs(dec)-deg)*60);
var sec = (Math.round((((Math.abs(dec) - deg) - (min/60)) * 60 * 60) * 100) / 100 ) ;
var len = String(deg).length
deg = Array(3 + 1 - len).join('0') + deg;
var len = String(min).length
min = Array(2 + 1 - len).join('0') + min;
var len = String(sec).length
sec = Array(5 + 1 - len).join('0') + sec;
deg = dec < 0 ? '-' + deg : deg;
var dms = deg + '° ' + min + '\' ' + sec + '"';
return dms;
}
MStatusControl.prototype.getDefaultPosition = function() {
return this.position;
}
////////////////////////////
MStatusControl.prototype.setStyleValue = function(obj) {
obj.style.padding = '0px';
obj.style.paddingRight = '2px';
obj.style.paddingLeft = '2px';
obj.style.textAlign = 'left';
obj.style.color = this.foreground;
obj.style.backgroundColor = this.background;
obj.style.font = 'normal 12px courier new';
obj.style.lineHeight = '14px'
obj.setAttribute('noWrap','true');
if (!this.vertical) {
obj.style.width = '50%'
}
}
MStatusControl.prototype.show = function () {
this.container.style.display = '';
}
MStatusControl.prototype.hide = function () {
this.container.style.display = 'none';
}
MStatusControl.prototype.toggle = function () {
this.container.style.display = this.container.style.display == '' ? 'none' : '';
}
//////////// END MStatusControl /////////////////
#7
http://greatmaps.codeplex.com/
http://gmapdotnet.codeplex.com/
http://gmapdotnet.codeplex.com/
#8
那个js太长 ,是googleMap官方的
你就凑合看看!
你就凑合看看!
#9
用过gmap.net插件的求指教啊,http://greatmaps.codeplex.com/
下的源码无法导入vs 需要什么密钥,QQ:382505554
下的源码无法导入vs 需要什么密钥,QQ:382505554
#1
我刚做了一套基于GMap.NET 的东东,有什么不明白的可以问,代码是项目里边的,不能给你!
#2
我只是要找个例子研究一下 要说问题就多了 一堆 你可以把你的给我一部分研究一下吗
#3
给你一个 我做的画圆 里面有详细注释
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0044)http://maps.forum.nu/gm_driving_radius.html -->
<HTML xmlns="http://www.w3.org/1999/xhtml" xmlns:v =
"urn:schemas-microsoft-com:vml"><HEAD><TITLE>Google Maps</TITLE>
<META content="text/html; charset=iso-8859-1" http-equiv=content-type>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<SCRIPT>
var scriptTag = '<' + 'script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAM2yl1mX_7cDIg07mHXKQOhQnF99Ky5e4pKKTdf7-jr0ehRH-oBQqZCOcBo_dv2kR9Bq5cHhhVm3nRw">'+'<'+'/script>';
document.write(scriptTag);
</SCRIPT>
<SCRIPT src="MStatusControl.js" charset='utf-8'></SCRIPT>
<SCRIPT type=text/javascript>
//<![CDATA[
var map;
var container;
var zoom = 15;
var centerPoint = new GLatLng(34.762,113.636);
var dirObj = new GDirections();
var centerMarker;
var circleMarkers = Array();
var circlePoints = Array();
var drivePolyPoints = Array();
var searchPolygon,drivePolygon;
var distToDrive = 30; // miles
var pointInterval = 30;
GEvent.addListener(dirObj, "load", onDirectionsLoad);
GEvent.addListener(dirObj, "error", onDirectionsError);
var baseIcon = new GIcon();
baseIcon.shadow = "http://www.google.cn/mapfiles/shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);
var redIcon8 = (new GIcon(baseIcon, "/images/redSquare_8.png", null, ""));
function load() {
if (GBrowserIsCompatible()) {
container = document.getElementById("mapDiv");
map = new GMap2(container, {draggableCursor:"crosshair"});
map.addMapType(G_PHYSICAL_MAP)//将新地图类型添加到地图中。
map.setCenter(centerPoint, zoom, G_NORMAL_MAP );//按指定的中心设置地图视图。也可以同时设置缩放级别和地图类型。地图类型必须是地图已知的类型。请参见构造函数和方法 addMapType()。必须在构造后先调用此方法,才能设置地图的初始状态。在调用此函数之前调用对新构造的 GMap2 对象执行的操作,这是错误的。
map.addControl(new GScaleControl());//添加比例尺控件
map.addControl(new GLargeMapControl());//大号平移和缩放控件 位置为左上角
map.addControl(new GMapTypeControl());//地图类型控件 可选平面图 卫星图 混合地图
var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(0, -80));//此类描述了地图视图中控件的位置。它由相对于控件所在位置的角和确定此位置的偏移量组成
map.addControl(new MStatusControl({position:pos}));
map.enableContinuousZoom();//启用选择浏览器的连续平滑缩放(默认情况下禁用)。
map.enableScrollWheelZoom(); //启用使用鼠标滚轮缩放。注意:默认情况下禁用滚轮缩放。
GEvent.addListener(map, "click", mapClick);//GEvent.addListener(source:Object, event:String, handler:Function) GEventListener 为源对象的自定义事件注册事件处理程序。返回一个可用于最终注销处理程序的句柄。可使用源对象的 this 集合调用事件处理程序。
}
}
function mapClick(ov,pt) {
alert(ov);
alert(pt);
map.clearOverlays();//clearOverlays() 无 删除所有地图上的标注,并触发clearoverlays事件.
circleMarkers = Array();
if (!centerMarker) {
centerMarker = new GMarker(pt);//GMarker 标记地图上的位置。它实现 GOverlay 接口,因此可使用 GMap2.addOverlay() 方法添加到地图中。
}
else {
map.removeOverlay(centerMarker);//当使用 removeOverlay() 方法删除单个叠加层时会触发此事件。删除的叠加层会作为参数 overlay 传递到事件处理程序中。从地图中删除叠加层。尝试删除不在地图上的叠加层是错误的。如果调用成功,会触发 removeoverlay 事件。
centerMarker.setPoint(pt);
}
map.addOverlay(centerMarker);//将叠加层添加到地图中,并触发 addoverlay 事件。
searchPoints = getCirclePoints(pt,distToDrive);//调用getCirclePoints
drivePolyPoints = Array();
getDirections();
}
function getCirclePoints(center,radius){
var circlePoints = Array();
var searchPoints = Array();
with (Math) {
var rLat = (radius/39630.189) * (180/PI); // miles
var rLng = rLat/cos(center.lat() * (PI/180));
for (var a = 0 ; a < 361 ; a++ ) {
var aRad = a*(PI/180);
var x = center.lng() + (rLng * cos(aRad));
var y = center.lat() + (rLat * sin(aRad));
var point = new GLatLng(parseFloat(y),parseFloat(x),true);//GLatLng(lat:Number, lng:Number, unbounded?:Boolean) 注意纬度和经度的顺序。如果 unbounded 标记为 true,则将使用传递的数字,否则纬度会限定在 -90 度和 +90 度之间,而经度会限定在 -180 度和 +180 度之间。
circlePoints.push(point);
if (a % pointInterval ==0) {
searchPoints.push(point);//push 方法
//将新元素添加到一个数组中,并返回数组的新长度值。
//arrayObj.push([item1 [item2 [. . . [itemN ]]]])
// 参数
// arrayObj
// 必选项。一个 Array 对象。
// item, item2,. . . itemN
//可选项。该 Array 的新元素。
}
}
}
searchPolygon = new GPolygon(circlePoints, '#0000ff', 1, 1, '#0000ff', 0.2);//GPolygon(latlngs:GLatLng[], strokeColor?:String, strokeWeight?:Number, strokeOpacity?:Number, fillColor?:Number, fillOpacity?:Number, opts?:GPolygonOptions) 根据顶点数组创建多边形。colors 是一个字符串,包含十六进制数字、HTML 样式的颜色,如 #RRGGBB。weight 是以像素为单位的线宽度。opacities 为 0 到 1 之间的数字。该线条平滑且半透明。
map.addOverlay(searchPolygon);//将叠加层添加到地图中,并触发 addoverlay 事件。
map.setCenter(searchPolygon.getBounds().getCenter(),map.getBoundsZoomLevel(searchPolygon.getBounds()));
//setCenter(center:GLatLng, zoom?:Number, type?:GMapType) None 按指定的中心设置地图视图。也可以同时设置缩放级别和地图类型。地图类型必须是地图已知的类型。请参见构造函数和方法 addMapType()。必须在构造后先调用此方法,才能设置地图的初始状态。在调用此函数之前调用对新构造的 GMap2 对象执行的操作,这是错误的。
//getCenter() GLatLng 返回地图视图中心点的地理坐标。
//getBounds() GLatLngBounds 返回地图视图的可视矩形区域(以地理坐标表示)。
//getBoundsZoomLevel(bounds:GLatLngBounds) Number 返回指定矩形区域在地图视图中的缩放级别。缩放级别要按当前选中的地图类型计算。如果还未选择地图类型,将使用地图类型列表中列出的第一个类型。
return searchPoints;
}
// 创建信息窗口显示对应给定索引的字母的标记
function createMarker(point, index) {
// Create a lettered icon for this point using our icon class
var letter = String.fromCharCode("A".charCodeAt(0) + index);
var letteredIcon = new GIcon(baseIcon);
letteredIcon.image = "http://www.google.cn/mapfiles/marker" + letter + ".png";
// 设置 GMarkerOptions 对象
markerOptions = { icon:letteredIcon };
var marker = new GMarker(point, markerOptions);
GEvent.addListener(marker, "mouseover", function() {
marker.openInfoWindowHtml("标记 <b>"+point+"</b>");
});
return marker;
}
function getDirections() {
if (!searchPoints.length) {
return;
}
var from = centerMarker.getLatLng().lat() + ' ' + centerMarker.getLatLng().lng();
var to = searchPoints[0].lat() + ' ' + searchPoints[0].lng();
var loadStr = 'from: ' + from + ' to: ' + to;
dirObj.load(loadStr,{getPolyline:true,getSteps:true});
var latlng = new GLatLng(searchPoints[0].lat(),
searchPoints[0].lng());
map.addOverlay(createMarker(latlng, 1));
searchPoints.shift();
}
function onDirectionsLoad() {
var status = dirObj.getStatus();
var bounds = dirObj.getBounds();
var distance = parseInt(dirObj.getDistance().meters / 1609);
var duration = parseFloat(dirObj.getDuration().seconds / 3600).toFixed(2);
var polyline = dirObj.getPolyline();
getDirections();
}
function onDirectionsError() {
GLog.write('Error: ' + dirObj.getStatus().code);
getDirections();
}
function unload() {
GUnload();
}
//]]>
</SCRIPT>
<META name=GENERATOR content="MSHTML 8.00.6001.18999"></HEAD>
<BODY>
<CENTER>
<TABLE cellSpacing=5 cellPadding=10>
<TBODY>
<TR>
<TD vAlign=top>
<DIV style="WIDTH: 800px; HEIGHT: 500px" id=mapDiv></DIV></TD>
</TR></TBODY></TABLE></CENTER>
<SCRIPT>
window.onload = load;
window.onunload = unload;
</SCRIPT>
</BODY></HTML>
#4
GMap.NET 官网上有例子,你下载了看看就行了,有基于WinForm和WPF两种的(主要区别是客户端技术不一样),底层代码都一样.
#5
function MStatusControl(MOptions) {
MOptions = MOptions ? MOptions : {};
this.DMS = MOptions.DMS ? MOptions.DMS : false;
this.background = MOptions.background ? MOptions.background : '#eeeeee';
this.foreground = MOptions.foreground ? MOptions.foreground : '#000000';
this.vertical = MOptions.vertical ? MOptions.vertical : false;
this.position = MOptions.position ? MOptions.position : new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(0, 45));
this.parent = MOptions.container ? MOptions.container : null;
}
MStatusControl.prototype = new GControl(true,true);
MStatusControl.prototype.initialize = function(map) {
// REMOVE - REMOVE - REMOVE - REMOVE - REMOVE - REMOVE - REMOVE - REMOVE - REMOVE - REMOVE
// Remove this block after saving the file to your server
if (window.location.host != 'maps.forum.nu') {
alert('Please do not hotlink this script.\n Save this file to your own server instead and remove this message.');
// return;
}
// END Remove
// END REMOVE - END REMOVE - END REMOVE - END REMOVE - END REMOVE - END REMOVE - END REMOVE
var globalThis_3456 = this;
this.map = map;
this.projection = this.map.getCurrentMapType().getProjection();
this.container = document.createElement('div');
if (!this.vertical) {
var w = this.map.getContainer().clientWidth - 2;
this.container.style.width = w + 'px';
}
this.container.style.backgroundColor = this.background;
this.container.style.border = '1px solid gray';
var innerDiv = document.createElement('div');
this.container.appendChild(innerDiv);
var crDiv = document.createElement('div');
this.container.appendChild(crDiv);
crDiv.innerHTML = 'Marcelo Montagna©2008 - <a style="color: #aaaaaa;" href="http://maps.forum.nu" target="_blank">http://maps.forum.nu</a>';
crDiv.style.padding = '2px';
crDiv.style.marginTop = '2px';
crDiv.style.textAlign = 'right';
crDiv.style.color = '#aaaaaa';
crDiv.style.backgroundColor = '#eeeeee';
crDiv.style.font = 'normal 10px verdana';
var oTable = document.createElement('table');
oTable.setAttribute('cellSpacing','0');
oTable.setAttribute('cellPadding','0');
if (!this.vertical) {
oTable.style.width = '100%';
}
innerDiv.appendChild(oTable);
var oTableBody = document.createElement('tbody');
oTable.appendChild(oTableBody);
if (this.vertical) {
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.centerDisplay = document.createElement('td');
this.setStyleValue(this.centerDisplay);
// this.centerDisplay.style.width = iWidth + 'px';
oRow.appendChild(this.centerDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.zDisplay = document.createElement('td');
this.setStyleValue(this.zDisplay);
oRow.appendChild(this.zDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.swDisplay = document.createElement('td');
this.setStyleValue(this.swDisplay);
oRow.appendChild(this.swDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.neDisplay = document.createElement('td');
this.setStyleValue(this.neDisplay);
oRow.appendChild(this.neDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.mouseDisplay = document.createElement('td');
this.setStyleValue(this.mouseDisplay);
// this.mouseDisplay.style.width = iWidth + 'px';
oRow.appendChild(this.mouseDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.mousePxDisplay = document.createElement('td');
this.setStyleValue(this.mousePxDisplay);
oRow.appendChild(this.mousePxDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.mouseTileDisplay = document.createElement('td');
this.setStyleValue(this.mouseTileDisplay);
oRow.appendChild(this.mouseTileDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.clickDisplay = document.createElement('td');
this.setStyleValue(this.clickDisplay);
oRow.appendChild(this.clickDisplay);
//-------------------------
}
else {
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.centerDisplay = document.createElement('td');
this.setStyleValue(this.centerDisplay);
// this.centerDisplay.style.width = iWidth + 'px';
oRow.appendChild(this.centerDisplay);
this.mouseDisplay = document.createElement('td');
this.setStyleValue(this.mouseDisplay);
// this.mouseDisplay.style.width = iWidth + 'px';
oRow.appendChild(this.mouseDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.swDisplay = document.createElement('td');
this.setStyleValue(this.swDisplay);
oRow.appendChild(this.swDisplay);
this.mousePxDisplay = document.createElement('td');
this.setStyleValue(this.mousePxDisplay);
oRow.appendChild(this.mousePxDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.neDisplay = document.createElement('td');
this.setStyleValue(this.neDisplay);
oRow.appendChild(this.neDisplay);
this.mouseTileDisplay = document.createElement('td');
this.setStyleValue(this.mouseTileDisplay);
oRow.appendChild(this.mouseTileDisplay);
//-------------------------
var oRow = document.createElement('tr');
oTableBody.appendChild(oRow);
this.zDisplay = document.createElement('td');
this.setStyleValue(this.zDisplay);
oRow.appendChild(this.zDisplay);
this.clickDisplay = document.createElement('td');
this.setStyleValue(this.clickDisplay);
oRow.appendChild(this.clickDisplay);
//-------------------------
}
#6
this.mouseDisplay.innerHTML = 'Mouse LatLon: '
this.mousePxDisplay.innerHTML = 'Mouse Px: '
this.mouseTileDisplay.innerHTML = 'Mouse Tile: '
this.clickDisplay.innerHTML = 'Mouse Click: '
if (this.parent) {
this.parent.appendChild(container);
}
else {
this.map.getContainer().appendChild(this.container);
}
GEvent.addListener(this.map, "click", function(ol,pt){globalThis_3456.MMapClick(pt)});
GEvent.addListener(this.map, "moveend", function(){globalThis_3456.MMoveEnd()});
GEvent.addListener(this.map, "zoomend", function(){globalThis_3456.MZoomEnd()});
GEvent.addListener(this.map, "mousemove", function(pt){globalThis_3456.MMouseMove(pt)});
this.MMapClick = function (pt) {
var point = pt ? pt : null;
if (point) {
if (this.DMS) {
this.clickDisplay.innerHTML = 'Mouse Click: ' + this.degToDms(point.lat()) + ', ' + this.degToDms(point.lng());
}
else {
this.clickDisplay.innerHTML = 'Mouse Click: ' + point.lat().toFixed(6) + ', ' + point.lng().toFixed(6);
}
}
}
this.MMoveEnd = function() {
this.MUpdateStatus();
}
this.MZoomEnd = function() {
this.MUpdateStatus();
}
this.MMouseMove = function(mousePt) {
var zoom = this.map.getZoom();
var mousePx = this.projection.fromLatLngToPixel(mousePt, zoom);
if (this.DMS) {
this.mouseDisplay.innerHTML = 'Mouse LatLon: ' + this.degToDms(mousePt.lat()) + ', ' + this.degToDms(mousePt.lng());
}
else {
this.mouseDisplay.innerHTML = 'Mouse LatLon: ' + mousePt.lat().toFixed(6) + ', ' + mousePt.lng().toFixed(6);
}
this.mousePxDisplay.innerHTML = 'Mouse Px: ' + mousePx.x + ', ' + mousePx.y;
this.mouseTileDisplay.innerHTML = 'Mouse Tile: ' + Math.floor(mousePx.x / 256) + ', ' + Math.floor(mousePx.y / 256);
}
this.MUpdateStatus = function() {
var center = this.map.getCenter();
var zoom = this.map.getZoom();
var bounds = this.map.getBounds();
var SW = bounds.getSouthWest();
var NE = bounds.getNorthEast();
if (this.DMS) {
this.centerDisplay.innerHTML = 'Map Center: ' + this.degToDms(center.lat()) + ', ' + this.degToDms(center.lng());
this.swDisplay.innerHTML = 'Map SW: ' + this.degToDms(SW.lat()) + ', ' + this.degToDms(SW.lng());
this.neDisplay.innerHTML = 'Map NE: ' + this.degToDms(NE.lat()) + ', ' + this.degToDms(NE.lng());
this.zDisplay.innerHTML = 'Map Zoom: ' + zoom;
}
else {
this.centerDisplay.innerHTML = 'Map Center: ' + center.lat().toFixed(6) + ', ' + center.lng().toFixed(6);
this.swDisplay.innerHTML = 'Map SW: ' + SW.lat().toFixed(6) + ', ' + SW.lng().toFixed(6);
this.neDisplay.innerHTML = 'Map NE: ' + NE.lat().toFixed(6) + ', ' + NE.lng().toFixed(6);
this.zDisplay.innerHTML = 'Map Zoom: ' + zoom;
}
}
this.MUpdateStatus();
return this.container;
}
MStatusControl.prototype.degToDms = function(dec) {
var deg = Math.floor(Math.abs(dec));
var min = Math.floor((Math.abs(dec)-deg)*60);
var sec = (Math.round((((Math.abs(dec) - deg) - (min/60)) * 60 * 60) * 100) / 100 ) ;
var len = String(deg).length
deg = Array(3 + 1 - len).join('0') + deg;
var len = String(min).length
min = Array(2 + 1 - len).join('0') + min;
var len = String(sec).length
sec = Array(5 + 1 - len).join('0') + sec;
deg = dec < 0 ? '-' + deg : deg;
var dms = deg + '° ' + min + '\' ' + sec + '"';
return dms;
}
MStatusControl.prototype.getDefaultPosition = function() {
return this.position;
}
////////////////////////////
MStatusControl.prototype.setStyleValue = function(obj) {
obj.style.padding = '0px';
obj.style.paddingRight = '2px';
obj.style.paddingLeft = '2px';
obj.style.textAlign = 'left';
obj.style.color = this.foreground;
obj.style.backgroundColor = this.background;
obj.style.font = 'normal 12px courier new';
obj.style.lineHeight = '14px'
obj.setAttribute('noWrap','true');
if (!this.vertical) {
obj.style.width = '50%'
}
}
MStatusControl.prototype.show = function () {
this.container.style.display = '';
}
MStatusControl.prototype.hide = function () {
this.container.style.display = 'none';
}
MStatusControl.prototype.toggle = function () {
this.container.style.display = this.container.style.display == '' ? 'none' : '';
}
//////////// END MStatusControl /////////////////
this.mousePxDisplay.innerHTML = 'Mouse Px: '
this.mouseTileDisplay.innerHTML = 'Mouse Tile: '
this.clickDisplay.innerHTML = 'Mouse Click: '
if (this.parent) {
this.parent.appendChild(container);
}
else {
this.map.getContainer().appendChild(this.container);
}
GEvent.addListener(this.map, "click", function(ol,pt){globalThis_3456.MMapClick(pt)});
GEvent.addListener(this.map, "moveend", function(){globalThis_3456.MMoveEnd()});
GEvent.addListener(this.map, "zoomend", function(){globalThis_3456.MZoomEnd()});
GEvent.addListener(this.map, "mousemove", function(pt){globalThis_3456.MMouseMove(pt)});
this.MMapClick = function (pt) {
var point = pt ? pt : null;
if (point) {
if (this.DMS) {
this.clickDisplay.innerHTML = 'Mouse Click: ' + this.degToDms(point.lat()) + ', ' + this.degToDms(point.lng());
}
else {
this.clickDisplay.innerHTML = 'Mouse Click: ' + point.lat().toFixed(6) + ', ' + point.lng().toFixed(6);
}
}
}
this.MMoveEnd = function() {
this.MUpdateStatus();
}
this.MZoomEnd = function() {
this.MUpdateStatus();
}
this.MMouseMove = function(mousePt) {
var zoom = this.map.getZoom();
var mousePx = this.projection.fromLatLngToPixel(mousePt, zoom);
if (this.DMS) {
this.mouseDisplay.innerHTML = 'Mouse LatLon: ' + this.degToDms(mousePt.lat()) + ', ' + this.degToDms(mousePt.lng());
}
else {
this.mouseDisplay.innerHTML = 'Mouse LatLon: ' + mousePt.lat().toFixed(6) + ', ' + mousePt.lng().toFixed(6);
}
this.mousePxDisplay.innerHTML = 'Mouse Px: ' + mousePx.x + ', ' + mousePx.y;
this.mouseTileDisplay.innerHTML = 'Mouse Tile: ' + Math.floor(mousePx.x / 256) + ', ' + Math.floor(mousePx.y / 256);
}
this.MUpdateStatus = function() {
var center = this.map.getCenter();
var zoom = this.map.getZoom();
var bounds = this.map.getBounds();
var SW = bounds.getSouthWest();
var NE = bounds.getNorthEast();
if (this.DMS) {
this.centerDisplay.innerHTML = 'Map Center: ' + this.degToDms(center.lat()) + ', ' + this.degToDms(center.lng());
this.swDisplay.innerHTML = 'Map SW: ' + this.degToDms(SW.lat()) + ', ' + this.degToDms(SW.lng());
this.neDisplay.innerHTML = 'Map NE: ' + this.degToDms(NE.lat()) + ', ' + this.degToDms(NE.lng());
this.zDisplay.innerHTML = 'Map Zoom: ' + zoom;
}
else {
this.centerDisplay.innerHTML = 'Map Center: ' + center.lat().toFixed(6) + ', ' + center.lng().toFixed(6);
this.swDisplay.innerHTML = 'Map SW: ' + SW.lat().toFixed(6) + ', ' + SW.lng().toFixed(6);
this.neDisplay.innerHTML = 'Map NE: ' + NE.lat().toFixed(6) + ', ' + NE.lng().toFixed(6);
this.zDisplay.innerHTML = 'Map Zoom: ' + zoom;
}
}
this.MUpdateStatus();
return this.container;
}
MStatusControl.prototype.degToDms = function(dec) {
var deg = Math.floor(Math.abs(dec));
var min = Math.floor((Math.abs(dec)-deg)*60);
var sec = (Math.round((((Math.abs(dec) - deg) - (min/60)) * 60 * 60) * 100) / 100 ) ;
var len = String(deg).length
deg = Array(3 + 1 - len).join('0') + deg;
var len = String(min).length
min = Array(2 + 1 - len).join('0') + min;
var len = String(sec).length
sec = Array(5 + 1 - len).join('0') + sec;
deg = dec < 0 ? '-' + deg : deg;
var dms = deg + '° ' + min + '\' ' + sec + '"';
return dms;
}
MStatusControl.prototype.getDefaultPosition = function() {
return this.position;
}
////////////////////////////
MStatusControl.prototype.setStyleValue = function(obj) {
obj.style.padding = '0px';
obj.style.paddingRight = '2px';
obj.style.paddingLeft = '2px';
obj.style.textAlign = 'left';
obj.style.color = this.foreground;
obj.style.backgroundColor = this.background;
obj.style.font = 'normal 12px courier new';
obj.style.lineHeight = '14px'
obj.setAttribute('noWrap','true');
if (!this.vertical) {
obj.style.width = '50%'
}
}
MStatusControl.prototype.show = function () {
this.container.style.display = '';
}
MStatusControl.prototype.hide = function () {
this.container.style.display = 'none';
}
MStatusControl.prototype.toggle = function () {
this.container.style.display = this.container.style.display == '' ? 'none' : '';
}
//////////// END MStatusControl /////////////////
#7
http://greatmaps.codeplex.com/
http://gmapdotnet.codeplex.com/
http://gmapdotnet.codeplex.com/
#8
那个js太长 ,是googleMap官方的
你就凑合看看!
你就凑合看看!
#9
用过gmap.net插件的求指教啊,http://greatmaps.codeplex.com/
下的源码无法导入vs 需要什么密钥,QQ:382505554
下的源码无法导入vs 需要什么密钥,QQ:382505554