Android 将纬度和经度转换为esri arcGIS MapPoint
我无法将纬度和经度值转换为android esri arcGIS地图点。以下是我从GPS坐标获取纬度和经度值的代码:Android 将纬度和经度转换为esri arcGIS MapPoint,android,gps,arcgis,esri,Android,Gps,Arcgis,Esri,我无法将纬度和经度值转换为android esri arcGIS地图点。以下是我从GPS坐标获取纬度和经度值的代码: LocationManager lm; String towers; double lat; double longi; TextView txt; lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria crit = new Crit
LocationManager lm;
String towers;
double lat;
double longi;
TextView txt;
lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria crit = new Criteria();
towers = lm.getBestProvider(crit, false);
Location location = lm.getLastKnownLocation(towers);
if(location != null)
{
lat = location.getLatitude();
longi = location.getLongitude();
}
现在我有了纬度和经度值。现在我只需要将这些值转换为有效的esri arcGIS MapPoint。有人能帮我吗
提前感谢。免责声明:我不是这方面的专家,但想尽力帮助。:) 现在有一个网站。有更多的信息一直在添加,是一个很好的整合资源相比,有什么是在互联网上支付 对于框架,我推荐Android 顺便说一句,这是一个有趣的项目从马可伯纳索奇,你可能会发现作为参考有用
希望你能找到你想要的 假设您使用的是ESRI Android API?如果是,请在地图上创建图形层。然后创建一个点对象
com.esri.core.geometry.Point
Point myPoint = new Point();
然后设置x/y值:
myPoint.setX(longi);
myPoint.setY(lat);
然后将myPoint添加到图形对象
是的,这是可能的。但在ArcGis中不使用locationmanager ArcGIS具有类似LocationListener的预定义方法,即:OnStatusChangedListener。 有关将位置纬度和经度转换为esri arcGIS MapPoint的信息,请参见下面的代码
mMapView.setOnStatusChangedListener(new OnStatusChangedListener() {
/**
*
*/
private static final long serialVersionUID = 1L;
public void onStatusChanged(Object source, STATUS status) {
if (source == mMapView && status == STATUS.INITIALIZED) {
LocationService ls = mMapView.getLocationService();
ls.setAutoPan(false);
ls.setLocationListener(new LocationListener() {
boolean locationChanged = false;
// Zooms to the current location when first GPS fix
// arrives.
public void onLocationChanged(Location loc) {
if (!locationChanged) {
locationChanged = true;
double locy = loc.getLatitude();
double locx = loc.getLongitude();
Point wgspoint = new Point(locx, locy);
Point mapPoint = (Point) GeometryEngine.project(wgspoint,
SpatialReference.create(4326),
mMapView.getSpatialReference());
Unit mapUnit = mMapView.getSpatialReference().getUnit();
double zoomWidth = Unit.convertUnits(
SEARCH_RADIUS, Unit.create(LinearUnit.Code.MILE_US), mapUnit);
Envelope zoomExtent = new Envelope(mapPoint, zoomWidth, zoomWidth);
mMapView.setExtent(zoomExtent);
GraphicsLayer gLayer = new GraphicsLayer();
PictureMarkerSymbol symbol = new
PictureMarkerSymbol(getResources().getDrawable(R.drawable.twiz_car_red));
Graphic graphic = new Graphic(mapPoint, symbol);
//Graphic point=new Graphic(new Point(x, y),new
SimpleMarkerSymbol(Color.CYAN,20,STYLE.CIRCLE));
gLayer.addGraphic(graphic);
mMapView .addLayer(gLayer);
}
}
public void onProviderDisabled(String arg0) {
}
public void onProviderEnabled(String arg0) {
}
public void onStatusChanged(String arg0, int arg1,
Bundle arg2) {
}
});
ls.start();
}
}
});
我从你那里借了一些代码
专用点到地理(点pnt)
{
双精度=pnt.getX();
双倍商业利率=pnt.getY();
如果(数学绝对值小于180和数学绝对值小于90)
返回pnt;
如果((数学abs(mercatorY_lon)>20037508.3427892)|(数学abs(mercatorY_lat)>20037508.3427892))
返回pnt;
双x=0;
双y=商业水平;
双num3=x/6378137.0;
双num4=num3*57.295779513082323;
双num5=数学地板((双)((num4+180.0)/360.0));
双num6=num4-(num5*360.0);
双num7=1.57079636267948966-(2.0*Math.atan(Math.exp(-1.0*y)/6378137.0));
梅尔卡托伦=num6;
mercatorY_lat=num7*57.295779513082323;
返回新点(mercatorY_-lon、mercatorY_-lat);
}
专用点式塔式起重机(点式pnt)
{
双精度=pnt.getX();
双倍商业利率=pnt.getY();
如果((数学绝对值(平均值)>180 | |数学绝对值(平均值)>90))
返回pnt;
双数值=0.017453292519943295;
双x=6378137.0*num;
双a=mercatorY_lat*0.017453292519943295;
麦卡隆=x;
mercatorY_lat=3189068.5*Math.log((1.0+Math.sin(a))/(1.0-Math.sin(a));
返回新点(mercatorY_-lon、mercatorY_-lat);
}
我不主张效率,但这至少是一个起点 //将经度和纬度转换为地图点X和Y
- (AGSPoint *)agsPointFromLatitude:(double)latitude longitude:(double)longitude
{
double mercatorX = longitude * 0.017453292519943295 * 6378137.0;
double a = latitude * 0.017453292519943295;
double mercatorY = 3189068.5 * log((1.0 + sin(a))/(1.0 - sin(a)));
AGSPoint *obj = [AGSPoint pointWithX:mercatorX y:mercatorY spatialReference: [AGSSpatialReference wgs84SpatialReference]];
return obj;
}
我制作了一个函数,将位置点的两个参数转换为arcgis点:
private Point ConvertMyLocationPoint(final double x, final double y) {
Point wgspoint = new Point(x, y);
Point mapPoint = (Point) GeometryEngine.project(wgspoint, SpatialReference.create(4326),
mMapView.getSpatialReference());
return mapPoint;
}
真是太棒了
private Point ConvertMyLocationPoint(final double x, final double y) {
Point wgspoint = new Point(x, y);
Point mapPoint = (Point) GeometryEngine.project(wgspoint, SpatialReference.create(4326),
mMapView.getSpatialReference());
return mapPoint;
}