Search in sources :

Example 1 with LatLng

use of com.baidu.mapapi.model.LatLng in project SmartCampus by Vegen.

the class EaseBaiduMapActivity method showMap.

private void showMap(double latitude, double longtitude, String address) {
    sendButton.setVisibility(View.GONE);
    LatLng llA = new LatLng(latitude, longtitude);
    CoordinateConverter converter = new CoordinateConverter();
    converter.coord(llA);
    converter.from(CoordinateConverter.CoordType.COMMON);
    LatLng convertLatLng = converter.convert();
    OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory.fromResource(R.drawable.ease_icon_marka)).zIndex(4).draggable(true);
    mBaiduMap.addOverlay(ooA);
    MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f);
    mBaiduMap.animateMapStatus(u);
}
Also used : MapStatusUpdate(com.baidu.mapapi.map.MapStatusUpdate) MarkerOptions(com.baidu.mapapi.map.MarkerOptions) OverlayOptions(com.baidu.mapapi.map.OverlayOptions) CoordinateConverter(com.baidu.mapapi.utils.CoordinateConverter) LatLng(com.baidu.mapapi.model.LatLng)

Example 2 with LatLng

use of com.baidu.mapapi.model.LatLng in project SmartCampus by Vegen.

the class EaseBaiduMapActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    instance = this;
    // initialize SDK with context, should call this before setContentView
    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.ease_activity_baidumap);
    mMapView = (MapView) findViewById(R.id.bmapView);
    sendButton = (Button) findViewById(R.id.btn_location_send);
    Intent intent = getIntent();
    double latitude = intent.getDoubleExtra("latitude", 0);
    LocationMode mCurrentMode = LocationMode.NORMAL;
    mBaiduMap = mMapView.getMap();
    MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(15.0f);
    mBaiduMap.setMapStatus(msu);
    initMapView();
    if (latitude == 0) {
        mMapView = new MapView(this, new BaiduMapOptions());
        mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(mCurrentMode, true, null));
        showMapWithLocationClient();
    } else {
        double longtitude = intent.getDoubleExtra("longitude", 0);
        String address = intent.getStringExtra("address");
        LatLng p = new LatLng(latitude, longtitude);
        mMapView = new MapView(this, new BaiduMapOptions().mapStatus(new MapStatus.Builder().target(p).build()));
        showMap(latitude, longtitude, address);
    }
    IntentFilter iFilter = new IntentFilter();
    iFilter.addAction(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR);
    iFilter.addAction(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR);
    mBaiduReceiver = new BaiduSDKReceiver();
    registerReceiver(mBaiduReceiver, iFilter);
}
Also used : IntentFilter(android.content.IntentFilter) Intent(android.content.Intent) MapStatusUpdate(com.baidu.mapapi.map.MapStatusUpdate) LocationMode(com.baidu.mapapi.map.MyLocationConfiguration.LocationMode) BaiduMapOptions(com.baidu.mapapi.map.BaiduMapOptions) MapView(com.baidu.mapapi.map.MapView) MapStatus(com.baidu.mapapi.map.MapStatus) MyLocationConfiguration(com.baidu.mapapi.map.MyLocationConfiguration) LatLng(com.baidu.mapapi.model.LatLng)

Example 3 with LatLng

use of com.baidu.mapapi.model.LatLng in project AndroidStudy by tinggengyan.

the class BaiduMapActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_baidumap);
    textView = (TextView) findViewById(R.id.textView);
    MapView mMapView = (MapView) findViewById(R.id.bmapView);
    mapUtil = new BaiduMapUtil(this, mMapView);
    locationUtil = new BaiduLocationUtil(this, new BaiduLocationUtil.LocationSuccessListener() {

        @Override
        public void onReceiveLocation(BDLocation location) {
            float accuracy = location.getRadius();
            double latitude = location.getLatitude();
            double longitude = location.getLongitude();
            float direction = location.getDirection();
            int satelliteNumber = location.getSatelliteNumber();
            float speed = location.getSpeed();
            mapUtil.setCurrentLocation(accuracy, direction, longitude, latitude, satelliteNumber, speed);
        }
    });
    findViewById(R.id.refreshLocation).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            locationUtil.requestLocation();
        }
    });
    findViewById(R.id.zoomButton).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mapUtil.setZoom(18);
        }
    });
    mapUtil.setOnMapStatusChangeListener(new BaiduMapUtil.OnMapStatusChangeListener() {

        @Override
        public void onMapStatusChangeFinish(final MapStatus mapStatus) {
            // TODO: 2017/1/6 根据中心点,获取数据
            // 地图操作的中心点。
            LatLng target = mapStatus.target;
            // 地图操作中心点在屏幕中的坐标
            Point targetScreen = mapStatus.targetScreen;
            // 地图缩放级别 3~21
            float zoom = mapStatus.zoom;
        }
    });
}
Also used : Point(android.graphics.Point) TextView(android.widget.TextView) MapView(com.baidu.mapapi.map.MapView) View(android.view.View) Point(android.graphics.Point) BDLocation(com.baidu.location.BDLocation) MapView(com.baidu.mapapi.map.MapView) MapStatus(com.baidu.mapapi.map.MapStatus) LatLng(com.baidu.mapapi.model.LatLng)

Example 4 with LatLng

use of com.baidu.mapapi.model.LatLng in project AndroidStudy by tinggengyan.

the class BaiduMapUtil method addInfoWindow.

// 
private void addInfoWindow(final Marker marker, @DrawableRes int resID, String msg) {
    Button button = new Button(context);
    button.setBackgroundResource(resID);
    button.setText(msg);
    button.setBackgroundColor(0x0000f);
    button.setWidth(300);
    InfoWindow.OnInfoWindowClickListener listener = new InfoWindow.OnInfoWindowClickListener() {

        public void onInfoWindowClick() {
            LatLng ll = marker.getPosition();
            LatLng llNew = new LatLng(ll.latitude + 0.005, ll.longitude + 0.005);
            marker.setPosition(llNew);
            // 隐藏当前 InfoWindow
            mBaiduMap.hideInfoWindow();
        }
    };
    LatLng ll = marker.getPosition();
    BitmapDescriptor descriptor = BitmapDescriptorFactory.fromView(button);
    InfoWindow mInfoWindow = new InfoWindow(descriptor, ll, -47, listener);
    this.mBaiduMap.showInfoWindow(mInfoWindow);
}
Also used : Button(android.widget.Button) BitmapDescriptor(com.baidu.mapapi.map.BitmapDescriptor) InfoWindow(com.baidu.mapapi.map.InfoWindow) LatLng(com.baidu.mapapi.model.LatLng)

Example 5 with LatLng

use of com.baidu.mapapi.model.LatLng in project KL2 by jweihao.

the class BaiduActivity method navigateTo.

private void navigateTo(BDLocation location) {
    if (isFirstLocate) {
        LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
        MapStatusUpdate update = MapStatusUpdateFactory.newLatLng(latLng);
        mBaiduMap.animateMapStatus(update);
        update = MapStatusUpdateFactory.zoomTo(16f);
        mBaiduMap.animateMapStatus(update);
        isFirstLocate = false;
    }
    MyLocationData.Builder locationBuilder = new MyLocationData.Builder();
    locationBuilder.latitude(location.getLatitude());
    locationBuilder.longitude(location.getLatitude());
    MyLocationData myLocationData = locationBuilder.build();
    mBaiduMap.setMyLocationData(myLocationData);
}
Also used : MapStatusUpdate(com.baidu.mapapi.map.MapStatusUpdate) MyLocationData(com.baidu.mapapi.map.MyLocationData) LatLng(com.baidu.mapapi.model.LatLng)

Aggregations

LatLng (com.baidu.mapapi.model.LatLng)9 MapStatusUpdate (com.baidu.mapapi.map.MapStatusUpdate)5 MapStatus (com.baidu.mapapi.map.MapStatus)3 MapView (com.baidu.mapapi.map.MapView)3 MarkerOptions (com.baidu.mapapi.map.MarkerOptions)3 Intent (android.content.Intent)2 IntentFilter (android.content.IntentFilter)2 Point (android.graphics.Point)2 BaiduMapOptions (com.baidu.mapapi.map.BaiduMapOptions)2 MyLocationConfiguration (com.baidu.mapapi.map.MyLocationConfiguration)2 OverlayOptions (com.baidu.mapapi.map.OverlayOptions)2 CoordinateConverter (com.baidu.mapapi.utils.CoordinateConverter)2 View (android.view.View)1 Button (android.widget.Button)1 TextView (android.widget.TextView)1 BDLocation (com.baidu.location.BDLocation)1 BitmapDescriptor (com.baidu.mapapi.map.BitmapDescriptor)1 InfoWindow (com.baidu.mapapi.map.InfoWindow)1 LocationMode (com.baidu.mapapi.map.MyLocationConfiguration.LocationMode)1 MyLocationData (com.baidu.mapapi.map.MyLocationData)1