地图显示默认标记但从未设置

时间:2016-09-23 15:05:40

标签: android dictionary marker

map with default marker that is never set

在地图中间有一个标记,当我用其中的地图片段开始活动时,该标记始终显示在此位置。但是我从来没有设置过这个标记......有人知道为什么会这样,也许我可以删除这个标记吗?

这是我的代码:

@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    int permissionCheck = ContextCompat.checkSelfPermission(MapsActivity.this,
            android.Manifest.permission.ACCESS_FINE_LOCATION);

    if(permissionCheck == PackageManager.PERMISSION_GRANTED){
        getCurrentLocation();
        onSearch();
    }else if(permissionCheck == PackageManager.PERMISSION_DENIED){
        onSearch();
    }
}
//gets current location of the user.
public void getCurrentLocation() {
    double lat = 0;
    double lng = 0;
    try {
        mMap.setMyLocationEnabled(true); //allows query of current location.
    }catch(SecurityException e){
        e.printStackTrace();
    }

    LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
    Geocoder geocoderGetAddress = new Geocoder(MapsActivity.this);
    try{
        Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        if(location!=null) {
            lat = location.getLatitude();
            lng = location.getLongitude();
        }
    }catch(SecurityException e){
        e.printStackTrace();
    }
    //the rest of this method gets the address from the geocoder, so that it can be displayed as a String on the marker info window.
    String displayAddress ="";
    try {
        List<Address> currAddress = geocoderGetAddress.getFromLocation(lat, lng, 1);
        if(currAddress.size() >0){
            for(int i=0; i<currAddress.get(0).getMaxAddressLineIndex();i++){
                displayAddress += currAddress.get(0).getAddressLine(i) +"\n";
            }
        }
    }catch (IOException e){
        e.printStackTrace();
    }
    mMap.addMarker(new MarkerOptions().position(new LatLng(lat,lng)).title(myLoc).snippet(displayAddress));
    LatLng myLatLng = new LatLng(lat, lng);
    mMap.animateCamera(CameraUpdateFactory.newLatLng(myLatLng));
    initAcceptButton();
}

谢谢!

1 个答案:

答案 0 :(得分:0)

我刚刚解决了添加

的问题
CREATE PROCEDURE [hsip].[MDT] 
(
@cRegion CHAR(2) = '00',
@cState_Code CHAR(2) = '00',
@nFY NUMERIC(4,0) = 0,
@nREPORT_ID NUMERIC(2,0) = 0,
@nSECTION_ID NUMERIC(2,0) = 0,
@nSUBSECTION_ID NUMERIC(2,0) = 0,
@nDISPLAY_NUMBER NUMERIC(38,0) = 0,
@nQUESTION_NUMBER NUMERIC(38,0) = 0,
@nQUESTION_PART_NUMBER NUMERIC(38,0) = 0,
@sUSER_ID VARCHAR(25) = NULL,
@nIsMerge char ='N'
)
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    declare @starting_row_index as integer=0,
            @ncolumn_index as integer=0,
            @sresponse_string as varchar(4000),
            @srepsonse_stringm as varchar(4000),
            @response_stringo as varchar(4000),
            @nFY_ST_QUESTION_DTL_TABLE_ID as numeric(38,0),


  select qd.FY_ST_QUESTION_DTL_TABLE_ID
from FY_ST_QUESTION_DETAIL qd inner join FY_ST_QUESTION_INFO qi
on qd.FY_ST_QUESTION_INFO_TABLE_ID =  qi.FY_ST_QUESTION_INFO_TABLE_ID
       where qi.region = @cRegion
         and qi.state_code = @cState_Code
         and qi.fy = @nFY
         and qi.report_id = @nREPORT_ID
         and qi.section_id = @nSECTION_ID
         and qi.subsection_id = @nSUBSECTION_ID
         and qi.display_number = @nDISPLAY_NUMBER
         and qi.QUESTION_NUMBER = @nQUESTION_NUMBER
         and ( QI.REPORTER_ID = @sUSER_ID or
               QI.DELEGATE_ID = @suser_id or
               QI.SUB_DELEGATE_ID = @suser_id )
         and QD.QUESTION_PART_NUMBER = @nQUESTION_PART_NUMBER;

         set @ncolumn_index=
         case
         when (@nREPORT_ID = 1 and @nQUESTION_NUMBER = 21) then  17
            when (@nREPORT_ID = 1 and @nQUESTION_NUMBER = 32) then  16
            when (@nREPORT_ID = 3 and @nQUESTION_NUMBER = 11) then  15
            when (@nREPORT_ID = 3 and @nQUESTION_NUMBER = 12) then  27
        end;

if(@nFY_ST_QUESTION_DTL_TABLE_ID >0)

        if(@nIsMerge = 'Y')

        select (max(ad.ROW_NUMBER)) 
        from FY_ST_ANSWER_DETAIL as ad
        where ad.FY_ST_QUESTION_DTL_TABLE_ID=@nFY_ST_QUESTION_DTL_TABLE_ID;

        else

        --begin

        delete from FY_ST_ANSWER_DETAIL ad
        where ad.fy_st_question_dtl_table_id = @nFY_ST_QUESTION_DTL_TABLE_ID;

        end;

        INSERT INTO FY_ST_ANSWER_DETAIL AD
            SELECT UL.FY_ST_QUESTION_DTL_TABLE_ID,UL.REGION,UL.STATE_CODE,UL.FY,
                   UL.REPORT_ID,UL.SECTION_ID,UL.SUBSECTION_ID,
                   UL.DISPLAY_NUMBER,UL.QUESTION_NUMBER,UL.QUESTION_PART_NUMBER,
                   UL.ROW_NUMBER+@starting_row_index,
                   UL.COLUMN_NUMBER,
                   UL.LAST_UPDATE_USERID,UL.LAST_UPDATE_TIME,
                   UL.RESPONSE_STRING
              FROM UPLOAD_TEMP_DATA UL
             WHERE UL.FY_ST_QUESTION_DTL_TABLE_ID = @nFY_ST_QUESTION_DTL_TABLE_ID
               and UL.COLUMN_NUMBER <= @ncolumn_index;

               DELETE FROM UPLOAD_TEMP_DATA UL
              WHERE UL.FY_ST_QUESTION_DTL_TABLE_ID = @nFY_ST_QUESTION_DTL_TABLE_ID;

--end;


END
GO