2a47d844 by chiangbt

标注更新

1 parent c3145696
package com.pashanhoo.landsurvey;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import com.esri.android.map.GraphicsLayer;
import com.esri.android.map.LocationDisplayManager;
import com.esri.android.map.MapView;
import com.esri.android.map.event.OnStatusChangedListener;
import com.esri.android.runtime.ArcGISRuntime;
import com.esri.core.geometry.Point;
import com.esri.core.map.Graphic;
import com.esri.core.symbol.SimpleMarkerSymbol;
import com.pashanhoo.landsurvey.layers.baidu.BaiduMapLayerTypes;
import com.pashanhoo.landsurvey.layers.baidu.BaiduMapsTiledServiceLayer;
import com.pashanhoo.landsurvey.layers.google.GoogleMapsTiledServiceLayer;
......@@ -20,6 +24,7 @@ import com.pashanhoo.landsurvey.utils.JZLocationConverter;
public class BaiduMapActivity extends AppCompatActivity {
private MapView mapView;
private GraphicsLayer graphicsLayer;
// GPS定位器对象
private LocationDisplayManager locationDisplayManager;
......@@ -37,23 +42,23 @@ public class BaiduMapActivity extends AppCompatActivity {
BaiduMapsTiledServiceLayer baiduMapsTiledServiceLayer = new BaiduMapsTiledServiceLayer(BaiduMapLayerTypes.BAIDU_VECTOR);
mapView.addLayer(baiduMapsTiledServiceLayer);
graphicsLayer = new GraphicsLayer();
mapView.addLayer(graphicsLayer);
final float offsetX = 2518238;
final float offsetY = 910065;
mapView.setOnStatusChangedListener(new OnStatusChangedListener() {
@Override
public void onStatusChanged(Object o, STATUS status) {
if(status == STATUS.INITIALIZED){
Point curPt = JZLocationConverter.wgs84ToGcj02(AppInfo.initPoint);
Log.i("baidu", curPt.getX() + ":" + curPt.getY());
if (status == STATUS.INITIALIZED) {
Point curPt = JZLocationConverter.wgs84ToBd09(new Point(121.540614, 29.872488));
Point pt = GISHelper.lonLat2Mercator(curPt);
Log.i("baidu2", pt.getX()+":"+pt.getY());
// mapView.zoomToResolution(pt, BaiduMapsTiledServiceLayer.getRes()[10]);
Toast.makeText(BaiduMapActivity.this,
mapView.getCenter().getX() + ":" + mapView.getCenter().getY(),
Toast.LENGTH_LONG).show();
mapView.zoomToResolution(new Point(pt.getX() + offsetX, pt.getY() + offsetY), GoogleMapsTiledServiceLayer.getRes()[10]);
mapView.zoomTo(pt, (float) 50.10);
// mapView.centerAndZoom(curPt.getY(), curPt.getX(), 6);
SimpleMarkerSymbol sms = new SimpleMarkerSymbol(Color.RED, 15, SimpleMarkerSymbol.STYLE.CIRCLE);
Graphic graphic = new Graphic(new Point(pt.getX() + offsetX, pt.getY() + offsetY), sms);
graphicsLayer.addGraphic(graphic);
}
}
});
......
......@@ -2,7 +2,6 @@ package com.pashanhoo.landsurvey;
import android.location.Location;
import android.location.LocationListener;
import android.os.Environment;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
......@@ -13,13 +12,8 @@ import com.esri.android.map.LocationDisplayManager;
import com.esri.android.map.MapView;
import com.esri.android.runtime.ArcGISRuntime;
import com.esri.core.geometry.Point;
import com.pashanhoo.landsurvey.layers.baidu.BaiduMapLayerTypes;
import com.pashanhoo.landsurvey.layers.baidu.BaiduMapsTiledServiceLayer;
import com.pashanhoo.landsurvey.layers.gaode.GaodeMapLayerTypes;
import com.pashanhoo.landsurvey.layers.gaode.GaodeMapsTiledServiceLayer;
import com.pashanhoo.landsurvey.layers.geoq.GeoQMapLayerTypes;
import com.pashanhoo.landsurvey.layers.geoq.GeoQMapsTiledServiceLayer;
import com.pashanhoo.landsurvey.layers.google.GoogleMapLayerTypes;
import com.pashanhoo.landsurvey.layers.google.GoogleMapsTiledServiceLayer;
import com.pashanhoo.landsurvey.layers.tencent.TencentMapLayerTypes;
import com.pashanhoo.landsurvey.layers.tencent.TencentMapsTiledServiceLayer;
......
......@@ -8,19 +8,15 @@ import android.util.Log;
import com.esri.android.map.TiledServiceLayer;
import com.esri.android.map.event.OnStatusChangedListener;
import com.esri.core.geometry.Envelope;
import com.esri.core.geometry.GeometryEngine;
import com.esri.core.geometry.GeometryUtil;
import com.esri.core.geometry.Point;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.internal.io.handler.ResponseListener;
import com.esri.core.internal.io.handler.a;
import com.esri.core.io.UserCredentials;
import com.pashanhoo.landsurvey.layers.gaode.GaodeMapLayerTypes;
import com.pashanhoo.landsurvey.layers.tencent.TencentMapLayerTypes;
import com.pashanhoo.landsurvey.utils.AppInfo;
import com.pashanhoo.landsurvey.utils.GADBHelper;
import java.util.Calendar;
import java.util.TimeZone;
import java.util.concurrent.RejectedExecutionException;
/**
......@@ -28,13 +24,12 @@ import java.util.concurrent.RejectedExecutionException;
*/
public class BaiduMapsTiledServiceLayer extends TiledServiceLayer {
private static final double xmin = -20037508.3427892;
private static final double ymin = -20037508.3427892;
private static final double xmax = 20037508.3427892;
private static final double ymax = 20037508.3427892;
private static final double xmin = -22041257.773878;
private static final double ymin = -32673939.6727517;
private static final double xmax = 22041257.773878;
private static final double ymax = 20851350.0432886;
private static final double[] res = {
156543.03392800014,
private static final double[] res = {156543.03392800014,
78271.516963999937,
39135.758482000092,
19567.879240999919,
......@@ -55,8 +50,7 @@ public class BaiduMapsTiledServiceLayer extends TiledServiceLayer {
0.59716428355981721,
0.29858214164761665};
private static final double[] scale = {
591657527.591555,
private static final double[] scale = {591657527.591555,
295828763.79577702,
147914381.89788899,
73957190.948944002,
......@@ -72,13 +66,13 @@ public class BaiduMapsTiledServiceLayer extends TiledServiceLayer {
72223.819286, 6111.909643,
18055.954822,
9027.9774109999998,
4513.9887049999998,
2256.994353,
4513.9887049999998
, 2256.994353,
1128.4971760000001};
private static String URL = "http://maps.iwxlh.com";
private ResponseListener responseListener;
private static Point origin = new Point(-20037508.3427892, 20037508.3427892);
private static Point origin = new Point(-20037508.342787, 20037508.342787);
private BaiduMapLayerTypes baiduMapLayerTypes;
......@@ -135,33 +129,30 @@ public class BaiduMapsTiledServiceLayer extends TiledServiceLayer {
String url = "";
String s = "Galil";
// int zoom = level - 1;
int offsetX = (int)Math.pow(2, level - 1);
// int offsetY = offsetX - 1;
int numX = col - offsetX;
int numY = offsetX - row - 1 ;
int zoom = level + 1;
int num = (col + row) % 8 + 1;
num = 2;
int offsetV = (int) (Math.pow(2, level - 1));
switch (baiduMapLayerTypes) {
case BAIDU_VECTOR:
// url= "http://online" + num + ".map.bdimg.com/tile/?qt=tile&x="+numX+"&y="+numY+"&z="+level+"&styles=pl&scaler=1&udt=20141103";
url = "http://online" + num +".map.bdimg.com/tile/?qt=tile&x=" + numX + "&y=" + numY + "&z=" + zoom + "&styles=pl";
break;
case BAIDU_ROAD:
url = "http://online" + num +".map.bdimg.com/tile/?qt=tile&x=" + numX + "&y=" + numY + "&z=" + zoom + "&styles=sl";
url = "http://online" + ((col + row) % 8 + 1) + ".map.bdimg.com/onlinelabel/?qt=tile"
+ "&x=" + (col - offsetV) + "&y=" + (offsetV - row - 1) + "&z=" + (level + 1)
+ "&styles=pl";
break;
case BAIDU_IMAGE:
url = "http://shangetu" + ((col + row) % 8 + 1) + ".map.bdimg.com/it/u="
+ "x=" + numX + ";y=" + numY+ ";z=" + zoom + ";v=009;type=sate&fm=46";
+ "x=" + (col - offsetV) + ";y=" + (offsetV - row - 1) + ";z=" + (level + 1)
+ ";v=009;type=sate&fm=46";
break;
case BAIDU_ROAD:
url = "http://online" + ((col + row) % 8 + 1) + ".map.bdimg.com/onlinelabel/?qt=tile"
+ "&x=" + (col - offsetV) + "&y=" + (offsetV - row - 1) + "&z=" + (level + 1)
+ "&styles=sl";
break;
case BAIDU_TRAFFIC:
url = "http://its.map.baidu.com:8002/traffic/TrafficTileService?"
+ "level=" + zoom + "&x=" + numX + "&y=" + numY + "&time=" + System.currentTimeMillis();
+ "level=" + (level + 1) + "&x=" + (col - offsetV) + "&y=" + (offsetV - row - 1)
+ "&time=" + System.currentTimeMillis();
break;
}
Log.i("baidu", url);
try {
// 首先从离线数据库中读取
result = getOfflineCacheDB(level, col, row);
......
......@@ -65,6 +65,15 @@ mapView.zoomToResolution(initPoint, t_vec.getRes()[16]);
```
百度地图
```java
BaiduMapsTiledServiceLayer baiduMapsTiledServiceLayer = new BaiduMapsTiledServiceLayer(BaiduMapLayerTypes.BAIDU_VECTOR);
mapView.addLayer(baiduMapsTiledServiceLayer);
final float offsetX = 2518238;
final float offsetY = 910065;
Point curPt = JZLocationConverter.wgs84ToBd09(new Point(121.540614, 29.872488));
Point pt = GISHelper.lonLat2Mercator(curPt);
mapView.zoomToResolution(new Point(pt.getX() + offsetX, pt.getY() + offsetY), GoogleMapsTiledServiceLayer.getRes()[10]);
```
......