折线停止在我的地图上绘图

时间:2015-12-21 23:30:21

标签: java android location maps polyline

由于某些原因,我的折线不会绘制。我不确定发生了什么。这应该根据手机的位置更新绘制一条线。有什么想法吗?

public Boolean isTracking = false;
public String routeID;
public int pointID = 0;
@Override

public void onLocationChanged(Location location) {
    mCurrentLocation = location;
    double lat = location.getLatitude();
    double lng = location.getLongitude();
    LatLng latLng = new LatLng(lat, lng);      //Location declared into a LatLng

    if (isTracking){
        trackRoute(lat, lng, latLng);
    }
}

private void trackRoute(double lat, double lng, LatLng latLng){
    drawLine(latLng);                                                  //call drawline
    database.insertPoint(routeID, pointID, lat, lng);                  //Insert points into database
    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 18));
    pointID++;
}
private void drawLine(LatLng latLng){
    PolylineOptions options = new PolylineOptions()
            .width(5)
            .color(Color.BLUE)
            .geodesic(true);
            options.add(latLng);

    line = mMap.addPolyline(options);                   //set up options and draw line.
}

1 个答案:

答案 0 :(得分:0)

在drawLine方法中简单传递Lat和Lon,并使用两个参数制作drawline方法。 将CREATE FUNCTION `GetWorkingDays_FromDateRange`(date1 DATE, date2 DATE) RETURNS INT(11) BEGIN DECLARE dateOne DATE; DECLARE dateTwo DATE; DECLARE i INT; IF date1>date2 THEN SET dateTwo = date1; SET dateOne = date2; ELSE SET dateTwo = date2; SET dateOne = date1; END IF; SELECT COUNT(*) INTO i FROM holidays WHERE calendar_date BETWEEN dateOne AND dateTwo; RETURN ABS(DATEDIFF(dateTwo, dateOne)) + 1 - ABS(DATEDIFF(ADDDATE(dateTwo, INTERVAL 1 - DAYOFWEEK(dateTwo) DAY), ADDDATE(dateOne, INTERVAL 1 - DAYOFWEEK(dateOne) DAY))) / 7 * 2 - (DAYOFWEEK(IF(dateOne < dateTwo, dateOne, dateTwo)) = 1) - (DAYOFWEEK(IF(dateOne > dateTwo, dateOne, dateTwo)) = 7) - i; END 行替换为options.add(latLng);

options.add(new LatLng(lat,lng));