A.ArcGIS Android 10.2.7 API地址:https://developers.arcgis.com/android/api-reference/reference/packages.html
B.ArcGIS for Android地图控件的5大常见操作:http://blog.youkuaiyun.com/arcgis_mobile/article/details/7801467
1.在MyEclipse中配置SDK后,在MyEclipse安装目录MyEclipse10\dripins目录下新建arcgis文件夹,放入解压后的jar包,重启MyEclipse即可发现项目右键出现ArcGIS Tools选项。
2.layout中加入
<com.esri.android.map.MapView
android:id="@+id/mMap"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</com.esri.android.map.MapView>
3.Activity中
mMapView = (MapView) findViewById(R.id.mMap);
ArcGISTiledMapServiceLayer tileLayer = new ArcGISTiledMapServiceLayer(mapUrl);
mMapView.addLayer(tileLayer); //添加图层到地图窗口中
ArcGISRuntime.setClientId("1eFHW78avlnRUPHm"); //去除地图水印
gLayer = new GraphicsLayer();
mMapView.addLayer(gLayer);
4.在地图上标注显示
public void pointMap(List<Map<String,Object>> carList){
if(gLayer.getGraphicIDs()!=null){
gLayer.removeGraphics(gLayer.getGraphicsIDs()); //清楚地图上的点
}
for(Map<String,Object> map : carList){
if("0".equals(map.get("State").toString())){
double longtitude = Double.parseDouble(map.get("Longitude").toString); //维度同理
Point mPoint = new Point(longtitude,lantitude);
Drawable drawable = getResources().getDrawable(R.drawable.normal);
graphic = new Graphic(mPoint,new PictureMarkerSymbol(drawable));
int graphicId = gLayer.addGraphic(graphic);
gLayer.updateGraphic(graphicId,graphic);
}
popCallout(); //callout是点击标注弹出气泡
}
}
public void popCallout(){
mMapView.setOnSingleTapListener(new OnSingleTapListener(){
public void onSingleTap(float x,float y){
Graphic result = getGraphicsFromLayer(x,y,gLayer); //检索当前光标点(手指按压位置)的附近的graphic对象
if(result != null){
callout = mMapView.getCallout();
callout.setStyle(R.xml.calloutstyle);
View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.callout_car,null);
callout.setMaxHeight(400);
callout.setMaxWidth(500);
callout.setContent(view);
callout.setCoordinates(mMapView,toMapPoint(new Point(x,y)); //显示位置
callout.show();
}
}
})
}
public Graphic getGraphicsFromLayer(double xScreen,double yScreen,GraphicsLayer gLayer){
Graphic result = null;
try{
int[] idsArr = gLayer.getGraphicsIDs();
double x = xScreen; double y = yScreen;
for(int i=0; i< idsArr.length;i++){
Graphic graphic = gLayer.getGraphic(idsArr[i]);
if(graphic !=null){
Point point = (Point)graphic.getGeometry();
point = mMapView.toScreenPoint(point);
double x1 = point.getX(); double y1 = point.getY();
if(Math.sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1))<25){
result = graphic;
break;
}
}
}
}
}
4326经纬度坐标系,3857也就是102100另外一个坐标系
获取地图的坐标系:int wkId = mMapView.getSpatialReference().getID();
mPoint = (Point)GeometryEngine.projecct(mPoint,SpatialReference.create(4326),mMapView.getSpatialReference());