- 浏览: 321026 次
- 性别:
- 来自: 苏州
文章分类
- 全部博客 (228)
- ArcGis (4)
- UI设计 (32)
- SQLite (7)
- ListView (12)
- Handler_Thread (6)
- XML (5)
- Menu (7)
- TabHost (6)
- Inflater (2)
- Activity (5)
- SDCard (3)
- Dialog (7)
- Spinner (3)
- 设备信息 (2)
- 资源文件 (7)
- 多媒体 (7)
- 图片浏览 (5)
- 工具的使用 (3)
- Animation动画 (7)
- GIS (14)
- 软件发布 (4)
- GPS (2)
- 手机Feature开发 (6)
- 加密解密 (1)
- Time (2)
- JWeb (5)
- SQL (2)
- PhoneGap (3)
- JavaScript (3)
- Object-C入门 (7)
- Oracle (1)
- AutoCompleteTextView (1)
- APN (1)
- IOS开发 (12)
- 数据库工具 (3)
- UITableView (0)
- Arcgis for iOS (1)
最新评论
-
waterM:
...
DBVis 连接数据库配置 -
航空母舰:
上源码吧,差资源,都跑不起来!
ListView_split 分割 -
wade200:
学习了
启动另一个Activity并返回结果(附源码) -
AndLi:
里面的坐标被我写死了啊,你注释掉就可以了
GPS定位 -
kunlinchen2010:
求指教,QQ:446482624
GPS定位
111111111111111111
public class Demo extends Activity { public static final String INTENT_QUERY = "cn.hotgis.QueryUI"; public static final String INTENT_RESULT = "cn.hotgis.RESULTUI"; public static final String INTENT_STEP3 = "com.novoda.STEP3"; private static final int QUERY = 1; private static final int RESULT = 2; boolean bDraw = false; double loc_x = 0, loc_y = 0; // 文件夹名称 String foldername = "test3"; // 地图资源路径 String path = "/" + foldername + "/" + foldername + ".map"; double x; double y; List<PointInfoModel> pointList; PointInfoModel pointInfo; AlertDialog selectDialog; private List<Map<String, Object>> mData; eMyMapWnd2 m_myMapWnd = null; eMyMapWnd2 m_myMapWnd2 = null; boolean m_bRotate = false; @SuppressWarnings("unused") private SensorManager sensorMgr; int penI = 0; @SuppressWarnings("unused") private final static int CWJ_HEAP_SIZE = 6 * 1024 * 1024; public class eMyMapWnd2 extends eMyMapWnd { public eMyMapWnd2(Context context) { super(context); } @Override public void OnGeometrySelected(int count) { pointList = new ArrayList<PointInfoModel>(); int c = m_myMapWnd.GetMap().Selection().GetCount(); System.out.println("c=" + c); for (int i = 0; i < c; i++) { eMyResultSet rs = m_myMapWnd.GetMap().Selection().GetAt(i); System.out.println("所属层名:" + rs.GetLayer().GetName()); rs.Reset(); while (rs.HasNext()) { eMyPoint point = rs.GetGeometry().GetPointAt(0);// 获取逻辑坐标 eMyPoint2D point2D = m_myMapWnd.GetMap().MapToGeo(point);// 转物理坐标 x = point2D.GetX(); y = point2D.GetY(); pointInfo = new PointInfoModel(); pointInfo.setX(x); pointInfo.setY(y); pointInfo.setName(rs.GetString(0).toString()); pointInfo.setId(rs.GetString(1).toString()); pointInfo.setCity(rs.GetString(2).toString()); pointInfo.setArea(rs.GetString(3).toString()); pointInfo.setCategory(rs.GetString(4).toString()); pointInfo.setGeocode(rs.GetString(5).toString()); pointList.add(pointInfo); } } // 输出显示结果 if (pointList.size() > 0) { // 点选 // if (pointList.size() == 1) { // double x = pointList.get(0).getX(); // double y = pointList.get(0).getY(); // String name = pointList.get(0).getName(); // String id = pointList.get(0).getId(); // String city = pointList.get(0).getCity(); // String area = pointList.get(0).getArea(); // String category = pointList.get(0).getCategory(); // String geocode = pointList.get(0).getGeocode(); // show(0, name, id, city, area, category, geocode, x, y); // // } // 多选 // else { // for (int i = 0; i < pointList.size(); i++) { // double x = pointList.get(i).getX(); // double y = pointList.get(i).getY(); // String name = pointList.get(i).getName(); // String id = pointList.get(i).getId(); // String city = pointList.get(i).getCity(); // String area = pointList.get(i).getArea(); // String category = pointList.get(i).getCategory(); // String geocode = pointList.get(i).getGeocode(); // show(i, name, id, city, area, category, geocode, x, // y); // } mData = new ArrayList<Map<String, Object>>(); Map<String, Object> map = new HashMap<String, Object>(); for (int i = 0; i < pointList.size(); i++) { map = new HashMap<String, Object>(); map.put("name", pointList.get(i).getName()); map.put("pointx", pointList.get(i).getX()); map.put("pointy", pointList.get(i).getY()); map.put("area", pointList.get(i).getArea()); map.put("geocode", pointList.get(i).getGeocode()); mData.add(map); } MyAdapter myAdapter = new MyAdapter(Demo.this, mData); showDialog(myAdapter);// 显示选中列表 } // } // Toast.makeText(Demo.this, text, 9000).show(); } protected Drawable boundCenterBottom(Drawable balloon) { int markerWidth = balloon.getIntrinsicWidth(); int markerHeight = balloon.getIntrinsicHeight(); Rect srcRect = balloon.getBounds(); srcRect.offset(-markerWidth / 2, -markerHeight); balloon.setBounds(srcRect); return balloon; } @Override public void OnDraw(Canvas canvas) { // if (bDraw = true) // return; Paint paint = new Paint(); // loc_x = 120.46158699979; // loc_y = 36.09769800014725; eMyPoint pt = m_myMapWnd.GeoToPixel(new eMyPoint2D(loc_x, loc_y)); Point myScreenCoords = new Point((int) pt.GetX(), (int) pt.GetY()); // 转换当前地图位置到屏幕坐标点 // mv.getProjection().toPixels(gp1, myScreenCoords); paint.setStrokeWidth(1); paint.setARGB(255, 255, 0, 0); paint.setStyle(Paint.Style.FILL); @SuppressWarnings("unused") Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.location); canvas.save(Canvas.MATRIX_SAVE_FLAG); // 加载两次图片资源 Drawable drawable = getResources().getDrawable(R.drawable.location); // 这里调用mutate 做测试 Drawable drawable1 = getResources() .getDrawable(R.drawable.location).mutate(); drawable.setBounds(myScreenCoords.x, myScreenCoords.y, myScreenCoords.x + drawable.getIntrinsicWidth(), myScreenCoords.y + drawable.getIntrinsicHeight()); drawable1.setBounds(0, 0, drawable1.getIntrinsicWidth(), drawable1 .getIntrinsicHeight()); // 位置的调节操作 boundCenterBottom(drawable); drawable.draw(canvas); canvas.restore(); canvas.save(Canvas.MATRIX_SAVE_FLAG); // 颜色的过滤 drawable1.setColorFilter(0x7f000000, PorterDuff.Mode.SRC_IN); // 位移操作 canvas.translate(myScreenCoords.x, myScreenCoords.y); // 倾斜操作 canvas.skew(-0.9F, 0.0F); // 进行缩放 canvas.scale(1.0F, 0.5F); boundCenterBottom(drawable1); drawable1.draw(canvas); // 这里清除颜色过滤 drawable1.clearColorFilter(); canvas.restore(); } } // 弹出对话框 public void showDialog(MyAdapter myAdapter) { LayoutInflater inflater = LayoutInflater.from(Demo.this);// 渲染器 View customdialog2view = inflater.inflate(R.layout.dialog_select, null); // 自定义的透明dialog----------------------------------------------------- // 创建Dialog并设置样式主题 SelectDialog selectDialog = new SelectDialog(Demo.this, R.style.dialog); // 设置点击Dialog外部任意区域关闭Dialog selectDialog.setCanceledOnTouchOutside(true); selectDialog.setContentView(customdialog2view); // selectDialog.setTitle("选中列表:"); // 系统dialog----------------------------------------------------- // AlertDialog.Builder builder = new AlertDialog.Builder(Demo.this); // builder.setTitle("选中列表:"); // builder.setView(customdialog2view); // builder.setNegativeButton("取消", // new DialogInterface.OnClickListener() { // public void onClick(DialogInterface dialog, int which) { // } // }); ListView listView = (ListView) customdialog2view .findViewById(R.id.listview); listView.setAdapter(myAdapter); listView.setItemsCanFocus(false); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); listView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ViewHolder viewHolder = (ViewHolder) view.getTag(); String name = viewHolder.name.getText().toString(); String area = viewHolder.area.getText().toString(); String geocode = viewHolder.geocode.getText().toString(); String x = viewHolder.point_x.getText().toString(); String y = viewHolder.point_y.getText().toString(); show(0, name, "", "", area, "", geocode, Double.valueOf(x), Double.valueOf(y)); } }); // 如果使用系统Dialog,请去掉该句注释 // selectDialog = builder.create(); selectDialog.show(); } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); m_myMapWnd = new eMyMapWnd2(this); setContentView(m_myMapWnd); // 初始化Location initLocation(); // ========================================================= WindowManager wm = (WindowManager) this .getSystemService(Context.WINDOW_SERVICE); int screenWidth = wm.getDefaultDisplay().getWidth();// 屏幕宽度 int screenHeight = wm.getDefaultDisplay().getHeight();// 屏幕高度 Rect rect = new Rect(); this.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect); // 旋转 // m_myView.m_myMapWnd.m_map.DrawParam().SetRotateAngle(45); m_myMapWnd.setSize(screenWidth, screenHeight - 50); // 打开文件 File sdDir = null; boolean sdCardExist = Environment.getExternalStorageState().equals( android.os.Environment.MEDIA_MOUNTED); // 判断sd卡是否存在 if (sdCardExist) { sdDir = Environment.getExternalStorageDirectory();// 获取跟目录 String sdPath = sdDir.toString(); String fileName = sdPath + path;// 以name存在目录中 double firClick = System.currentTimeMillis(); boolean bRet = m_myMapWnd.Open(fileName); double secClick = System.currentTimeMillis(); double distanceTime = secClick - firClick; String cost = String.valueOf(distanceTime); if (bRet) { int c = m_myMapWnd.GetMap().GetLayerCount(); for (int i = 0; i < c; i++) { eMyLayer pLayer = m_myMapWnd.GetMap().GetLayerAt(i); } } } m_myMapWnd.GetMap().Compass().visible = true; m_myMapWnd.GetMap().Scale().visible = true; } private LocationManager locationManager; private Location location; private Criteria criteria; private String provider; @SuppressWarnings("static-access") private void initLocation() { // 初始化locationManager:获得系统所提供的location_service locationManager = (LocationManager) getSystemService(this.LOCATION_SERVICE); // 精度比较高,但是慢而且消耗电力, 而且可能因为天气原因或者障碍物而无法获取卫星信息,另外设备可能没有GPS模块 // if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){ // 通过网络获取定位信息,精度低,耗电少,获取信息速度较快,不依赖GPS模块 if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE);// 高精度 criteria.setAltitudeRequired(false);// 海拔 criteria.setBearingRequired(false);// 方向 criteria.setSpeedRequired(false);// 速度 criteria.setCostAllowed(false);// 不允许有花费 criteria.setPowerRequirement(Criteria.POWER_LOW);// 低功耗 provider = locationManager.getBestProvider(criteria, true); // 位置变化监听,默认5秒一次,距离10米以上 locationManager.requestLocationUpdates(provider, 5000, 10, locationListener); } else { showGPSDate(null, -1); } } @SuppressWarnings("unused") private final SensorEventListener mSensorEventListener = new SensorEventListener() { public void onSensorChanged(SensorEvent event) { if (event.sensor.getType() == Sensor.TYPE_ORIENTATION) { float x; x = event.values[SensorManager.DATA_X]; if (m_myMapWnd != null && m_bRotate) { m_myMapWnd.SetRotateAngle(x); m_myMapWnd.reDraw(); m_myMapWnd.repaint(0, 0); } } } public void onAccuracyChanged(Sensor sensor, int accuracy) { } }; @Override public void onWindowFocusChanged(boolean hasFocus) { // TODO Auto-generated method stub super.onWindowFocusChanged(hasFocus); Rect frame = new Rect(); getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); int statusBarHeight = frame.top; int contentTop = getWindow().findViewById(Window.ID_ANDROID_CONTENT) .getTop(); // statusBarHeight是上面所求的状态栏的高度 @SuppressWarnings("unused") int titleBarHeight = contentTop - statusBarHeight; // textView = (TextView)findViewById(R.id.textView1); // textView.setText("状态栏的高度" + Integer.toString(titleBarHeight)); } protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case QUERY: bDraw = false; String Keyword = data.getStringExtra("Keyword"); int index = data.getIntExtra("Index", 0); eMyLayer lyr = m_myMapWnd.GetMap().GetLayerAt(index); eMyQueryDefn qd = new eMyQueryDefn(); String wc = " OBJNAME like '%"; wc += Keyword; wc += "%'"; qd.SetWhereClause(wc); eMyResultSet rs = lyr.Query(qd); String str = ""; String[] value = new String[rs.GetCount()]; String[] coor = new String[rs.GetCount()]; int j = 0; while (rs.HasNext()) { str += rs.GetString(0); str += rs.GetString(1); str += rs.GetString(2); str += rs.GetString(3); str += rs.GetString(4); str += rs.GetString(5); value[j] = str; str = ""; int x = rs.GetGeometry().GetPointAt(0).GetX(); int y = rs.GetGeometry().GetPointAt(0).GetY(); eMyPoint2D pt = m_myMapWnd.GetMap() .MapToGeo(new eMyPoint(x, y)); coor[j] = String.valueOf(pt.GetX()) + "," + String.valueOf(pt.GetY()); j++; } Intent intent = new Intent(); intent.setClass(Demo.this, ResultUI.class); Bundle bundle = new Bundle(); bundle.putSerializable("rs_string", value); bundle.putSerializable("rs_coor", coor); intent.putExtras(bundle); startActivityForResult(intent, RESULT); break; case RESULT: // 定位 { @SuppressWarnings("unused") String R_Keyword = data.getStringExtra("R_Keyword"); String R_Coor = data.getStringExtra("R_Coor"); String[] xy = R_Coor.split(","); bDraw = true; loc_x = Double.valueOf(xy[0]); loc_y = Double.valueOf(xy[1]); m_myMapWnd.ZoomTo(loc_x, loc_y, 0.002); m_myMapWnd.reDraw(); m_myMapWnd.repaint(0, 0); break; } } } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: m_myMapWnd.pan(20, 0); break; case KeyEvent.KEYCODE_DPAD_RIGHT: m_myMapWnd.pan(-20, 0); break; case KeyEvent.KEYCODE_DPAD_UP: m_myMapWnd.pan(0, -20); break; case KeyEvent.KEYCODE_DPAD_DOWN: m_myMapWnd.pan(0, 20); break; case KeyEvent.KEYCODE_DPAD_CENTER: m_myMapWnd.ZoomByRatio(1 / 1.1); break; case KeyEvent.KEYCODE_BACK: if (event.getRepeatCount() == 0) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("确定退出本程序吗?").setTitle("提示").setCancelable( false).setPositiveButton("确定", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); System.exit(0); } }).setNegativeButton("取消", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).show(); return false; } break; } double firClick = System.currentTimeMillis(); m_myMapWnd.reDraw(); m_myMapWnd.repaint(0, 0); double secClick = System.currentTimeMillis(); double distanceTime = secClick - firClick; @SuppressWarnings("unused") String cost = String.valueOf(distanceTime); // Toast.makeText(this, cost, Toast.LENGTH_LONG).show(); return super.onKeyDown(keyCode, event); } public void onResume() { super.onResume(); } @Override public void onConfigurationChanged(Configuration config) { super.onConfigurationChanged(config); WindowManager windowManager = getWindowManager(); Display display = windowManager.getDefaultDisplay(); int screenWidth = display.getWidth(); int screenHeight = display.getHeight(); if (m_myMapWnd != null) { m_myMapWnd.setSize(screenWidth, screenHeight); m_myMapWnd.reDraw(); m_myMapWnd.repaint(0, 0); m_myMapWnd.invalidate(); } } // 菜单 public boolean onCreateOptionsMenu(android.view.Menu menu) { // 自定义的菜单 // ------------------------------------------------------- // 点选 menu.add(0, Menu.FIRST + 1, Menu.NONE, "点选"); // 矩形选 menu.add(0, Menu.FIRST + 15, Menu.NONE, "矩形选"); // 补偿漫游 menu.add(0, Menu.FIRST + 11, Menu.NONE, "漫游"); // 定位 menu.add(0, Menu.FIRST + 28, Menu.NONE, "定位"); // GPS menu.add(0, Menu.FIRST + 29, Menu.NONE, "GPS"); // 全图显示 menu.add(0, Menu.FIRST, Menu.NONE, "全图显示"); // ------------------------------------------------------- // SubMenu baseMenu = menu.addSubMenu("基本操作").setIcon( // android.R.drawable.ic_menu_myplaces); // baseMenu.add(0, Menu.FIRST + 9, Menu.NONE, "放大"); // baseMenu.add(0, Menu.FIRST + 10, Menu.NONE, "缩小"); // baseMenu.add(0, Menu.FIRST + 11, Menu.NONE, "补偿漫游"); // baseMenu.add(0, Menu.FIRST + 12, Menu.NONE, "平滑漫游"); // baseMenu.add(0, Menu.FIRST + 13, Menu.NONE, "旋转"); // baseMenu.add(0, Menu.FIRST, Menu.NONE, "全图显示"); // SubMenu selMenu = menu.addSubMenu("选取").setIcon( // android.R.drawable.ic_menu_crop); // selMenu.add(0, Menu.FIRST + 1, Menu.NONE, "点选"); // selMenu.add(0, Menu.FIRST + 15, Menu.NONE, "矩形选"); // selMenu.add(0, Menu.FIRST + 16, Menu.NONE, "多边形选"); // SubMenu trackMenu = menu.addSubMenu("临时图层").setIcon( // android.R.drawable.ic_menu_mapmode); // trackMenu.add(0, Menu.FIRST + 2, Menu.NONE, "添加点"); // trackMenu.add(0, Menu.FIRST + 3, Menu.NONE, "添加线"); // trackMenu.add(0, Menu.FIRST + 4, Menu.NONE, "添加面"); // trackMenu.add(0, Menu.FIRST + 14, Menu.NONE, "清空"); // SubMenu queryMenu = menu.addSubMenu("查询").setIcon( // android.R.drawable.ic_menu_search); // queryMenu.add(0, Menu.FIRST + 6, Menu.NONE, "点查询"); // queryMenu.add(0, Menu.FIRST + 7, Menu.NONE, "面查询"); // queryMenu.add(0, Menu.FIRST + 8, Menu.NONE, "SQL查询"); // menu.add(0, Menu.FIRST + 17, Menu.NONE, "图层管理器").setIcon( // android.R.drawable.ic_menu_slideshow); // SubMenu otherMenu = menu.addSubMenu("专题图").setIcon( // android.R.drawable.ic_menu_upload_you_tube); // otherMenu.add(0, Menu.FIRST + 18, Menu.NONE, "专题图"); // otherMenu.add(0, Menu.FIRST + 19, Menu.NONE, "清空"); // SubMenu cosmeticMenu = menu.addSubMenu("装饰图层").setIcon( // android.R.drawable.ic_menu_always_landscape_portrait); // cosmeticMenu.add(0, Menu.FIRST + 20, Menu.NONE, "添加点"); // cosmeticMenu.add(0, Menu.FIRST + 21, Menu.NONE, "添加线"); // cosmeticMenu.add(0, Menu.FIRST + 22, Menu.NONE, "添加面"); // cosmeticMenu.add(0, Menu.FIRST + 23, Menu.NONE, "清空"); // cosmeticMenu.add(0, Menu.FIRST + 24, Menu.NONE, "SQL查询"); // cosmeticMenu.add(0, Menu.FIRST + 25, Menu.NONE, "查询"); // cosmeticMenu.add(0, Menu.FIRST + 26, Menu.NONE, "删除"); // cosmeticMenu.add(0, Menu.FIRST + 27, Menu.NONE, "添加自定义字段"); return true; } // 菜单的单击事件 public boolean onOptionsItemSelected(MenuItem item) { super.onOptionsItemSelected(item); switch (item.getItemId()) {// 获取菜单项的ID,即前面Menu.add方法的第二个参数 case Menu.FIRST: { m_myMapWnd.viewEntire(); m_myMapWnd.reDraw(); m_myMapWnd.repaint(0, 0); } break; case Menu.FIRST + 1: // 点选 m_myMapWnd.setTool(eMapAction.mcaSelectPoint); break; case Menu.FIRST + 2: { // TrackingLayer 添加点 eMyGeometry geom = new eMyGeometry(1, 1); eMyPoint pt1 = m_myMapWnd.GetMap().GeoToMap( new eMyPoint2D(120.46, 36.0972)); geom.SetPointAt(0, pt1); int type = 1; eMyStyle style = new eMyStyle(); style.SetBmpIndex(40); String tag = "P1"; m_myMapWnd.GetMap().TrackingLayer().AddEvent(geom, type, style, tag, 0); m_myMapWnd.GetMap().TrackingLayer().SetVisible(true); m_myMapWnd.repaint(0, 0); } break; case Menu.FIRST + 3: { // TrackingLayer 添加线 eMyGeometry geom = new eMyGeometry(3, 1); eMyPoint pt1 = m_myMapWnd.GetMap().GeoToMap( new eMyPoint2D(120.4531, 36.0930)); geom.SetPointAt(0, pt1); eMyPoint pt2 = m_myMapWnd.GetMap().GeoToMap( new eMyPoint2D(120.4664, 36.0901)); geom.SetPointAt(1, pt2); eMyPoint pt3 = m_myMapWnd.GetMap().GeoToMap( new eMyPoint2D(120.4641, 36.0999)); geom.SetPointAt(2, pt3); int type = 3; eMyStyle style = new eMyStyle(); style.SetPenColor(Color.GREEN); style.SetPenWidth(3); String tag = "L1"; m_myMapWnd.GetMap().TrackingLayer().AddEvent(geom, type, style, tag, 0); m_myMapWnd.GetMap().TrackingLayer().SetVisible(true); m_myMapWnd.repaint(0, 0); } break; case Menu.FIRST + 4: { // TrackingLayer 添加面 eMyGeometry geom = new eMyGeometry(3, 1); eMyPoint pt1 = m_myMapWnd.GetMap().GeoToMap( new eMyPoint2D(120.4531, 36.0930)); geom.SetPointAt(0, pt1); eMyPoint pt2 = m_myMapWnd.GetMap().GeoToMap( new eMyPoint2D(120.4614, 36.0981)); geom.SetPointAt(1, pt2); eMyPoint pt3 = m_myMapWnd.GetMap().GeoToMap( new eMyPoint2D(120.4641, 36.0929)); geom.SetPointAt(2, pt3); int type = 5; eMyStyle style = new eMyStyle(); style.SetBrushColor(Color.RED); String tag = "A1"; m_myMapWnd.GetMap().TrackingLayer().AddEvent(geom, type, style, tag, 0); m_myMapWnd.GetMap().TrackingLayer().SetVisible(true); m_myMapWnd.repaint(0, 0); } break; case Menu.FIRST + 5: System.exit(0); break; case Menu.FIRST + 7: { // 面查询 eMyLayer lyr = m_myMapWnd.GetMap().GetLayerAt(2); if (lyr != null) { eMyRect bounds = new eMyRect(0, 0, 240, 320); eMyResultSet rs = lyr.QueryWithBounds(bounds); m_myMapWnd.GetMap().Selection().Add(rs); m_myMapWnd.repaint(0, 0); } } break; case Menu.FIRST + 8: { // SQL查询 Intent intent = new Intent(); intent.setClass(Demo.this, QueryUI.class); Bundle bundle = new Bundle(); int c = m_myMapWnd.GetMap().GetLayerCount(); String[] name = new String[c]; for (short i = 0; i < c; i++) { name[i] = m_myMapWnd.GetMap().GetLayerAt(i).GetName(); } bundle.putSerializable("layername", name); intent.putExtras(bundle); // @startActivity(intent); startActivityForResult(intent, QUERY); /* * eMyLayer lyr = m_myMapWnd.GetMap().GetLayerAt(2); eMyResultSet rs * = new eMyResultSet(); eMyQueryDefn qd = new eMyQueryDefn(); * qd.m_strWhereClause=" SID like '%67%'"; * qd.m_apFieldNames.add("类别码"); qd.m_apFieldNames.add("所在区"); * * eMyClauseDefn cDefn = new eMyClauseDefn(); cDefn.m_strWhereClause * = " SID like '%67%'"; * * eMyStyle style = new eMyStyle(); style.SetBrushColor(Color.BLUE); * cDefn.m_style =style; lyr.SetHighlightStyle(style); * lyr.ThemeClause().AddClauseDefn(cDefn); * lyr.ThemeClause().SetVisible(true); lyr.Query(qd, rs); String str * = ""; while(rs.HasNext()){ str += rs.GetString(0); str += * rs.GetString(1); str += rs.GetString(2); str += rs.GetString(3); * str += rs.GetString(4); str += rs.GetString(5); * * } m_myMapWnd.GetMap().Selection().Add(rs); * m_myMapWnd.repaint(0,0); * Toast.makeText(this,str,Toast.LENGTH_SHORT).show(); */ } break; case Menu.FIRST + 9: { // 放大 // m_myMapWnd.ZoomByRatio(1.2); // m_myMapWnd.reDraw(); // m_myMapWnd.repaint(0,0); m_myMapWnd.setTool(eMapAction.mcaZoomIn); } break; case Menu.FIRST + 10: { // 缩小 // m_myMapWnd.ZoomByRatio(1/1.2); // m_myMapWnd.reDraw(); // m_myMapWnd.repaint(0,0); m_myMapWnd.setTool(eMapAction.mcaZoomOut); } break; case Menu.FIRST + 11: { // 补偿漫游 m_myMapWnd.setTool(eMapAction.mcaPan2); } break; case Menu.FIRST + 12: { // 平滑漫游 m_myMapWnd.setTool(eMapAction.mcaPan); } break; case Menu.FIRST + 13: { // 旋转 item.setCheckable(true); m_bRotate = !item.isChecked(); item.setChecked(m_bRotate); if (!m_bRotate) { m_myMapWnd.SetRotateAngle(0); m_myMapWnd.reDraw(); m_myMapWnd.repaint(0, 0); } } break; case Menu.FIRST + 14: { // 清空 m_myMapWnd.GetMap().TrackingLayer().ClearEvents(); m_myMapWnd.repaint(0, 0); } break; case Menu.FIRST + 15: { // 矩形选 m_myMapWnd.setTool(eMapAction.mcaSelectRect); } break; case Menu.FIRST + 16: { // 多边形选 m_myMapWnd.setTool(eMapAction.mcaSelectPolygon); } break; case Menu.FIRST + 17: { // 图层管理器 Intent intent = new Intent(); intent.setClass(Demo.this, layerControl.class); Bundle bundle = new Bundle(); int c = m_myMapWnd.GetMap().GetLayerCount(); String[] name = new String[c]; boolean[] selectable = new boolean[c]; for (short i = 0; i < c; i++) { name[i] = m_myMapWnd.GetMap().GetLayerAt(i).GetName(); selectable[i] = m_myMapWnd.GetMap().GetLayerAt(i) .IsSelectable(); } bundle.putSerializable("layername", name); bundle.putSerializable("selectable", selectable); intent.putExtras(bundle); startActivity(intent); } break; case Menu.FIRST + 18: { // 条件专题图 eMyLayer layer = m_myMapWnd.GetMap().GetLayerAt(1); @SuppressWarnings("unused") String name = layer.GetName(); eMyClauseDefn cd = new eMyClauseDefn(); eMyStyle style = new eMyStyle(); // style.SetPenColor(Color.RED); style.SetPenColor(255); style.SetPenWidth(5); style.SetPenStyle(11); cd.SetStyle(style); cd.SetName("1"); cd.SetWhereClause("名称 LIKE '%海尔路%'"); boolean b = layer.ThemeClause().AddClauseDefn(cd); if (b) { layer.ThemeClause().SetVisible(true); m_myMapWnd.reDraw(); m_myMapWnd.repaint(0, 0); } } break; case Menu.FIRST + 19: { // 清空条件专题图 eMyLayer layer = m_myMapWnd.GetMap().GetLayerAt(1); layer.ThemeClause().ClearClauseDefns(); m_myMapWnd.reDraw(); m_myMapWnd.repaint(0, 0); } break; case Menu.FIRST + 20: { // cometiclayer 添加点 eMyGeometry geom = new eMyGeometry(1, 1); eMyPoint2D geoPt = new eMyPoint2D(120.46, 36.0972); eMyPoint pt = m_myMapWnd.GetMap().GeoToMap(geoPt); geoPt.Dispose();// 一定要调用Dispose销毁对象,否则会照成内存泄露! geom.SetPointAt(0, pt); @SuppressWarnings("unused") int type = 1; eMyStyle style = new eMyStyle(); style.SetBmpIndex(3); @SuppressWarnings("unused") String tag = "A1"; /* * int stmt = m_myMapWnd.GetMap().CosmeticLayer().Add(); * m_myMapWnd.GetMap().CosmeticLayer().Set(stmt, geom, type, style, * tag, "text"); m_myMapWnd.GetMap().CosmeticLayer().Update(stmt); * m_myMapWnd.GetMap().CosmeticLayer().SetVisible(true); * m_myMapWnd.reDraw(); m_myMapWnd.repaint(0, 0); */ } break; case Menu.FIRST + 21: { /* * //cometiclayer 添加线 eMyGeometry geom = new eMyGeometry(); * geom.m_sPartCount = 1; geom.m_sPointCount = 3; geom.m_pPoints = * new eMyPoint[3]; eMyPoint pt1 = m_myMapWnd.GetMap().GeoToMap(new * eMyPoint2D(120.4531,36.0930)); geom.m_pPoints[0] = new * eMyPoint(); geom.m_pPoints[0].x = pt1.x; geom.m_pPoints[0].y = * pt1.y; eMyPoint pt2 = m_myMapWnd.GetMap().GeoToMap(new * eMyPoint2D(120.4614,36.0981)); geom.m_pPoints[1] = new * eMyPoint(); geom.m_pPoints[1].x = pt2.x; geom.m_pPoints[1].y = * pt2.y; eMyPoint pt3 = m_myMapWnd.GetMap().GeoToMap(new * eMyPoint2D(120.4641,36.0929)); geom.m_pPoints[2] = new * eMyPoint(); geom.m_pPoints[2].x = pt3.x; geom.m_pPoints[2].y = * pt3.y; int type = 3; eMyStyle style = new eMyStyle(); * style.SetBrushColor(Color.RED); style.SetPenColor(Color.GREEN); * style.SetPenWidth(5); style.SetPenStyle(1); * style.SetBmpOffsetX(88); style.SetBmpOffsetY(88); String tag = * "A3"; SQLiteStatement stmt = * m_myMapWnd.GetMap().CosmeticLayer().add(); * m_myMapWnd.GetMap().CosmeticLayer().Set(stmt, geom, type, style, * tag, "text"); m_myMapWnd.GetMap().CosmeticLayer().Set(stmt, * "mobile", 54321); m_myMapWnd.GetMap().CosmeticLayer().Set(stmt, * "label", "美国改革开放"); * m_myMapWnd.GetMap().CosmeticLayer().Update(stmt); * m_myMapWnd.GetMap().CosmeticLayer().SetVisible(true); * m_myMapWnd.reDraw(); m_myMapWnd.repaint(0, 0); */ } break; case Menu.FIRST + 22: { /* * //cometiclayer 添加面 eMyGeometry geom = new eMyGeometry(); * geom.m_sPartCount = 1; geom.m_sPointCount = 3; geom.m_pPoints = * new eMyPoint[3]; eMyPoint pt1 = m_myMapWnd.GetMap().GeoToMap(new * eMyPoint2D(120.4531,36.0930)); geom.m_pPoints[0] = new * eMyPoint(); geom.m_pPoints[0].x = pt1.x; geom.m_pPoints[0].y = * pt1.y; eMyPoint pt2 = m_myMapWnd.GetMap().GeoToMap(new * eMyPoint2D(120.4614,36.0981)); geom.m_pPoints[1] = new * eMyPoint(); geom.m_pPoints[1].x = pt2.x; geom.m_pPoints[1].y = * pt2.y; eMyPoint pt3 = m_myMapWnd.GetMap().GeoToMap(new * eMyPoint2D(120.4641,36.0929)); geom.m_pPoints[2] = new * eMyPoint(); geom.m_pPoints[2].x = pt3.x; geom.m_pPoints[2].y = * pt3.y; int type = 5; eMyStyle style = new eMyStyle(); * style.SetBrushColor(Color.RED); style.SetBmpOffsetX(88); * style.SetBmpOffsetY(88); String tag = "A5"; eMyCosmeticLayer cl = * m_myMapWnd.GetMap().CosmeticLayer(); SQLiteStatement stmt = * cl.add(); cl.Set(stmt, geom, type, style, tag, "text"); * cl.Set(stmt, "mobile", 12345); cl.Set(stmt, "label", "中国改革开放"); * cl.Update(stmt); cl.SetVisible(true); m_myMapWnd.reDraw(); * m_myMapWnd.repaint(0, 0); */ } break; case Menu.FIRST + 23: { /* * //cometiclayer 清空 * m_myMapWnd.GetMap().CosmeticLayer().removeAll(); * m_myMapWnd.reDraw(); m_myMapWnd.repaint(0, 0); */ } break; case Menu.FIRST + 24: { /* * //cometiclayer SQL查询 eMyQueryDefn queryDefn = new eMyQueryDefn(); * //queryDefn.AddSelectField("label"); * //queryDefn.AddSelectField("moible"); * queryDefn.SetWhereClause("label like '%美国%'"); * eMyCosmeticResultSet rs = new eMyCosmeticResultSet(); * m_myMapWnd.GetMap().CosmeticLayer().Query(queryDefn, rs); * while(rs.HasNext()){ String label = rs.GetText("label"); int * mobile = rs.GetInt("mobile"); mobile = 1; } */ } break; case Menu.FIRST + 25: { /* * //cometiclayer 空间查询 eMyRect2D bounds = * m_myMapWnd.GetMap().GetGeoBounds(); eMyCosmeticResultSet rs = new * eMyCosmeticResultSet(); * m_myMapWnd.GetMap().CosmeticLayer().QueryWithBounds(bounds, rs); * while(rs.HasNext()){ eMyGeometry geom = rs.GetGeometry(); } * rs.Close(); * * m_myMapWnd.reDraw(); m_myMapWnd.repaint(0, 0); */ } break; case Menu.FIRST + 26: // { /* * //cometiclayer 删除 m_myMapWnd.GetMap().CosmeticLayer().Delete(); * m_myMapWnd.reDraw(); m_myMapWnd.repaint(0, 0); */ } break; case Menu.FIRST + 27: // { /* * //cometiclayer 添加自定义字段 eMyCosmeticField fld = new * eMyCosmeticField("label","TEXT"); eMyCosmeticField fld2 = new * eMyCosmeticField("mobile","NUMERIC"); * * m_myMapWnd.GetMap().CosmeticLayer().addCustomFields(fld); * m_myMapWnd.GetMap().CosmeticLayer().addCustomFields(fld2); * m_myMapWnd.reDraw(); m_myMapWnd.repaint(0, 0); */ } break; case Menu.FIRST + 28: // 定位到某个点 { // 测试定位数据 // 边际物理坐标:( 120.46245999981475) , (36.101044000086 ) // 中心物理坐标:( 120.45992200009175) , (36.095697000196125 ) // 测试物理坐标:( 120.46158699979) , (36.09769800014725 ) loc_x = 120.46158699979; loc_y = 36.09769800014725; m_myMapWnd.ZoomTo(loc_x, loc_y, 0.002);// 0.02 小 0.002 大 0.011 适中 m_myMapWnd.reDraw();// 那个Ondraw在redraw就会触发 m_myMapWnd.repaint(0, 0); Toast.makeText(this, "定位", 6000).show(); } break; case Menu.FIRST + 29: { // 获得GPS数据 showGPSDate(getGPSDate(), 1); GPSModel gpsModel = new GPSModel(); gpsModel = getGPSDate(); loc_x = gpsModel.Longitude; loc_y = gpsModel.Latitude; // 定位到该点 m_myMapWnd.ZoomTo(loc_x, loc_y, 0.002); m_myMapWnd.reDraw();// 那个Ondraw在redraw就会触发 m_myMapWnd.repaint(0, 0); Toast.makeText(this, "GPS", 6000).show(); } break; } return true; } // 显示方法 public void show(int i, String name, String id, String city, String area, String category, String geocode, double x, double y) { String text = ""; int j = i + 1; // System.out.println("---------" + j + "---------"); // String xy = "物理坐标:(" + x + "),(" + y + ")"; // System.out.println(xy); // System.out.println("名称:" + name); // System.out.println("ID:" + id); // System.out.println("城市:" + city); // System.out.println("所在区:" + area); // System.out.println("类别码:" + category); // System.out.println("地理编码:" + geocode); // System.out.println("---------------------------------"); text += "名称:" + name + "\n"; text += "ID:" + id + "\n"; text += "城市:" + city + "\n"; text += "所在区:" + area + "\n"; text += "类别码:" + category + "\n"; text += "地理编码:" + geocode + "\n"; text += "物理坐标:(" + x + "),(" + y + ")" + "\n"; Toast.makeText(Demo.this, text, 5000).show(); } // 显示信息 private void showGPSDate(GPSModel gpsModel, int infotype) { // GPS功能已关闭 if (gpsModel == null) { if (infotype == -1) { Toast.makeText(this, "GPS功能已关闭,请打开后重试!", 3000).show(); } } else { double y = gpsModel.Latitude;// 纬度 double x = gpsModel.Longitude;// 经度 String text = ""; text += "经度X=" + String.valueOf(x) + "\n"; text += "经度Y=" + String.valueOf(y) + "\n"; gpsModel.InfoType = infotype; switch (infotype) { case 1: text += "获取方式=手动获取更新" + "\n"; Toast.makeText(this, text, 5000).show(); break; case 2: text += "获取方式=位置改变更新" + "\n"; // 模拟器测试:发送GPS坐标============== // GPSModel gpsModel2 = new GPSModel(); // gpsModel2 = getGPSDate(); // loc_x = gpsModel2.Longitude; // loc_y = gpsModel2.Latitude; // m_myMapWnd.ZoomTo(loc_x, loc_y, 0.002); // m_myMapWnd.reDraw();// 那个Ondraw在redraw就会触发 // m_myMapWnd.repaint(0, 0); // =================================== Toast.makeText(this, text, 5000).show(); break; } } } // 获取GPS相应的数据 private GPSModel getGPSDate() { GPSModel gpsModel = new GPSModel(); location = locationManager.getLastKnownLocation(provider); if (location != null) { gpsModel.Latitude = (double) (location.getLatitude()); gpsModel.Longitude = (double) (location.getLongitude()); gpsModel.High = location.getAltitude(); gpsModel.Direct = location.getBearing(); gpsModel.Speed = location.getSpeed(); Date d = new Date(); d.setTime(location.getTime()); gpsModel.GpsTime = DateFormat.format("yyyy-MM-dd kk:mm:ss", d) .toString(); d = null; } return gpsModel; } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location arg0) { showGPSDate(getGPSDate(), 2);// 位置改变 } public void onProviderDisabled(String arg0) { showGPSDate(null, -1); } public void onProviderEnabled(String arg0) { } public void onStatusChanged(String arg0, int arg1, Bundle arg2) { } }; }
发表评论
-
ArcGis 9.3 破解过程
2012-02-25 10:05 13021) 安装"license_server_setup ... -
显示所有图层菜单
2011-12-27 15:54 911// 菜单-------------------------- ... -
GIS地图制作
2011-12-23 12:33 1100111111111111111111111111111111 ... -
GIS常用方法总结
2011-12-22 10:52 1031// 记录下当前地图的屏幕中心点 eMyPoin ... -
使用ArcGis工具合并图层
2011-12-19 20:04 41921.开始编辑 2.选中要合并的图层:根据图层的编号,点击S ... -
使用ArcGis工具分离图层
2011-12-19 19:31 27321.准备该地区的单位网格图层 2.安装好ArcGis工具 ... -
动态加载地图代码段
2011-12-17 13:05 2385// 得到GridNo图层 eMyLayer l ... -
长按标记点
2011-12-16 15:12 769@Override public void OnLon ... -
GIS注册工具
2011-11-23 11:08 1121111111111111 -
贴图偏移值设置
2011-11-22 19:49 921取中间值 16*16 就是8,8 13*13 就是 6.5 ... -
矩形选
2011-11-22 14:07 922@Override public void OnGeom ... -
GPS定位
2011-11-22 10:11 923// GPS,定位到某个点 { // 边际物理坐 ... -
点选的实现
2011-11-22 10:04 937public class eMyMapWnd2 extend ...
相关推荐
一个android端读写shp文件的小demo, 集成了ArcGIS for android runtime.
本资源“windows mobile GIS demo(acrinfo程序源代码)”提供的是一个基于Windows Mobile平台的GIS应用示例——acrinfo的源代码。ArcInfo是Esri公司开发的专业级GIS软件,它提供了强大的地理数据管理和分析功能。在...
《Silverlight GIS演示详解》 在信息技术领域,GIS(Geographic Information System,地理信息...对于学习GIS应用开发的人员来说,深入理解和研究"Silverlight GIS Demo",无疑能够提升自身在Web GIS领域的技术水平。
VC++开发的GIS系统源码无错完整版,陈建春书中的一个源代码,可以顺利编译完成,GIS软件VC版的不太多,这一个也算是一个能为VC朋友提供参考的好实例吧。这套系统可完成VC++使用鼠标绘图、图形移动、放大、选择等操作
GISMap地图demo 两个版本,一个旧版本GISMap和GISMapNew,旧版本中需要在代码内部自己配置区域编号,搜索地址,类型等。 新版直接可以在界面的combox中直接选择区域,类型,制定关键词等。
GIS演示 地理空间数据管理应用程序演示 指示 在数据标签上,选择提供的示例数据之一 在“规则”选项卡上,选择要检查数据的规则 在“操作”选项卡上,选择要执行的操作,然后单击“应用”按钮 在结果选项卡上,收集...
在本示例中,我们关注的是一个名为"PythonApplication_gis_python_DEMO_arcgis_"的项目,它是一个使用Python和ArcGIS Pro 2.2的GIS应用。这个应用的核心是利用Arcpy模块来处理和分析Shapefile矢量数据集。Arcpy是...
《Android ArcGIS Demo详解与应用》 ArcGIS是Esri公司推出的一款强大的地理信息系统,它在各个平台上都有着广泛的应用,包括Android。本文将深入探讨"android arcgis demo"这一主题,解析其核心概念、功能以及如何...
"GIS" 通常指的是 地理信息系统(Geographic Information System)。它是一种特定的空间信息系统,用于捕获、存储、管理、分析、查询和显示与地理空间相关的数据。GIS 是一种多学科交叉的产物,涉及地理学、地图学、...
WebGIS前端开发是一个将地理信息系统(GIS)与Web技术相结合的领域,主要目的是在网页上展示、操作和分析地理数据。在这个"WebGIS前端开发demo"项目中,开发者使用了OpenLayers框架,这是一种广泛使用的开源...
总结,MapGIS 10 组建开发DEMO是一个综合性的学习资源,涵盖了GIS开发的关键环节。通过对"DataManage"等子文件的学习,开发者不仅能掌握MapGIS的基本操作,还能深入了解其在数据管理、地图绘制和空间分析方面的高级...
在本项目"基于C#的GIS开发Demo"中,我们将深入探讨如何利用C#语言进行GIS应用的开发。 【C#语言与GIS的结合】 C#是一种面向对象的编程语言,由微软公司推出,广泛应用于Windows平台的开发。在GIS领域,C#提供了...
对于初学者来说,了解这些基础知识并动手实践一个简单的GIS demo,不仅可以熟悉Delphi和Tmap的用法,还能深入理解GIS的基本原理。在实践中遇到问题时,可以参考相关文档、教程或者在线社区的讨论,不断积累经验,...
排水管网GIS系统DEMO是一个基于AE93平台和.NET 2.0框架的应用程序,它专为管理和分析城市排水管网而设计。这个系统利用地理信息系统(GIS)的技术,结合了数据库管理和数据分析的功能,以实现对排水设施的高效管理。...
`GisDemo.sln`和`GisDemo.suo`是Visual Studio解决方案和用户配置文件,用于构建和运行GIS应用。`说明.txt`可能是关于如何使用这些文件的指南,而`GisDemo`可能是包含主程序代码的项目文件,实现了动态地图事件的...
最后,"GISDemo"很可能是一个项目或工程文件夹,其中可能包含了源代码文件(如.cs)、资源文件(如图片、地图服务配置文件)、配置文件(如app.config)以及其他与项目相关的文件。这些文件共同构成了一个完整的...
- ADD: New demo project FlexCADImport. - FIX: The height of the TFlexRegularPolygon object incorrectly changes with its rotation. - FIX: Added division by zero protect in method TFlexControl....
总的来说,"demo-_gis_DEMO_"提供了一个学习和探索GIS功能的机会,无论是对于初次接触GIS的初学者,还是希望尝试新工具的专业人士,都能从中受益。通过这个DEMO,用户不仅可以直观地理解矢量和影像数据的呈现方式,...
在提供的压缩包文件中,`www.pudn.com.txt`可能是下载链接或说明文档,而`GisDemo`可能是一个包含示例代码或数据的工作空间。为了具体应用上述概念,你需要解压并查看这些文件以获取实际的数据和脚本示例。 总的来...
"GIS_demo.rar"这个压缩包文件似乎是一个GIS开发的演示项目,包含以下几个关键部分: 1. **bldat**:这是一个可能的数据文件,通常在GIS应用中,这样的文件用于存储地理空间数据,如点、线、面等几何对象,以及与之...