-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Showing
143 changed files
with
12,987 additions
and
131 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!-- | ||
Copyright 2018 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 | ||
https://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. | ||
--> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/demo_title" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
|
||
<activity android:name=".MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".AdvancedMarkersDemoActivity" | ||
android:label="@string/advanced_markers_demo_label" /> | ||
<activity | ||
android:name=".BasicMapDemoActivity" | ||
android:label="@string/basic_map_demo_label" /> | ||
<activity | ||
android:name=".BackgroundColorCustomizationDemoActivity" | ||
android:label="@string/background_color_customization_demo_label"/> | ||
<activity | ||
android:name=".BackgroundColorCustomizationProgrammaticDemoActivity" | ||
android:label="@string/background_color_customization_programmatic_demo_label"/> | ||
<activity | ||
android:name=".CameraDemoActivity" | ||
android:label="@string/camera_demo_label" /> | ||
<activity | ||
android:name=".CameraClampingDemoActivity" | ||
android:label="@string/camera_clamping_demo_label" /> | ||
<activity | ||
android:name=".CloudBasedMapStylingDemoActivity" | ||
android:label="@string/cloud_styling_label" /> | ||
<activity | ||
android:name=".CircleDemoActivity" | ||
android:label="@string/circle_demo_label" /> | ||
<activity | ||
android:name=".EventsDemoActivity" | ||
android:label="@string/events_demo_label" /> | ||
<activity | ||
android:name=".GroundOverlayDemoActivity" | ||
android:label="@string/ground_overlay_demo_label" /> | ||
<activity | ||
android:name=".IndoorDemoActivity" | ||
android:label="@string/indoor_demo_label" /> | ||
<activity | ||
android:name=".LayersDemoActivity" | ||
android:label="@string/layers_demo_label" /> | ||
<activity | ||
android:name=".LiteDemoActivity" | ||
android:label="@string/lite_demo_label" /> | ||
<activity | ||
android:name=".LiteListDemoActivity" | ||
android:label="@string/lite_list_demo_label" /> | ||
<activity | ||
android:name=".LocationSourceDemoActivity" | ||
android:label="@string/location_source_demo_label" /> | ||
<activity | ||
android:name=".MapInPagerDemoActivity" | ||
android:label="@string/map_in_pager_demo_label" /> | ||
<activity | ||
android:name=".MapColorSchemeActivity" | ||
android:label="@string/marker_demo_label" /> | ||
<activity | ||
android:name=".MarkerDemoActivity" | ||
android:label="@string/marker_demo_label" /> | ||
<activity | ||
android:name=".MarkerCloseInfoWindowOnRetapDemoActivity" | ||
android:label="@string/marker_close_info_window_on_retap_demo_label" /> | ||
<activity | ||
android:name=".PolylineDemoActivity" | ||
android:label="@string/polyline_demo_label" /> | ||
<activity | ||
android:name=".MultiMapDemoActivity" | ||
android:label="@string/multi_map_demo_label" /> | ||
<activity | ||
android:name=".MyLocationDemoActivity" | ||
android:label="@string/my_location_demo_label" /> | ||
<activity | ||
android:name=".OptionsDemoActivity" | ||
android:label="@string/options_demo_label" /> | ||
<activity | ||
android:name=".PolygonDemoActivity" | ||
android:label="@string/polygon_demo_label" /> | ||
<activity | ||
android:name=".ProgrammaticDemoActivity" | ||
android:label="@string/programmatic_demo_label" /> | ||
<activity | ||
android:name=".RawMapViewDemoActivity" | ||
android:label="@string/raw_map_view_demo_label" /> | ||
<activity | ||
android:name=".RetainMapDemoActivity" | ||
android:label="@string/retain_map_demo_label" /> | ||
<activity | ||
android:name=".SaveStateDemoActivity" | ||
android:label="@string/save_state_demo_label" /> | ||
<activity | ||
android:name=".SnapshotDemoActivity" | ||
android:label="@string/snapshot_demo_label" /> | ||
<activity | ||
android:name=".SplitStreetViewPanoramaAndMapDemoActivity" | ||
android:label="@string/split_street_view_panorama_and_map_demo_label" /> | ||
<activity | ||
android:name=".StreetViewPanoramaBasicDemoActivity" | ||
android:label="@string/street_view_panorama_basic_demo_label" /> | ||
<activity | ||
android:name=".StreetViewPanoramaEventsDemoActivity" | ||
android:label="@string/street_view_panorama_events_demo_label" /> | ||
<activity | ||
android:name=".StreetViewPanoramaNavigationDemoActivity" | ||
android:label="@string/street_view_panorama_navigation_demo_label" /> | ||
<activity | ||
android:name=".StreetViewPanoramaOptionsDemoActivity" | ||
android:label="@string/street_view_panorama_options_demo_label" /> | ||
<activity | ||
android:name=".StreetViewPanoramaViewDemoActivity" | ||
android:label="@string/street_view_panorama_view_demo_label" /> | ||
<activity | ||
android:name=".StyledMapDemoActivity" | ||
android:label="@string/styled_map_demo_label" /> | ||
<activity | ||
android:name=".TagsDemoActivity" | ||
android:label="@string/tags_demo_label" /> | ||
<activity | ||
android:name=".TileCoordinateDemoActivity" | ||
android:label="@string/tile_coordinate_demo_label" /> | ||
<activity | ||
android:name=".TileOverlayDemoActivity" | ||
android:label="@string/tile_overlay_demo_label" /> | ||
<activity | ||
android:name=".UiSettingsDemoActivity" | ||
android:label="@string/ui_settings_demo_label" /> | ||
<activity | ||
android:name=".VisibleRegionDemoActivity" | ||
android:label="@string/visible_region_demo_label" /> | ||
|
||
</application> | ||
|
||
</manifest> |
139 changes: 139 additions & 0 deletions
139
ApiDemos/java/app/src/gms/java/com/example/mapdemo/AdvancedMarkersDemoActivity.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,139 @@ | ||
// Copyright 2023 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.mapdemo; | ||
|
||
import android.graphics.Color; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.widget.TextView; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import com.google.android.gms.maps.CameraUpdateFactory; | ||
import com.google.android.gms.maps.GoogleMap; | ||
import com.google.android.gms.maps.OnMapReadyCallback; | ||
import com.google.android.gms.maps.SupportMapFragment; | ||
import com.google.android.gms.maps.model.AdvancedMarkerOptions; | ||
import com.google.android.gms.maps.model.BitmapDescriptorFactory; | ||
import com.google.android.gms.maps.model.LatLng; | ||
import com.google.android.gms.maps.model.MapCapabilities; | ||
import com.google.android.gms.maps.model.Marker; | ||
import com.google.android.gms.maps.model.PinConfig; | ||
|
||
/** | ||
* The following sample showcases how to create Advanced Markers, and use all their customization | ||
* possibilities. | ||
*/ | ||
// [START maps_android_sample_marker_advanced] | ||
public class AdvancedMarkersDemoActivity extends AppCompatActivity implements OnMapReadyCallback { | ||
|
||
private static final LatLng SINGAPORE = new LatLng(1.3521, 103.8198); | ||
private static final LatLng KUALA_LUMPUR = new LatLng(3.1390, 101.6869); | ||
private static final LatLng JAKARTA = new LatLng(-6.2088, 106.8456); | ||
private static final LatLng BANGKOK = new LatLng(13.7563, 100.5018); | ||
private static final LatLng MANILA = new LatLng(14.5995, 120.9842); | ||
private static final LatLng HO_CHI_MINH_CITY = new LatLng(10.7769, 106.7009); | ||
|
||
private static final float ZOOM_LEVEL = 3.5f; | ||
|
||
private static final String TAG = AdvancedMarkersDemoActivity.class.getName(); | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.advanced_markers_demo); | ||
|
||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); | ||
if (mapFragment != null) { | ||
mapFragment.getMapAsync(this); | ||
} | ||
} | ||
|
||
@Override | ||
public void onMapReady(GoogleMap map) { | ||
map.moveCamera(CameraUpdateFactory.newLatLngZoom(SINGAPORE, ZOOM_LEVEL)); | ||
|
||
MapCapabilities capabilities = map.getMapCapabilities(); | ||
Log.d(TAG, "Are advanced markers enabled? " + capabilities.isAdvancedMarkersAvailable()); | ||
|
||
// This sample sets a view as the iconView for the Advanced Marker | ||
TextView textView = new TextView(this); | ||
textView.setText("Hello!"); | ||
Marker advancedMarkerView = map.addMarker(new AdvancedMarkerOptions() | ||
.position(SINGAPORE) | ||
.iconView(textView) | ||
.zIndex(1f)); | ||
|
||
// This uses PinConfig.Builder to create an instance of PinConfig. | ||
PinConfig.Builder pinConfigBuilder = PinConfig.builder(); | ||
pinConfigBuilder.setBackgroundColor(Color.MAGENTA); | ||
PinConfig pinConfig = pinConfigBuilder.build(); | ||
|
||
// Use the PinConfig instance to set the icon for AdvancedMarkerOptions. | ||
AdvancedMarkerOptions advancedMarkerOptions = new AdvancedMarkerOptions() | ||
.icon(BitmapDescriptorFactory.fromPinConfig(pinConfig)) | ||
.position(KUALA_LUMPUR); | ||
|
||
// Pass the AdvancedMarkerOptions instance to addMarker(). | ||
Marker marker = map.addMarker(advancedMarkerOptions); | ||
|
||
// This sample changes the border color of the advanced marker | ||
PinConfig.Builder pinConfigBuilder2 = PinConfig.builder(); | ||
pinConfigBuilder2.setBorderColor(Color.BLUE); | ||
PinConfig pinConfig2 = pinConfigBuilder2.build(); | ||
|
||
AdvancedMarkerOptions advancedMarkerOptions2 = new AdvancedMarkerOptions() | ||
.icon(BitmapDescriptorFactory.fromPinConfig(pinConfig2)) | ||
.position(JAKARTA); | ||
|
||
Marker marker2 = map.addMarker(advancedMarkerOptions2); | ||
|
||
// Set the glyph text. | ||
PinConfig.Builder pinConfigBuilder3 = PinConfig.builder(); | ||
PinConfig.Glyph glyphText = new PinConfig.Glyph("A"); | ||
|
||
// Alternatively, you can set the text color: | ||
// Glyph glyphText = new Glyph("A", Color.GREEN); | ||
pinConfigBuilder3.setGlyph(glyphText); | ||
PinConfig pinConfig3 = pinConfigBuilder3.build(); | ||
|
||
AdvancedMarkerOptions advancedMarkerOptions3 = new AdvancedMarkerOptions() | ||
.icon(BitmapDescriptorFactory.fromPinConfig(pinConfig3)) | ||
.position(BANGKOK); | ||
|
||
Marker marker3 = map.addMarker(advancedMarkerOptions3); | ||
|
||
// Create a transparent glyph. | ||
PinConfig.Builder pinConfigBuilder4 = PinConfig.builder(); | ||
pinConfigBuilder4.setBackgroundColor(Color.MAGENTA); | ||
pinConfigBuilder4.setGlyph(new PinConfig.Glyph(Color.TRANSPARENT)); | ||
PinConfig pinConfig4 = pinConfigBuilder4.build(); | ||
|
||
AdvancedMarkerOptions advancedMarkerOptions4 = new AdvancedMarkerOptions() | ||
.icon(BitmapDescriptorFactory.fromPinConfig(pinConfig4)) | ||
.position(MANILA); | ||
|
||
Marker marker4 = map.addMarker(advancedMarkerOptions4); | ||
|
||
// Collision behavior can only be changed in the AdvancedMarkerOptions object. | ||
// Changes to collision behavior after a marker has been created are not possible | ||
int collisionBehavior = AdvancedMarkerOptions.CollisionBehavior.REQUIRED_AND_HIDES_OPTIONAL; | ||
AdvancedMarkerOptions advancedMarkerOptions5 = new AdvancedMarkerOptions() | ||
.position(HO_CHI_MINH_CITY) | ||
.collisionBehavior(collisionBehavior); | ||
|
||
Marker marker5 = map.addMarker(advancedMarkerOptions5); | ||
} | ||
} | ||
// [END maps_android_sample_marker_advanced] |
61 changes: 61 additions & 0 deletions
61
...s/java/app/src/gms/java/com/example/mapdemo/BackgroundColorCustomizationDemoActivity.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,61 @@ | ||
// Copyright 2021 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.mapdemo; | ||
|
||
import android.os.Bundle; | ||
import android.widget.CheckBox; | ||
import androidx.annotation.Nullable; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import com.google.android.gms.common.internal.Preconditions; | ||
import com.google.android.gms.maps.GoogleMap; | ||
import com.google.android.gms.maps.OnMapReadyCallback; | ||
import com.google.android.gms.maps.SupportMapFragment; | ||
import com.google.android.gms.maps.model.LatLng; | ||
import com.google.android.gms.maps.model.MarkerOptions; | ||
|
||
/** | ||
* This shows how to create a simple activity with a custom background color appiled to the map, and | ||
* add a marker on the map. | ||
*/ | ||
public class BackgroundColorCustomizationDemoActivity extends AppCompatActivity | ||
implements OnMapReadyCallback { | ||
|
||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.background_color_customization_demo); | ||
|
||
SupportMapFragment mapFragment = | ||
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); | ||
|
||
Preconditions.checkNotNull(mapFragment) | ||
.getMapAsync(this); | ||
} | ||
|
||
/** | ||
* This is where we can add markers or lines, add listeners or move the camera. In this case, we | ||
* just add a marker near Africa. | ||
*/ | ||
@Override | ||
public void onMapReady(GoogleMap map) { | ||
map.setMapType(GoogleMap.MAP_TYPE_NONE); | ||
|
||
CheckBox mapTypeToggleCheckbox = (CheckBox) findViewById(R.id.map_type_toggle); | ||
mapTypeToggleCheckbox.setOnCheckedChangeListener( | ||
(view, isChecked) -> map.setMapType(isChecked ? GoogleMap.MAP_TYPE_NORMAL : GoogleMap.MAP_TYPE_NONE)); | ||
|
||
map.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker")); | ||
} | ||
} |
Oops, something went wrong.