本文整理汇总了Java中com.google.android.gms.maps.model.LatLngBounds.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java LatLngBounds.Builder方法的具体用法?Java LatLngBounds.Builder怎么用?Java LatLngBounds.Builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.maps.model.LatLngBounds
的用法示例。
在下文中一共展示了LatLngBounds.Builder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: zoomToPolyline
import com.google.android.gms.maps.model.LatLngBounds; //导入方法依赖的package包/类
public static void zoomToPolyline(GoogleMap map, Polyline p) {
if (p == null || p.getPoints().isEmpty())
return;
LatLngBounds.Builder builder = LatLngBounds.builder();
for (LatLng latLng : p.getPoints()) {
builder.include(latLng);
}
final LatLngBounds bounds = builder.build();
try{
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 150));
} catch (Exception e){
e.printStackTrace();
}
}
示例2: onCreate
import com.google.android.gms.maps.model.LatLngBounds; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_liveshare);
builder = new LatLngBounds.Builder();
userdata = FirebaseDatabase.getInstance().getReference().child(Constants.users);
user = FirebaseAuth.getInstance().getCurrentUser();
key = (String) getIntent().getExtras().get("uid");
livedata = FirebaseDatabase.getInstance().getReference(Constants.events).child(key).child(Constants.livepart);
lat = (Double) getIntent().getExtras().get("lat");
lon = (Double) getIntent().getExtras().get("lon");
builder.include(new LatLng(lat,lon));
SupportMapFragment mapFragment =
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
// Intent i = new Intent(getApplicationContext(), LocationData.class);
// startService(i);
}
示例3: onClusterClick
import com.google.android.gms.maps.model.LatLngBounds; //导入方法依赖的package包/类
@Override
public boolean onClusterClick(Cluster<CustomMarker> cluster) {
// Zoom in the cluster. Need to create LatLngBounds and including all the cluster items
// inside of bounds, then animate to center of the bounds.
// Create the builder to collect all essential cluster items for the bounds.
LatLngBounds.Builder builder = LatLngBounds.builder();
for (CustomMarker item : cluster.getItems()) {
builder.include(item.getPosition());
}
// Get the LatLngBounds
final LatLngBounds bounds = builder.build();
// Animate camera to the bounds
try {
mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 150));
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
示例4: PlacePinAndPositionCamera
import com.google.android.gms.maps.model.LatLngBounds; //导入方法依赖的package包/类
public void PlacePinAndPositionCamera(LatLng addressPosition) {
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(addressPosition);
mMap.addMarker(markerOptions
.title("Crisis Location").icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(addressPosition, 12));
LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(addressPosition);
LatLngBounds bounds = builder.build();
int padding = 150; // offset from edges of the map in pixels
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
mMap.animateCamera(cu);
}
示例5: refreshMarkers
import com.google.android.gms.maps.model.LatLngBounds; //导入方法依赖的package包/类
private void refreshMarkers() {
// if (allMarkers.size() == allTrips.size()) return;
LatLngBounds.Builder boundBuilder = new LatLngBounds.Builder();
allMarkers.clear();
gMap.clear();
for (Trip t : allTrips) {
DateTime begDate = DateTime.parse(t.getStartDate());
DateTime endDate = DateTime.parse(t.getEndDate());
LatLng thisLoc = new LatLng(t.getLat(), t.getLng());
Marker m = gMap.addMarker(
new MarkerOptions().position(thisLoc).title(t.getName())
.snippet(formatDate(begDate, endDate)));
m.setTag(t);
allMarkers.add(m);
boundBuilder.include(thisLoc);
}
if (allMarkers.size() > 0) {
int screenWidth = getResources().getDisplayMetrics().widthPixels;
int screenHeight = getResources().getDisplayMetrics().heightPixels;
LatLngBounds bound = boundBuilder.build();
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(bound,
screenWidth, screenHeight, 56);
gMap.animateCamera(cameraUpdate);
}
}
示例6: updateMapPOIs
import com.google.android.gms.maps.model.LatLngBounds; //导入方法依赖的package包/类
private void updateMapPOIs() {
googleMap.clear();
if (hits.isEmpty()) {
return;
}
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (final JSONObject hit: hits) {
final MarkerOptions marker = HitMarker.marker(hit);
builder.include(marker.getPosition());
googleMap.addMarker(marker);
}
LatLngBounds bounds = builder.build();
// update the camera
int padding = 10;
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
googleMap.animateCamera(cu);
}
示例7: addPanPropertiesToMap
import com.google.android.gms.maps.model.LatLngBounds; //导入方法依赖的package包/类
private void addPanPropertiesToMap() {
LatLngBounds bounds = null;
Builder latLngBoundBuilder = new LatLngBounds.Builder();
if (punchLocationCollection != null && punchLocationCollection.size() > 0) {
int totalLocations = punchLocationCollection.size();
for (int currentLocation = 0; currentLocation < totalLocations; currentLocation++) {
LatLng latLng = new LatLng(Double.parseDouble(punchLocationCollection.get(currentLocation).getLatitude()), Double.parseDouble(punchLocationCollection.get(currentLocation)
.getLongitude()));
latLngBoundBuilder = latLngBoundBuilder.include(latLng);
}
}
if (deviceCurrentLocation != null) {
latLngBoundBuilder.include(new LatLng(deviceCurrentLocation.getLatitude(), deviceCurrentLocation.getLongitude()));
}
// Build the map with the bounds that encompass all the
// specified location as well the current location
bounds = latLngBoundBuilder.build();
mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 50));
// Zoom in, animating the camera.
// mMap.animateCamera(CameraUpdateFactory.zoomTo(50), 2000, null);
}
示例8: showAvailableRestaurants
import com.google.android.gms.maps.model.LatLngBounds; //导入方法依赖的package包/类
@Override
public void showAvailableRestaurants(List<Restaurant> items) {
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (Restaurant restaurant : items) {
Marker marker = this.googleMap.addMarker(
new MarkerOptions()
.position(new LatLng(restaurant.latitude, restaurant.longitude))
.title(restaurant.name)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.mikuy_marker))
.snippet(restaurant.category));
marker.setTag(restaurant);
builder.include(marker.getPosition());
}
LatLngBounds bounds = builder.build();
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, 100);
this.googleMap.moveCamera(cu);
}
示例9: onDirectionsTaskResponse
import com.google.android.gms.maps.model.LatLngBounds; //导入方法依赖的package包/类
@Override
public void onDirectionsTaskResponse(DirectionsTaskResponse response) {
if (currentPolyline != null) {
currentPolyline.remove();
}
Log.v(TAG, "Got directions");
if (response != null) {
List<LatLng> points = response.getPolylineOptions().getPoints();
LatLngBounds.Builder bnds = LatLngBounds.builder().include(new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude()));
for (LatLng point : points) {
bnds.include(point);
}
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bnds.build(), 250));
currentPolyline = map.addPolyline(response.getPolylineOptions());
}
}
示例10: onClusterClick
import com.google.android.gms.maps.model.LatLngBounds; //导入方法依赖的package包/类
@Override
public boolean onClusterClick(Cluster<Asset> cluster) {
// Show a toast with some info when the cluster is clicked.
String firstName = cluster.getItems().iterator().next().name;
Toast.makeText(this, cluster.getSize() + " (including " + firstName + ")", Toast.LENGTH_SHORT).show();
// Zoom in the cluster. Need to create LatLngBounds and including all the cluster items
// inside of bounds, then animate to center of the bounds.
// Create the builder to collect all essential cluster items for the bounds.
LatLngBounds.Builder builder = LatLngBounds.builder();
for (ClusterItem item : cluster.getItems()) {
builder.include(item.getPosition());
}
// Get the LatLngBounds
final LatLngBounds bounds = builder.build();
// Animate camera to the bounds
try {
getMap().animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 100));
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
开发者ID:aminyazdanpanah,项目名称:google-maps-3D-pie-chart-marker-clustering-java,代码行数:27,代码来源:DemoActivity.java
示例11: addRouteToMap
import com.google.android.gms.maps.model.LatLngBounds; //导入方法依赖的package包/类
/**
* Adds the route to the map.
*
* @param googleMap the map
* @param routeMapInfo the view model containing the information for the route
*/
public void addRouteToMap(final GoogleMap googleMap, final RouteMapData routeMapInfo) {
final LatLngBounds.Builder latLngBounds = new LatLngBounds.Builder();
for (PolylineData polylineData : routeMapInfo.getPolylineDataList()) {
PolylineOptions polyline = getPolylineOptions(latLngBounds, polylineData);
if (polyline != null) {
googleMap.addPolyline(polyline);
}
}
googleMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
@Override
public void onMapLoaded() {
addMarker(routeMapInfo.getStartPoint(), googleMap);
addMarker(routeMapInfo.getEndPoint(), googleMap);
googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds.build(), 200));
}
});
}
示例12: loadMapPins
import com.google.android.gms.maps.model.LatLngBounds; //导入方法依赖的package包/类
private void loadMapPins(List<Unit> units) {
mMap.clear();
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (Unit u : units) {
mMap.addMarker(new MarkerOptions()
.title(u.getNome())
.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_action_pin))
.snippet(u.buildSnippet())
.position(new LatLng(u.getGeo().getLatitude(), u.getGeo().getLongitude())));
builder.include(new LatLng(u.getGeo().getLatitude(), u.getGeo().getLongitude()));
}
LatLngBounds bounds = builder.build();
int padding = (int) (16 * getResources().getDisplayMetrics().density);
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
mMap.animateCamera(cu);
}
示例13: setPoints
import com.google.android.gms.maps.model.LatLngBounds; //导入方法依赖的package包/类
/**
* Set points
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void setPoints(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
String id = args.getString(1);
Polygon polygon = this.getPolygon(id);
JSONArray points = args.getJSONArray(2);
List<LatLng> path = PluginUtil.JSONArray2LatLngList(points);
polygon.setPoints(path);
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (int i = 0; i < path.size(); i++) {
builder.include(path.get(i));
}
this.objects.put("polygon_bounds_" + polygon.getId(), builder.build());
this.sendNoResult(callbackContext);
}
示例14: zoomToPoint
import com.google.android.gms.maps.model.LatLngBounds; //导入方法依赖的package包/类
private void zoomToPoint(LatLng newPoint) {
// Zoom in as need be, cover an area of a couple graticules in any
// direction, leaving space for the graticule picker on the bottom of
// the screen.
LatLngBounds.Builder builder = LatLngBounds.builder();
LatLng point = new LatLng(newPoint.latitude - CLOSENESS_Y_DOWN, newPoint.longitude - CLOSENESS_X);
builder.include(point);
point = new LatLng(newPoint.latitude - CLOSENESS_Y_DOWN, newPoint.longitude + CLOSENESS_X);
builder.include(point);
point = new LatLng(newPoint.latitude + CLOSENESS_Y_UP, newPoint.longitude + CLOSENESS_X);
builder.include(point);
point = new LatLng(newPoint.latitude + CLOSENESS_Y_UP, newPoint.longitude - CLOSENESS_X);
builder.include(point);
mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 0));
}
示例15: getPolyLineOptions
import com.google.android.gms.maps.model.LatLngBounds; //导入方法依赖的package包/类
private List<PolylineOptions> getPolyLineOptions(
ArrayList<LatLng> latLngPath, Set<LatLng> duplicates,
LatLngBounds.Builder builder, boolean healthiest) {
int color = healthiest ? Color.rgb(0, 204, 204) : Color
.rgb(227, 74, 51);
List<PolylineOptions> optionsList = Lists.newLinkedList();
LatLng previous = null;
for (LatLng current : latLngPath) {
builder.include(current);
if (previous != null) {
PolylineOptions polylineOptions = new PolylineOptions();
polylineOptions.add(previous).add(current);
polylineOptions.color(color);
if (healthiest && duplicates.contains(previous)
&& duplicates.contains(current)) {
polylineOptions.width(WIDTH_THIN);
} else {
polylineOptions.width(WIDTH_THICK);
}
optionsList.add(polylineOptions);
}
previous = current;
}
return optionsList;
}