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


Java LatLng类代码示例

本文整理汇总了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));
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:29,代码来源:SetFavoriteMapActivity.java

示例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));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:MainActivity.java

示例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();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:NavUtil.java

示例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();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:NavUtil.java

示例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();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:NavUtil.java

示例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);
    }
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:21,代码来源:SetFavoriteMapActivity.java

示例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);
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:19,代码来源:NaviConfirmPointActivity.java

示例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);
    }
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:18,代码来源:TrafficShowPresenter.java

示例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();
    }
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:26,代码来源:TrafficShowPresenter.java

示例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
    }
}
 
开发者ID:SailFlorve,项目名称:RunHDU,代码行数:27,代码来源:RunDetailsActivity.java

示例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();
}
 
开发者ID:WindFromFarEast,项目名称:SmartButler,代码行数:17,代码来源:LocationActivity.java

示例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);
        }

    }
}
 
开发者ID:yiwent,项目名称:Mobike,代码行数:25,代码来源:MainActivity.java

示例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());

}
 
开发者ID:MoonRiser,项目名称:MaterialLearning,代码行数:19,代码来源:BaiduMapActivity.java

示例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;
    }
}
 
开发者ID:organizationAllink,项目名称:wzyx-android-user,代码行数:20,代码来源:BaiduMapActivity.java

示例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();
            }
        });
    }
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:34,代码来源:RoutePlanDemo.java


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