/** * Adds ground overlays from a given URL onto the map * * @param groundOverlayUrl url of ground overlay * @param groundOverlays hashmap of ground overlays to add to the map */ private void addGroundOverlayToMap(String groundOverlayUrl, HashMap<KmlGroundOverlay, GroundOverlay> groundOverlays, boolean containerVisibility) { BitmapDescriptor groundOverlayBitmap = BitmapDescriptorFactory .fromBitmap(getImagesCache().get(groundOverlayUrl)); for (KmlGroundOverlay kmlGroundOverlay : groundOverlays.keySet()) { if (kmlGroundOverlay.getImageUrl().equals(groundOverlayUrl)) { GroundOverlayOptions groundOverlayOptions = kmlGroundOverlay.getGroundOverlayOptions() .image(groundOverlayBitmap); GroundOverlay mapGroundOverlay = attachGroundOverlay(groundOverlayOptions); if (!containerVisibility) { mapGroundOverlay.setVisible(false); } groundOverlays.put(kmlGroundOverlay, mapGroundOverlay); } } }
/** * Creates a new Ground Overlay * * @param imageUrl url of the ground overlay image * @param latLonBox bounds of the image * @param drawOrder z index of the image * @param visibility true if visible, false otherwise * @param properties properties hashmap * @param rotation rotation of image */ /* package */ KmlGroundOverlay(String imageUrl, LatLngBounds latLonBox, float drawOrder, int visibility, HashMap<String, String> properties, float rotation) { mGroundOverlayOptions = new GroundOverlayOptions(); mImageUrl = imageUrl; mProperties = properties; if (latLonBox == null) { throw new IllegalArgumentException("No LatLonBox given"); } mLatLngBox = latLonBox; mGroundOverlayOptions.positionFromBounds(latLonBox); mGroundOverlayOptions.bearing(rotation); mGroundOverlayOptions.zIndex(drawOrder); mGroundOverlayOptions.visible(visibility != 0); }
/** * Sets bitmap of floor plan as ground overlay on Google Maps */ private void setupGroundOverlay(IAFloorPlan floorPlan, Bitmap bitmap) { if (mGroundOverlay != null) { mGroundOverlay.remove(); } if (mMap != null) { BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap); IALatLng iaLatLng = floorPlan.getCenter(); LatLng center = new LatLng(iaLatLng.latitude, iaLatLng.longitude); GroundOverlayOptions fpOverlay = new GroundOverlayOptions() .image(bitmapDescriptor) .zIndex(0.0f) .position(center, floorPlan.getWidthMeters(), floorPlan.getHeightMeters()) .bearing(floorPlan.getBearing()); mGroundOverlay = mMap.addGroundOverlay(fpOverlay); } }
public void addOverlay(LatLng place) { GroundOverlay groundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions() .position(place, 100) .transparency(0.5f) .zIndex(3) .image(BitmapDescriptorFactory.fromBitmap(drawableToBitmap(getDrawable(R.drawable.map_overlay))))); startOverlayAnimation(groundOverlay); }
@Override public void onMapReady(GoogleMap map) { // Register a listener to respond to clicks on GroundOverlays. map.setOnGroundOverlayClickListener(this); map.moveCamera(CameraUpdateFactory.newLatLngZoom(NEWARK, 11)); mImages.clear(); mImages.add(BitmapDescriptorFactory.fromResource(R.drawable.newark_nj_1922)); mImages.add(BitmapDescriptorFactory.fromResource(R.drawable.newark_prudential_sunny)); // Add a small, rotated overlay that is clickable by default // (set by the initial state of the checkbox.) mGroundOverlayRotated = map.addGroundOverlay(new GroundOverlayOptions() .image(mImages.get(1)).anchor(0, 1) .position(NEAR_NEWARK, 4300f, 3025f) .bearing(30) .clickable(((CheckBox) findViewById(R.id.toggleClickability)).isChecked())); // Add a large overlay at Newark on top of the smaller overlay. mGroundOverlay = map.addGroundOverlay(new GroundOverlayOptions() .image(mImages.get(mCurrentEntry)).anchor(0, 1) .position(NEWARK, 8600f, 6500f)); mTransparencyBar.setOnSeekBarChangeListener(this); // Override the default content description on the view, for accessibility mode. // Ideally this string would be localised. map.setContentDescription("Google Map with ground overlay."); }
mSydneyGroundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions() .image(BitmapDescriptorFactory.fromResource(R.drawable.harbour_bridge)) .position(SYDNEY, 700000) .clickable(true)); mSydneyGroundOverlay.setTag(new CustomTag("Sydney ground overlay"));
/** * Triggered when the map is ready to be used. * * @param googleMap The GoogleMap object representing the Google Map. */ @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // Pan the camera to your home address (in this case, Google HQ). LatLng home = new LatLng(37.421982, -122.085109); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(home, INITIAL_ZOOM)); // Add a ground overlay 100 meters in width to the home location. GroundOverlayOptions homeOverlay = new GroundOverlayOptions() .image(BitmapDescriptorFactory.fromResource(R.drawable.android)) .position(home, 100); mMap.addGroundOverlay(homeOverlay); setMapLongClick(mMap); // Set a long click listener for the map; setPoiClick(mMap); // Set a click listener for points of interest. setMapStyle(mMap); // Set the custom map style. enableMyLocation(mMap); // Enable location tracking. // Enable going into StreetView by clicking on an InfoWindow from a // point of interest. setInfoWindowClickToPanorama(mMap); }
public GroundOverlayOptions position(LatLng location, float width) { real.position(location, width); return this; }
public GroundOverlayOptions zIndex(float zIndex) { real.zIndex(zIndex); return this; } }
public GroundOverlayOptions bearing(float bearing) { real.bearing(bearing); return this; }
public GroundOverlayOptions positionFromBounds(LatLngBounds bounds) { real.positionFromBounds(bounds); return this; }
public GroundOverlayOptions transparency(float transparency) { real.transparency(transparency); return this; }
public GroundOverlayOptions visible(boolean visible) { real.visible(visible); return this; }
/** * Sets bitmap of floor plan as ground overlay on Google Maps */ private void setupGroundOverlay(IAFloorPlan floorPlan, Bitmap bitmap) { if (mGroundOverlay != null) { mGroundOverlay.remove(); } if (mMap != null) { BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap); IALatLng iaLatLng = floorPlan.getCenter(); LatLng center = new LatLng(iaLatLng.latitude, iaLatLng.longitude); GroundOverlayOptions fpOverlay = new GroundOverlayOptions() .image(bitmapDescriptor) .zIndex(0.0f) .position(center, floorPlan.getWidthMeters(), floorPlan.getHeightMeters()) .bearing(floorPlan.getBearing()); mGroundOverlay = mMap.addGroundOverlay(fpOverlay); } }
public void addOverlay(LatLng place) { GroundOverlay groundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions() .position(place, 100) .transparency(0.5f) .zIndex(3) .image(BitmapDescriptorFactory.fromBitmap(drawableToBitmap(getActivity().getResources().getDrawable(R.drawable.map_overlay))))); startOverlayAnimation(groundOverlay); }
public GroundOverlayOptions position(LatLng location, float width, float height) { real.position(location, width, height); return this; }
/** * Creates a new Ground Overlay * * @param imageUrl url of the ground overlay image * @param latLonBox bounds of the image * @param drawOrder z index of the image * @param visibility true if visible, false otherwise * @param properties properties hashmap * @param rotation rotation of image */ /* package */ KmlGroundOverlay(String imageUrl, LatLngBounds latLonBox, float drawOrder, int visibility, HashMap<String, String> properties, float rotation) { mGroundOverlayOptions = new GroundOverlayOptions(); mImageUrl = imageUrl; mProperties = properties; if (latLonBox == null) { throw new IllegalArgumentException("No LatLonBox given"); } mLatLngBox = latLonBox; mGroundOverlayOptions.positionFromBounds(latLonBox); mGroundOverlayOptions.bearing(rotation); mGroundOverlayOptions.zIndex(drawOrder); mGroundOverlayOptions.visible(visibility != 0); }
public GroundOverlayOptions image(BitmapDescriptor image) { real.image(image); return this; }
/** * Adds ground overlays from a given URL onto the map * * @param groundOverlayUrl url of ground overlay * @param groundOverlays hashmap of ground overlays to add to the map */ private void addGroundOverlayToMap(String groundOverlayUrl, HashMap<KmlGroundOverlay, GroundOverlay> groundOverlays, boolean containerVisibility) { BitmapDescriptor groundOverlayBitmap = BitmapDescriptorFactory .fromBitmap(mImagesCache.get(groundOverlayUrl)); for (KmlGroundOverlay kmlGroundOverlay : groundOverlays.keySet()) { if (kmlGroundOverlay.getImageUrl().equals(groundOverlayUrl)) { GroundOverlayOptions groundOverlayOptions = kmlGroundOverlay.getGroundOverlayOptions() .image(groundOverlayBitmap); GroundOverlay mapGroundOverlay = mMap.addGroundOverlay(groundOverlayOptions); if (containerVisibility == false) { mapGroundOverlay.setVisible(false); } groundOverlays.put(kmlGroundOverlay, mapGroundOverlay); } } }