Hi Am working on google maps. i have added location in a fragment now am trying to add StreetViewPanoramaView to the fragment . But am getting Oops! something went wrong error message as shown in 2nd image
this is my code
maps_activity.xml
<Button
android:id="#+id/button_streetview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Open StreetView"
/>
<androidx.fragment.app.FragmentContainerView
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".MapsActivity" />
<com.google.android.gms.maps.StreetViewPanoramaView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/streetview"/>
This is my MapActivity.kt
button_streetview.setOnClickListener(View.OnClickListener {
var mStreetViewPanoramaView : StreetViewPanoramaView = findViewById(R.id.streetview)
mStreetViewPanoramaView.onCreate(savedInstanceState)
var streetViewPanorama: StreetViewPanoramaOptions = StreetViewPanoramaOptions()
streetViewPanorama.panningGesturesEnabled(false)
streetViewPanorama.position(address)
streetViewPanorama.userNavigationEnabled(false)
streetViewPanorama.zoomGesturesEnabled(true)
var streetViewPanoramaCamera : StreetViewPanoramaCamera = StreetViewPanoramaCamera(25F,30F,1F)
streetViewPanorama.panoramaCamera(streetViewPanoramaCamera)
mStreetViewPanoramaView = StreetViewPanoramaView(this,streetViewPanorama)
mStreetViewPanoramaView.getStreetViewPanoramaAsync(this)
})
i can successfully retrive latitude and longitude of a place by address and display it in infoWindow and add custom marker as shown in image.
But when i click openstreetview button error message is coming.
This is the StreetView
This is the logcat
As This Error message is showing Wrong API key but i have added correct Key as i can retrive and display a marker successfully. Can anyone please tell me where am doing wrong
It looks like you are getting the error described here:
If you receive an error such as Your card does not support automatic
recurring payments or General decline of the card, please select a
different form of payment.
You might encounter these errors if you are using a debit card that
requires two-factor authentication to complete an online transaction.
Two-factor authentication requires you to be in-session at the time of
the transaction. Cards that require you to be in-session are not
usable for subscriptions or similar recurring automatic transactions.
Your street view map should work without problem once you enable billing on your project. Hope this helps!
Related
We had a requirement of sharing location which is a similar kind of WhatsApp with respective to User Interface & functionality.
I have come across that Google Place Picker has got deprecated and also migrated to Places Clients.
Say Like as,
and when they are trying to search,
May be, I am not good at explaining my idea but overall I am in the search of the above kind of implementation.
And also I came to know that Google Charges for the search or the places from the below Url,
https://github.com/rtchagas/pingplacepicker
What all I have tired is,
Coding Part:
Places.initialize(applicationContext, "Google API Key")
placesClient = Places.createClient(this)
val autocompleteFragment =
getSupportFragmentManager().findFragmentById(R.id.autocomplete_fragment) as AutocompleteSupportFragment
autocompleteFragment.setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.NAME));
autocompleteFragment.setOnPlaceSelectedListener(object : PlaceSelectionListener {
override fun onPlaceSelected(p0: Place) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun onError(p0: Status) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
});
val intent = Autocomplete.IntentBuilder(
AutocompleteActivityMode.FULLSCREEN, fields
)
.build(this);
startActivityForResult(intent, AUTOCOMPLETE_REQUEST_CODE);
After searching for two three places I am get an error saying Retry. Don't know the reason.
Error:
Help is really appreciated.
I faced the same problem since i'm working with place picker within my app , but since google decided to remove it , i have no choice than have a work around to find a solution !
i decided to use google map to recreate a place picker close experience .
First i created the map as full screen , and i putted an ImageView (Marker) as overlay of it as xml below :
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/coordinator_layout"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.streetdev.goodnecity.SelectLocationPicker" />
<ImageView
android:layout_centerInParent="true"
android:src="#drawable/ic_map"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="56dp"
android:layout_height="56dp"
app:backgroundTint="#color/colorPrimaryDark"
android:src="#drawable/ic_plus"
android:layout_margin="16dp"
app:layout_anchor="#id/map"
app:layout_anchorGravity="bottom|end" />
</android.support.design.widget.CoordinatorLayout>
So whenever the user is navigating on the map , the marker will stay in the center of the map like place picker
Now all you have to do is start your map picker using startActivityForResult, you have to handle the cameraPosition with gps ( if its available ) and then as soon as you want to go back with the result ( for me i click on the Fab button ) , you can get the result this way :
LatLng latng = mMap.getCameraPosition().target;
Intent returnIntent = new Intent();
returnIntent.putExtra("result",String.valueOf(latng.latitude)+";"+String.valueOf(latng.longitude));
setResult(Activity.RESULT_OK,returnIntent);
finish();
The last step is to handle the result in onActivityResult, you get your result , you do a split using ";" to separate latitude from longitude
hope my example will help some one !
I want to show VR tour like this http://alfavr.ir/alfavr.ir/to/park.html in my Android app.
how can I do that?
I tried to display with web view because the file format is Html but did not work.
You can try with VRPanormaView which is included in the Google VR SDK. This is an example from https://developers.google.com/vr/develop/android/vrview:
<com.google.vr.sdk.widgets.pano.VrPanoramaView
android:id="#+id/pano_view"
android:layout_margin="5dip"
android:layout_width="match_parent"
android:scrollbars="#null"
android:layout_height="250dip" />
Inside the Activity, the primary method is VrPanoramaView.loadImageFromBitmap(). Call it with a standard Android Bitmap object and an optional VrPanoramaView.Options object. The latter is used to configure the format of the image. The Activity also implements a VrPanoramaEventListener which receives events when the load operation succeeds or fails.
Adding this line make It work.
webView.getSettings().setJavaScriptEnabled(true);
I recently implemented Algolia on my app successfully just like the examples.
But the initial search takes about 5 to 7 seconds and I couldn't find a way to make it faster after checking the whole library code and documentation. After the initial search, search becomes very fast.
There is nothing unusual in my implementation but maybe you can see something that I don't. The following code is from the activity where I initialize Algolia:
Searcher searcher = new Searcher(ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY, ALGOLIA_INDEX_NAME);
searcher.setQuery(new Query("word").setExactOnSingleWordQuery(Query.ExactOnSingleWordQuery.ATTRIBUTE));
searcher.addNumericRefinement(new NumericRefinement("CountryId", NumericRefinement.OPERATOR_EQ, 1));
InstantSearch helper = new InstantSearch(this, searcher);
helper.setSearchOnEmptyString(false);
helper.search();
And this is the related xml layout:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="6dp"
android:paddingRight="10dp"
android:paddingLeft="1dp"
android:paddingTop="6dp">
<com.algolia.instantsearch.ui.views.SearchBox
android:id="#+id/searchBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:queryHint="#string/search_text_hint"
algolia:searchIcon="#drawable/icn_search_big"
algolia:closeIcon="#drawable/icn_clear_filled_big"
android:queryBackground="#drawable/sarch_query_shape"
android:background="#drawable/search_shape"
algolia:autofocus="true"
algolia:submitButtonEnabled="false" />
</FrameLayout>`
<com.algolia.instantsearch.ui.views.Hits
android:id="#+id/hits"
android:layout_width="match_parent"
android:layout_height="match_parent"
algolia:autoHideKeyboard="true"
algolia:hitsPerPage="6"
android:layout_below="#+id/searchBarParentLayout"
algolia:infiniteScroll="false"
algolia:itemLayout="#layout/search_item_algolia_row"/>
Do you have any idea what can be the issue here?
I'm glad that the issue disappeared when you switched to another wifi.
For future readers that may encounter network issues with InstantSearch Android:
First of all, build and run one of our demo applications
If you see no problem running the example application, you can try using a proxy like Charles to investigate what's happening between your app and the network
If your problem persists when running the examples, or if you are following the documentation, send an email to support#algolia.com describing the issue with a sample of your code!
I am designing an android app with Xamarin which will have an activity with google maps inside it, but i am struggling to display the map. It shows an empty box with no map display on it. Following is the code which i used for this practice.
My Activity
namespace teslin
{
[Activity(Label = "Map")]
public class MpActivity : Android.GoogleMaps.MapActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.MapView);
var map = FindViewById<MapView>(Resource.Id.mapv);
map.Clickable = true;
map.Controller.SetZoom(16);
map.Controller.SetCenter(new GeoPoint((int)40.8270449E6, (int)-73.9279148E6));
}}
xml lay out
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout3"
android:layout_weight="9" />
<com.google.android.maps.MapView
android:id="#+id/mapv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:enabled="true"
android:apiKey="AIzaSyD-UMij5IO6ezjuFCNnF7tRoG3niaPbNEU" />
</LinearLayout>
It looks like you're using the obsolete/outdated Maps API v1. Google removed support for this last year.
Instead you want to use Android Maps API v2 (a part of Google Play Services). Xamarin has some documentation on Maps in Android. It can be a bit tricky to get Maps working in Android, so carefully read these docs. Specifically, you'll want to read the section on the Maps API.
There is an example on Github that shows how to use the Google Play Services Component to add Maps to your application.
For those who are looking for a thorough example, check out this video that demonstrates how to integrate Google Maps with Xamarin Android, hope this helps!
I am working on a project using Google Maps v2 for Android and I am getting a NoSuchFieldError while instantiating the Google map fragment on a rooted HTC Desire HD.
Afaik, the issue should not be caused by Google Play Services not being installed on the device (event though they are and other applications using Google Maps v2 are working).
I have tried making a check to see if Google Play Services library is installed on the device (by calling GooglePlayServicesUtil.isGooglePlayServicesAvailable) prior to setting the Activity's content view.
Furthermore, the application runs on other Android phones and the map fragment is successfully inflated.
At the moment I suspect that this issue is caused by my Android project setup in Eclipse, as the Google Play Services library project seems not to be included along with my project during packaging or deployment.
Has anyone had and solved this issue with Google Maps working only on some devices and throwing a NoSuchFieldError exception on others? If so, what can I do to solve this?
If you need more information such as project setup and/or code, please leave a comment.
Thank you!
This is the stack trace report from ACRA in JSON format:
{ CUSTOM_DATA: '',
STACK_TRACE: 'java.lang.NoSuchFieldError: com.google.android.gms.R$string.common_google_play_services_unsupported_text\n\tat com.google.android.gms.common.GooglePlayServicesUtil.b(Unknown Source)\n\tat com.google.android.gms.internal.bb.a(Unknown Source)\n\tat com.google.android.gms.internal.bb.onCreateView(Unknown Source)\n\tat com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)\n\tat android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)\n\tat android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:884)\n\tat android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1066)\n\tat android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1168)\n\tat android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:280)\n\tat android.view.LayoutInflater.createViewFromTag(LayoutInflater.java)\n\tat android.view.LayoutInflater.rInflate(LayoutInflater.java)\n\tat android.view.LayoutInflater.inflate(LayoutInflater.java)\n\tat android.view.LayoutInflater.inflate(LayoutInflater.java)\n\tat android.view.LayoutInflater.inflate(LayoutInflater.java)\n\tat com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java)\n\tat android.app.Activity.setContentView(Activity.java)\n\tat ro.myapp.app.activities.MapActivity.onCreate(MapActivity.java:62)\n\tat android.app.Activity.performCreate(Activity.java)\n\tat android.app.Instrumentation.callActivityOnCreate(Instrumentation.java)\n\tat android.app.ActivityThread.performLaunchActivity(ActivityThread.java)\n\tat android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)\n\tat android.app.ActivityThread.access$600(ActivityThread.java)\n\tat android.app.ActivityThread$H.handleMessage(ActivityThread.java)\n\tat android.os.Handler.dispatchMessage(Handler.java)\n\tat android.os.Looper.loop(Looper.java)\n\tat android.app.ActivityThread.main(ActivityThread.java)\n\tat java.lang.reflect.Method.invokeNative(Native Method)\n\tat java.lang.reflect.Method.invoke(Method.java)\n\tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java)\n\tat dalvik.system.NativeStart.main(Native Method)\n',
PHONE_MODEL: 'HTC Desire HD',
ANDROID_VERSION: '4.0.4' }
This is my onCreate method throwing the exception:
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
checkForPlayServices();
setContentView(R.layout.activity_map);
mapFragment = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map);
map = mapFragment.getMap();
map.setMyLocationEnabled(true);
map.setInfoWindowAdapter(this);
map.setOnInfoWindowClickListener(this);
}
Contents of activity_map.xml layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapActivity" >
<ro.myapp.app.views.actionbar.ActionbarMap
android:id="#+id/actionBar"
android:layout_width="match_parent"
android:layout_height="#dimen/myapp_actionbar_height" />
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="#id/actionBar"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
java.lang.NoSuchFieldError: com.google.android.gms.R$string.common_google_play_services_unsupported_text
says exactly what is the problem.
In values/strings.xml there is no
<string name="common_google_play_services_unsupported_text">...</string>
defined.
I see this value defined in my google-play-services_lib/res, so you may want to check if you correctly added this library project to your workspace. Seems like you have forgot to update strings.xml when updating library.
Ok so I changed my answer I found out there is a way to find out if there is anything overriding your libs.... You are using the Location Objects somewhere so add this bit of code and debug it when running one of those devices..... The location object should be in your location listener.
location.getClass().getProtectionDomain().getCodeSource().getLocation() ;