本文整理汇总了Java中com.amap.api.maps.model.LatLngBounds类的典型用法代码示例。如果您正苦于以下问题:Java LatLngBounds类的具体用法?Java LatLngBounds怎么用?Java LatLngBounds使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LatLngBounds类属于com.amap.api.maps.model包,在下文中一共展示了LatLngBounds类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawFence
import com.amap.api.maps.model.LatLngBounds; //导入依赖的package包/类
private void drawFence(GeoFence fence) {
switch (fence.getType()) {
case GeoFence.TYPE_ROUND :
case GeoFence.TYPE_AMAPPOI :
drawCircle(fence);
break;
case GeoFence.TYPE_POLYGON :
case GeoFence.TYPE_DISTRICT :
drawPolygon(fence);
break;
default :
break;
}
// 设置所有maker显示在当前可视区域地图中
LatLngBounds bounds = boundsBuilder.build();
mAMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 150));
}
示例2: drawFence
import com.amap.api.maps.model.LatLngBounds; //导入依赖的package包/类
private void drawFence(GeoFence fence) {
switch (fence.getType()) {
case GeoFence.TYPE_ROUND :
case GeoFence.TYPE_AMAPPOI :
drawCircle(fence);
break;
case GeoFence.TYPE_POLYGON :
case GeoFence.TYPE_DISTRICT :
drawPolygon(fence);
break;
default :
break;
}
// 设置所有maker显示在当前可视区域地图中
LatLngBounds bounds = boundsBuilder.build();
mAMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 150));
removeMarkers();
}
示例3: drawFence
import com.amap.api.maps.model.LatLngBounds; //导入依赖的package包/类
private void drawFence(GeoFence fence) {
switch (fence.getType()) {
case GeoFence.TYPE_ROUND :
case GeoFence.TYPE_AMAPPOI :
drawCircle(fence);
break;
case GeoFence.TYPE_POLYGON :
case GeoFence.TYPE_DISTRICT :
drawPolygon(fence);
break;
default :
break;
}
// 设置所有maker显示在当前可视区域地图中
LatLngBounds bounds = boundsBuilder.build();
mAMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 150));
polygonPoints.clear();
removeMarkers();
}
示例4: setRegion
import com.amap.api.maps.model.LatLngBounds; //导入依赖的package包/类
@ReactProp(name = "region")
public void setRegion(MapView mapView, @Nullable ReadableMap region) {
if (region == null) return;
AMap map = mapView.getMap();
Double lat = region.getDouble("latitude");
Double lng = region.getDouble("longitude");
Double lngDelta = region.getDouble("longitudeDelta");
Double latDelta = region.getDouble("latitudeDelta");
LatLngBounds bounds = new LatLngBounds(
new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest
new LatLng(lat + latDelta / 2, lng + lngDelta / 2) // northeast
);
if (mapView.getHeight() <= 0 || mapView.getWidth() <= 0) {
map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lng), 10));
boundsToMove = bounds;
} else {
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
}
}
示例5: getExpandedBounds
import com.amap.api.maps.model.LatLngBounds; //导入依赖的package包/类
private LatLngBounds getExpandedBounds(LatLngBounds bounds) {
if (bounds != null && options != null) {
double expandBoundsFactor = options.getExpandBoundsFactor();
boolean spans180Meridian = bounds.northeast.longitude < bounds.southwest.longitude;
double distanceFromNorthToSouth = bounds.northeast.latitude - bounds.southwest.latitude;
double distanceFromEastToWest;
if (spans180Meridian == false) {
distanceFromEastToWest = bounds.northeast.longitude - bounds.southwest.longitude;
} else {
distanceFromEastToWest = (180 + bounds.northeast.longitude) + (180 - bounds.southwest.longitude);
}
double expandLatitude = distanceFromNorthToSouth * expandBoundsFactor;
double expandLongitude = distanceFromEastToWest * expandBoundsFactor;
LatLng newNortheast = new LatLng(bounds.northeast.latitude + expandLatitude, bounds.northeast.longitude + expandLongitude);
LatLng newSouthwest = new LatLng(bounds.southwest.latitude - expandLatitude, bounds.southwest.longitude - expandLongitude);
return new LatLngBounds(newSouthwest, newNortheast);
}
return null;
}
示例6: calculateClusters
import com.amap.api.maps.model.LatLngBounds; //导入依赖的package包/类
private void calculateClusters() {
mIsCanceled = false;
mClusters.clear();
LatLngBounds visibleBounds = mAMap.getProjection().getVisibleRegion().latLngBounds;
for (ClusterItem clusterItem : mClusterItems) {
if (mIsCanceled) {
return;
}
LatLng latlng = clusterItem.getPosition();
if (visibleBounds.contains(latlng)) {
Cluster cluster = getCluster(latlng,mClusters);
if (cluster != null) {
cluster.addClusterItem(clusterItem);
} else {
cluster = new Cluster(latlng);
mClusters.add(cluster);
cluster.addClusterItem(clusterItem);
}
}
}
//复制一份数据,规避同步
List<Cluster> clusters = new ArrayList<Cluster>();
clusters.addAll(mClusters);
Message message = Message.obtain();
message.what = MarkerHandler.ADD_CLUSTER_LIST;
message.obj = clusters;
if (mIsCanceled) {
return;
}
mMarkerhandler.sendMessage(message);
}
示例7: zoomToSpan
import com.amap.api.maps.model.LatLngBounds; //导入依赖的package包/类
public void zoomToSpan(){
if (mRankEntities != null && mRankEntities.size() > 0) {
if (mAMap == null)
return;
LatLngBounds bounds = getLatLngBounds(mRankEntities);
mAMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 100));
}
}
示例8: getLatLngBounds
import com.amap.api.maps.model.LatLngBounds; //导入依赖的package包/类
/**
* 根据自定义内容获取缩放bounds
*/
private LatLngBounds getLatLngBounds( List<RankEntity> RankEntitiesList) {
LatLngBounds.Builder b = LatLngBounds.builder();
for (int i = 0; i < RankEntitiesList.size(); i++) {
LatLng p = RankEntitiesList.get(i).getPosition();
b.include(p);
}
return b.build();
}
示例9: scaleCurrentCamera
import com.amap.api.maps.model.LatLngBounds; //导入依赖的package包/类
@Override
public void scaleCurrentCamera() {
CameraPosition position = mapObject.getController().getCameraPosition();
List<TrackPoint> trackPoints = mMoveModel.getHistoryCoordiates();
LatLng start = new LatLng(trackPoints.get(0).getLatitude(), trackPoints.get(0).getLongitude());
LatLng end = new LatLng(trackPoints.get(trackPoints.size() - 1).getLatitude(), trackPoints.get(trackPoints.size() - 1).getLongitude());
CameraUpdate update = CameraUpdateFactory.newLatLngBounds(new LatLngBounds(start, end), (int) (position.zoom - 6));
mapObject.moveToSpecficCamera(update);
}
示例10: onClick
import com.amap.api.maps.model.LatLngBounds; //导入依赖的package包/类
@Override
public void onClick(Marker marker, List<ClusterItem> clusterItems) {
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (ClusterItem clusterItem : clusterItems) {
builder.include(clusterItem.getPosition());
}
LatLngBounds latLngBounds = builder.build();
mAMap.animateCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 0));
}
示例11: calculateClusters
import com.amap.api.maps.model.LatLngBounds; //导入依赖的package包/类
private void calculateClusters() {
mIsCanceled = false;
mClusters.clear();
LatLngBounds visibleBounds = mAMap.getProjection().getVisibleRegion().latLngBounds;
for (ClusterItem clusterItem : mClusterItems) {
if (mIsCanceled) {
return;
}
LatLng latlng = clusterItem.getPosition();
if (visibleBounds.contains(latlng)) {
Cluster cluster = getCluster(latlng, mClusters);
if (cluster != null) {
cluster.addClusterItem(clusterItem);
} else {
cluster = new Cluster(latlng);
mClusters.add(cluster);
cluster.addClusterItem(clusterItem);
}
}
}
//复制一份数据,规避同步
List<Cluster> clusters = new ArrayList<Cluster>();
clusters.addAll(mClusters);
Message message = Message.obtain();
message.what = MarkerHandler.ADD_CLUSTER_LIST;
message.obj = clusters;
if (mIsCanceled) {
return;
}
mMarkerhandler.sendMessage(message);
}
示例12: zoomToSpan
import com.amap.api.maps.model.LatLngBounds; //导入依赖的package包/类
/**
* 移动镜头到当前的视角。
* @since V2.1.0
*/
public void zoomToSpan(){
if (startPoint != null){
if (mAMap == null){
return;
}
try{
LatLngBounds bounds = getLatLngBounds();
mAMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds,50));
}catch (Throwable e){
e.printStackTrace();
}
}
}
示例13: onClick
import com.amap.api.maps.model.LatLngBounds; //导入依赖的package包/类
@Override
public void onClick(Marker marker, List<ClusterItem> clusterItems) {
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (ClusterItem clusterItem : clusterItems) {
builder.include(clusterItem.getPosition());
}
LatLngBounds latLngBounds = builder.build();
mAMap.animateCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 0)
);
}
示例14: getBounds
import com.amap.api.maps.model.LatLngBounds; //导入依赖的package包/类
private LatLngBounds getBounds() {
LatLngBounds.Builder b = LatLngBounds.builder();
if (mOriginLatLngList == null) {
return b.build();
}
for (int i = 0; i < mOriginLatLngList.size(); i++) {
b.include(mOriginLatLngList.get(i));
}
return b.build();
}
示例15: centerPoints
import com.amap.api.maps.model.LatLngBounds; //导入依赖的package包/类
public static void centerPoints(AMap map, List<LatLng> points){
if(points == null || points.size() < 2){
return;
}
LatLng first = points.get(0);
double minLat = first.latitude;
double maxLat = first.latitude;
double minLon = first.longitude;
double maxLon = first.longitude;
for(int i = 1, num = points.size() ; i < num ; i++){
LatLng t = points.get(i);
if(t.latitude > maxLat){
maxLat = t.latitude;
}
if(t.latitude < minLat){
minLat = t.latitude;
}
if(t.longitude > maxLon){
maxLon = t.longitude;
}
if(t.longitude < minLon){
minLon = t.longitude;
}
}
LatLngBounds bounds = new LatLngBounds(new LatLng(minLat, minLon), new LatLng(maxLat, maxLon));
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 5));
}