|
|
@ -171,7 +171,8 @@ import pub.devrel.easypermissions.EasyPermissions;
|
|
171
|
171
|
|
|
172
|
172
|
public class MainMapActivity extends Activity implements LocationSource, AMapLocationListener,
|
|
173
|
173
|
View.OnClickListener, AMap.OnMapLoadedListener, AMap.OnCameraChangeListener, AMap.OnMapClickListener,
|
|
174
|
|
ClusterRender, ClusterClickListener, WeatherSearch.OnWeatherSearchListener, EasyPermissions.PermissionCallbacks {
|
|
|
174
|
ClusterRender, ClusterClickListener, WeatherSearch.OnWeatherSearchListener, EasyPermissions.PermissionCallbacks,
|
|
|
175
|
AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, AMap.OnInfoWindowClickListener {
|
|
175
|
176
|
private static final String TAG = "MainMapActivity";
|
|
176
|
177
|
public static String screen_jing = "", screen_wei = "";
|
|
177
|
178
|
public static String location_city = "";
|
|
|
@ -736,6 +737,7 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
|
|
736
|
737
|
}
|
|
737
|
738
|
}
|
|
738
|
739
|
};
|
|
|
740
|
private View infoWindow;
|
|
739
|
741
|
|
|
740
|
742
|
|
|
741
|
743
|
@Override
|
|
|
@ -1483,6 +1485,9 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
|
|
1483
|
1485
|
aMap.setOnCameraChangeListener(this);
|
|
1484
|
1486
|
aMap.setLocationSource(this);// 设置定位监听
|
|
1485
|
1487
|
aMap.setOnMapClickListener(this);
|
|
|
1488
|
aMap.setOnMarkerClickListener(this);
|
|
|
1489
|
aMap.setInfoWindowAdapter(this);
|
|
|
1490
|
aMap.setOnInfoWindowClickListener(this);
|
|
1486
|
1491
|
aMap.setOnMapLoadedListener(this);// 设置amap加载成功事件监听器
|
|
1487
|
1492
|
aMap.getUiSettings().setMyLocationButtonEnabled(false);// 设置默认定位按钮是否显示
|
|
1488
|
1493
|
aMap.getUiSettings().setZoomControlsEnabled(false);// 设置默认缩放按钮是否显示
|
|
|
@ -3398,6 +3403,57 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
|
|
3398
|
3403
|
}
|
|
3399
|
3404
|
}
|
|
3400
|
3405
|
|
|
|
3406
|
@Override
|
|
|
3407
|
public boolean onMarkerClick(Marker marker) {
|
|
|
3408
|
return false;
|
|
|
3409
|
}
|
|
|
3410
|
|
|
|
3411
|
/**
|
|
|
3412
|
* 监听自定义infowindow窗口的infowindow时间回调
|
|
|
3413
|
* add by huyuguo
|
|
|
3414
|
* @param marker
|
|
|
3415
|
* @return
|
|
|
3416
|
*/
|
|
|
3417
|
@Override
|
|
|
3418
|
public View getInfoWindow(Marker marker) {
|
|
|
3419
|
if (infoWindow == null) {
|
|
|
3420
|
infoWindow = getLayoutInflater().inflate(R.layout.custom_info_window, null);
|
|
|
3421
|
}
|
|
|
3422
|
return infoWindow;
|
|
|
3423
|
}
|
|
|
3424
|
|
|
|
3425
|
@Override
|
|
|
3426
|
public View getInfoContents(Marker marker) {
|
|
|
3427
|
return null;
|
|
|
3428
|
}
|
|
|
3429
|
|
|
|
3430
|
/**
|
|
|
3431
|
* 自定义infowindow窗口
|
|
|
3432
|
* 如果想修改自定义Infow中内容,请通过view找到它并修改
|
|
|
3433
|
*/
|
|
|
3434
|
public void updateInfoWindow(String text) {
|
|
|
3435
|
if (nMarker == null) {
|
|
|
3436
|
return;
|
|
|
3437
|
}
|
|
|
3438
|
|
|
|
3439
|
if (infoWindow == null) {
|
|
|
3440
|
return;
|
|
|
3441
|
}
|
|
|
3442
|
|
|
|
3443
|
TextView distance = infoWindow.findViewById(R.id.distance);
|
|
|
3444
|
distance.setText(text);
|
|
|
3445
|
|
|
|
3446
|
}
|
|
|
3447
|
|
|
|
3448
|
/**
|
|
|
3449
|
* 点击自定义气泡,进行导航操作
|
|
|
3450
|
* @param marker
|
|
|
3451
|
*/
|
|
|
3452
|
@Override
|
|
|
3453
|
public void onInfoWindowClick(Marker marker) {
|
|
|
3454
|
ToastUtil.showToast(getApplicationContext(), "sdsfsdf", Toast.LENGTH_SHORT);
|
|
|
3455
|
}
|
|
|
3456
|
|
|
3401
|
3457
|
public class ZhanAdapter extends BaseAdapter {
|
|
3402
|
3458
|
@Override
|
|
3403
|
3459
|
public int getCount() {
|
|
|
@ -4914,6 +4970,10 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
|
|
4914
|
4970
|
// Log.d(TAG, "onClick: latitude=" + position.latitude + " long=" + position.longitude + "\n" + ((RegionItem) clusterItem).getChargePoint().toString());
|
|
4915
|
4971
|
Long zhan_id = ((RegionItem) clusterItem).getChargePoint().getId();
|
|
4916
|
4972
|
nMarker = marker;
|
|
|
4973
|
|
|
|
4974
|
// add by hyg 显示气泡
|
|
|
4975
|
nMarker.showInfoWindow();
|
|
|
4976
|
|
|
4917
|
4977
|
current_chargePoint = chargePoint;
|
|
4918
|
4978
|
dialog.show();
|
|
4919
|
4979
|
if (null != marker.getPosition()) {
|
|
|
@ -5005,13 +5065,17 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
|
|
5005
|
5065
|
latLng = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing));
|
|
5006
|
5066
|
}
|
|
5007
|
5067
|
|
|
5008
|
|
//OK
|
|
|
5068
|
// OK
|
|
5009
|
5069
|
double d = AMapUtils.calculateLineDistance(center, latLng);
|
|
5010
|
5070
|
if ("0m".equals(Util.getDistance(d))) {
|
|
5011
|
5071
|
windowDistance.setText("未知");
|
|
|
5072
|
updateInfoWindow("未知距离");
|
|
5012
|
5073
|
} else {
|
|
5013
|
|
windowDistance.setText(Util.getDistance(d));
|
|
|
5074
|
String text = Util.getDistance(d);
|
|
|
5075
|
windowDistance.setText(text);
|
|
|
5076
|
updateInfoWindow("距您 " + text);
|
|
5014
|
5077
|
}
|
|
|
5078
|
|
|
5015
|
5079
|
}
|
|
5016
|
5080
|
|
|
5017
|
5081
|
String acNum = null, dcNum = null, acableNum = null, dcableNum = null;
|