Back to project page GoogleMapsV2Demo.
The source code is released under:
Apache License
If you think the Android project GoogleMapsV2Demo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Copyright (C) 2012 The Android Open Source Project *//from w w w. ja v a2s .c o m * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.example.mapdemo; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.android.gms.maps.model.GroundOverlay; import com.google.android.gms.maps.model.GroundOverlayOptions; import com.google.android.gms.maps.model.LatLng; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; /** * This shows how to add a ground overlay to a map. */ public class GroundOverlayDemoActivity extends FragmentActivity implements OnSeekBarChangeListener { private static final int TRANSPARENCY_MAX = 100; private static final LatLng NEWARK = new LatLng(40.714086, -74.228697); private GoogleMap mMap; private GroundOverlay mGroundOverlay; private SeekBar mTransparencyBar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.ground_overlay_demo); mTransparencyBar = (SeekBar) findViewById(R.id.transparencySeekBar); mTransparencyBar.setMax(TRANSPARENCY_MAX); mTransparencyBar.setProgress(0); setUpMapIfNeeded(); } @Override protected void onResume() { super.onResume(); setUpMapIfNeeded(); } private void setUpMapIfNeeded() { if (mMap == null) { mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)) .getMap(); if (mMap != null) { setUpMap(); } } } private void setUpMap() { mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(NEWARK, 11)); mGroundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions() .image(BitmapDescriptorFactory.fromResource(R.drawable.newark_nj_1922)).anchor(0, 1) .position(NEWARK, 8600f, 6500f)); mTransparencyBar.setOnSeekBarChangeListener(this); } @Override public void onStopTrackingTouch(SeekBar seekBar) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (mGroundOverlay != null) { mGroundOverlay.setTransparency((float) progress / (float) TRANSPARENCY_MAX); } } }