com.google.android.gms.maps.model.GroundOverlayOptions Java Examples

The following examples show how to use com.google.android.gms.maps.model.GroundOverlayOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KmlRenderer.java    From android-maps-utils with Apache License 2.0 6 votes vote down vote up
/**
 * 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 = getCachedGroundOverlayImage(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);
        }
    }
}
 
Example #2
Source File: ShapeActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 5 votes vote down vote up
private void addGroundOverlays()
{
	googleMap.clear();
	GroundOverlayOptions groundOverlayOptions = new GroundOverlayOptions();
	groundOverlayOptions.image(BitmapDescriptorFactory.fromResource(R.drawable.city)).anchor(0, 1);
	groundOverlayOptions.position(new LatLng(40, -74), 8600f, 6500f);
	groundOverlayOptions.bearing(0);
	groundOverlayOptions.clickable(true);

	googleMap.addGroundOverlay(groundOverlayOptions).setTag(new CustomTag("ground overlay"));
	googleMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(40, -74)));
}
 
Example #3
Source File: BaseNiboFragment.java    From Nibo with MIT License 5 votes vote down vote up
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);
}
 
Example #4
Source File: RichLayer.java    From richmaps with Apache License 2.0 5 votes vote down vote up
public void refresh() {
    CameraPosition cameraPosition = map.getCameraPosition();
    if (cameraPosition.zoom >= MINIMUM_ZOOM_LEVEL) {
        Projection projection = map.getProjection();

        prepareBitmap();
        draw(bitmap, projection);

        float mapWidth = (float) SphericalUtil.computeDistanceBetween(
                projection.getVisibleRegion().nearLeft,
                projection.getVisibleRegion().nearRight);

        if (overlay == null) {
            GroundOverlayOptions background = new GroundOverlayOptions()
                    .image(BitmapDescriptorFactory.fromBitmap(bitmap))
                    .position(cameraPosition.target, mapWidth)
                    .bearing(cameraPosition.bearing)
                    .zIndex(zIndex);
            overlay = map.addGroundOverlay(background);
        } else {
            overlay.setImage(BitmapDescriptorFactory.fromBitmap(bitmap));
            overlay.setPosition(cameraPosition.target);
            overlay.setDimensions(mapWidth);
            overlay.setBearing(cameraPosition.bearing);
        }
    } else {
        if (overlay != null) {
            overlay.remove();
            overlay = null;
        }
    }
}
 
Example #5
Source File: MapFragment.java    From Android-GoogleMaps-Part1 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void drawOverlay( LatLng location, int width, int height ) {
    GroundOverlayOptions options = new GroundOverlayOptions();
    options.position(location, width, height);

    options.image( BitmapDescriptorFactory
            .fromBitmap( BitmapFactory
                .decodeResource( getResources(), R.mipmap.ic_launcher ) ) );
    getMap().addGroundOverlay(options);
}
 
Example #6
Source File: GroundOverlayDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onMapReady(GoogleMap map) {
    // Register a listener to respond to clicks on GroundOverlays.
    map.setOnGroundOverlayClickListener(this);

    map.moveCamera(CameraUpdateFactory.newLatLngZoom(NEWARK, 11));

    images.clear();
    images.add(BitmapDescriptorFactory.fromResource(R.drawable.newark_nj_1922));
    images.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.)
    groundOverlayRotated = map.addGroundOverlay(new GroundOverlayOptions()
            .image(images.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.
    groundOverlay = map.addGroundOverlay(new GroundOverlayOptions()
            .image(images.get(currentEntry)).anchor(0, 1)
            .position(NEWARK, 8600f, 6500f));

    transparencyBar.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.");
}
 
Example #7
Source File: MapFragment.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
private void drawOverlay( LatLng location, int width, int height ) {
    GroundOverlayOptions options = new GroundOverlayOptions();
    options.position(location, width, height);

    options.image( BitmapDescriptorFactory
            .fromBitmap( BitmapFactory
                .decodeResource( getResources(), R.mipmap.ic_launcher ) ) );
    getMap().addGroundOverlay(options);
}
 
Example #8
Source File: KmlGroundOverlay.java    From android-maps-utils with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #9
Source File: TagsDemoActivity.java    From android-samples with Apache License 2.0 4 votes vote down vote up
private void addObjectsToMap() {
    // A circle centered on Adelaide.
    mAdelaideCircle = mMap.addCircle(new CircleOptions()
            .center(ADELAIDE)
            .radius(500000)
            .fillColor(Color.argb(150, 66, 173, 244))
            .strokeColor(Color.rgb(66, 173, 244))
            .clickable(true));
    mAdelaideCircle.setTag(new CustomTag("Adelaide circle"));

    // A ground overlay at Sydney.
    mSydneyGroundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions()
            .image(BitmapDescriptorFactory.fromResource(R.drawable.harbour_bridge))
            .position(SYDNEY, 700000)
            .clickable(true));
    mSydneyGroundOverlay.setTag(new CustomTag("Sydney ground overlay"));

    // A marker at Hobart.
    mHobartMarker = mMap.addMarker(new MarkerOptions().position(HOBART));
    mHobartMarker.setTag(new CustomTag("Hobart marker"));

    // A polygon centered at Darwin.
    mDarwinPolygon = mMap.addPolygon(new PolygonOptions()
            .add(
                    new LatLng(DARWIN.latitude + 3, DARWIN.longitude - 3),
                    new LatLng(DARWIN.latitude + 3, DARWIN.longitude + 3),
                    new LatLng(DARWIN.latitude - 3, DARWIN.longitude + 3),
                    new LatLng(DARWIN.latitude - 3, DARWIN.longitude - 3))
            .fillColor(Color.argb(150, 34, 173, 24))
            .strokeColor(Color.rgb(34, 173, 24))
            .clickable(true));
    mDarwinPolygon.setTag(new CustomTag("Darwin polygon"));

    // A polyline from Perth to Brisbane.
    mPolyline = mMap.addPolyline(new PolylineOptions()
            .add(PERTH, BRISBANE)
            .color(Color.rgb(103, 24, 173))
            .width(30)
            .clickable(true));
    mPolyline.setTag(new CustomTag("Perth to Brisbane polyline"));
}
 
Example #10
Source File: GoogleMapImpl.java    From android_packages_apps_GmsCore with Apache License 2.0 4 votes vote down vote up
@Override
public IGroundOverlayDelegate addGroundOverlay(GroundOverlayOptions options)
        throws RemoteException {
    Log.d(TAG, "not yet usable: addGroundOverlay");
    return new GroundOverlayImpl(options); // TODO
}
 
Example #11
Source File: GroundOverlayManager.java    From android-maps-utils with Apache License 2.0 4 votes vote down vote up
public GroundOverlay addGroundOverlay(GroundOverlayOptions opts) {
    GroundOverlay groundOverlay = mMap.addGroundOverlay(opts);
    super.add(groundOverlay);
    return groundOverlay;
}
 
Example #12
Source File: GroundOverlayManager.java    From android-maps-utils with Apache License 2.0 4 votes vote down vote up
public void addAll(java.util.Collection<GroundOverlayOptions> opts) {
    for (GroundOverlayOptions opt : opts) {
        addGroundOverlay(opt);
    }
}
 
Example #13
Source File: GroundOverlayManager.java    From android-maps-utils with Apache License 2.0 4 votes vote down vote up
public void addAll(java.util.Collection<GroundOverlayOptions> opts, boolean defaultVisible) {
    for (GroundOverlayOptions opt : opts) {
        addGroundOverlay(opt).setVisible(defaultVisible);
    }
}
 
Example #14
Source File: GroundOverlayImpl.java    From android_packages_apps_GmsCore with Apache License 2.0 2 votes vote down vote up
public GroundOverlayImpl(GroundOverlayOptions options) {
    
}
 
Example #15
Source File: Renderer.java    From android-maps-utils with Apache License 2.0 2 votes vote down vote up
/**
 * Adds a ground overlay to the map
 *
 * @param groundOverlayOptions GroundOverlay style options to be added to the map
 * @return new GroundOverlay object created from the given GroundOverlayOptions
 */
protected GroundOverlay attachGroundOverlay(GroundOverlayOptions groundOverlayOptions) {
    return mGroundOverlays.addGroundOverlay(groundOverlayOptions);
}
 
Example #16
Source File: KmlGroundOverlay.java    From android-maps-utils with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the ground overlay option of the ground overlay on the map
 *
 * @return GroundOverlayOptions
 */
/* package */ GroundOverlayOptions getGroundOverlayOptions() {
    return mGroundOverlayOptions;
}