- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我为我的应用程序创建了一个 Google Places API,它目前显示附近的所有地点,如医院、餐馆、学校等。我希望它只显示餐馆。是否可以?如果是这样,怎么办?非常感谢您的帮助。谢谢:)
MapActivity.JAVA
package com.golo.acer.mrestro4;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;
import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.ui.PlacePicker;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
public class MapActivity extends AppCompatActivity {
private static final int PLACE_PICKER_REQUEST = 1;
private TextView mName;
private TextView mAddress;
private TextView mAttributions;
private static final LatLngBounds BOUNDS_MOUNTAIN_VIEW = new LatLngBounds(
new LatLng(27.689753, 85.311188), new LatLng(27.689753, 85.311188));
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_place_picker);
mName = (TextView) findViewById(R.id.textView);
mAddress = (TextView) findViewById(R.id.textView2);
mAttributions = (TextView) findViewById(R.id.textView3);
Button pickerButton = (Button) findViewById(R.id.pickerButton);
pickerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
PlacePicker.IntentBuilder intentBuilder =
new PlacePicker.IntentBuilder();
intentBuilder.setLatLngBounds(BOUNDS_MOUNTAIN_VIEW);
Intent intent = intentBuilder.build(MapActivity.this);
startActivityForResult(intent, PLACE_PICKER_REQUEST);
} catch (GooglePlayServicesRepairableException
| GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
}
});
}
public void moveToInternalChoiceActivity(View view) {
Intent intent = new Intent(this, InternalChoiceActivity.class);
startActivity(intent);
}
@Override
protected void onActivityResult(int requestCode,
int resultCode, Intent data) {
if (requestCode == PLACE_PICKER_REQUEST
&& resultCode == Activity.RESULT_OK) {
final Place place = PlacePicker.getPlace(this, data);
final CharSequence name = place.getName();
final CharSequence address = place.getAddress();
String attributions = (String) place.getAttributions();
if (attributions == null) {
attributions = "";
}
mName.setText(name);
mAddress.setText(address);
mAttributions.setText(Html.fromHtml(attributions));
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
}
最佳答案
place.getPlaceTypes()
返回一个整数列表,如果您想要查找餐厅类型,请检查它是否包含 Place.TYPE_RESTAURANT
。您可以在 Place
类中获取以 TYPE_
开头的类型值。
引用号https://developers.google.com/android/reference/com/google/android/gms/location/places/Place
[编辑]在您的代码中:
final Place place = PlacePicker.getPlace(this, data);
List<Integer> types = place.getPlaceTypes();
for(Integer i : types){
if (i == Place.TYPE_RESTAURANT){
// its restaurant do something
final CharSequence name = place.getName();
final CharSequence address = place.getAddress();
String attributions = (String) place.getAttributions();
if (attributions == null) {
attributions = "";
}
mName.setText(name);
mAddress.setText(address);
mAttributions.setText(Html.fromHtml(attributions));
}
}
[编辑:(来自用户的评论)]
您所描述的红色图标是一个标记,您可以将它们添加到 map 上。因此,在您的 onActivityResult
中,您会得到一个 Place
(已在您的代码中显示)。地点包含名称和位置,使用它在 map 上显示标记,如下所示:
Marker markerPlace = map.addMarker(new MarkerOptions().position(place.getLatLng()).title(place.getName));
查看 map 标记的文档和相关文章。
现在如何添加 map ?别问我,上网查资料 http://www.vogella.com/tutorials/AndroidGoogleMaps/article.html#mapsview
关于java - 如何从 Google Places API 中删除不需要的地点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39065545/
$query = "SELECT Name, CountryCode FROM City ORDER BY Name"; if ($result = $mysqli->query($query)) {
我是 GWT 的新手,我的英语不太好,请见谅。 我需要使用 GWT 创建一个网站。该网站具有层次结构:主要的全局标题和几个按钮。每个按钮都会打开应用程序的新部分,该部分有自己的子选项卡。每个子选项卡都
我正在尝试使用此网站 https://www.timeanddate.com/weather/通过打开如下 URL 使用 BeautifulSoup4 抓取天气数据: quote_page=r"htt
由于我要在移动应用中使用谷歌地图和地点,因此我不希望任何东西减慢应用加载速度。 我发现在边缘网络上,我的应用程序启动速度非常慢。我所有的js都是本地的,所以只有谷歌地图和地点需要很长时间才能加载(如果
我可以通过带有位置 ID 的图形 API 发送查询来返回位置的详细信息,但是我希望实现相反的结果 - 通过发送包含位置名称(城市,州等)。这可能吗? 最佳答案 这在几种不同的方法下是可能的。您可以使用
我正在尝试返回仅限于某种区域的自动完成结果 - the (regions) type collection instructs the Places service to return any res
我有一个多语言网站... 我在 visual studio 中为语言(en + 我的语言)制作了两个文件夹,并为每个文件夹制作了我的网站! 对于一种语言的网站,我有一门类(class)可以根据我的文化
我使用 this向FS请求获取 field 但有些场馆与要求的位置之间的距离超过 500 米。换句话说,ll 和 radius 参数没有像我预期的那样工作。因为我希望拥有所请求区域的所有 field
如果我有一段文本,例如包含一篇加泰罗尼亚语报纸文章,我如何从该文本中找到所有城市? 我一直在查看 python 的 nltk 包,我已经下载了加泰罗尼亚语的语料库 (nltk.corpus.cess_
R 的帮助系统很棒,我喜欢几乎所有函数的帮助页面都包含一个示例,但有时我希望有一种方法可以查看示例代码的结果,而无需复制并粘贴到我当前的 session 中。这对于图形功能来说是双重的。 有没有办法执
我想实现类似的效果,其中引脚被分组在一起,然后当您接近点时用动画分开。当您选择带有地理标记应用的地点时,会在“照片”应用中看到此效果 最佳答案 似乎没有,但有一个第三方库提供了此功能: http://
我在报表生成器/设计模式中看到,有一个“位置”和“位置”属性,可让您设置表格应显示在距顶部或左侧的距离。 我的问题是,有没有办法在同一位置设置 2 个或更多表格(即页面顶部,从顶部开始 0,从左边开始
所以,我有一个 Spring MVC 应用程序,我想要一种方法来确定资源何时不支持特定媒体类型。我正在考虑使用自定义 View 解析器来执行此操作...如果没有一个 View 解析器找到 View 名
有了这个类 import UIKit import CoreLocation private let geometryKey = "geometry" private let locationKey
我正在构建一个系统,其中应该有一个包含组织、位置、部门和用户的数据库。它们按照您的预期连接起来: 每个组织可以包含一个或多个地点 每个地点(建筑物)可以包含一个或多个部门 每个部门工作一名或多名用户
我一直在旧项目上使用 Google place API,但在那些项目中我必须选择一个地方,然后 API 返回给我相关信息地方... 问题是使用相同的 API 我可以请求一个地方,例如 Restaura
这里我有一个脚本,它通过 google places api 显示对象的开放时间。 http://jsbin.com/ATaZEXE/4 现在我想将 .label 类的背景颜色更改为“红色”,如果 p
我正在开发一款 Google map 应用,目标用户可能需要关于特定位置的路线,这些位置只能通过应用中的经纬度获知。 问题是方向需要解析为人类可读的名称,最好是任何位置都可以相对于另一个附近的位置进行
我正在开发一款应用程序,我相信它会对学生有所帮助。我想根据位置包括天气(仅温度)。例如,如果我要从一个城市前往另一个城市,我希望它能针对新城市自动更新。我该怎么做?对于我的第二个问题,我还想将日期(即
我正在使用上游模块来平衡我的网站。出于某种原因,我必须将一些请求重定向到指定的服务器。简而言之:我想将 domain.com 重定向到指定的服务器,domain.com/anything 可以由上游模
我是一名优秀的程序员,十分优秀!