-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* # This is a combination of 5 commits. # This is the 1st commit message: add Building plugin # The commit message #2 will be skipped: # fixed issues reviewed by me # The commit message #3 will be skipped: # fixed bitrise script # The commit message #4 will be skipped: # added DDS for building height # The commit message #5 will be skipped: # removed commented out code * cleaned up gradle file * updated Makefile * added optional constructor param to place buildings below layer * added comment with more information
- Loading branch information
Showing
18 changed files
with
596 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
180 changes: 180 additions & 0 deletions
180
...ins/app/src/main/java/com/mapbox/mapboxsdk/plugins/testapp/activity/BuildingActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
package com.mapbox.mapboxsdk.plugins.testapp.activity; | ||
|
||
import android.graphics.Color; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.widget.SeekBar; | ||
|
||
import com.mapbox.androidsdk.plugins.building.BuildingPlugin; | ||
import com.mapbox.mapboxsdk.constants.Style; | ||
import com.mapbox.mapboxsdk.maps.MapView; | ||
import com.mapbox.mapboxsdk.maps.MapboxMap; | ||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; | ||
import com.mapbox.mapboxsdk.plugins.testapp.R; | ||
import com.mapbox.mapboxsdk.style.light.Light; | ||
import com.mapbox.mapboxsdk.style.light.Position; | ||
|
||
import butterknife.BindView; | ||
import butterknife.ButterKnife; | ||
import butterknife.OnClick; | ||
import timber.log.Timber; | ||
|
||
/** | ||
* Activity showcasing building plugin integration | ||
*/ | ||
public class BuildingActivity extends AppCompatActivity implements OnMapReadyCallback { | ||
|
||
@BindView(R.id.mapView) | ||
MapView mapView; | ||
|
||
@BindView(R.id.fabBuilding) | ||
View fab; | ||
|
||
@BindView(R.id.seekbarLightRadialCoordinate) | ||
SeekBar seekbarRadialCoordinate; | ||
|
||
@BindView(R.id.seekbarLightAzimuthalAngle) | ||
SeekBar seekbarAzimuthalAngle; | ||
|
||
@BindView(R.id.seekbarLightPolarAngle) | ||
SeekBar seekbarPolarAngle; | ||
|
||
private MapboxMap mapboxMap; | ||
private BuildingPlugin buildingPlugin; | ||
private boolean isEnabled; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_building); | ||
ButterKnife.bind(this); | ||
mapView.onCreate(savedInstanceState); | ||
mapView.getMapAsync(this); | ||
} | ||
|
||
@Override | ||
public void onMapReady(MapboxMap mapboxMap) { | ||
this.mapboxMap = mapboxMap; | ||
buildingPlugin = new BuildingPlugin(mapView, mapboxMap); | ||
buildingPlugin.setMinZoomLevel(15); | ||
fab.setVisibility(View.VISIBLE); | ||
initLightSeekbar(); | ||
} | ||
|
||
// See https://en.wikipedia.org/wiki/Spherical_coordinate_system for more information on these values | ||
private void initLightSeekbar() { | ||
seekbarRadialCoordinate.setMax(24); // unknown? | ||
seekbarAzimuthalAngle.setMax(180); // unknown? | ||
seekbarPolarAngle.setMax(180); // polar angle ranges from 0 to 180 degrees | ||
|
||
PositionChangeListener positionChangeListener = new PositionChangeListener(); | ||
seekbarRadialCoordinate.setOnSeekBarChangeListener(positionChangeListener); | ||
seekbarAzimuthalAngle.setOnSeekBarChangeListener(positionChangeListener); | ||
seekbarPolarAngle.setOnSeekBarChangeListener(positionChangeListener); | ||
} | ||
|
||
@OnClick(R.id.fabBuilding) | ||
public void onBuildingFabClicked() { | ||
if (mapboxMap != null) { | ||
isEnabled = !isEnabled; | ||
buildingPlugin.setVisibility(isEnabled); | ||
Timber.e("Building plugin is enabled :%s", isEnabled); | ||
} | ||
} | ||
|
||
private class PositionChangeListener implements SeekBar.OnSeekBarChangeListener { | ||
@Override | ||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | ||
invalidateLightPosition(); | ||
} | ||
|
||
@Override | ||
public void onStartTrackingTouch(SeekBar seekBar) { | ||
// Only listening to positionChange for onProgress. | ||
} | ||
|
||
@Override | ||
public void onStopTrackingTouch(SeekBar seekBar) { | ||
// Only listening to positionChange for onProgress. | ||
} | ||
} | ||
|
||
private void invalidateLightPosition() { | ||
Light light = mapboxMap.getLight(); | ||
float radialCoordinate = (float) seekbarRadialCoordinate.getProgress() / 20; | ||
float azimuthalAngle = seekbarAzimuthalAngle.getProgress(); | ||
float polarAngle = seekbarPolarAngle.getProgress(); | ||
light.setPosition(new Position(radialCoordinate, azimuthalAngle, polarAngle)); | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
switch (item.getItemId()) { | ||
case R.id.menu_building_min_zoom: | ||
buildingPlugin.setMinZoomLevel(14); | ||
return true; | ||
case R.id.menu_building_opacity: | ||
buildingPlugin.setOpacity(1.0f); | ||
return true; | ||
case R.id.menu_building_color: | ||
buildingPlugin.setColor(Color.RED); | ||
return true; | ||
case R.id.menu_building_style: | ||
mapboxMap.setStyle(Style.DARK); | ||
return true; | ||
default: | ||
return super.onOptionsItemSelected(item); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
getMenuInflater().inflate(R.menu.menu_building, menu); | ||
return super.onCreateOptionsMenu(menu); | ||
} | ||
|
||
@Override | ||
protected void onStart() { | ||
super.onStart(); | ||
mapView.onStart(); | ||
} | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
mapView.onResume(); | ||
} | ||
|
||
@Override | ||
protected void onPause() { | ||
super.onPause(); | ||
mapView.onPause(); | ||
} | ||
|
||
@Override | ||
protected void onStop() { | ||
super.onStop(); | ||
mapView.onStop(); | ||
} | ||
|
||
@Override | ||
protected void onSaveInstanceState(Bundle outState) { | ||
super.onSaveInstanceState(outState); | ||
mapView.onSaveInstanceState(outState); | ||
} | ||
|
||
@Override | ||
protected void onDestroy() { | ||
super.onDestroy(); | ||
mapView.onDestroy(); | ||
} | ||
|
||
@Override | ||
public void onLowMemory() { | ||
super.onLowMemory(); | ||
mapView.onLowMemory(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24.0" | ||
android:viewportHeight="24.0"> | ||
<path | ||
android:fillColor="#FF000000" | ||
android:pathData="M12,7L12,3L2,3v18h20L22,7L12,7zM6,19L4,19v-2h2v2zM6,15L4,15v-2h2v2zM6,11L4,11L4,9h2v2zM6,7L4,7L4,5h2v2zM10,19L8,19v-2h2v2zM10,15L8,15v-2h2v2zM10,11L8,11L8,9h2v2zM10,7L8,7L8,5h2v2zM20,19h-8v-2h2v-2h-2v-2h2v-2h-2L12,9h8v10zM18,11h-2v2h2v-2zM18,15h-2v2h2v-2z"/> | ||
</vector> |
Oops, something went wrong.