如何实现安卓定位,用arcGis开发

我做出了一部分,按照教程来的,但是还是有错误,不知道是为什么,求大神指导

Agslocation

import com.esri.android.map.LocationService;
import com.esri.android.map.MapView;
import com.esri.core.geometry.Envelope;
import com.esri.core.geometry.GeometryEngine;
import com.esri.core.geometry.LinearUnit;
import com.esri.core.geometry.Point;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.geometry.Unit;

import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;

public class AgsLocation {

 private LocationService ls=null;
    private AgsLocation agslocation=null;
 public void AgsLocation(MapView mMapView) {
  // TODO Auto-generated method stub 
  final MapView mMapView1 = null;
  LocationService ls=mMapView1.getLocationService();
  ls.setAutoPan(true);
  ls.setAllowNetworkLocation(true);
  ls.setAccuracyCircleOn(true);
  
  
  ls.setLocationListener( new LocationListener(){

   public void onLocationChanged(Location loc) {
    // TODO Auto-generated method stub
    boolean  LocationChanged=false;
    if(!LocationChanged){
     
     LocationChanged=true;
     double locx=loc.getLatitude();
     double locy=loc.getLongitude();
     Point wgspoint=new Point(locx,locy);
     Point mappoint=(Point)GeometryEngine.project(wgspoint, SpatialReference.create(4326),mMapView1.getSpatialReference());
     Unit mapUnit=mMapView1.getSpatialReference().getUnit();
     double SEARCH_RADIUS=5.0;
     double zoomWidth=Unit.convertUnits(SEARCH_RADIUS, Unit.create(LinearUnit.Code.MILE_US), mapUnit);
     Envelope zoomExtent=new Envelope(mappoint,zoomWidth,zoomWidth);
     mMapView1.setExtent(zoomExtent);
     
    }  
   }

   public void onProviderDisabled(String provider) {
    // TODO Auto-generated method stub
    
   }

   public void onProviderEnabled(String provider) {
    // TODO Auto-generated method stub
    
   }

   public void onStatusChanged(String provider, int status,
     Bundle extras) {
    // TODO Auto-generated method stub
    
   }
   
  });
  ls.start();//开始定位
 }
     
}

 

我想把它封装一下,在地图上运行不出来,是怎么回事

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值