本文整理汇总了Java中com.google.android.gms.maps.model.LatLngBounds.Builder类的典型用法代码示例。如果您正苦于以下问题:Java Builder类的具体用法?Java Builder怎么用?Java Builder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Builder类属于com.google.android.gms.maps.model.LatLngBounds包,在下文中一共展示了Builder类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addPanPropertiesToMap
import com.google.android.gms.maps.model.LatLngBounds.Builder; //导入依赖的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);
}
示例2: JSONArray2LatLngBounds
import com.google.android.gms.maps.model.LatLngBounds.Builder; //导入依赖的package包/类
public static LatLngBounds JSONArray2LatLngBounds(JSONArray points) throws JSONException {
List<LatLng> path = JSONArray2LatLngList(points);
Builder builder = LatLngBounds.builder();
int i = 0;
for (i = 0; i < path.size(); i++) {
builder.include(path.get(i));
}
return builder.build();
}
示例3: convertToLatLngBounds
import com.google.android.gms.maps.model.LatLngBounds.Builder; //导入依赖的package包/类
public static LatLngBounds convertToLatLngBounds(List<LatLng> points) {
LatLngBounds.Builder latLngBuilder = LatLngBounds.builder();
Iterator<LatLng> iterator = points.listIterator();
while (iterator.hasNext()) {
latLngBuilder.include(iterator.next());
}
return latLngBuilder.build();
}
示例4: onMapChange
import com.google.android.gms.maps.model.LatLngBounds.Builder; //导入依赖的package包/类
@Override
public void onMapChange(List<Node> nodes, List<? extends Edge> edges) {
Builder bounds = LatLngBounds.builder();
boolean hasBounds = false;
for (Node n: nodes) {
Marker m = gmap.addMarker(new MarkerOptions()
.position(toGms(n.location))
.title(n.name)
.snippet(n.description));
hasBounds = true;
bounds.include(toGms(n.location));
markers.put(m, n);
}
for (Edge e: edges) {
gmap.addPolyline(new PolylineOptions()
.add(toGms(e.nodeA.location), toGms(e.nodeB.location))
.color(getColor(e.type)));
}
if (hasBounds) {
gameBounds = bounds.build();
if (zoom == null) {
zoom = Zoom.ToGame;
}
zoomMap();
}
}
示例5: onMarkerClick
import com.google.android.gms.maps.model.LatLngBounds.Builder; //导入依赖的package包/类
@Override
public boolean onMarkerClick(Marker marker) {
Node source = markers.get(marker),
target;
Builder bounds = LatLngBounds.builder();
ArrayList<Node> targets = new ArrayList<Node>();
bounds.include(toGms(source.location));
for (Edge e: source.getEdges()) {
target = e.getOtherNode(source);
targets.add(target);
bounds.include(toGms(target.location));
}
Log.i(THIS, "found "+ targets.size() +" targets/edges");
for (Entry<Marker, Node> m: markers.entrySet()) {
Marker current = m.getKey();
boolean cond = targets.contains(m.getValue());
current.setVisible(cond);
}
marker.setVisible(true);
zoom = Zoom.ToBounds;
currentBounds = bounds.build();
zoomMap();
marker.showInfoWindow();
return true;
}
示例6: doAnimateCameraToIncludePosition
import com.google.android.gms.maps.model.LatLngBounds.Builder; //导入依赖的package包/类
private void doAnimateCameraToIncludePosition(GoogleMap map, LatLng position) {
map.animateCamera(CameraUpdateFactory.newLatLngBounds(
new Builder().include(map.getCameraPosition().target).include(position).build(),
mContext.getResources().getDimensionPixelOffset(R.dimen.touch_target_min_size)));
}
示例7: onLayersUpdate
import com.google.android.gms.maps.model.LatLngBounds.Builder; //导入依赖的package包/类
/** Called when the user confirms layer selection in LayersDialog */
public void onLayersUpdate(List<String> enabledLayers) {
// Clear the map
gmap.clear();
// If no layers at all were selected, then reset the camera and return
if (enabledLayers.size() == 0) {
gmap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(mpd.PURDUE_CENTER_LAT, mpd.PURDUE_CENTER_LNG),
mpd.PURDUE_CAMPUS_ZOOM));
return;
}
// Create a camera update bounds which will be updated as we add pins
LatLngBounds.Builder latlngbuilder = LatLngBounds.builder();
// The list of layers contains each layer the user has selected.
// If the user selects multiple layers then they should be displayed simultaneously
for (String i : enabledLayers) {
for (LatLng loc : mpd.getLayerPoints(i)) {
// Calculate the distance between the user's location and the pin (in meters)
int dBetween = 0;
if (gmap.getMyLocation() != null) {
double dBetweenD = MapData.distanceBetween(gmap.getMyLocation().getLatitude(),
gmap.getMyLocation().getLongitude(), loc.latitude, loc.longitude) * 1000;
// Cast it as an int to chop of the decimal as we really don't care about anything less than 1 meter
dBetween = (int) dBetweenD;
}
// Create a new marker at that position with the title set as the distance
gmap.addMarker(new MarkerOptions()
.position(loc)
.title("" + dBetween + " m"));
latlngbuilder.include(loc);
}
}
// Animate the camera so it includes all the new pins
gmap.animateCamera(CameraUpdateFactory.newLatLngBounds(latlngbuilder.build(), 300));
}
示例8: seleccionarProximidad
import com.google.android.gms.maps.model.LatLngBounds.Builder; //导入依赖的package包/类
/**
* Seleccion de proximidad de paradas
*/
public void seleccionarProximidad() {
final CharSequence[] items = {context.getString(R.string.proximidad_1), context.getString(R.string.proximidad_2), context.getString(R.string.proximidad_3)};
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.proximidad);
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
if (item == 0) {
context.distancia = DISTACIA_CERCANA;
miLocalizacion(true);
} else if (item == 1) {
context.distancia = DISTACIA_MEDIA;
miLocalizacion(true);
} else if (item == 2) {
context.distancia = DISTACIA_LEJOS;
miLocalizacion(true);
}
}
});
AlertDialog alert = builder.create();
alert.show();
}