1.获得手机的地理位置(经纬度坐标)
使用phonegap框架类库(Android版本),可以方便的获得(目前已经能够简单的获得到经纬度坐标),经过查阅,使用sample中的如下过程:
var getLocation = function() { var suc = function(p){ alert(p.coords.latitude + " " + p.coords.longitude); }; var fail = function(){}; navigator.geolocation.getCurrentPosition(suc,fail); };
在此基础上,根据自己项目的需求进行完善修改,比如:判断GPS是否启动、在不同的网络连接环境中(WiFi等)的操作方法。
今天碰到的问题是:真机调试时联通卡能获得,移动的手机卡则不行,呼呼。。。。
2.ADF JavaScript获取地图坐标及与屏幕坐标的互转
http://www.cnblogs.com/tuncaysanli/archive/2009/08/28/1556006.html
//在地图上单击画点
var map = $find('Map1');map.getGeometry(ESRI.ADF.Graphics.ShapeType.Point, usePoint, null, 'red', '#0000FF', 'pointer', true);
//获取鼠标点击的位置的地图坐标
function usePoint(clickPoint) {
//地理坐标转到屏幕坐标 var screenPoint=map.toScreenPoint(clickPoint);
//获取屏幕坐标的X和Y分量
var screenX=screenPoint.offsetX;
var screenY=screenPoint.offsetY;
}
//屏幕坐标转到地理坐标
function ToMapXY(screenX,screenY){ var map = $find('Map1');
//返回 ESRI.ADF.Geometries.Point 类型的点 var mapPoint=map.toMapPoint(screenX,screenY);
}
