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


Java Location.getLongitude方法代码示例

本文整理汇总了Java中android.location.Location.getLongitude方法的典型用法代码示例。如果您正苦于以下问题:Java Location.getLongitude方法的具体用法?Java Location.getLongitude怎么用?Java Location.getLongitude使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.location.Location的用法示例。


在下文中一共展示了Location.getLongitude方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onListItemClick

import android.location.Location; //导入方法依赖的package包/类
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    Location loc = (Location) l.getAdapter().getItem(position);
    Toast.makeText(this, loc.getLatitude() + " " + loc.getLongitude(), Toast.LENGTH_SHORT).show();

    //simplesmente centraliza o mapa na latitude/longitude escolhida
    //nao amarra com google maps
    String locData = "geo:"+loc.getLatitude()+","+loc.getLongitude();

    //abre streetview
    locData = "google.streetview:cbll="+loc.getLatitude()+","+loc.getLongitude();

    //abre navigation
    //locData = "google.navigation:q="+loc.getLatitude()+","+loc.getLongitude();

    Uri locationURI = Uri.parse(locData);

    Intent i = new Intent(Intent.ACTION_VIEW, locationURI);
    if (i.resolveActivity(getPackageManager()) != null) {
        startActivity(i);
    }
}
 
开发者ID:if710,项目名称:2017.2-codigo,代码行数:23,代码来源:FusedLocationActivity.java

示例2: onLocationChanged

import android.location.Location; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location location) {

    currentLatitude = location.getLatitude();
    currentLongitude = location.getLongitude();

    //Toast.makeText(this, currentLatitude + " WORKS " + currentLongitude + "", Toast.LENGTH_LONG).show();

    LatLng latLng = new LatLng(currentLatitude, currentLongitude);
    googleMap.addMarker(new MarkerOptions().position(latLng));
    googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));
    googleMap.animateCamera(CameraUpdateFactory.zoomIn());
    googleMap.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null);

    getNearByClinics(currentLongitude, currentLatitude);

}
 
开发者ID:webianks,项目名称:Crimson,代码行数:18,代码来源:SearchClinics.java

示例3: getCurrentLocation

import android.location.Location; //导入方法依赖的package包/类
private void getCurrentLocation() {
    mMap.clear();
    if(ActivityCompat.checkSelfPermission(this,android.Manifest.permission.ACCESS_FINE_LOCATION)!= PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this,android.Manifest.permission.ACCESS_COARSE_LOCATION)!=PackageManager.PERMISSION_GRANTED )
    {
        //Creating a location object
        return ;}
    Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
    if (location != null) {
        //Getting longitude and latitude
        longitude = location.getLongitude();
        latitude = location.getLatitude();

        //moving the map to location
        moveMap();
    }
}
 
开发者ID:ayushghd,项目名称:iSPY,代码行数:17,代码来源:MyLocation.java

示例4: gotoLocation

import android.location.Location; //导入方法依赖的package包/类
/**
 * For actually moving the map to the desired location.
 * @param fctx
 * @param loc
 */
public static void gotoLocation(Activity fctx, Location loc) {
    Location locc = loc;
    sloc = loc;
    if(loc == null){
        locc = getCurrentLocation(fctx);
    }
    if(code == AddHabitEventActivity.EVENT_PERMISSION_CHECK){
    }

    float zoom = 15.0f;
    if(locc == null){
        DummyMainActivity.toastMe("Could not get location", fctx);
    }else{
        double[] d = {locc.getLatitude(), locc.getLongitude()};
        AddHabitEventActivity.setLocation(d);

        LatLng ll = new LatLng(locc.getLatitude(), locc.getLongitude());
        CameraUpdate update = CameraUpdateFactory.newLatLngZoom(ll, zoom);
        gmap.moveCamera(update);
    }
}
 
开发者ID:CMPUT301F17T17,项目名称:Habitizer,代码行数:27,代码来源:MapController.java

示例5: getLocation

import android.location.Location; //导入方法依赖的package包/类
public static String getLocation(Context context) {
    if (context == null) {
        return "";
    }
    try {
        LocationManager locationManager = (LocationManager) context.getSystemService(HOME_RECOMMEND_PARAMETERS.LOCATION);
        Criteria criteria = new Criteria();
        criteria.setCostAllowed(false);
        criteria.setAccuracy(2);
        String bestProvider = locationManager.getBestProvider(criteria, true);
        if (bestProvider != null) {
            Location lastKnownLocation = locationManager.getLastKnownLocation(bestProvider);
            if (lastKnownLocation == null) {
                return "";
            }
            double latitude = lastKnownLocation.getLatitude();
            g = latitude + "*" + lastKnownLocation.getLongitude();
            return g;
        }
    } catch (Throwable e) {
        f.b("getLocation", "getLocation>>>", e);
    }
    return "";
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:25,代码来源:Util.java

示例6: checkInterval

import android.location.Location; //导入方法依赖的package包/类
private void checkInterval(Location location) {
        if (location == null) {
            return;
        }
        if (!isValidState()) {
            distanceInterval = 0;
            recentSpeed = 0;
            return;
        }
        recentSpeed = location.getSpeed();
        if (!isValidSpeed()) {
            return;
        }
        double distance = 0;
        if (prevLatitude != location.getLatitude()
         || prevLongitude != location.getLongitude()) {
            distance = calcDistance(location);
        }
// enable fake speed for tests:
        if (BuildConfig.FAKE) {
            distance += 20;
        }
        prevLatitude = location.getLatitude();
        prevLongitude = location.getLongitude();
        prevAltitude = location.getAltitude();
        if (distance < intervalLength) {
            distanceInterval += distance;
        } else {
            sendOnIntervalChanged(distanceInterval, false);
            distanceInterval = 0;
            return;
        }
        if (distanceInterval >= intervalLength) {
            boolean correctData = distanceInterval < MAX_DISTANCE;
            sendOnIntervalChanged(distanceInterval, correctData);
            distanceInterval = 0;
        }
    }
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:39,代码来源:GPSDetector.java

示例7: LocSample

import android.location.Location; //导入方法依赖的package包/类
LocSample(Location l) {
    super();
    Latitude = l.getLatitude();
    Longitude = l.getLongitude();
    Alt = (int) (l.getAltitude() * MFBConstants.METERS_TO_FEET);
    Speed = l.getSpeed() * MFBConstants.MPS_TO_KNOTS;
    HError = l.getAccuracy();
    TimeStamp.setTime(l.getTime());
    TZOffset = 0;
}
 
开发者ID:ericberman,项目名称:MyFlightbookAndroid,代码行数:11,代码来源:LocSample.java

示例8: onLocationChanged

import android.location.Location; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location location) {
    Log.e("lococococ", String.valueOf(location.getLatitude()));
    latlong=location.getLatitude()+","+location.getLongitude();
    lat=location.getLatitude();
    longi=location.getLongitude();
    go();

}
 
开发者ID:iamjaspreetsingh,项目名称:LifeSaver,代码行数:10,代码来源:MainActivity.java

示例9: setLatLong

import android.location.Location; //导入方法依赖的package包/类
public void setLatLong(Location location) {
    double lastLat = location.getLatitude();
    double lastLong = location.getLongitude();
    SharedPreferences.Editor edit = preferences.edit();
    edit.putString("last_gps_lat", String.valueOf(lastLat));
    edit.putString("last_gps_long", String.valueOf(lastLong));
    edit.apply();
}
 
开发者ID:MTBehnke,项目名称:NightSkyGuide,代码行数:9,代码来源:MainActivity.java

示例10: onLocationChanged

import android.location.Location; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location l) {
    if (l != null) {
        userLocation = new LatLng(l.getLatitude(), l.getLongitude());
        if (mUser.getUserID() != null) {
            mDatabase.child("users").child(mUser.getUserID()).child("latitude").setValue(userLocation.latitude);
            mDatabase.child("users").child(mUser.getUserID()).child("longitude").setValue(userLocation.longitude);
        } else {
            Toast.makeText(getApplicationContext(), "Current user not recognized. Try reauthenticating.",
                    Toast.LENGTH_LONG).show();
        }
    }
}
 
开发者ID:panzerama,项目名称:Dispatch,代码行数:14,代码来源:LocationUpdaterService.java

示例11: contains

import android.location.Location; //导入方法依赖的package包/类
/**
 * @param point {@link Location} object
 * @return location contains in box
 */
public boolean contains(Location point) {
    return point.getLatitude() >= minLatitude
            && point.getLongitude() >= minLongitude
            && point.getLatitude() <= maxLatitude
            && point.getLongitude() <= maxLongitude;
}
 
开发者ID:drfonfon,项目名称:android-geohash,代码行数:11,代码来源:BoundingBox.java

示例12: locationUpdates

import android.location.Location; //导入方法依赖的package包/类
@Override
public void locationUpdates(Location location)
{
    double currentLatitude = location.getLatitude();
    double currentLongitude = location.getLongitude();

    Toast.makeText(MainActivity.this, "Latitude: " + currentLatitude + "" + " Longitude: " + currentLongitude + "", Toast.LENGTH_LONG).show();

}
 
开发者ID:yash786agg,项目名称:GPS,代码行数:10,代码来源:MainActivity.java

示例13: onLocationChanged

import android.location.Location; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location location) {
    float latitude = (float) location.getLatitude();
    float longitude = (float) location.getLongitude();
    float altitude = (float) location.getAltitude();

    for (SensorInfo sensorInfo : sensorInfos) {
        if (sensorInfo.getType() == SensorType.GPS) {
            sensorInfo.setValues(new float[]{latitude, longitude, altitude});
            break;
        }
    }
}
 
开发者ID:SKT-ThingPlug,项目名称:thingplug-sdk-android,代码行数:14,代码来源:SensorListener.java

示例14: onLocationChanged

import android.location.Location; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location location) {
    Log.d("onLocationChanged", "entered");

    mLastLocation = location;
    if (mCurrLocationMarker != null) {
        mCurrLocationMarker.remove();
    }

    //Place current location marker
    latitude = location.getLatitude();
    longitude = location.getLongitude();
    LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(latLng);
    markerOptions.title("Current Position");
    markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
    mCurrLocationMarker = mMap.addMarker(markerOptions);

    //move map camera
    mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
    mMap.animateCamera(CameraUpdateFactory.zoomTo(11));
    Toast.makeText(MapsActivity2.this,"Your Current Location", Toast.LENGTH_LONG).show();

    Log.d("onLocationChanged", String.format("latitude:%.3f longitude:%.3f",latitude,longitude));

    //stop location updates
    if (mGoogleApiClient != null) {
        LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
        Log.d("onLocationChanged", "Removing Location Updates");
    }
    Log.d("onLocationChanged", "Exit");

}
 
开发者ID:ayushghd,项目名称:iSPY,代码行数:35,代码来源:MapsActivity2.java

示例15: checkIsDataAvailableForRecord

import android.location.Location; //导入方法依赖的package包/类
private boolean checkIsDataAvailableForRecord() {
    GPSDetector gpsDetector = getGPSDetector();
    if (gpsDetector == null ||
       !gpsDetector.isValidSpeed() || !gpsDetector.isValidState()) {
        return false;
    }
    Location loc = gpsDetector.getLocation();
    if (loc == null) {
        return false;
    }
    double latitude = loc.getLatitude();
    double longitude = loc.getLongitude();
    double altitude = loc.getAltitude();
    curSpeed = loc.getSpeed();
    double distance = 0;
    if (latitude >= 0 && longitude >= 0) {
        distance = calcDistance(latitude, longitude);
        if (curLatitude != latitude && curLongitude != longitude) {
            curLatitude = latitude;
            curLongitude = longitude;
            curAltitude = altitude;
            //Log.d(TAG, "curLatitude= " + curLatitude + ", curLongitude= "
            //+ curLongitude + ", distance= " + distance);
        }
    }
    if (distance >= MIN_DISTANCE) {
        curDistance = distance;
        Log.d(TAG, "data available for record, distance= " + distance);
        return true;
    }
    return false;
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:33,代码来源:GeoTagTracker.java


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