本文整理匯總了Java中com.google.android.maps.GeoPoint類的典型用法代碼示例。如果您正苦於以下問題:Java GeoPoint類的具體用法?Java GeoPoint怎麽用?Java GeoPoint使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GeoPoint類屬於com.google.android.maps包,在下文中一共展示了GeoPoint類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: recenterMap
import com.google.android.maps.GeoPoint; //導入依賴的package包/類
private void recenterMap() {
if (DEBUG) Log.d(TAG, "Recentering map.");
GeoPoint center = mMyLocationOverlay.getMyLocation();
// if we have venues in a search result, focus on those.
if (mVenueItemizedOverlay != null && mVenueItemizedOverlay.size() > 0) {
if (DEBUG) Log.d(TAG, "Centering on venues: "
+ String.valueOf(mVenueItemizedOverlay.getLatSpanE6()) + " "
+ String.valueOf(mVenueItemizedOverlay.getLonSpanE6()));
mMapController.setCenter(mVenueItemizedOverlay.getCenter());
mMapController.zoomToSpan(mVenueItemizedOverlay.getLatSpanE6(), mVenueItemizedOverlay
.getLonSpanE6());
} else if (center != null
&& SearchVenuesActivity.searchResultsObservable.getQuery() == SearchVenuesActivity.QUERY_NEARBY) {
if (DEBUG) Log.d(TAG, "recenterMap via MyLocation as we are doing a nearby search");
mMapController.animateTo(center);
mMapController.zoomToSpan(center.getLatitudeE6(), center.getLongitudeE6());
} else if (center != null) {
if (DEBUG) Log.d(TAG, "Fallback, recenterMap via MyLocation overlay");
mMapController.animateTo(center);
mMapController.setZoom(16);
return;
}
}
示例2: recenterMap
import com.google.android.maps.GeoPoint; //導入依賴的package包/類
private void recenterMap() {
// Previously we'd try to zoom to span, but this gives us odd results a lot of times,
// so falling back to zoom at a fixed level.
GeoPoint center = mMyLocationOverlay.getMyLocation();
if (center != null) {
Log.i(TAG, "Using my location overlay as center point for map centering.");
mMapController.animateTo(center);
mMapController.setZoom(16);
} else {
// Location overlay wasn't ready yet, try using last known geolocation from manager.
Location bestLocation = GeoUtils.getBestLastGeolocation(this);
if (bestLocation != null) {
Log.i(TAG, "Using last known location for map centering.");
mMapController.animateTo(GeoUtils.locationToGeoPoint(bestLocation));
mMapController.setZoom(16);
} else {
// We have no location information at all, so we'll just show the map at a high
// zoom level and the user can zoom in as they wish.
Log.i(TAG, "No location available for map centering.");
mMapController.setZoom(8);
}
}
}
示例3: recenterMap
import com.google.android.maps.GeoPoint; //導入依賴的package包/類
private void recenterMap() {
// Previously we'd try to zoom to span, but this gives us odd results a lot of times,
// so falling back to zoom at a fixed level.
GeoPoint center = mMyLocationOverlay.getMyLocation();
if (center != null) {
mMapController.animateTo(center);
mMapController.setZoom(14);
} else {
// Location overlay wasn't ready yet, try using last known geolocation from manager.
Location bestLocation = GeoUtils.getBestLastGeolocation(this);
if (bestLocation != null) {
mMapController.animateTo(GeoUtils.locationToGeoPoint(bestLocation));
mMapController.setZoom(14);
} else {
// We have no location information at all, so we'll just show the map at a high
// zoom level and the user can zoom in as they wish.
Venue venue = mStateHolder.getVenues().get(0);
mMapController.animateTo(new GeoPoint(
(int)(Float.valueOf(venue.getGeolat()) * 1E6),
(int)(Float.valueOf(venue.getGeolong()) * 1E6)));
mMapController.setZoom(8);
}
}
}
示例4: onClick
import com.google.android.maps.GeoPoint; //導入依賴的package包/類
/** Called when a button has been clicked on by the user
* @param v Reference to the {@link android.view.View} of the button
*/
public void onClick(View v)
{
GeoPoint ownPoint;
// dispatch depending on button pressed
switch(v.getId())
{
case R.id.mapview_my_location:
ownPoint = ownLocation.getMyLocation();
if (ownPoint != null)
mapController.animateTo(ownPoint);
break;
case R.id.mapview_last_location:
mapController.animateTo(last_recorded_location); // then centre map at it and use different marker pin!
break;
}
}
示例5: MapOverlay
import com.google.android.maps.GeoPoint; //導入依賴的package包/類
MapOverlay(int color, GeoPoint[] points) {
mPaintPoint = new Paint();
mPaintPoint.setStyle(Paint.Style.FILL);
mPaintPoint.setShadowLayer(6, 3, 3, 0xff000000);
mPaintPoint.setColor(color);
mPaintPoint.setAntiAlias(true);
mPaintPointBorder = new Paint();
mPaintPointBorder.setStyle(Paint.Style.STROKE);
mPaintPointBorder.setColor(Color.BLACK);
mPaintPointBorder.setAntiAlias(true);
mPaintPointDot = new Paint();
mPaintPointDot.setStyle(Paint.Style.FILL);
mPaintPointDot.setColor(Color.BLACK);
mPaintPointDot.setAntiAlias(true);
this.setPointsToDraw(points);
}
示例6: draw
import com.google.android.maps.GeoPoint; //導入依賴的package包/類
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
super.draw(canvas, mapView, shadow);
if (shadow || pointsToDraw == null || pointsToDraw.length == 0)
return;
for (GeoPoint p : pointsToDraw) {
// convert point to pixels
Point screenPts = new Point();
GeoPoint pointToDraw = new GeoPoint(p.getLatitudeE6(),
p.getLongitudeE6());
mapView.getProjection().toPixels(pointToDraw, screenPts);
int pointRadius = (int) mapView.getProjection()
.metersToEquatorPixels(5);
int dotRadius = (int) mapView.getProjection()
.metersToEquatorPixels(2);
canvas.drawCircle(screenPts.x, screenPts.y, pointRadius,
mPaintPoint);
canvas.drawCircle(screenPts.x, screenPts.y, pointRadius,
mPaintPointBorder);
canvas.drawCircle(screenPts.x, screenPts.y, dotRadius,
mPaintPointDot);
}
return;
}
示例7: onStart
import com.google.android.maps.GeoPoint; //導入依賴的package包/類
@Override
protected void onStart()
{
super.onStart();
//locations.open();
Cursor c = locations.getAllLocations();
c.moveToFirst();
while (!c.isAfterLast())
{
adapter.add(c.getString(c.getColumnIndex(MyLocations.KEY_NAME)));
loc.add(new GeoPoint(c.getInt(c.getColumnIndex(MyLocations.KEY_LAT)), c.getInt(c.getColumnIndex(MyLocations.KEY_LON))));
rowID.add(new Integer(c.getInt(c.getColumnIndex(MyLocations.KEY_ROWID))));
stopid.add(new Integer(c.getInt(c.getColumnIndex("stopid"))));
c.moveToNext();
}
c.close();
}
示例8: requerry
import com.google.android.maps.GeoPoint; //導入依賴的package包/類
public void requerry()
{
//if (!locations.isOpen()) return;
adapter.clear();
loc.clear();
rowID.clear();
stopid.clear();
Cursor c = locations.getAllLocations();
c.moveToFirst();
while (!c.isAfterLast())
{
adapter.add(c.getString(c.getColumnIndex(MyLocations.KEY_NAME)));
loc.add(new GeoPoint(c.getInt(c.getColumnIndex(MyLocations.KEY_LAT)), c.getInt(c.getColumnIndex(MyLocations.KEY_LON))));
rowID.add(new Integer(c.getInt(c.getColumnIndex(MyLocations.KEY_ROWID))));
stopid.add(new Integer(c.getInt(c.getColumnIndex("stopid"))));
c.moveToNext();
}
c.close();
}
示例9: try_fetch
import com.google.android.maps.GeoPoint; //導入依賴的package包/類
void try_fetch(int routeid) throws Exception {
ArrayList<BusOverlay.BusLocation> bus_locs = new ArrayList<BusOverlay.BusLocation>();
JSONObject result = rpc(routeid);
if (result.isNull("d")) {
return;
}
JSONArray vehicles = result.getJSONArray("d");
for (int i = 0; i < vehicles.length(); i++) {
JSONObject vehicle = vehicles.getJSONObject(i);
double lat = vehicle.getDouble("lat");
double lng = vehicle.getDouble("lon");
int heading = vehicle.getInt("heading");
BusOverlay.BusLocation bus_loc = new BusOverlay.BusLocation();
bus_loc.loc = new GeoPoint(
(int) (lat*1E6),
(int) (lng*1E6));
bus_loc.heading = heading;
bus_locs.add(bus_loc);
}
publishProgress(bus_locs);
}
示例10: updateWithNewLocation
import com.google.android.maps.GeoPoint; //導入依賴的package包/類
private void updateWithNewLocation(Location location) {
// Update the map position and overlay
if (location != null) {
// Update my location marker
mapView.invalidate();
// Update the map location.
Double geoLat = location.getLatitude()*1E6;
Double geoLng = location.getLongitude()*1E6;
p = new GeoPoint(geoLat.intValue(), geoLng.intValue());
if(first_time == true) {
mc.animateTo(p);
mc.setZoom(17);
first_time = false;
}
}
}
示例11: onCreate
import com.google.android.maps.GeoPoint; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
/**
* To show a map of San Francisco, we need to create a geo point object
* with longitude and latitude in center of SF.
*/
GeoPoint point = new GeoPoint(37779300, -122419200);
/**
* MapController is needed to set view location and zooming.
*/
MapController mc = mapView.getController();
mc.setCenter(point);
mc.setZoom(14);
}
示例12: setLocText
import com.google.android.maps.GeoPoint; //導入依賴的package包/類
private void setLocText(final GeoPoint gp, final boolean change) {
pHandler.removeCallbacks(prevRunnable);
prevRunnable = new Runnable() {
@Override
public void run() {
final String ftext = mFormatUtil.getLocText(gp);
runOnUiThread(new Runnable() {
public void run() {
if (change) {
locText.setText(ftext);
} else {
((TextView) locText.getCurrentView())
.setText(ftext);
}
}
});
}
};
pHandler.postDelayed(prevRunnable, 20);
}
示例13: onActivityResult
import com.google.android.maps.GeoPoint; //導入依賴的package包/類
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == REQUEST_BOOKMARK_LIST && resultCode == Activity.RESULT_OK){
int lat = data.getIntExtra("lat", 0);
int lon = data.getIntExtra("lon", 0);
final GeoPoint gp = new GeoPoint(lat,lon);
mMapView.getController().animateTo(gp, new Runnable() {
public void run() {
mPin.setPosition(gp);
}
});
}
}
示例14: getLocCopy
import com.google.android.maps.GeoPoint; //導入依賴的package包/類
public String getLocCopy(GeoPoint gp) {
MessageFormat formatter = new MessageFormat("{0}, {1}");
String result;
if (mGeoFormat == FORMAT_DEGREES_MINUTES_SECONDS) {
result = formatter.format(new Object[] {
FormatUtil.getFormatedLat(gp.getLatitudeE6()),
FormatUtil.getFormatedLon(gp.getLongitudeE6())});
} else {
DecimalFormat df = new DecimalFormat("###.######");
String latStr = df.format(gp.getLatitudeE6() / 1e6D);
String lonStr = df.format(gp.getLongitudeE6() / 1e6D);
result = formatter.format(new Object[] {latStr, lonStr});
}
return result;
}
示例15: addMarker
import com.google.android.maps.GeoPoint; //導入依賴的package包/類
@Override
public void addMarker(final Marker aMarker) {
if (mItemizedOverlay == null) {
mItemizedOverlay = new GoogleItemizedOverlay(mMapView.getContext().getResources().getDrawable(R.drawable.marker_default));
mMapView.getOverlays().add(mItemizedOverlay);
}
final OverlayItem item = new OverlayItem(new GeoPoint((int)(aMarker.latitude*1E6), (int)(aMarker.longitude*1E6)), aMarker.title, aMarker.snippet);
if (aMarker.bitmap != null || aMarker.icon != 0) {
final Drawable drawable = aMarker.bitmap != null
? new BitmapDrawable(mMapView.getResources(), aMarker.bitmap)
: mMapView.getResources().getDrawable(aMarker.icon);
if (aMarker.anchor == Marker.Anchor.CENTER) {
GoogleItemizedOverlay.setOverlayMarkerCentered(item, drawable);
} else {
item.setMarker(drawable);
}}
mItemizedOverlay.addOverlay(item);
}