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


Java Place.getLatLng方法代码示例

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


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

示例1: updateGeofencesList

import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
/**
 * Updates the local {@link ArrayList} of geofences from the data in the passed list
 *Uses the place id defined by the API as the geofence object id.
 *
 * @param places the placeBuffer result of the getPlaceByid call.
 */
public void updateGeofencesList(PlaceBuffer places){
    mGeofenceList = new ArrayList<>();
    if (places==null || places.getCount()==0) return;
    for (Place place: places){
        String placeUid = place.getId();
        double latitude = place.getLatLng().latitude;
        double longitude = place.getLatLng().longitude;
        //Build a geofence object
        Geofence geofence = new Geofence.Builder()
                .setRequestId(placeUid)
                .setExpirationDuration(GEOFENCE_TIMEOUT)
                .setCircularRegion(latitude,longitude,GEOFENCE_RADIUS)
                .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT)
                .build();
        mGeofenceList.add(geofence);
    }
}
 
开发者ID:samagra14,项目名称:Shush,代码行数:24,代码来源:Geofencing.java

示例2: onSuggestResult

import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
@Override
public void onSuggestResult(final Place place, final AutoCompleteTextView act) {
	final LatLng placelatlng=place.getLatLng();
	if (!isNavigationReady() && (addr_from.getText().length() < 1 || addr_to.getText().length() < 1))
		gmaps.animateCamera(CameraUpdateFactory.newLatLng(place.getLatLng()), 1000, new GoogleMap.CancelableCallback(){
				@Override
				public void onFinish() {
					setAddrValue(act == addr_from ?addr_from: addr_to, placelatlng);
				}

				@Override
				public void onCancel() {
					setAddrValue(act == addr_from ?addr_from: addr_to, placelatlng);
				}
			});
	else setAddrValue(act == addr_from ?addr_from: addr_to, placelatlng);
}
 
开发者ID:agusibrahim,项目名称:go-jay,代码行数:18,代码来源:MainActivity.java

示例3: onActivityResult

import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            Place pl = PlaceAutocomplete.getPlace(this, data);
            location.setText(pl.getName());
            currentTrip.location = pl.getName().toString();
            currentTrip.lat = pl.getLatLng().latitude;
            currentTrip.lng = pl.getLatLng().longitude;
            currentTrip.placeId = pl.getId();

            Log.i(TAG, "onActivityResult: " + pl.getName() + "/" + pl.getAddress());

        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status stat = PlaceAutocomplete.getStatus(this, data);
            Log.d(TAG, "onActivityResult: ");
        }
        else if (requestCode == RESULT_CANCELED){
            System.out.println("Cancelled by the user");
        }
    }
    else
        super.onActivityResult(requestCode, resultCode, data);
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:25,代码来源:NewJournalActivity.java

示例4: onActivityResult

import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_LOCATION) {
        final LocationSettingsStates states = LocationSettingsStates.fromIntent(data);
        if (resultCode == Activity.RESULT_OK) {
            Toast.makeText(getApplicationContext(), R.string.location_enabled, Toast.LENGTH_LONG).show();
            startLocationUpdates();
        } else {
            Toast.makeText(getApplicationContext(), "Loc is still off,", Toast.LENGTH_LONG).show();
        }
    } else if (requestCode == PLACE_PICKER_REQUEST) {
        if (resultCode == RESULT_OK) {
            Place place = PlacePicker.getPlace(data, this);
            double lat = place.getLatLng().latitude;
            double lon = place.getLatLng().longitude;
            setMyLocationToSharePref((float) lat, (float) lon);
            setMyAddress(this, place.getAddress().toString());
            Location newLoc = new Location("");
            newLoc.setLatitude(lat);
            newLoc.setLongitude(lon);
            EventBus.getDefault().post(newLoc);

        }
    }
}
 
开发者ID:shivarajp,项目名称:LivePokemonFinder,代码行数:26,代码来源:MainActivity.java

示例5: onActivityResult

import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
public void onActivityResult(final Activity activity, final int requestCode, final int resultCode, final Intent data) {
    if (mCallback == null || requestCode != REQUEST_PLACE_PICKER) {
        return;
    }
    response = Arguments.createMap();
    if (resultCode == 2) {
        response.putString("error", "Google Maps not setup correctly. Did you forget the API key, or enabling the Places API for Android?");
        mCallback.invoke(response);
    } else if (resultCode == Activity.RESULT_OK) {
        final Place place = PlacePicker.getPlace(data, reactContext);
        final CharSequence address = place.getAddress();
        final LatLng coordinate = place.getLatLng();
        final CharSequence name = place.getName();
        final CharSequence id = place.getId();
        response.putString("address", address.toString());
        response.putDouble("latitude", coordinate.latitude);
        response.putDouble("longitude", coordinate.longitude);
        response.putString("name", name.toString());
        response.putString("google_id", id.toString());
        mCallback.invoke(response);
    } else {
        response.putBoolean("didCancel", true);
        mCallback.invoke(response);
        return;
    }
}
 
开发者ID:zhangtaii,项目名称:react-native-google-place-picker,代码行数:27,代码来源:RNGooglePlacePickerModule.java

示例6: Station

import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
public Station(Place place){
    List<Integer> types = place.getPlaceTypes();
    boolean isGasStation = false;
    for (Integer i: types){
        if(i==Place.TYPE_GAS_STATION){
            isGasStation = true;
            break;
        }
    }
    if(isGasStation){
        id = place.getId();
        name = place.getName().toString();
        address = place.getAddress().toString();
        phoneNumber = place.getPhoneNumber().toString();
        Location l = new Location(place.getLatLng().latitude,place.getLatLng().longitude);
        location = l;
        generalRate = place.getRating();
        moneyRate = place.getPriceLevel();
    } else {
        throw new IllegalArgumentException("Place is not a gas station.");
    }
}
 
开发者ID:Gaso-UFS,项目名称:gaso,代码行数:23,代码来源:Station.java

示例7: onActivityResult

import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_PLACE_PICKER) {
        // This result is from the PlacePicker dialog.

        if (resultCode == Activity.RESULT_OK) {
            // retrieve latitude and longitude from result data
            final Place place = PlacePicker.getPlace(data, this);
            LatLng latLng = place.getLatLng();
            Log.i(TAG, "Lat: " + latLng.latitude + " Lon: " + latLng.longitude);

            onLocationPicked(latLng);
        }
    } else if (requestCode == REQUEST_RESOLVE_ERROR) {
        // This result is from the google play services error resolution intent

        resolvingError = false;
        if (resultCode == RESULT_OK) {
            Snackbar.make(snackbarCoordinator, R.string.resolution_successful,
                    Snackbar.LENGTH_LONG).show();
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:maciekjanusz,项目名称:compass-project,代码行数:26,代码来源:CompassActivity.java

示例8: fromPlace

import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
public static PlaceModel fromPlace(Place place) {
    PlaceModel placeModel = new Select().from(PlaceModel.class)
                                        .where(PlaceContract.Columns.GOOGLE_ID + " = ?", place.getId())
                                        .executeSingle();
    if (placeModel == null) {
        placeModel = new PlaceModel();
        placeModel.googleID = place.getId();
        placeModel.address = place.getAddress().toString();
        placeModel.latitude = place.getLatLng().latitude;
        placeModel.longitude = place.getLatLng().longitude;
        placeModel.name = place.getName().toString();
        placeModel.saveWithAudit();
    }

    return placeModel;
}
 
开发者ID:SenAndAaron,项目名称:voyager2-android,代码行数:17,代码来源:PlaceModel.java

示例9: onPlaceSelected

import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
@Override
public void onPlaceSelected(Place place) {
    String name = place.getName().toString();
    mTargetLocation = place.getLatLng();
    Log.i("LocationInfo", name + "\n" + mTargetLocation.toString());
    makeMarker(name);
}
 
开发者ID:OldBigBuddha,项目名称:AlarmWithL-T,代码行数:8,代码来源:SettingFragment.java

示例10: fromPlace

import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
public static PointOfInterest fromPlace(Place place) {
    PointOfInterest pointOfInterest = new PointOfInterest();
    pointOfInterest.id = place.getId();
    pointOfInterest.name = place.getName().toString();
    pointOfInterest.address = place.getAddress().toString();
    pointOfInterest.latLng = place.getLatLng();
    pointOfInterest.phoneNumber = place.getPhoneNumber().toString();
    pointOfInterest.latLngBounds = place.getViewport();
    return pointOfInterest;
}
 
开发者ID:sathishmscict,项目名称:Pickr,代码行数:11,代码来源:PointOfInterest.java

示例11: onActivityResult

import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    try {
        if (requestCode == REQUEST_CODE_PICKER && resultCode == RESULT_OK && data != null) {
            ArrayList<Image> dat = data.getParcelableArrayListExtra(ImagePickerActivity.INTENT_EXTRA_SELECTED_IMAGES);
            renderViewImage(dat);
        }
        else if (requestCode == PLACE_PICKER_REQUEST) {
            if (resultCode == RESULT_OK) {
                Place place = PlacePicker.getPlace(AddActivity.this, data);
                String placename = String.format("%s", place.getName());
                latitude = place.getLatLng().latitude;
                longitude = place.getLatLng().longitude;
                location_name.setText("" + placename);
                Toast.makeText(AddActivity.this, "You Select: " + placename, Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(this, "You Haven't Select Any Places", Toast.LENGTH_LONG).show();

            }
        }


    } catch (Exception e) {
        Toast.makeText(this, "Something went wrong", Toast.LENGTH_LONG).show();
        Log.d("Additem_Activity", "onActivityResult: " + e);
    }


}
 
开发者ID:Elbehiry,项目名称:Viajes,代码行数:29,代码来源:AddActivity.java

示例12: onActivityResult

import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    StorageReference storageRef = storage.getReferenceFromUrl(Utils.URL_STORAGE_REFERENCE).child(Utils.FOLDER_STORAGE_IMG);

    if (requestCode == IMAGE_GALLERY_REQUEST) {
        if (resultCode == RESULT_OK) {
            Uri selectedImageUri = data.getData();
            if (selectedImageUri != null) {
                sendFileFirebase(storageRef, selectedImageUri);
            }
        }
    }
    else if (requestCode == IMAGE_CAMERA_REQUEST) {
        if (resultCode == RESULT_OK) {
            if (filePathImageCamera != null && filePathImageCamera.exists()) {
                StorageReference imageCameraRef = storageRef.child(filePathImageCamera.getName() + "_camera");
                sendFileFirebase(imageCameraRef, filePathImageCamera);
            }
        }
    }
    else if (requestCode == PLACE_PICKER_REQUEST) {
        if (resultCode == RESULT_OK) {
            Place place = PlacePicker.getPlace(this, data);
            if (place != null) {
                LatLng latLng = place.getLatLng();
                MapModel mapModel = new MapModel(latLng.latitude + "", latLng.longitude + "");
                ChatModel chatModel = new ChatModel(userModel, Calendar.getInstance().getTime().getTime() + "", mapModel);
                mFirebaseDatabaseReference.child(room).push().setValue(chatModel);
            }
        }
    }


}
 
开发者ID:sega4revenge,项目名称:Sega,代码行数:36,代码来源:ChatActivity.java

示例13: onActivityResult

import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case LOCATION_NAME_REQUEST:

            if (resultCode == RESULT_OK) {
                Log.d(TAG, "Add city name request to queue");

                Place place = PlaceAutocomplete.getPlace(getActivity(), data);
                LatLng coords = place.getLatLng();

                cityAddQueue.add(new CityCoordinatesModel(place.getName().toString(),
                        coords.latitude, coords.longitude));

                if (!isRefreshing && !isAddQueueHandling) {
                    Log.d(TAG, "Start new city name request queue");

                    makeCityNameWeatherRequest();
                }

                isAddQueueHandling = true;

            } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
                Status status = PlaceAutocomplete.getStatus(getActivity(), data);

                Log.d(TAG, status.getStatusMessage());
            }

            break;
    }
}
 
开发者ID:farukydnn,项目名称:WeatherPlus,代码行数:32,代码来源:CityListFragment.java

示例14: onActivityResult

import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_PICKER_REQUEST) {
        if (resultCode == RESULT_OK) {
            Place place = PlacePicker.getPlace(data, this);
            String toastMsg = String.format("Place: %s", place.getName());
            Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show();
            location = place.getLatLng();
            title.setText(place.getName());
        } else {
            finish();
        }
    }
}
 
开发者ID:RobinCaroff,项目名称:MyGeofencer,代码行数:14,代码来源:AddGeofenceActivity.java

示例15: onActivityResult

import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == Constants.REQUEST_CODE_PLACE_PICKER) {
        if (resultCode == Activity.RESULT_OK) {
            Place place = PlacePicker.getPlace(data, getActivity());
            if (place == null) {
                return;
            }
            // The place picker presents two selection options: "select this location" and
            // "nearby places". Only the nearby places selection returns a placeId we can
            // submit to the service; the location selection will return a hex-like 0xbeef
            // identifier for that position instead, which isn't what we want. Here we check
            // if the entire string is hex and clear the placeId if it is.
            String id = place.getId();
            if (id.startsWith("0x") && id.matches("0x[0-9a-f]+")) {
                placeId.setText("");
                beaconInstance.placeId = "";
            } else {
                placeId.setText(id);
                beaconInstance.placeId = id;
            }
            LatLng placeLatLng = place.getLatLng();
            latLng.setText(placeLatLng.toString());
            beaconInstance.latitude = placeLatLng.latitude;
            beaconInstance.longitude = placeLatLng.longitude;
            updateBeacon();
        } else {
            logErrorAndToast("Error loading place picker. Is the Places API enabled? "
                    + "See https://developers.google.com/places/android-api/signup for more detail");
        }
    }
}
 
开发者ID:cullengao,项目名称:BeeksBeacon,代码行数:33,代码来源:ManageBeaconFragment.java


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