feat: Adding kotlin sample for MapWithMarker. (#192)

* feat: Adding kotlin sample for MapWithMarker.

* Using gradle technique for passing the API key

* Adding license headers.

* Modify java MapWithMarker to use secure.properties as well.

* Adding more license headers

* Update build.yml cd

* Fix dir.

* Using maps_api_key

* Update tutorials/kotlin/MapWithMarker/app/src/main/java/com/example/mapwithmarker/MapsMarkerActivity.kt

Co-authored-by: Sean Barbeau <sjbarbeau@gmail.com>

* Comments

* Add missing import

Co-authored-by: Sean Barbeau <sjbarbeau@gmail.com>
This commit is contained in:
Chris Arriola 2020-05-07 15:02:38 -07:00 committed by GitHub
parent 581ae289a6
commit 69f17a8fb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
121 changed files with 737 additions and 14 deletions

View File

@ -19,25 +19,31 @@ update_configs:
prefix: "chore(deps)"
- package_manager: "java:gradle"
directory: "./tutorials/CurrentPlaceDetailsOnMap/"
directory: "./tutorials/java/CurrentPlaceDetailsOnMap/"
update_schedule: "daily"
commit_message:
prefix: "chore(deps)"
- package_manager: "java:gradle"
directory: "./tutorials/MapWithMarker/"
directory: "./tutorials/java/MapWithMarker/"
update_schedule: "daily"
commit_message:
prefix: "chore(deps)"
- package_manager: "java:gradle"
directory: "./tutorials/Polygons/"
directory: "./tutorials/java/Polygons/"
update_schedule: "daily"
commit_message:
prefix: "chore(deps)"
- package_manager: "java:gradle"
directory: "./tutorials/StyledMap/"
directory: "./tutorials/java/StyledMap/"
update_schedule: "daily"
commit_message:
prefix: "chore(deps)"
- package_manager: "java:gradle"
directory: "./tutorials/kotlin/MapWithMarker/"
update_schedule: "daily"
commit_message:
prefix: "chore(deps)"

View File

@ -61,4 +61,13 @@ jobs:
- name: Build and check
run: |
cd tutorials
for dir in ./*/ ; do ( cd "$dir" && ./gradlew assembleDebug lintDebug ); done
for dir in ./*/
do
cd "$dir"
for tutorial in ./*/
do
cd "$tutorial" && ./gradlew assembleDebug lintDebug
cd ..
done
cd ..
done

View File

@ -1,3 +1,17 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.example.currentplacedetailsonmap;
import android.content.DialogInterface;

View File

@ -18,14 +18,19 @@ This sample uses the Gradle build system.
1. Download the samples by cloning this repository or downloading an archived
snapshot. (See the options at the top of the page.)
1. In Android Studio, create a new project and choose the "Import non-Android Studio project" or
"Import Project" option.
1. Select the `MapWithMarker` directory that you downloaded with this repository.
1. In Android Studio, use "Open an existing Android Studio project". Next select the
`tutorials/java/MapWithMarker` directory that you downloaded
1. If prompted for a gradle configuration, accept the default settings.
Alternatively use the "gradlew build" command to build the project directly.
1. Add your API key to your app's `gradle.properties` file.
(For information on getting an API key, see the
[documentation](https://developers.google.com/maps/documentation/android-api/signup).)
Alternatively use the `gradlew build` command to build the project directly.
This demo app requires that you add your own Google Maps API key:
1. [Get a Maps API key](https://developers.google.com/maps/documentation/android-sdk/get-api-key)
1. Create a file in the `tutorials/java/MapWithMarker` directory called `secure.properties`
(this file should *NOT* be under version control to protect your API key)
1. Add a single line to `tutorials/java/MapWithMarker/secure.properties` that looks like
`MAPS_API_KEY=YOUR_API_KEY`, where `YOUR_API_KEY` is the API key you obtained in the first step
1. Build and run
Support
-------

View File

@ -10,7 +10,18 @@ android {
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
resValue "string", "google_maps_key", (project.findProperty("GOOGLE_MAPS_API_KEY") ?: "")
// Read the API key from tutorials/java/MapWithMarker/app/secure.properties into R.string.maps_api_key
def secureProps = new Properties()
if (file("secure.properties").exists()) {
file("secure.properties")?.withInputStream { secureProps.load(it) }
}
resValue "string", "maps_api_key", (secureProps.getProperty("MAPS_API_KEY") ?: "")
// To add your Maps API key to this project:
// 1. Create a file tutorials/java/MapWithMarker/app/secure.properties
// 2. Add this line, where YOUR_API_KEY is your API key:
// MAPS_API_KEY=YOUR_API_KEY
}
buildTypes {
release {

View File

@ -18,7 +18,7 @@
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
android:value="@string/maps_api_key" />
<activity
android:name=".MapsMarkerActivity"

View File

@ -1,3 +1,17 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.example.mapwithmarker;
import android.os.Bundle;

View File

@ -1,3 +1,17 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.example.polygons;
import android.os.Bundle;

View File

Before

Width:  |  Height:  |  Size: 200 B

After

Width:  |  Height:  |  Size: 200 B

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -1,3 +1,17 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.example.styledmap;
import android.content.res.Resources;

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild

View File

@ -0,0 +1,51 @@
Google Maps Android API Sample: Adding a Map with a Marker
==========================================================
This sample goes hand in hand with a tutorial for the Google Maps Android API:
[Adding a Map with a Marker](https://developers.google.com/maps/documentation/android-api/map-with-marker).
Prerequisites
--------------
- Android SDK v24
- Latest Android Build Tools
- Android Support Repository
Getting started
---------------
This sample uses the Gradle build system.
1. Download the samples by cloning this repository or downloading an archived
snapshot. (See the options at the top of the page.)
1. In Android Studio, use "Open an existing Android Studio project". Next select the
`tutorials/kotlin/MapWithMarker` directory that you downloaded
1. If prompted for a gradle configuration, accept the default settings.
Alternatively use the `gradlew build` command to build the project directly.
This demo app requires that you add your own Google Maps API key:
1. [Get a Maps API key](https://developers.google.com/maps/documentation/android-sdk/get-api-key)
1. Create a file in the `tutorials/kotlin/MapWithMarker` directory called `secure.properties`
(this file should *NOT* be under version control to protect your API key)
1. Add a single line to `tutorials/kotlin/MapWithMarker/secure.properties` that looks like
`MAPS_API_KEY=YOUR_API_KEY`, where `YOUR_API_KEY` is the API key you obtained in the first step
1. Build and run
Support
-------
Stack Overflow: https://stackoverflow.com/questions/tagged/android+google-maps
If you have discovered an issue with the Google Maps Android API v2, please see
the resources here: https://developers.google.com/maps/documentation/android-api/support
If you've found an error in these samples, please file an issue:
https://github.com/googlemaps/android-samples/issues
![Analytics](https://ga-beacon.appspot.com/UA-12846745-20/android-samples-apidemos/readme?pixel)
License
-------
Please refer to the [LICENSE](https://github.com/googlemaps/android-samples/blob/master/LICENSE) at the root of this repo.

Some files were not shown because too many files have changed in this diff Show More