Skip to content

Commit

Permalink
feat: replacing files
Browse files Browse the repository at this point in the history
feat: replacing files
  • Loading branch information
kikoso committed Nov 8, 2024
1 parent 214b8b7 commit 1a097f6
Show file tree
Hide file tree
Showing 8 changed files with 1,292 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import android.graphics.Color
import androidx.appcompat.app.AppCompatActivity
import com.google.android.gms.maps.OnMapReadyCallback
import android.os.Bundle
import android.util.Log
import android.widget.Button
import androidx.core.graphics.ColorUtils
import com.google.android.gms.maps.SupportMapFragment
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.CameraUpdateFactory
Expand All @@ -32,9 +34,9 @@ import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.MapCapabilities


private val SEATTLE = LatLng(47.6062, -122.3321)
private val NEW_YORK = LatLng(40.7128, -74.0060)
private val FALSE_BAY_CAPE_TOWN = LatLng(-34.1476, 18.6722)
private val KYOTO = LatLng(35.0016, 135.7681)
private val NEW_YORK = LatLng(40.7826, -73.9656)
private val BOULDER = LatLng(40.0150, -105.2705)

private const val ZOOM_LEVEL = 13.5f

Expand All @@ -61,24 +63,24 @@ class DataDrivenDatasetStylingActivity : AppCompatActivity(), OnMapReadyCallback
mapFragment?.getMapAsync(this)


findViewById<Button>(R.id.button_seattle).setOnClickListener {
centerMapOnLocation(SEATTLE) // Seattle coordinates
findViewById<Button>(R.id.button_kyoto).setOnClickListener {
centerMapOnLocation(KYOTO) // Seattle coordinates
}

findViewById<Button>(R.id.button_ny).setOnClickListener {
centerMapOnLocation(NEW_YORK) // New York coordinates
}

findViewById<Button>(R.id.button_south_africa).setOnClickListener {
centerMapOnLocation(FALSE_BAY_CAPE_TOWN) // False Bay, Cape Town coordinates
findViewById<Button>(R.id.button_boulder).setOnClickListener {
centerMapOnLocation(BOULDER) // New York coordinates
}
}

override fun onMapReady(googleMap: GoogleMap) {
map = googleMap

with(map) {
moveCamera(CameraUpdateFactory.newLatLngZoom(SEATTLE, ZOOM_LEVEL))
moveCamera(CameraUpdateFactory.newLatLngZoom(KYOTO, ZOOM_LEVEL))
}

val capabilities: MapCapabilities = map.mapCapabilities
Expand Down Expand Up @@ -118,8 +120,8 @@ class DataDrivenDatasetStylingActivity : AppCompatActivity(), OnMapReadyCallback
if (feature is DatasetFeature) {

val furColors: MutableMap<String, String> = feature.datasetAttributes
// Determine CombinationofPrimaryandHighlightColor attribute.
val furColor = furColors["CombinationofPrimaryandHighlightColor"]
// Determine Color attribute.
val furColor = furColors["Color"]
when (furColor) {
"Black+" -> {
fillColor = Color.BLACK
Expand Down Expand Up @@ -184,23 +186,17 @@ class DataDrivenDatasetStylingActivity : AppCompatActivity(), OnMapReadyCallback
if (feature is DatasetFeature) {
// Determine the value of the typecategory attribute.
val typeCategories: MutableMap<String, String> = feature.datasetAttributes
val typeCategory = typeCategories["typecategory"]
val typeCategory = typeCategories["type"]
// Set default colors to green.
val fillColor: Int
val strokeColor: Int
when (typeCategory) {
"Undeveloped" -> {
// Color undeveloped areas blue.
"temple" -> {
// Color temples areas blue.
fillColor = Color.BLUE
strokeColor = Color.BLUE
}

"Parkway" -> {
// Color parkway areas red.
fillColor = Color.RED
strokeColor = Color.RED
}

else -> {
// Color all other areas green.
fillColor = Color.GREEN
Expand All @@ -221,17 +217,64 @@ class DataDrivenDatasetStylingActivity : AppCompatActivity(), OnMapReadyCallback
}

private fun styleDatasetsLayerPolyline() {
val EASY = Color.GREEN
val MODERATE = Color.BLUE
val DIFFICULT = Color.RED

// Create the style factory function.
val styleFactory = FeatureLayer.StyleFactory { feature: Feature ->

// Set default colors to to yellow and point radius to 8.
var fillColor = Color.GREEN
var strokeColor = Color.YELLOW
var pointRadius = 8F
var strokeWidth = 3F
// Check if the feature is an instance of DatasetFeature.
if (feature is DatasetFeature) {

val attributes: MutableMap<String, String> = feature.datasetAttributes
val difficulty = attributes["OSMPTrailsOSMPDIFFICULTY"]
val name = attributes["OSMPTrailsOSMPTRAILNAME"]
val dogsAllowed = attributes["OSMPTrailsOSMPDOGREGGEN"]

when (difficulty) {
"Easy" -> {
fillColor = EASY
}
"Moderate" -> {
fillColor = MODERATE
}
"Difficult" -> {
fillColor = DIFFICULT
}
else -> {
Log.w(TAG, "$name -> Unknown difficulty: $difficulty")
fillColor = Color.MAGENTA
}
}

when (dogsAllowed) {
"No Dogs" -> {
fillColor = ColorUtils.setAlphaComponent(fillColor, 66)
strokeWidth = 5f
}
"LVS" -> {
}
"LR", "RV" -> {
fillColor = ColorUtils.setAlphaComponent(fillColor, 75)
}
else -> {
Log.w(TAG, "$name -> Unknown dogs reg: $dogsAllowed")
}
}

strokeColor = fillColor

return@StyleFactory FeatureStyle.Builder()
// Define a style with green stroke with a width of 4.
.strokeColor(0xff00ff00.toInt())
.strokeWidth(4F)
.fillColor(fillColor)
.strokeColor(strokeColor)
.pointRadius(pointRadius)
.strokeWidth(strokeWidth)
.build()
}
return@StyleFactory null
Expand All @@ -241,6 +284,7 @@ class DataDrivenDatasetStylingActivity : AppCompatActivity(), OnMapReadyCallback
datasetLayer?.featureStyle = styleFactory
}


private fun centerMapOnLocation(location: LatLng) {
map.moveCamera(CameraUpdateFactory.newLatLngZoom(location, ZOOM_LEVEL))
}
Expand All @@ -251,7 +295,7 @@ class DataDrivenDatasetStylingActivity : AppCompatActivity(), OnMapReadyCallback
val clickFeatures: MutableList<Feature> = event.features
lastGlobalId = null
if (clickFeatures[0] is DatasetFeature) {
lastGlobalId = ((clickFeatures[0] as DatasetFeature).datasetAttributes.get("globalid"))
lastGlobalId = ((clickFeatures[0] as DatasetFeature).datasetAttributes["globalid"])
// Remember to reset the Style Factory.
styleDatasetsLayerClickEvent()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
android:padding="16dp">

<Button
android:id="@+id/button_seattle"
android:id="@+id/button_kyoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Seattle" />
android:text="Kyoto" />

<Button
android:id="@+id/button_ny"
Expand All @@ -49,10 +49,10 @@
android:text="New York" />

<Button
android:id="@+id/button_south_africa"
android:id="@+id/button_boulder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="South Africa" />
android:text="Boulder" />
</LinearLayout>


Expand Down

This file was deleted.

74 changes: 0 additions & 74 deletions ApiDemos/kotlin/app/src/main/res/raw/multiple_points_nyc.csv

This file was deleted.

Loading

0 comments on commit 1a097f6

Please sign in to comment.