本文整理匯總了Java中com.baidu.mapapi.model.LatLng類的典型用法代碼示例。如果您正苦於以下問題:Java LatLng類的具體用法?Java LatLng怎麽用?Java LatLng使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LatLng類屬於com.baidu.mapapi.model包,在下文中一共展示了LatLng類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: locationReceiveAddress
import com.baidu.mapapi.model.LatLng; //導入依賴的package包/類
/**
* 定位接收到的地址
**/
private void locationReceiveAddress() {
if (receiveAddress == null) {
return;
}
LatLng p = new LatLng(receiveAddress.getLatitude(), receiveAddress.getLongitude());
MarkerOptions markerOptions = new MarkerOptions();
/* 設置覆蓋物圖標 */
markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_openmap_focuse_mark))
.position(p)
.visible(true);
baiduMap.setOnMarkerClickListener(new BaiduMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
setSinglePoiDetail();
return true;
}
});
if (NetUtil.getInstance(SetFavoriteMapActivity.this).getCurrentNetType().equals(NetUtil.NetType.NETWORK_TYPE_NONE)) {
// Snackbar.make(mAmosfPoiList,mAppConfig.getResources().getString(R.string.no_network), Snackbar.LENGTH_SHORT).show();
return;
}
/* 添加覆蓋圖層 */
baiduMap.addOverlay(markerOptions);
baiduMap.setMapStatus(MapStatusUpdateFactory.newLatLngZoom(p, 17F));
}
示例2: addOverLayout
import com.baidu.mapapi.model.LatLng; //導入依賴的package包/類
private void addOverLayout(double _latitude, double _longitude) {
//先清除圖層
mBaiduMap.clear();
mlocationClient.requestLocation();
// 定義Maker坐標點
LatLng point = new LatLng(_latitude, _longitude);
// 構建MarkerOption,用於在地圖上添加Marker
MarkerOptions options = new MarkerOptions().position(point)
.icon(dragLocationIcon);
// 在地圖上添加Marker,並顯示
mBaiduMap.addOverlay(options);
infos.clear();
infos.add(new BikeInfo(_latitude - new Random().nextInt(5) * 0.0005, _longitude - new Random().nextInt(5) * 0.0005, R.mipmap.bike_mobai, "001",
"100米", "1分鍾"));
infos.add(new BikeInfo(_latitude - new Random().nextInt(5) * 0.0005, _longitude - new Random().nextInt(5) * 0.0005, R.mipmap.bike_youbai, "002",
"200米", "2分鍾"));
infos.add(new BikeInfo(_latitude - new Random().nextInt(5) * 0.0005, _longitude - new Random().nextInt(5) * 0.0005, R.mipmap.bike_ofo, "003",
"300米", "3分鍾"));
infos.add(new BikeInfo(_latitude - new Random().nextInt(5) * 0.0005, _longitude - new Random().nextInt(5) * 0.0005, R.mipmap.bike_xiaolan, "004",
"400米", "4分鍾"));
BikeInfo bikeInfo = new BikeInfo(_latitude - 0.0005, _longitude - 0.0005, R.mipmap.bike_xiaolan, "005",
"50米", "0.5分鍾");
infos.add(bikeInfo);
addInfosOverlay(infos);
initNearestBike(bikeInfo, new LatLng(_latitude - 0.0005, _longitude - 0.0005));
}
示例3: startBikingNavi
import com.baidu.mapapi.model.LatLng; //導入依賴的package包/類
/**
* 啟動百度地圖騎行導航(Native)
*/
private static void startBikingNavi(Activity activity, LatLng startLL, LatLng endLL) {
//距離太近toast提示(100米內)
double dis = DistanceUtil.getDistance(new LatLng(startLL.latitude, startLL.longitude), new LatLng(endLL.latitude, endLL.longitude));
if (dis <= 100) {
Toast.makeText(activity, "起點、途經點、終點距離太近", Toast.LENGTH_SHORT).show();
return;
}
// 構建 導航參數
NaviParaOption para = new NaviParaOption()
.startPoint(startLL).endPoint(endLL);
try {
BaiduMapNavigation.openBaiduMapBikeNavi(para, activity);
} catch (BaiduMapAppNotSupportNaviException e) {
e.printStackTrace();
}
}
示例4: startNative_Baidu
import com.baidu.mapapi.model.LatLng; //導入依賴的package包/類
/**
* 通過Uri跳轉到百度地圖導航
*/
public static void startNative_Baidu(Activity activity, LatLng pt1, LatLng pt2, String start_address, String end_address) {
try {
double dis = DistanceUtil.getDistance(new LatLng(pt1.latitude,pt1.longitude), new LatLng(pt2.latitude,pt2.longitude));
if (dis <= 100) {
Toast.makeText(activity, "起點、途經點、終點距離太近", Toast.LENGTH_SHORT).show();
return;
}
String start_latlng = pt1.latitude + "," + pt1.longitude;
String end_latlng = pt2.latitude + "," + pt2.longitude;
Intent intent = Intent.getIntent("intent://map/direction?origin=latlng:"+start_latlng+"|name:"+"Start"+"&destination=latlng:"+end_latlng+"|name:"+"End"+"&mode=riding&src=這裏隨便寫#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end");
Log.d("gaolei", "---------------" + start_address + "," + end_address);
activity.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(activity, "地址解析錯誤", Toast.LENGTH_SHORT).show();
}
}
示例5: startGaodeNavi
import com.baidu.mapapi.model.LatLng; //導入依賴的package包/類
/**
* 啟動高德地圖駕車路線規劃
*/
public static void startGaodeNavi(Activity activity, LatLng pt1, LatLng pt2, String start_place) {
try {
Intent intent = new Intent();
double sLat = pt1.latitude, sLon = pt1.longitude, eLat = pt2.latitude, eLon = pt2.longitude;
String poiAddress = LocationManager.getInstance().getAddress();
Log.d("gaolei", "poiAddress---------gaode-----------" + poiAddress);
intent.setData(android.net.Uri
.parse("androidamap://navi?sourceApplication=yongche&poiname=" + start_place + "&lat="
+ eLat
+ "&lon="
+ eLon + "&dev=0&style=2"));
intent.addCategory("android.intent.category.DEFAULT");
intent.setPackage("com.autonavi.minimap");
activity.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
示例6: setListReverse
import com.baidu.mapapi.model.LatLng; //導入依賴的package包/類
/**
* 將所有BaiduAddress對象信息填充到poi搜索信息集合中
**/
public void setListReverse() {
int al = aList.size();
list.clear();
int l = Math.min(al, 10);
for (int i = 0; i < l; i++) {
PoiInfo poiInfo = new PoiInfo();
poiInfo.name = aList.get(i).getName();
poiInfo.uid = aList.get(i).getUid();
poiInfo.address = aList.get(i).getAddress();
poiInfo.city = aList.get(i).getCity();
poiInfo.phoneNum = aList.get(i).getPhoneNum();
poiInfo.postCode = aList.get(i).getPostCode();
poiInfo.type = PoiInfo.POITYPE.POINT;
poiInfo.location = new LatLng(aList.get(i).getLatitude(), aList.get(i).getLongitude());
list.add(poiInfo);
}
}
示例7: onBindViewHolder
import com.baidu.mapapi.model.LatLng; //導入依賴的package包/類
@Override
public void onBindViewHolder(NaviPointHolder holder, int position) {
PoiInfo poiInfo = list.get(position);
holder.mTpiNameText.setText((position + 1) + "." + poiInfo.name);
holder.mTpiAddressText.setText(poiInfo.address);
if (addMode) {
holder.mTpiItemConfirmText.setText("添加");
holder.mTpiDistanceText.setVisibility(View.GONE);
} else {
holder.mTpiItemConfirmText.setText("出發");
holder.mTpiDistanceText.setVisibility(View.VISIBLE);
double distance = DistanceUtil.getDistance(new LatLng(address.getLatitude(), address.getLongitude()),
poiInfo.location) / 1000;
holder.mTpiDistanceText.setText(String.format("%.1f", distance) + "km");
}
holder.mTpiTargetConfirmBt.setTag(position);
holder.itemView.setTag(position);
}
示例8: setListReverse
import com.baidu.mapapi.model.LatLng; //導入依賴的package包/類
public void setListReverse() {
int al = aList.size();
poiInfoList.clear();
int l = Math.min(al, 10);
for (int i = 0; i < l; i++) {
PoiInfo poiInfo = new PoiInfo();
poiInfo.name = aList.get(i).getName();
poiInfo.uid = aList.get(i).getUid();
poiInfo.address = aList.get(i).getAddress();
poiInfo.city = aList.get(i).getCity();
poiInfo.phoneNum = aList.get(i).getPhoneNum();
poiInfo.postCode = aList.get(i).getPostCode();
poiInfo.type = PoiInfo.POITYPE.POINT;
poiInfo.location = new LatLng(aList.get(i).getLatitude(), aList.get(i).getLongitude());
poiInfoList.add(poiInfo);
}
}
示例9: update
import com.baidu.mapapi.model.LatLng; //導入依賴的package包/類
@Override
public void update(Address addr) {
Log.i(TAG, "onReceiveLocation>>");
if (addr == null)
return;
// BDLocation location = new BDLocation();
// location.setLatitude(addr.getLatitude());
// location.setLongitude(addr.getLongitude());
// location = LocationClient.getBDLocationInCoorType(location, BDLocation.BDLOCATION_GCJ02_TO_BD09LL);
LatLng now = new LatLng(addr.getLatitude(), addr.getLongitude());
// location.setLatitude(address.getLatitude());
// location.setLongitude(address.getLongitude());
// location = LocationClient.getBDLocationInCoorType(location, BDLocation.BDLOCATION_GCJ02_TO_BD09LL);
LatLng before = new LatLng(address.getLatitude(), address.getLongitude());
address = addr;
// ((TextView) mContext.findViewById(R.id.ast_location_text)).setText(addr.getAddressDetail());
if (DistanceUtil.getDistance(before, now) > 2000) {
updateHomeAndCompany();
if (goHomeNodes.size() > 0)
setGoHomeCalculate();
else
setGoCompanyCalculate();
}
}
示例10: drawTrailLines
import com.baidu.mapapi.model.LatLng; //導入依賴的package包/類
private void drawTrailLines(List<LatLng> pointList) {
baiduMap.clear();
//把地圖移動到point點
moveToLocation(pointList.get(pointList.size() / 2));
//繪製跑步開始標記
if (!pointList.isEmpty()) {
addMarker(pointList.get(0), R.drawable.ic_loc_start);
}
//繪製跑步結束標記
if (!pointList.isEmpty()) {
addMarker(pointList.get(pointList.size() - 1), R.drawable.ic_loc_end);
}
//畫路徑線
PolylineOptions polyline;
if (pointList.size() >= 2 && pointList.size() < 10000) {
polyline = new PolylineOptions()
.width(6)
.color(ContextCompat.getColor(this, R.color.colorPrimary))
.zIndex(0)
.points(pointList);
baiduMap.addOverlay(polyline);//添加Marker
}
}
示例11: moveToMe
import com.baidu.mapapi.model.LatLng; //導入依賴的package包/類
private void moveToMe(BDLocation location)
{
MapStatusUpdate mapUpdate=MapStatusUpdateFactory.zoomTo(18);
baiduMap.setMapStatus(mapUpdate);
//開始移動
MapStatusUpdate mapLatlng=MapStatusUpdateFactory.newLatLng(new LatLng(location.getLatitude(),location.getLongitude()));
baiduMap.setMapStatus(mapLatlng);
//顯示我的位置
MyLocationData.Builder locationBuilder=new MyLocationData.Builder();
locationBuilder.latitude(location.getLatitude());
locationBuilder.longitude(location.getLongitude());
MyLocationData locationData=locationBuilder.build();
baiduMap.setMyLocationData(locationData);
//顯示用戶所在地附近
Toast.makeText(this,"您當前在"+location.getAddrStr()+"附近",Toast.LENGTH_SHORT).show();
}
示例12: onMapStatusChangeFinish
import com.baidu.mapapi.model.LatLng; //導入依賴的package包/類
public void onMapStatusChangeFinish(MapStatus mapStatus) {
String _str = mapStatus.toString();
String _regex = "target lat: (.*)\ntarget lng";
String _regex2 = "target lng: (.*)\ntarget screen x";
changeLatitude = Double.parseDouble(latlng(_regex, _str));
changeLongitude = Double.parseDouble(latlng(_regex2, _str));
LatLng changeLL = new LatLng(changeLatitude, changeLongitude);
startNodeStr = PlanNode.withLocation(changeLL);
Log.d(TAG, "changeLatitude-----change--------" + changeLatitude);
Log.d(TAG, "changeLongitude-----change--------" + changeLongitude);
if (!isNeedCurrentlocation) {
MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(changeLL);
baiduMap.setMapStatus(u);
if (Math.hypot((changeLatitude - currentLatitude),
(changeLongitude - currentLongitude)) > 0.00001) {
Logger.d(Math.hypot((changeLatitude - currentLatitude),
(changeLongitude - currentLongitude)));
if (routeOverlay != null)
routeOverlay.removeFromMap();
addOverLayout(changeLatitude, changeLongitude);
}
}
}
示例13: navigateTo
import com.baidu.mapapi.model.LatLng; //導入依賴的package包/類
public void navigateTo(BDLocation location){
if(isFirstLocate){
LatLng latLng=new LatLng(location.getLatitude(),location.getLongitude());
showToast("定位到當前位置已執行");
MapStatusUpdate update=MapStatusUpdateFactory.zoomTo(8f);
baiduMap.animateMapStatus(update);
update= MapStatusUpdateFactory.newLatLng(latLng);
baiduMap.animateMapStatus(update);
isFirstLocate=false;
}
MyLocationData.Builder locationBuilder=new MyLocationData.Builder();
locationBuilder.latitude(location.getLatitude());
locationBuilder.longitude(location.getLongitude());
baiduMap.setMyLocationData(locationBuilder.build());
}
示例14: onReceiveLocation
import com.baidu.mapapi.model.LatLng; //導入依賴的package包/類
@Override
public void onReceiveLocation(BDLocation bdLocation) {
mLastLocationData=bdLocation;
MyLocationData myLocationData=new MyLocationData.Builder()
.accuracy(bdLocation.getRadius())
.latitude(bdLocation.getLatitude())
.longitude(bdLocation.getLongitude())
.build();
mBaiduMap.setMyLocationData(myLocationData);
MapStatusUpdate msu1 = MapStatusUpdateFactory.zoomTo(15.0f);
mBaiduMap.setMapStatus(msu1);
if(isFirstIn){
LatLng ll=new LatLng(bdLocation.getLatitude(),bdLocation.getLongitude());
MapStatusUpdate msu=MapStatusUpdateFactory.newLatLng(ll);
mBaiduMap.setMapStatus(msu);
isFirstIn=false;
}
}
示例15: onCreate
import com.baidu.mapapi.model.LatLng; //導入依賴的package包/類
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_routeplan);
mTvtitle = (TextView) findViewById(R.id.tv_topbar_title);
mTvtitle.setText("財神穀地址");
ImageView img = (ImageView) findViewById(R.id.img_topbar_back);
img.setImageResource(R.mipmap.icon_back);
img.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
RoutePlanDemo.this.finish();
}
});
// mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);//獲取傳感器管理服務
// 初始化地圖
mMapView = (MapView) findViewById(R.id.map);
mBaidumap = mMapView.getMap();
MapStatus.Builder builder = new MapStatus.Builder();
builder.zoom(18.0f);
builder.target(new LatLng(29.184662, 121.305024));
mMapStatusUpdate = MapStatusUpdateFactory.newMapStatus(builder.build());
mBaidumap.setMapStatus(mMapStatusUpdate);
MarkerOptions ooA = new MarkerOptions().position(GEO_NINGBO).icon(bdA)
.zIndex(9).draggable(true);
mBaidumap.addOverlay(ooA);
mBaidumap.setTrafficEnabled(true);
findViewById(R.id.lin_action_route).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
go2ThirdMap();
}
});
}