android arcgis开发
2016-01-05 11:27
423 查看
A.ArcGIS Android 10.2.7 API地址:https://developers.arcgis.com/android/api-reference/reference/packages.html
B.ArcGIS
for Android地图控件的5大常见操作:http://blog.csdn.net/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());
B.ArcGIS
for Android地图控件的5大常见操作:http://blog.csdn.net/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());
相关文章推荐
- android定位并获取城市
- Android开发:什么是Parcel
- Android:方向传感器
- Android的Recovery中font_10x18.h字库文件制作
- Android:状态栏Notification
- Android文件读写注意点
- android studio中的极光推送
- Android编程解析XML方法详解(SAX,DOM与PULL)
- Android夜间模式最佳实践
- android studio 下的debug模式下的keystore变成自己的keystore
- android:windowSoftInputMode属性详解
- Android实现通知栏透明的方法
- Android Studio中如何跳到某一个方法
- Android 自定义View (一)
- 关于android studio 下获取签名文件SHA1的方法
- Android单元测试
- Android API Level 对应关系 6.0
- android preferences使用
- android 自定义TextView中Html超链接点击事件详解
- Android编程中的消息机制实例详解