Tag: 谷歌地图

PlaceAutocomplete小部件在Android 4.1中不起作用

PlaceAutocomplete小部件在Android 5.0中工作正常,但是在openAutocomplete被调用的时候4.1没有任何反应。 LogCat中没有错误。 执行onActivityResult,但在数据参数中为null。 问题是什么? 码: override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == 1) { if (resultCode == FragmentActivity.RESULT_OK) { val place = PlaceAutocomplete.getPlace(activity, data) val cameraUpdate = CameraUpdateFactory.newLatLng(place.latLng) // map.moveCamera(cameraUpdate) map.animateCamera(cameraUpdate) if (action === AddressPickerType.FROM) { activity.order.from.onNext(place) } else { activity.order.to.onNext(place) } } else if (resultCode […]

复制Googlemap上的APK protobuf.meta文件复制商业用途

我按照这里的指示来实现Googlemap for business(选项2:将SDK导入为库模块): https://developers.google.com/maps/premium/android-get-started当我尝试运行应用程序,它返回给我这个错误: * What went wrong: Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. > com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK protobuf.meta File1: /Users/name/.android/build-cache/f333e5a1ed5f958c1e7d100de7935a31efd81cd6/output/jars/classes.jar File2: /Users/name/Documents/name/project-name/googlemapssdkm4b_lib/build/intermediates/bundles/default/classes.jar 这是我的gradle文件: apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: 'test-environment.gradle' apply plugin: 'io.fabric' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' repositories { maven { url 'https://maven.fabric.io/public' } maven { url […]

如何运行Google Map?

我究竟做错了什么? 我字面上使用提供的模板为谷歌地图。 public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { /** Templated provide by google */} 我有一个项目的API密钥。 但是,当我运行它,这是我的错误: Error:Gradle: Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:Process'command'/Library/Java/JavaVirtualMachines/jdk1.8.0_101。 jdk / Contents / Home / bin / java''以非零的退出值2结束 其他错误: Information:Gradle: Executing tasks: [:app:assembleDebug] Information:Kotlin: Kotlin JPS plugin is disabled Gradle文件: apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "24.0.2" […]

Android:显示多个街景(Google Maps Api)

我有一个名为activity_collage.xml的xml文件,带有2个街景视图片段 – 我希望这两个片段都能显示给定位置的街景视图 – 因此,屏幕上共有2个街景视图 这是我的代码: public class Collage extends ActionBarActivity implements OnStreetViewPanoramaReadyCallback { StreetViewPanoramaFragment topLeft, topRight; static final LatLng posOne = new LatLng(43.771925, -79.512460); static final LatLng posTwo = new LatLng(43.790634, -79.193632); 这里是我在我的onCreate()方法中初始化我的2个StreetViewFragment对象的地方 topLeft = (StreetViewPanoramaFragment) getFragmentManager() .findFragmentById(R.id.picTL); topLeft.getStreetViewPanoramaAsync(this); topRight = (StreetViewPanoramaFragment) getFragmentManager() .findFragmentById(R.id.picTR); 这里是从OnStreetViewPanoramaReadyCallback接口重写的方法… @Override public void onStreetViewPanoramaReady(StreetViewPanorama panorama) { panorama.setPosition(posOne); } 但是,如何设置topRight的街景视图?

Android – 显示集群项目单击信息窗口(标题)

无法理解这个问题。 我有一个集群渲染器(OffersClusterRenderer)在哪里 @Override protected void onBeforeClusterItemRendered(OffersMarker item, MarkerOptions markerOptions) { int itemNumberOfOffers = item.getNrOfOffers(); BitmapDescriptor markerDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.ro1); markerOptions.icon(markerDescriptor); markerOptions.snippet("Show"); markerOptions.title("Show"); super.onBeforeClusterItemRendered(item, markerOptions); } 我也有ClusterManager,并在我的活动,我运行这个: rentClusterManager = new ClusterManager<OffersMarker>(this, gmap); rentClusterManager.setRenderer(rentClusterRenderer); 我的问题是,onClusterItemClick被调用时,如何显示标记的信息窗口(标题)? 难道这不应该表现出来吗? 它在谷歌文档中这样说。

Android的MapView在片段

我想在我的Fragment有MapView 这是我的FragmentLayout xml文件 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#17df0d" android:orientation="vertical" > <com.google.android.gms.maps.MapView android:id="@+id/mapview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/textView1" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_marginBottom="70dp" > </com.google.android.gms.maps.MapView> </RelativeLayout> 我的AndroidManifest.xml文件 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="abcd" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="17" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your_api_key" /> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> </application> <uses-permission android:name="android.permission.CAMERA" […]

Android Retrofit + Google Places API(文本搜索)

我正在尝试根据给定的查询来获取地点。 我实现了以下接口。 @GET("api/place/textsearch/json?key=MY_API_KEY") Call<PlaceResponse> getNearbyPlacesByText(@Query("query") String query, @Query("location") String location, @Query("radius") int radius); 然后我这样调用这个方法 Retrofit retrofit = new Retrofit.Builder() .baseUrl(url) .addConverterFactory(GsonConverterFactory.create()) .build(); ApiInterface service = retrofit.create(ApiInterface.class); Call<PlaceResponse> callByText = service.getNearbyPlacesByText("psí" + "škola", currentLocation.getLatitude() + "," + currentLocation.getLongitude(), PROXIMITY_RADIUS); 然后我正在检索结果。 callByText.enqueue(new Callback<PlaceResponse>() { @Override public void onResponse(Call<PlaceResponse> call, Response<PlaceResponse> response) { List<Place> places = response.body().getResults(); Log.d(TAG, […]

有问题从fragmentManager / MapFragment移动到supportfragmentManager / SupportMapFragment

所以我能够使用MapFragment没有问题,但是当我将其更改为支持MapFragment的时候,它已经退出了。 与下面的错误。 不知道我做错了,一个工程,另一个没有。 我需要支持的一个原因是,我不能删除使用mapfragment时的片段,因为下面的行是expectin片段! 并正在接收MapFragment …..所以它失败了…当我切换到SupportMapFragment下面的行的作品,但错误发生在下面。 谢谢 getFragmentManager().beginTransaction().remove(mapFragment).commit(); XML <fragment android:id="@+id/mapF" class="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_parent" android:layout_height="200dp" /> 类 import android.location.Address import android.os.Bundle import android.support.v4.app.Fragment import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import com.google.android.gms.maps.* import com.google.android.gms.maps.model.LatLng import com.google.android.gms.maps.model.MarkerOptions import android.location.Geocoder import android.text.Html import android.webkit.WebView import android.widget.Toast import com.beust.klaxon.JsonObject import com.beust.klaxon.Parser import com.beust.klaxon.obj import com.beust.klaxon.string import com.github.kittinunf.fuel.httpGet import […]

无法获得SupportMapFragment返回任何东西…似乎总是为空

所以这里是我的代码:克鲁克斯的事情是onMapReady没有被叫,所以我玩弄了 错误 进程:com.example.herbstzu.listview,PID:16963 kotlin.TypeCastException:null不能转换为非空类型com.google.android.gms.maps.SupportMapFragment XML ….. <LinearLayout android:id="@+id/LayoutInfo" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginVertical="10dp" android:orientation="horizontal"> <ImageView android:id="@+id/imagePhone2" android:layout_width="60dp" android:layout_height="60dp" android:layout_gravity="start" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" app:srcCompat="@drawable/ic_exclamation" /> <TextView android:id="@+id/info_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="TextView" android:textColor="#000000" /> </LinearLayout> <fragment class="com.google.android.gms.maps.MapFragment" android:id="@+id/mapF" android:layout_width="match_parent" android:layout_height="200dp"/> </LinearLayout> </ScrollView> Kotlin片段类 import android.os.Bundle import android.support.v4.app.Fragment import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import com.google.android.gms.maps.model.LatLng import com.google.android.gms.maps.model.MarkerOptions import […]

如何在Kotlin中设置回调?

我尝试将设备地理位置转换为片段并使用回调。 但设置一次后链接为空 fun updateLocation(location:LatLng){ Log.d(TAG,"Update fragment "+ localUpdater+" "+location) localUpdater?.tryOutLocation(location) } private inner class Receiver: BroadcastReceiver(){ override fun onReceive(context: Context?, intent: Intent?) { val bundle = intent?.extras!![AppConstants.LOCATION_BUNDLE] as Bundle val location = bundle.get(AppConstants.LOCATION_BUNDLE) as LatLng updateLocation(location) } } fun setUpdater(updater: IUpdateLocation){ this.localUpdater = updater Log.d(TAG,"Update fragment1 "+localUpdater) } 我声明回调: private var localUpdater: IUpdateLocation? = null […]