You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
The next iteration of the map interaction API should be to add a Camera API. The Camera API will be modeled on the Google Maps Android API to maximize familiarity. Key classes will be:
Basic classes, method stubs, and a TestApp activity are built. The next step is wiring up Core GL to the method stubs and verifying via TestApp activity.
Per chat, @zugaldia kicked the tires this morning on the branch and is happy with things. The only tweaks that we'll make are adding @UIThread annotations to the animateCamera() methods to remind everyone that these should only be used on the UI Thread as per regular Android UI conventions. As part of this we can also remove the View.post(new Runnable(){}) forced UI Thread wrapping of Callback firing command since everything will be on the UIThread.
Once these tweaks are made and tested that'll wrap up Iteration 0 on the Camera API and will then merge into master.
My Camera Animation is not working on API 23 and higher...but works fine on lower...Have this issue been solved? Please help!
here is my code...
// Marker
mapboxMap.addMarker(new MarkerOptions()
.position(new LatLng(latitude, longitude))
.icon(icon));
//41.900581, 12.487007 - Italy Rome
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(latitude, longitude)) // Sets the new camera position
.zoom(17) // Sets the zoom
.bearing(180) // Rotate the camera
.tilt(30) // Set the camera tilt
.build(); // Creates a CameraPosition from the builder
mapboxMap.animateCamera(CameraUpdateFactory
.newCameraPosition(cameraPosition), 7000);
here is how it's been called in the onMapReady() method
@Override
public void onMapReady(MapboxMap mapboxMap) {
map = mapboxMap;
mapboxMap.setOnMarkerClickListener(this);
//Controlling the components on the mapBox
mapboxMap.getUiSettings().setZoomControlsEnabled(false);//hide zoom control button
mapboxMap.getUiSettings().setCompassEnabled(false);//hide compass
mapboxMap.getUiSettings().setZoomGesturesEnabled(true);
mapboxMap.getUiSettings().setScrollGesturesEnabled(true);
mapboxMap.getUiSettings().setAllGesturesEnabled(true);
// Create an Icon object for the marker to use
Icon icon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.marker);
//This is the part where we check for the whether the permissions that are needed for this
//feature is allowed or not.
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
//Animate the camera and locate the marker
updateMap(41.900581, 12.487007, mapboxMap, icon);
}
@LukasPaczos For some reason which I am not sure why but it worked like this now
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Mapbox access token is configured here. This needs to be called either in your application
// object or in the same activity which contains the mapview.
Mapbox.getInstance(this, BuildConfig.MAPBOX_API_KEY);
// This contains the MapView in XML and needs to be called after the access token is configured.
setContentView(R.layout.activity_map);
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> {
//Controlling the components on the mapBox
mapboxMap.getUiSettings().setZoomControlsEnabled(false);//hide zoom control button
mapboxMap.getUiSettings().setCompassEnabled(false);//hide compass
mapboxMap.getUiSettings().setZoomGesturesEnabled(true);
mapboxMap.getUiSettings().setScrollGesturesEnabled(true);
mapboxMap.getUiSettings().setAllGesturesEnabled(true);
mapboxMap.setOnMarkerClickListener(this);
// Create an Icon object for the marker to use
Icon icon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.marker);
updateMap(41.900581, 12.487007, mapboxMap, icon);
//Don't forget the setCoordinate chain method is reverse while taking arguments NOTE that!
MapboxGeocoder client = new MapboxGeocoder.Builder()
.setAccessToken(BuildConfig.MAPBOX_API_KEY)
.setCoordinates(12.487007, 41.900581)
.setType(GeocoderCriteria.TYPE_POI)
.build();
client.enqueue(new Callback<GeocoderResponse>() {
@Override
public void onResponse(Response<GeocoderResponse> response, Retrofit retrofit) {
if (response.isSuccess()) {
if (response.body().getFeatures().size() > 0) {
placeName = response.body().getFeatures().get(0).getText();
String tempLocation = response.body().getFeatures().get(0).getPlaceName();
if (tempLocation.contains(",")) {
String[] places = TextUtils.split(response.body().getFeatures().get(0).getPlaceName(), ",");
if (places.length > 1) {
address = places[1];
}
}
}
} else {
//TODO add something later
}
}
@Override
public void onFailure(Throwable t) {
}
});
//TODO IMPROVE THE INFO WINDOW
mapboxMap.setInfoWindowAdapter(marker1 -> {
View v = getLayoutInflater().inflate(R.layout.layout_callout, null);
TextView title = v.findViewById(R.id.title);
TextView logo = v.findViewById(R.id.logoView);
TextView subTitle = v.findViewById(R.id.sub_title);
if (!placeName.isEmpty()) {
title.setText(placeName);
logo.setText(placeName.substring(0, 1));
}
subTitle.setText(address);
return v;
});
mapboxMap.setOnInfoWindowClickListener(marker -> {
startActivity(new Intent(MapActivity.this, DetailActivity.class));
return true;
});
});
}
private void updateMap(double latitude, double longitude, MapboxMap mapboxMap, Icon icon) {
// Marker
mapboxMap.addMarker(new MarkerOptions()
.position(new LatLng(latitude, longitude))
.icon(icon));
//41.900581, 12.487007 - Italy Rome
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(latitude, longitude)) // Sets the new camera position
.zoom(17) // Sets the zoom
.bearing(180) // Rotate the camera
.tilt(30) // Set the camera tilt
.build(); // Creates a CameraPosition from the builder
mapboxMap.animateCamera(CameraUpdateFactory
.newCameraPosition(cameraPosition), 7000);
}
this is my SDK version defined in the build config
Activity
bleege commentedon Dec 10, 2015
Related to #2805
[android] #3244 - Bringing back Camera API classes
[android] #3244 - Stubbing out API methods
[android] #3244 -Camera activity for TestApp
[android] #3244 -Material (vector) icon for Camera activity in TestApp
[android] #3244 - Fixing Camera activity call
bleege commentedon Dec 10, 2015
Basic classes, method stubs, and a TestApp activity are built. The next step is wiring up Core GL to the method stubs and verifying via TestApp activity.
[android] #3244 - Adding initial camera position in CameraActivity. B…
[android] #3244 - Reordering animateCamera() set data calls and makin…
60 remaining items
bleege commentedon Dec 18, 2015
Per chat, @zugaldia kicked the tires this morning on the branch and is happy with things. The only tweaks that we'll make are adding
@UIThreadannotations to theanimateCamera()methods to remind everyone that these should only be used on the UI Thread as per regular Android UI conventions. As part of this we can also remove theView.post(new Runnable(){}) forced UI Thread wrapping of Callback firing command since everything will be on the UIThread.Once these tweaks are made and tested that'll wrap up Iteration 0 on the Camera API and will then merge into
master./cc @twbell
[android] #3244 - Adding @UIThread annotations and removing View.post…
bleege commentedon Dec 18, 2015
Thanks to @jfirebaugh's help with git rebasing the Camera API is now merged into
masterfor everyone to enjoy![android] #3244 - Removing debug log statements
mb12 commentedon Dec 18, 2015
@bleege Is two finger drag gesture to tilt also available?
bleege commentedon Dec 18, 2015
@mb12 Yep. That's been in there since
2.3.0.KidusMT commentedon May 11, 2018
My Camera Animation is not working on API 23 and higher...but works fine on lower...Have this issue been solved? Please help!
here is my code...
here is how it's been called in the onMapReady() method
LukasPaczos commentedon May 11, 2018
@KidusMT What SDK version are you using? Could you check if there are no exceptions printed in your
Logcatafter the map is loaded?KidusMT commentedon May 12, 2018
@LukasPaczos For some reason which I am not sure why but it worked like this now
this is my SDK version defined in the build config
now its working on all API level I am targeting to work the app for.