在Android中使用Place picker google API选择匿名位置的位置时,禁用选择按钮 [英] Disable select button while selecting location of anonymous location using Place picker google API in android

查看:365
本文介绍了在Android中使用Place picker google API选择匿名位置的位置时,禁用选择按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用位置字段保存用户表单信息。对于位置,我想打开谷歌地图上的一些按钮点击和位置选择当用户点击地图上的位置和后填充的位置到表单。



我找到位置选择器作为相关解决方案,所以
我已经使用Place Picker Google API,并且我可以打开谷歌地图,当我将箭头移动到首选位置并单击选择此位置(显示黑色,现在坐标显示在那之下)



确认框以2个选项打开:

1。)更改位置

2 )选择(禁用模式)



我想选择匿名位置并返回到主要活动。

以下是我的代码:

  private TextView get_place; 
int PLACE_PICKER_REQUEST = 1;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
get_place =(TextView)findViewById(R.id.textView1);
get_place.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
Intent intent;
try {
intent = builder.build(getApplicationContext());
startActivityForResult(intent,PLACE_PICKER_REQUEST);
} catch(GooglePlayServicesRepairedException e){
e.printStackTrace();
} catch(GooglePlayServicesNotAvailableException e){
e.printStackTrace();
}
}
});
}

protected void onActivityResult(int requestCode,int resultCode,Intent data){
if(requestCode == PLACE_PICKER_REQUEST)
{
if(resultCode == RESULT_OK)
{
Place place = PlacePicker.getPlace(data,this);
Double latitude = place.getLatLng()。latitude;
Double longitude = place.getLatLng()。longitude;
String address = String.valueOf(latitude)+ String.valueOf(longitude);
get_place.setText(address);
}
}
}

当前位置坐标不可见





单击选择此按钮后,下面的窗口将打开,并且选择按钮被禁用





请让我知道如果还有其他最好的解决方案。
代码回复将有很大帮助或引用链接。

解决方案:启用

解决方案

/console.developers.google.com/apis/api/placesandroid/overview\">适用于Android的Google Places API


I want to save user form information with location field. For location I want to open google map on some button click and location to be selected when user click on location over map and post-filled location into form.

I found place picker as related solution, So I have used Place Picker Google API and I am able to open google map, when I move arrow over preferred location and click on Select this location (Appearing black color with now coordinates showing under that).

Confirmation box opens with 2 option :

1.) Change location
2.) Select (Disabled mode)

I want to select anonymous location and return to main activity.

Below is my code :

private TextView get_place;
int PLACE_PICKER_REQUEST    =   1;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    get_place   =   (TextView)findViewById(R.id.textView1);
    get_place.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            PlacePicker.IntentBuilder builder   =   new PlacePicker.IntentBuilder();
            Intent intent;
            try {
                intent  =   builder.build(getApplicationContext());
                startActivityForResult(intent,PLACE_PICKER_REQUEST );
            } catch (GooglePlayServicesRepairableException e) {
                e.printStackTrace();
            } catch (GooglePlayServicesNotAvailableException e) {
                e.printStackTrace();
            }
        }
    });
}

protected void onActivityResult( int requestCode , int resultCode , Intent data ){
    if( requestCode == PLACE_PICKER_REQUEST)
    {
        if(resultCode == RESULT_OK)
        {
            Place place =   PlacePicker.getPlace(data,this);
            Double latitude = place.getLatLng().latitude;
            Double longitude = place.getLatLng().longitude;
            String address = String.valueOf(latitude)+String.valueOf(longitude);
            get_place.setText(address);
        }
    }
}

Current location coordinates not visible

.

After click on SELECT THIS BUTTON, below window opens with Select button is disabled

.

Please let me know, If there is any other best solution. Code reply will be much helpful or reference link.

解决方案

Solution: Enable Google Places API for Android from dev console.

这篇关于在Android中使用Place picker google API选择匿名位置的位置时,禁用选择按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆