当前位置: 首页>>代码示例>>Java>>正文


Java LatLngBounds.Builder方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:18,代码来源:MapUtils.java

示例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);


    }
 
开发者ID:picopalette,项目名称:event-me,代码行数:23,代码来源:LiveShare.java

示例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;
}
 
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:22,代码来源:CustomRenderer.java

示例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);
    }
 
开发者ID:panzerama,项目名称:Dispatch,代码行数:20,代码来源:MainActivity.java

示例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);
        }
    }
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:26,代码来源:TripMapFragment.java

示例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);
}
 
开发者ID:algolia,项目名称:instantsearch-android-examples,代码行数:18,代码来源:MapWidget.java

示例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);
}
 
开发者ID:appez,项目名称:appez-android,代码行数:25,代码来源:SmartMapHandlerActivity.java

示例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);
}
 
开发者ID:Danihelsan,项目名称:MikuyConcept,代码行数:18,代码来源:ExploreFragment.java

示例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());
    }
}
 
开发者ID:rasmussaks,项目名称:aken-ajalukku,代码行数:17,代码来源:AbstractMapActivity.java

示例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));
		}
	});
}
 
开发者ID:Zlate87,项目名称:sample-transport-app,代码行数:24,代码来源:RouteMapService.java

示例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);
}
 
开发者ID:gkaffka,项目名称:simple-map-android,代码行数:18,代码来源:ActivityMap.java

示例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);
}
 
开发者ID:neo4art,项目名称:neo4art,代码行数:23,代码来源:PluginPolygon.java

示例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));
}
 
开发者ID:CaptainSpam,项目名称:geohashdroid,代码行数:20,代码来源:SelectAGraticuleMode.java

示例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;
}
 
开发者ID:dhasenfratz,项目名称:hRouting_Android,代码行数:27,代码来源:PathMapFragment.java


注:本文中的com.google.android.gms.maps.model.LatLngBounds.Builder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。