Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 单击微调器选项时,在地图上放置一个标记_Android_Google Maps - Fatal编程技术网

Android 单击微调器选项时,在地图上放置一个标记

Android 单击微调器选项时,在地图上放置一个标记,android,google-maps,Android,Google Maps,我有一个location活动类,带有一个由数据库值组成的微调器。我单击其中一个值,查询数据库并返回坐标。我知道我得到了正确的坐标,因为我已经在应用程序中测试了查询 spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> p

我有一个location活动类,带有一个由数据库值组成的微调器。我单击其中一个值,查询数据库并返回坐标。我知道我得到了正确的坐标,因为我已经在应用程序中测试了查询

spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> parent, View view, final int i, long id) {
                    switch (i) {
                        case 0:
                            //remove marker
                            break;
                        case 1:
                        case 2:
                        case 3:
                        case 4:
                        case 5:
                        case 6:
                        case 7:
                            getSuggestedLocation(i);
                            //Antrim marker
                            break;
                        //Armagh marker
                        //Belfast marker
                        //Derry marker
                        //Down marker
                        //Fermanagh marker
                        //Tyrone marker
                    }
                }

值得注意的是,我在onLocationResult方法中手动设置了currentLocation。但是,如果选择了某个选项,我想将值从我的db传递到该currentLocation,但我不知道如何从切换到所需方法的结果。请帮我把脑袋炸了哈哈,我一点也不喜欢安卓工作室

你可以这样称呼,只需在全球范围内申报你的谷歌地图

yourGoogleMap.clear();
LatLng latlng = new LatLng(YOUR_LATITUDE, YOUR_LONGITUDE);
MarkerOptions options = new MarkerOptions()
        .position(latlng)
        .title(YOUR_TITLE);
yourGoogleMap.addMarker(options);
yourGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latlng, 16.0f));
yourGoogleMap.clear();
LatLng latlng = new LatLng(YOUR_LATITUDE, YOUR_LONGITUDE);
MarkerOptions options = new MarkerOptions()
        .position(latlng)
        .title(YOUR_TITLE);
yourGoogleMap.addMarker(options);
yourGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latlng, 16.0f));