Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6759f8d
commit f74aac6
Showing
18 changed files
with
365 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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,33 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 24 | ||
buildToolsVersion "24.0.3" | ||
|
||
defaultConfig { | ||
applicationId "com.mapzen.dynamicmarkers" | ||
minSdkVersion 15 | ||
targetSdkVersion 24 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
|
||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
sourceSets.main.assets.srcDirs = ['../styles'] | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
} | ||
|
||
dependencies { | ||
compile 'com.android.support:appcompat-v7:24.2.1' | ||
compile 'com.mapzen.tangram:tangram:0.4.4.1-SNAPSHOT' | ||
} |
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,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/sarahlensing/Library/Android/sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
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,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.mapzen.dynamicmarkers"> | ||
|
||
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
195 changes: 195 additions & 0 deletions
195
dynamicmarkers/src/main/java/com/mapzen/dynamicmarkers/MainActivity.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,195 @@ | ||
package com.mapzen.dynamicmarkers; | ||
|
||
import android.graphics.Bitmap; | ||
import android.graphics.BitmapFactory; | ||
import android.graphics.drawable.BitmapDrawable; | ||
import android.graphics.drawable.Drawable; | ||
import android.os.Bundle; | ||
import android.support.v4.content.ContextCompat; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.util.DisplayMetrics; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.Button; | ||
|
||
import com.mapzen.tangram.LngLat; | ||
import com.mapzen.tangram.MapController; | ||
import com.mapzen.tangram.MapView; | ||
import com.mapzen.tangram.Marker; | ||
import com.mapzen.tangram.geometry.Polygon; | ||
import com.mapzen.tangram.geometry.Polyline; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class MainActivity extends AppCompatActivity implements MapView.OnMapReadyCallback { | ||
|
||
MapController map; | ||
MapView view; | ||
Marker pointMarker; | ||
Marker lineMarker; | ||
Marker polygonMarker; | ||
LngLat point = new LngLat(-73.9918, 40.73633); | ||
|
||
String pointStyle = "{ style: 'points', color: 'white', size: [50px, 50px], order: 2000, collide: false }"; | ||
String lineStyle = "{ style: 'lines', color: '#06a6d4', width: 5px, order: 2000 }"; | ||
String polygonStyle = "{ style: 'polygons', color: '#06a6d4', width: 5px, order: 2000 }"; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
view = (MapView)findViewById(R.id.map); | ||
view.onCreate(savedInstanceState); | ||
view.getMapAsync(this, "bubble-wrap/bubble-wrap.yaml"); | ||
|
||
Button addMarkerBtn = (Button) findViewById(R.id.add_marker_btn); | ||
addMarkerBtn.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
if (!mapReadyAndNoMarker()) { | ||
return; | ||
} | ||
pointMarker = map.addMarker(); | ||
lineMarker = map.addMarker(); | ||
polygonMarker = map.addMarker(); | ||
} | ||
}); | ||
|
||
Button rmMarkerBtn = (Button) findViewById(R.id.rm_markers_btn); | ||
rmMarkerBtn.setOnClickListener(new MapMarkerReadyClickListener() { | ||
@Override | ||
void onReadyClick(View view) { | ||
map.removeAllMarkers(); | ||
pointMarker = null; | ||
lineMarker = null; | ||
polygonMarker = null; | ||
} | ||
}); | ||
|
||
Button setBitmapBtn = (Button) findViewById(R.id.set_bitmap_btn); | ||
setBitmapBtn.setOnClickListener(new MapMarkerReadyClickListener() { | ||
@Override | ||
void onReadyClick(View view) { | ||
pointMarker.setDrawable(R.drawable.mapzen_logo); | ||
// Drawable drawable = ContextCompat.getDrawable(MainActivity.this, R.drawable.mapzen_logo); | ||
// pointMarker.setDrawable(drawable); | ||
} | ||
}); | ||
|
||
Button setMarkerPtBtn = (Button) findViewById(R.id.set_marker_pt_btn); | ||
setMarkerPtBtn.setOnClickListener(new MapMarkerReadyClickListener() { | ||
@Override | ||
void onReadyClick(View view) { | ||
pointMarker.setPoint(point); | ||
} | ||
}); | ||
|
||
Button setStylingBtn = (Button) findViewById(R.id.set_styling_btn); | ||
setStylingBtn.setOnClickListener(new MapMarkerReadyClickListener() { | ||
@Override | ||
void onReadyClick(View view) { | ||
pointMarker.setStyling(pointStyle); | ||
lineMarker.setStyling(lineStyle); | ||
polygonMarker.setStyling(polygonStyle); | ||
} | ||
}); | ||
|
||
Button setPolylineBtn = (Button) findViewById(R.id.set_polyline_btn); | ||
setPolylineBtn.setOnClickListener(new MapMarkerReadyClickListener() { | ||
@Override | ||
void onReadyClick(View view) { | ||
ArrayList<LngLat> points = new ArrayList<>(); | ||
points.add(new LngLat(-73.9903, 40.74433)); | ||
points.add(new LngLat(-73.984770, 40.734807)); | ||
points.add(new LngLat(-73.998674, 40.732172)); | ||
points.add(new LngLat(-73.996142, 40.741050)); | ||
points.add(new LngLat(-73.9903, 40.74433)); | ||
// dont pass style here, its not read | ||
Polyline polyline = new Polyline(points, null); | ||
lineMarker.setPolyline(polyline); | ||
} | ||
}); | ||
|
||
Button setPolygonBtn = (Button) findViewById(R.id.set_polygon_btn); | ||
setPolygonBtn.setOnClickListener(new MapMarkerReadyClickListener() { | ||
@Override | ||
void onReadyClick(View view) { | ||
List<List<LngLat>> outer = new ArrayList<>(); | ||
ArrayList<LngLat> points = new ArrayList<>(); | ||
points.add(new LngLat(-73.9903, 40.74433)); | ||
points.add(new LngLat(-73.984770, 40.734807)); | ||
points.add(new LngLat(-73.998674, 40.732172)); | ||
points.add(new LngLat(-73.996142, 40.741050)); | ||
points.add(new LngLat(-73.9903, 40.74433)); | ||
outer.add(points); | ||
// dont pass style here, its not read | ||
Polygon polygon = new Polygon(outer, null); | ||
polygonMarker.setPolygon(polygon); | ||
} | ||
}); | ||
|
||
Button setVisibleBtn = (Button) findViewById(R.id.set_visible_btn); | ||
setVisibleBtn.setOnClickListener(new MapMarkerReadyClickListener() { | ||
@Override | ||
void onReadyClick(View view) { | ||
pointMarker.setVisible(!pointMarker.isVisible()); | ||
lineMarker.setVisible(!lineMarker.isVisible()); | ||
polygonMarker.setVisible(!polygonMarker.isVisible()); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void onMapReady(MapController mapController) { | ||
map = mapController; | ||
map.setPosition(point); | ||
map.setZoom(15); | ||
} | ||
|
||
@Override | ||
public void onResume() { | ||
super.onResume(); | ||
view.onResume(); | ||
} | ||
|
||
@Override | ||
public void onPause() { | ||
super.onPause(); | ||
view.onPause(); | ||
} | ||
|
||
@Override | ||
public void onDestroy() { | ||
super.onDestroy(); | ||
view.onDestroy(); | ||
} | ||
|
||
@Override | ||
public void onLowMemory() { | ||
super.onLowMemory(); | ||
view.onLowMemory(); | ||
} | ||
|
||
private boolean mapReadyAndNoMarker() { | ||
return map != null && pointMarker == null; | ||
} | ||
|
||
private boolean mapAndMarkerReady() { | ||
return map != null && pointMarker != null; | ||
} | ||
|
||
abstract class MapMarkerReadyClickListener implements View.OnClickListener { | ||
|
||
abstract void onReadyClick(View view); | ||
|
||
@Override | ||
public void onClick(View view) { | ||
if (!mapAndMarkerReady()) { | ||
return; | ||
} | ||
onReadyClick(view); | ||
} | ||
} | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,71 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" | ||
android:layout_width="match_parent" android:layout_height="match_parent" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
tools:context="com.mapzen.dynamicmarkers.MainActivity"> | ||
|
||
<com.mapzen.tangram.MapView | ||
android:id="@+id/map" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content"/> | ||
|
||
<LinearLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<Button | ||
android:id="@+id/add_marker_btn" | ||
android:text="Add Markers" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
|
||
<Button | ||
android:id="@+id/rm_markers_btn" | ||
android:text="Remove Markers" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
|
||
<Button | ||
android:id="@+id/set_bitmap_btn" | ||
android:text="Set Marker Bitmap" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
|
||
<Button | ||
android:id="@+id/set_marker_pt_btn" | ||
android:text="Set Marker Point" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
|
||
<Button | ||
android:id="@+id/set_styling_btn" | ||
android:text="Set Marker Styling" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
|
||
<Button | ||
android:id="@+id/set_polyline_btn" | ||
android:text="Set Marker Polyline" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
|
||
<Button | ||
android:id="@+id/set_polygon_btn" | ||
android:text="Set Marker Polygon" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
|
||
<Button | ||
android:id="@+id/set_visible_btn" | ||
android:text="Toggle Marker Visible" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
|
||
</LinearLayout> | ||
|
||
</RelativeLayout> |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,6 @@ | ||
<resources> | ||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml | ||
(such as screen margins) for screens with more than 820dp of available width. This | ||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> | ||
<dimen name="activity_horizontal_margin">64dp</dimen> | ||
</resources> |
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#3F51B5</color> | ||
<color name="colorPrimaryDark">#303F9F</color> | ||
<color name="colorAccent">#FF4081</color> | ||
</resources> |
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,5 @@ | ||
<resources> | ||
<!-- Default screen margins, per the Android Design guidelines. --> | ||
<dimen name="activity_horizontal_margin">16dp</dimen> | ||
<dimen name="activity_vertical_margin">16dp</dimen> | ||
</resources> |
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,3 @@ | ||
<resources> | ||
<string name="app_name">dynamicmarkers</string> | ||
</resources> |
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,11 @@ | ||
<resources> | ||
|
||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | ||
<!-- Customize your theme here. --> | ||
<item name="colorPrimary">@color/colorPrimary</item> | ||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | ||
<item name="colorAccent">@color/colorAccent</item> | ||
</style> | ||
|
||
</resources> |
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 |
---|---|---|
@@ -1 +1 @@ | ||
include ':simplemap', ':mapmovement', ':mapgestures', ':featurepicking', ':sceneupdates', ':markers' | ||
include ':simplemap', ':mapmovement', ':mapgestures', ':featurepicking', ':sceneupdates', ':markers', ':dynamicmarkers' |