├── XcodeConfig ├── GMU-DevApp.debug.xcconfig ├── GMU-DevApp.release.xcconfig ├── GMU-UnitTest.debug.xcconfig ├── GMU-UnitTest.release.xcconfig └── GMU-Target.common.xcconfig ├── Cartfile ├── app ├── Resources │ └── Images │ │ ├── m1.png │ │ ├── m2.png │ │ ├── m3.png │ │ ├── m4.png │ │ └── m5.png ├── KMLViewController.h ├── BasicViewController.h ├── GeoJSONViewController.h ├── HeatmapViewController.h ├── AppApiKey.h ├── MasterViewController.h ├── AppDelegate.h ├── CustomMarkerViewController.h ├── Samples.h ├── main.m ├── POIItem.m ├── POIItem.h ├── Info.plist ├── Base.lproj │ ├── Main.storyboard │ └── LaunchScreen.storyboard ├── AppDelegate.m ├── Samples.m ├── KMLViewController.m ├── GeoJSONViewController.m └── MasterViewController.m ├── Cartfile.resolved ├── test ├── resources │ ├── GeoJSON │ │ ├── GeoJSON_Point_Test.geojson │ │ ├── GeoJSON_LineString_Test.geojson │ │ ├── GeoJSON_MultiPoint_Test.geojson │ │ ├── GeoJSON_Feature_Test.geojson │ │ ├── GeoJSON_MultiLineString_Test.geojson │ │ ├── GeoJSON_GeometryCollection_Test.geojson │ │ ├── GeoJSON_FeatureCollection_Test.geojson │ │ ├── GeoJSON_Polygon_Test.geojson │ │ └── GeoJSON_MultiPolygon_Test.geojson │ └── KML │ │ ├── KML_Point_Test.kml │ │ ├── KML_LineString_Test.kml │ │ ├── KML_Placemark_Test.kml │ │ ├── KML_MultiGeometry_Test.kml │ │ ├── KML_GroundOverlay_Test.kml │ │ ├── KML_Polygon_Test.kml │ │ ├── KML_Style_Test.kml │ │ └── KML_StyleMap_Test.kml ├── unit │ ├── BridgingHeader │ │ └── UnitTest-Bridging-Header.h │ ├── Helper │ │ ├── GMUObectiveCTestHelper.h │ │ └── GMUObectiveCTestHelper.m │ ├── GeometryUtils │ │ └── Internal │ │ │ └── LatLngRadiansTest.swift │ ├── Geometry │ │ ├── GMUPointTest.m │ │ ├── GMUGeometryCollectionTest.m │ │ ├── GMUFeatureTest.m │ │ ├── GMULineStringTest.m │ │ ├── GMUPlacemarkTest.m │ │ ├── GMUPolygonTest.m │ │ └── GMUGroundOverlayTest.m │ ├── Heatmap │ │ └── GMUWeightedLatLngTest.swift │ └── Clustering │ │ ├── GMUSimpleClusterAlgorithmTest.swift │ │ ├── GMUGridBasedClusterAlgorithmTest.m │ │ ├── GMUClusterAlgorithmTest.h │ │ └── GMUWrappingDictionaryKeyTest.m └── common │ └── Model │ ├── GMUTestClusterItem.m │ └── GMUTestClusterItem.h ├── samples ├── ObjCDemoApp │ ├── Podfile │ └── ObjCDemoApp │ │ ├── ViewController.h │ │ ├── AppDelegate.h │ │ ├── main.m │ │ ├── AppDelegate.m │ │ ├── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard │ │ ├── Info.plist │ │ └── Assets.xcassets │ │ └── AppIcon.appiconset │ │ └── Contents.json ├── SwiftDemoApp │ ├── Podfile │ └── SwiftDemoApp │ │ ├── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard │ │ ├── SwiftDemoApp-Bridging-Header.h │ │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── AppDelegate.swift │ │ ├── GeoJSONViewController.swift │ │ ├── Sample.swift │ │ ├── Info.plist │ │ ├── KMLViewController.swift │ │ └── MasterViewController.swift └── README.md ├── Podfile.template ├── src ├── Clustering │ ├── GMSMarker+GMUClusteritem.m │ ├── GMSMarker+GMUClusteritem.h │ ├── GMUClusterManager+Testing.h │ ├── Algo │ │ ├── GMUSimpleClusterAlgorithm.h │ │ ├── GMUGridBasedClusterAlgorithm.h │ │ ├── GMUWrappingDictionaryKey.h │ │ ├── GMUClusterAlgorithm.h │ │ ├── GMUWrappingDictionaryKey.m │ │ ├── GMUNonHierarchicalDistanceBasedAlgorithm.h │ │ └── GMUSimpleClusterAlgorithm.m │ ├── View │ │ ├── GMUClusterIconGenerator.h │ │ ├── GMUDefaultClusterRenderer+Testing.h │ │ ├── GMUClusterRenderer.h │ │ ├── GMUDefaultClusterIconGenerator+Testing.h │ │ └── GMUDefaultClusterIconGenerator.h │ ├── GMUClusterItem.h │ ├── GMUMarkerClustering.h │ ├── GMUCluster.h │ ├── GMUStaticCluster.m │ └── GMUStaticCluster.h ├── QuadTree │ ├── GQTPoint.h │ ├── GQTBounds.h │ ├── GQTPointQuadTreeItem.h │ ├── GQTPointQuadTree.h │ └── GQTPointQuadTreeChild.h ├── GeometryUtils │ ├── Internal │ │ └── CatesianPoint.swift │ ├── GMSPolyline+GeometryUtils.swift │ └── GMSPolygon+GeometryUtils.swift ├── Heatmap │ ├── GMUHeatmapTileLayer+Testing.h │ ├── GMUWeightedLatLng.m │ ├── GMUWeightedLatLng.h │ ├── GMUGradient.h │ └── GMUHeatmapTileLayer.h └── Geometry │ ├── Model │ ├── GMULineString.m │ ├── GMUPolygon.m │ ├── GMUPoint.m │ ├── GMUGeometry.h │ ├── GMUGeometryCollection.m │ ├── GMUPair.m │ ├── GMUStyleMap.m │ ├── GMUStyleMap.h │ ├── GMUPair.h │ ├── GMUGeometryContainer.h │ ├── GMULineString.h │ ├── GMUPlacemark.m │ ├── GMUGroundOverlay.m │ ├── GMUFeature.m │ ├── GMUPoint.h │ ├── GMUGeometryCollection.h │ ├── GMUPolygon.h │ ├── GMUStyle.m │ ├── GMUFeature.h │ ├── GMUPlacemark.h │ └── GMUGroundOverlay.h │ ├── GMUGeometryRenderer+Testing.h │ ├── GMUGeoJSONParser.h │ ├── GMUKMLParser.h │ └── GMUGeometryRenderer.h ├── .gitignore ├── AUTHORS.txt ├── SECURITY.md ├── .github ├── pull_request_template.md ├── PULL_REQUEST_TEMPLATE │ └── pull_request_template.md ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── support_request.md │ ├── bug_report.md │ └── feature_request.md ├── workflows │ ├── dependabot.yml │ └── test.yml └── sync-repo-settings.yaml ├── docs ├── GeometryRendering.md ├── CustomMarkers.md ├── GeometryUtils.md ├── Carthage.md └── HeatmapRendering.md ├── CONTRIBUTORS.txt ├── GoogleMapsUtils └── Info.plist ├── Package.swift ├── .releaserc ├── CONTRIBUTING.md ├── Google-Maps-iOS-Utils.podspec └── GoogleMapsUtils.xcodeproj └── xcshareddata └── xcschemes └── GoogleMapsUtils.xcscheme /XcodeConfig/GMU-DevApp.debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "GMU-Target.common.xcconfig" 2 | -------------------------------------------------------------------------------- /XcodeConfig/GMU-DevApp.release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "GMU-Target.common.xcconfig" 2 | -------------------------------------------------------------------------------- /XcodeConfig/GMU-UnitTest.debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "GMU-Target.common.xcconfig" 2 | -------------------------------------------------------------------------------- /XcodeConfig/GMU-UnitTest.release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "GMU-Target.common.xcconfig" 2 | -------------------------------------------------------------------------------- /Cartfile: -------------------------------------------------------------------------------- 1 | binary "https://dl.google.com/geosdk/GoogleMaps.json" == 6.2.1-beta 2 | github "erikdoe/ocmock" 3 | -------------------------------------------------------------------------------- /app/Resources/Images/m1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/todo/google-maps-ios-utils/main/app/Resources/Images/m1.png -------------------------------------------------------------------------------- /app/Resources/Images/m2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/todo/google-maps-ios-utils/main/app/Resources/Images/m2.png -------------------------------------------------------------------------------- /app/Resources/Images/m3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/todo/google-maps-ios-utils/main/app/Resources/Images/m3.png -------------------------------------------------------------------------------- /app/Resources/Images/m4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/todo/google-maps-ios-utils/main/app/Resources/Images/m4.png -------------------------------------------------------------------------------- /app/Resources/Images/m5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/todo/google-maps-ios-utils/main/app/Resources/Images/m5.png -------------------------------------------------------------------------------- /Cartfile.resolved: -------------------------------------------------------------------------------- 1 | binary "https://dl.google.com/geosdk/GoogleMaps.json" "6.2.1-beta" 2 | github "erikdoe/ocmock" "v3.9.1" 3 | -------------------------------------------------------------------------------- /test/resources/GeoJSON/GeoJSON_Point_Test.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type":"Point", 3 | "coordinates":[ 4 | 102.0, 5 | 0.5 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /samples/ObjCDemoApp/Podfile: -------------------------------------------------------------------------------- 1 | source 'https://cdn.cocoapods.org/' 2 | platform :ios, '13.0' 3 | 4 | target 'ObjCDemoApp' do 5 | use_frameworks! 6 | pod 'GoogleMaps', '~> 7.3' 7 | pod 'Google-Maps-iOS-Utils', :path => '../..' 8 | end 9 | -------------------------------------------------------------------------------- /samples/SwiftDemoApp/Podfile: -------------------------------------------------------------------------------- 1 | source 'https://cdn.cocoapods.org/' 2 | platform :ios, '13.0' 3 | 4 | target 'SwiftDemoApp' do 5 | use_frameworks! 6 | pod 'GoogleMaps', '~> 7.3' 7 | pod 'Google-Maps-iOS-Utils', :path => '../..', :testspecs => ['Tests'] 8 | end 9 | -------------------------------------------------------------------------------- /test/resources/KML/KML_Point_Test.kml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 102.0,0.5,1 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /XcodeConfig/GMU-Target.common.xcconfig: -------------------------------------------------------------------------------- 1 | // Custom project config. 2 | IPHONEOS_DEPLOYMENT_TARGET = 7.0 3 | USE_HEADERMAP = YES 4 | HEADER_SEARCH_PATHS = $(inherited) "${SRCROOT}/../src" "${SRCROOT}/../test" 5 | CLANG_ENABLE_MODULES = YES 6 | CODE_SIGNING_ALLOWED = NO 7 | CODE_SIGNING_REQUIRED = NO 8 | -------------------------------------------------------------------------------- /test/resources/KML/KML_LineString_Test.kml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 102.0,0,1 7 | 103.0,1,1 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Podfile.template: -------------------------------------------------------------------------------- 1 | # [START maps_ios_utils_podfile_template] 2 | source 'https://github.com/CocoaPods/Specs.git' 3 | platform :ios, '13.0' 4 | 5 | target 'YOUR_APPLICATION_TARGET_NAME_HERE' do 6 | use_frameworks! 7 | pod 'GoogleMaps', '7.4.0' 8 | pod 'Google-Maps-iOS-Utils', '4.2.2' 9 | end 10 | # [END maps_ios_utils_podfile_template] 11 | -------------------------------------------------------------------------------- /src/Clustering/GMSMarker+GMUClusteritem.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+GMSMarker_GMUClusteritem.m 3 | // DevApp 4 | // 5 | // Created by Alex Muramoto on 5/7/20. 6 | // Copyright © 2020 Google. All rights reserved. 7 | // 8 | 9 | #import "GMSMarker+GMUClusteritem.h" 10 | 11 | @implementation GMSMarker (GMSMarker_GMUClusteritem) 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /test/resources/GeoJSON/GeoJSON_LineString_Test.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type":"LineString", 3 | "coordinates":[ 4 | [ 5 | 102.0, 6 | 0.0 7 | ], 8 | [ 9 | 103.0, 10 | 1.0 11 | ] 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /test/resources/GeoJSON/GeoJSON_MultiPoint_Test.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type":"MultiPoint", 3 | "coordinates":[ 4 | [ 5 | 100.0, 6 | 0.0 7 | ], 8 | [ 9 | 101.0, 10 | 1.0 11 | ] 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | *.xcworkspace 13 | !default.xcworkspace 14 | xcuserdata 15 | profile 16 | *.moved-aside 17 | DerivedData 18 | .idea/ 19 | Pods/ 20 | Podfile.lock 21 | Carthage/ 22 | -------------------------------------------------------------------------------- /AUTHORS.txt: -------------------------------------------------------------------------------- 1 | # This is the official list of google-maps-ios-utils authors for copyright purposes. 2 | # This file is distinct from the CONTRIBUTORS files. 3 | # See the latter for an explanation. 4 | 5 | # Names should be added to this file as: 6 | # Name or Organization 7 | # The email address is not required for organizations. 8 | 9 | Google Inc. 10 | 11 | -------------------------------------------------------------------------------- /test/resources/KML/KML_Placemark_Test.kml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Test Placemark 5 | A Placemark for testing purposes. 6 | #exampleStyle 7 | 8 | 10.0,1.0,0 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Clustering/GMSMarker+GMUClusteritem.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+GMSMarker_GMUClusteritem.h 3 | // DevApp 4 | // 5 | // Created by Alex Muramoto on 5/7/20. 6 | // Copyright © 2020 Google. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "GMUClusterItem.h" 12 | 13 | @interface GMSMarker (GMSMarker_GMUClusteritem) 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /test/resources/KML/KML_MultiGeometry_Test.kml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10,1,0 8 | 9 | 10 | 11 | 12 | 20,2,0 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /test/resources/GeoJSON/GeoJSON_Feature_Test.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type":"Feature", 3 | "id":"Test Feature", 4 | "bbox":[ 5 | -10.0, 6 | -10.0, 7 | 10.0, 8 | 10.0 9 | ], 10 | "geometry":{ 11 | "type":"Point", 12 | "coordinates":[ 13 | 102.0, 14 | 0.5 15 | ] 16 | }, 17 | "properties":{ 18 | "description":"A feature for unit testing" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/resources/KML/KML_GroundOverlay_Test.kml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 6 | https://www.google.com/intl/en/images/logo.gif 7 | 8 | 9 | 10 10 | -10 11 | 10 12 | -10 13 | 45.0 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Report a security issue 2 | 3 | To report a security issue, please use https://g.co/vulnz. We use 4 | https://g.co/vulnz for our intake, and do coordination and disclosure here on 5 | GitHub (including using GitHub Security Advisory). The Google Security Team will 6 | respond within 5 working days of your report on g.co/vulnz. 7 | 8 | To contact us about other bugs, please open an issue on GitHub. 9 | 10 | > **Note**: This file is synchronized from the https://github.com/googlemaps/.github repository. 11 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | Thank you for opening a Pull Request! 2 | 3 | --- 4 | 5 | Before submitting your PR, there are a few things you can do to make sure it goes smoothly: 6 | - [ ] Make sure to open a GitHub issue as a bug/feature request before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea 7 | - [ ] Ensure the tests and linter pass 8 | - [ ] Code coverage does not decrease (if any source code was changed) 9 | - [ ] Appropriate docs were updated (if necessary) 10 | 11 | Fixes # 🦕 12 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/pull_request_template.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Pull request 3 | about: Create a pull request 4 | label: 'triage me' 5 | --- 6 | Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: 7 | - [ ] Make sure to open a GitHub issue as a bug/feature request before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea 8 | - [ ] Ensure the tests and linter pass 9 | - [ ] Code coverage does not decrease (if any source code was changed) 10 | - [ ] Appropriate docs were updated (if necessary) 11 | 12 | Fixes # 🦕 13 | -------------------------------------------------------------------------------- /test/resources/GeoJSON/GeoJSON_MultiLineString_Test.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type":"MultiLineString", 3 | "coordinates":[ 4 | [ 5 | [ 6 | 100.0, 7 | 0.0 8 | ], 9 | [ 10 | 101.0, 11 | 1.0 12 | ] 13 | ], 14 | [ 15 | [ 16 | 102.0, 17 | 2.0 18 | ], 19 | [ 20 | 103.0, 21 | 3.0 22 | ] 23 | ] 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /src/QuadTree/GQTPoint.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | typedef struct { 17 | double x; 18 | double y; 19 | } GQTPoint; 20 | -------------------------------------------------------------------------------- /app/KMLViewController.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | @interface KMLViewController : UIViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners 16 | 17 | .github/ @googlemaps/admin 18 | -------------------------------------------------------------------------------- /app/BasicViewController.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | @interface BasicViewController : UIViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /app/GeoJSONViewController.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | @interface GeoJSONViewController : UIViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /app/HeatmapViewController.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | @interface HeatmapViewController : UIViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /docs/GeometryRendering.md: -------------------------------------------------------------------------------- 1 | KML and GeoJSON rendering 2 | ========================= 3 | As of version 2.0.0 we have added new features for rendering KML and GeoJSON inputs. This first 4 | version supports common geometries like Point, Polyline, Polygon, GroundOverlay. Please note that 5 | this version does not support interaction with the rendered geometries. 6 | 7 | The following screenshot shows a demo of a KML file being rendered on the map. See 8 | [KMLViewController][kmlviewcontroller] for how to use the new APIs. 9 | 10 |

11 | 12 | [kmlviewcontroller]: https://github.com/googlemaps/google-maps-ios-utils/blob/master/app/KMLViewController.m 13 | -------------------------------------------------------------------------------- /test/unit/BridgingHeader/UnitTest-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | @import GoogleMaps; 17 | #import "GMUObectiveCTestHelper.h" 18 | #import "GMUClusterAlgorithmTest.h" 19 | -------------------------------------------------------------------------------- /samples/ObjCDemoApp/ObjCDemoApp/ViewController.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | @interface ViewController : UIViewController 19 | @end 20 | 21 | -------------------------------------------------------------------------------- /app/AppApiKey.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | //TODO: Change this key to a valid key registered with the demo app bundle id. Then delete this line. 17 | static NSString *const kMapsAPIKey = @""; 18 | -------------------------------------------------------------------------------- /src/QuadTree/GQTBounds.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GQTPoint.h" 17 | 18 | typedef struct { 19 | double minX; 20 | double minY; 21 | double maxX; 22 | double maxY; 23 | } GQTBounds; 24 | -------------------------------------------------------------------------------- /app/MasterViewController.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | @interface MasterViewController : UITableViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /src/GeometryUtils/Internal/CatesianPoint.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | struct CartesianPoint { 16 | static var zero: CartesianPoint = CartesianPoint(x: 0, y: 0) 17 | 18 | var x: Double 19 | var y: Double 20 | } 21 | -------------------------------------------------------------------------------- /test/resources/KML/KML_Polygon_Test.kml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10.0,10.0,1 9 | 10.0,20.0,1 10 | 20.0,20.0,1 11 | 20.0,10.0,1 12 | 10.0,10.0,1 13 | 14 | 15 | 16 | 17 | 18 | 19 | 12.5,12.5,1 20 | 12.5,17.5,1 21 | 17.5,17.5,1 22 | 17.5,12.5,1 23 | 12.5,12.5,1 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /test/resources/KML/KML_Style_Test.kml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 26 | 27 | -------------------------------------------------------------------------------- /app/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | @interface AppDelegate : UIResponder 19 | 20 | @property(strong, nonatomic) UIWindow *window; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /src/QuadTree/GQTPointQuadTreeItem.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | #import "GQTPoint.h" 18 | 19 | @protocol GQTPointQuadTreeItem 20 | 21 | - (GQTPoint)point; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /test/resources/GeoJSON/GeoJSON_GeometryCollection_Test.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type":"GeometryCollection", 3 | "geometries":[ 4 | { 5 | "type":"Point", 6 | "coordinates":[ 7 | 100.0, 8 | 0.0 9 | ] 10 | }, 11 | { 12 | "type":"LineString", 13 | "coordinates":[ 14 | [ 15 | 101.0, 16 | 0.0 17 | ], 18 | [ 19 | 102.0, 20 | 1.0 21 | ] 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /samples/ObjCDemoApp/ObjCDemoApp/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | @interface AppDelegate : UIResponder 19 | 20 | @property (strong, nonatomic) UIWindow *window; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /CONTRIBUTORS.txt: -------------------------------------------------------------------------------- 1 | # People who have agreed to one of the CLAs and can contribute patches. 2 | # The AUTHORS file lists the copyright holders; this file 3 | # lists people. For example, Google employees are listed here 4 | # but not in AUTHORS, because Google holds the copyright. 5 | # 6 | # https://developers.google.com/open-source/cla/individual 7 | # https://developers.google.com/open-source/cla/corporate 8 | # 9 | # Names should be added to this file as: 10 | # Name 11 | 12 | Brett Morgan 13 | Christian Ihle 14 | Christopher Arriola 15 | Daniel Kostrzynski 16 | Gareth Pearce 17 | Michael Lapuebla 18 | Son Nguyen 19 | Xurxo Mendez 20 | Subhodip Banerjee 21 | -------------------------------------------------------------------------------- /GoogleMapsUtils/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | $(MARKETING_VERSION) 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /test/unit/Helper/GMUObectiveCTestHelper.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | @interface GMUObectiveCTestHelper : NSObject 19 | 20 | + (BOOL)catchObjectiveCException:(void(^)(void))tryBlock error:(__autoreleasing NSError **)error; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /samples/ObjCDemoApp/ObjCDemoApp/main.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | #import "AppDelegate.h" 18 | 19 | int main(int argc, char* argv[]) { 20 | @autoreleasepool { 21 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Heatmap/GMUHeatmapTileLayer+Testing.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GMUHeatmapTileLayer.h" 17 | 18 | /* Extensions for testing purposes only. */ 19 | @interface GMUHeatmapTileLayer (Testing) 20 | 21 | - (UIImage *)tileForX:(NSUInteger)x y:(NSUInteger)y zoom:(NSUInteger)zoom; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /app/CustomMarkerViewController.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | /** 19 | * This demo shows the ability to customize marker icons by putting a number of people 20 | * on the map with their profile images. 21 | */ 22 | @interface CustomMarkerViewController : UIViewController 23 | @end 24 | -------------------------------------------------------------------------------- /app/Samples.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | @interface Samples : NSObject 19 | 20 | + (NSArray *)loadDemos; 21 | + (NSDictionary *)newDemo:(Class) class 22 | withTitle:(NSString *)title 23 | andDescription:(NSString *)description; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /src/Clustering/GMUClusterManager+Testing.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GMUClusterManager.h" 17 | 18 | /** 19 | * Extensions for testing purposes only. 20 | */ 21 | @interface GMUClusterManager (Testing) 22 | 23 | /** 24 | * Returns in number of cluster requests. 25 | */ 26 | - (NSUInteger)clusterRequestCount; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /src/Clustering/Algo/GMUSimpleClusterAlgorithm.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | #import "GMUClusterAlgorithm.h" 19 | 20 | /** 21 | * Not for production: used for experimenting with new clustering algorithms only. 22 | */ 23 | @interface GMUSimpleClusterAlgorithm : NSObject 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMULineString.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GMULineString.h" 17 | 18 | @implementation GMULineString 19 | 20 | @synthesize type = _type; 21 | 22 | - (instancetype)initWithPath:(GMSPath *)path { 23 | if (self = [super init]) { 24 | _type = @"LineString"; 25 | _path = path; 26 | } 27 | return self; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUPolygon.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GMUPolygon.h" 17 | 18 | @implementation GMUPolygon 19 | 20 | @synthesize type = _type; 21 | 22 | - (instancetype)initWithPaths:(NSArray *)paths { 23 | if (self = [super init]) { 24 | _type = @"Polygon"; 25 | _paths = [paths copy]; 26 | } 27 | return self; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /test/resources/KML/KML_StyleMap_Test.kml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | normal 6 | #line-FF0000-5000-nodesc-normal 7 | 8 | 9 | highlight 10 | #line-FF0000-5000-nodesc-highlight 11 | 12 | 13 | 22 | 31 | 32 | -------------------------------------------------------------------------------- /src/Geometry/GMUGeometryRenderer+Testing.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GMUGeometryRenderer.h" 17 | 18 | /* Extensions for testing purposes only. */ 19 | @interface GMUGeometryRenderer (Testing) 20 | 21 | - (NSArray *)mapOverlays; 22 | + (UIImage *)imageFromPath:(NSString *)path; 23 | - (GMUStyle *)getStyleFromStyleMaps:(NSString *)styleUrl; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUPoint.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GMUPoint.h" 17 | 18 | @implementation GMUPoint 19 | 20 | @synthesize type = _type; 21 | 22 | - (instancetype)initWithCoordinate:(CLLocationCoordinate2D)coordinate { 23 | if (self = [super init]) { 24 | _type = @"Point"; 25 | _coordinate = coordinate; 26 | } 27 | return self; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /src/Clustering/Algo/GMUGridBasedClusterAlgorithm.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | #import "GMUClusterAlgorithm.h" 19 | 20 | /** 21 | * A simple algorithm which devides the map into a grid where a cell has fixed dimension in 22 | * screen space. 23 | */ 24 | @interface GMUGridBasedClusterAlgorithm : NSObject 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUGeometry.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | NS_ASSUME_NONNULL_BEGIN 19 | 20 | /** 21 | * Defines a generic geometry object. 22 | */ 23 | @protocol GMUGeometry 24 | 25 | /** 26 | * The type of the geometry. 27 | */ 28 | @property(nonatomic, readonly) NSString *type; 29 | 30 | @end 31 | 32 | NS_ASSUME_NONNULL_END 33 | -------------------------------------------------------------------------------- /app/main.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #if !defined(__has_feature) || !__has_feature(objc_arc) 17 | #error "This file requires ARC support." 18 | #endif 19 | 20 | #import 21 | #import "AppDelegate.h" 22 | 23 | int main(int argc, char * argv[]) { 24 | @autoreleasepool { 25 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /docs/CustomMarkers.md: -------------------------------------------------------------------------------- 1 | Customize cluster and item markers 2 | ================================== 3 | As of version 1.1.0 we have added new features for easy customization of 4 | markers. There is a new delegate [GMUClusterRendererDelegate] 5 | [gmuclusterrendererdelegate] on ```GMUDefaultClusterRenderer``` which allows 6 | developers to customize properties of a marker before and after it is added 7 | to the map. Using this new delegate you can achieve something cool like this: 8 | 9 |

10 | 11 | 12 | See [CustomMarkerViewController][custommarkerviewcontroller] for the 13 | implementation. 14 | 15 | [custommarkerviewcontroller]: https://github.com/googlemaps/google-maps-ios-utils/blob/master/app/CustomMarkerViewController.m 16 | [gmuclusterrendererdelegate]: https://github.com/googlemaps/google-maps-ios-utils/blob/master/src/Clustering/View/GMUDefaultClusterRenderer.h 17 | -------------------------------------------------------------------------------- /src/Clustering/View/GMUClusterIconGenerator.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | #import 18 | 19 | /** 20 | * Defines a contract for cluster icon generation. 21 | */ 22 | @protocol GMUClusterIconGenerator 23 | 24 | /** 25 | * Generates an icon with the given size. 26 | */ 27 | - (UIImage *)iconForSize:(NSUInteger)size; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /src/Clustering/View/GMUDefaultClusterRenderer+Testing.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GMUDefaultClusterRenderer.h" 17 | 18 | /* Extensions for testing purposes only. */ 19 | @interface GMUDefaultClusterRenderer (Testing) 20 | 21 | - (NSArray> *)visibleClustersFromClusters:(NSArray> *)clusters; 22 | 23 | - (void)clearMarkersAnimated:(NSArray *)markers; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /test/unit/GeometryUtils/Internal/LatLngRadiansTest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LatLngRadiansTest.swift 3 | // UnitTest 4 | // 5 | // Created by Chris Arriola on 2/4/21. 6 | // Copyright © 2021 Google. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import GoogleMapsUtils 11 | 12 | class LatLngRadiansTest : XCTestCase { 13 | let latLng1 = LatLngRadians(latitude: 1, longitude: 2) 14 | let latLng2 = LatLngRadians(latitude: -1, longitude: 8) 15 | let latLng3 = LatLngRadians(latitude: 0, longitude: 10) 16 | 17 | private let accuracy = 1e-15 18 | 19 | func testAddition() { 20 | let sum = latLng1 + latLng2 21 | XCTAssertEqual(latLng3.latitude, sum.latitude, accuracy: accuracy) 22 | XCTAssertEqual(latLng3.longitude, sum.longitude, accuracy: accuracy) 23 | } 24 | 25 | func testSubtraction() { 26 | let difference = latLng3 - latLng2 27 | XCTAssertEqual(latLng1.latitude, difference.latitude, accuracy: accuracy) 28 | XCTAssertEqual(latLng1.longitude, difference.longitude, accuracy: accuracy) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUGeometryCollection.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GMUGeometryCollection.h" 17 | 18 | @implementation GMUGeometryCollection 19 | 20 | @synthesize type = _type; 21 | 22 | - (instancetype)initWithGeometries:(NSArray> *)geometries { 23 | if (self = [super init]) { 24 | _type = @"GeometryCollection"; 25 | _geometries = geometries; 26 | } 27 | return self; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/support_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Support request 3 | about: If you have a support contract with Google, please create an issue in the Google 4 | Cloud Support console. 5 | title: '' 6 | labels: 'triage me, type: question' 7 | assignees: '' 8 | 9 | --- 10 | 11 | **PLEASE READ** 12 | 13 | If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/). This will ensure a timely response. 14 | 15 | Discover additional support services for the Google Maps Platform, including developer communities, technical guidance, and expert support at the Google Maps Platform [support resources page](https://developers.google.com/maps/support/). 16 | 17 | If your bug or feature request is not related to this particular library, please visit the Google Maps Platform [issue trackers](https://developers.google.com/maps/support/#issue_tracker). 18 | 19 | Check for answers on StackOverflow with the [google-maps](http://stackoverflow.com/questions/tagged/google-maps) tag. 20 | 21 | --- 22 | -------------------------------------------------------------------------------- /samples/SwiftDemoApp/SwiftDemoApp/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Clustering/Algo/GMUWrappingDictionaryKey.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | /** 19 | * Wraps an object which does not implement NSCopying to be used as NSDictionary keys. 20 | * This class will forward -hash and -isEqual methods to the underlying object. 21 | */ 22 | @interface GMUWrappingDictionaryKey : NSObject 23 | 24 | - (instancetype)initWithObject:(id)object; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUPair.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2018 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GMUPair.h" 17 | 18 | @implementation GMUPair 19 | 20 | @synthesize key = _key; 21 | @synthesize styleUrl = _styleUrl; 22 | 23 | - (instancetype)initWithKey:(NSString *)key 24 | styleUrl:(NSString *)styleUrl { 25 | if (self = [super init]) { 26 | _key = key; 27 | _styleUrl = styleUrl; 28 | } 29 | return self; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /app/POIItem.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #if !defined(__has_feature) || !__has_feature(objc_arc) 17 | #error "This file requires ARC support." 18 | #endif 19 | 20 | #import "POIItem.h" 21 | 22 | @implementation POIItem 23 | 24 | - (instancetype)initWithPosition:(CLLocationCoordinate2D)position name:(NSString *)name { 25 | if ((self = [super init])) { 26 | _position = position; 27 | _name = [name copy]; 28 | } 29 | return self; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUStyleMap.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2018 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GMUPair.h" 17 | #import "GMUStyleMap.h" 18 | 19 | @implementation GMUStyleMap 20 | 21 | @synthesize styleMapId = _id; 22 | @synthesize pairs = _pairs; 23 | 24 | - (instancetype)initWithId:(NSString *)styleMapId 25 | pairs:(NSArray *)pairs { 26 | if (self = [super init]) { 27 | _id = styleMapId; 28 | _pairs = pairs; 29 | } 30 | return self; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /app/POIItem.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | 17 | #import 18 | @import GoogleMapsUtils.GMUClusterItem; 19 | 20 | // Point of Interest Item which implements the GMUClusterItem protocol. 21 | @interface POIItem : NSObject 22 | 23 | @property(nonatomic, readonly) CLLocationCoordinate2D position; 24 | @property(nonatomic, readonly) NSString *name; 25 | 26 | - (instancetype)initWithPosition:(CLLocationCoordinate2D)position name:(NSString *)name; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /samples/README.md: -------------------------------------------------------------------------------- 1 | Google Maps SDK for iOS Utility Library Samples 2 | =============================================== 3 | 4 | This directory contains sample code that demonstrates usage of the Maps SDK for iOS Utility Library. Once you have downloaded the repository to you local machine, follow the instructions below for the language you’re interested in. 5 | 6 | Note that you will need an API key to run the samples. See the [documentation](https://developers.google.com/maps/documentation/ios-sdk/get-api-key#get_key) to find more details on how to get an API key. 7 | 8 | ## Swift 9 | 10 | To view the Swift samples: 11 | 12 | ``` 13 | cd SwiftDemoApp 14 | pod install 15 | open SwiftDemoApp.xcworkspace 16 | ``` 17 | 18 | Lastly, copy and paste the API key that you created and replace the value of `mapsAPIKey` in `AppDelegate.swift` 19 | 20 | ## Objective-C 21 | 22 | To view the Objective-C samples: 23 | 24 | ``` 25 | cd ObjCDemoApp 26 | pod install 27 | open ObjCDemoApp.xcworkspace 28 | ``` 29 | 30 | Lastly, copy and paste the API key that you created and replace the value of `kMapsAPIKey` in `AppDelegate.m` 31 | -------------------------------------------------------------------------------- /samples/SwiftDemoApp/SwiftDemoApp/SwiftDemoApp-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | //#import 17 | //#import 18 | //#import 19 | //#import 20 | //#import 21 | //#import 22 | //#import 23 | 24 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUStyleMap.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2018 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | #import "GMUPair.h" 19 | 20 | NS_ASSUME_NONNULL_BEGIN 21 | 22 | @interface GMUStyleMap : NSObject 23 | 24 | @property(nonatomic, readonly) NSString *styleMapId; 25 | @property(nonatomic, readonly) NSArray *pairs; 26 | 27 | - (instancetype)initWithId:(NSString *)styleMapId 28 | pairs:(NSArray *)pairs; 29 | 30 | @end 31 | 32 | NS_ASSUME_NONNULL_END 33 | -------------------------------------------------------------------------------- /src/Clustering/GMUClusterItem.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | /** 19 | * This protocol defines the contract for a cluster item. 20 | */ 21 | @protocol GMUClusterItem 22 | 23 | /** 24 | * Returns the position of the item. 25 | */ 26 | @property(nonatomic, readonly) CLLocationCoordinate2D position; 27 | 28 | @optional 29 | @property(nonatomic, copy, nullable) NSString* title; 30 | 31 | @property(nonatomic, copy, nullable) NSString* snippet; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /test/unit/Helper/GMUObectiveCTestHelper.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GMUObectiveCTestHelper.h" 17 | 18 | @implementation GMUObectiveCTestHelper 19 | 20 | + (BOOL)catchObjectiveCException:(void(^)(void))tryBlock error:(__autoreleasing NSError **)error { 21 | @try { 22 | tryBlock(); 23 | return YES; 24 | } 25 | @catch (NSException *exception) { 26 | *error = [[NSError alloc] initWithDomain:exception.name code:0 userInfo:exception.userInfo]; 27 | return NO; 28 | } 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /docs/GeometryUtils.md: -------------------------------------------------------------------------------- 1 | Geometry Utilities 2 | ================== 3 | 4 | The utility library contains Swift-friendly extensions of the [GMSGeometryUtils](https://developers.google.com/maps/documentation/ios-sdk/reference/group___geometry_utils) module of the Maps SDK for iOS. Rather than using C-Style functions in `GMSGeometryUtils`, you can use the Swift classes and extensions defined in this library. 5 | 6 | See: 7 | * [MapPoint](https://github.com/googlemaps/google-maps-ios-utils/blob/main/src/GeometryUtils/MapPoint.swift) 8 | * [CLLocationCoordinate2D+GeometryUtils.swift](https://github.com/googlemaps/google-maps-ios-utils/blob/main/src/GeometryUtils/CLLocationCoordinate2D%2BGeometryUtils.swift) 9 | * [GMSPath+GeometryUtils.swfit](https://github.com/googlemaps/google-maps-ios-utils/blob/main/src/GeometryUtils/GMSPath%2BGeometryUtils.swift) 10 | * [GMSPolygon+GeometryUtils.swift](https://github.com/googlemaps/google-maps-ios-utils/blob/main/src/GeometryUtils/GMSPolygon%2BGeometryUtils.swift) 11 | * [GMSPolyline+GeometryUtils.swift](https://github.com/googlemaps/google-maps-ios-utils/blob/main/src/GeometryUtils/GMSPolyline%2BGeometryUtils.swift) 12 | -------------------------------------------------------------------------------- /samples/ObjCDemoApp/ObjCDemoApp/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "AppDelegate.h" 17 | 18 | @import GoogleMaps; 19 | 20 | //#error Change this key to a valid key registered with the demo app bundle id. Then delete this line. 21 | static NSString *const kMapsAPIKey = @""; 22 | 23 | @implementation AppDelegate 24 | 25 | - (BOOL)application:(UIApplication *)application 26 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 27 | [GMSServices provideAPIKey:kMapsAPIKey]; 28 | return YES; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.3 2 | 3 | // Copyright 2020 Google LLC 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | import PackageDescription 18 | 19 | let package = Package( 20 | name: "GoogleMapsUtils", 21 | products: [ 22 | .library(name: "GoogleMapsUtils", targets: ["GoogleMapsUtils"]) 23 | ], 24 | targets: [ 25 | .binaryTarget( 26 | name: "GoogleMapsUtils", 27 | url: "https://github.com/googlemaps/google-maps-ios-utils/releases/download/v4.2.2/GoogleMapsUtils.xcframework.zip", 28 | checksum: "e4c5c3a669ad65130d52c22bd993724707d054ba065d6f60b396715e465504a2" 29 | ) 30 | ] 31 | ) 32 | -------------------------------------------------------------------------------- /test/resources/GeoJSON/GeoJSON_FeatureCollection_Test.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type":"FeatureCollection", 3 | "features":[ 4 | { 5 | "type":"Feature", 6 | "geometry":{ 7 | "type":"Point", 8 | "coordinates":[ 9 | 102.0, 10 | 0.5 11 | ] 12 | }, 13 | "properties":{ 14 | "prop0":"value0" 15 | } 16 | }, 17 | { 18 | "type":"Feature", 19 | "geometry":{ 20 | "type":"LineString", 21 | "coordinates":[ 22 | [ 23 | 102.0, 24 | 0.0 25 | ], 26 | [ 27 | 103.0, 28 | 1.0 29 | ] 30 | ] 31 | }, 32 | "properties":{ 33 | "prop0":"value0", 34 | "prop1":0.0 35 | } 36 | } 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUPair.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2018 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | NS_ASSUME_NONNULL_BEGIN 19 | 20 | /** 21 | * Instances of this class represent a geometry Style. It is used to define the 22 | * stylings of any number of GMUGeometry objects. 23 | */ 24 | @interface GMUPair : NSObject 25 | 26 | @property(nonatomic, readonly) NSString *key; 27 | @property(nonatomic, readonly) NSString *styleUrl; 28 | 29 | - (instancetype)initWithKey:(NSString *)styleID 30 | styleUrl:(NSString *)strokeColor; 31 | 32 | @end 33 | 34 | NS_ASSUME_NONNULL_END 35 | 36 | -------------------------------------------------------------------------------- /src/Clustering/GMUMarkerClustering.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | #import 18 | #import 19 | #import 20 | #import 21 | #import 22 | #import 23 | #import 24 | 25 | #import "Google-Maps-iOS-Utils/GQTPointQuadTree.h" 26 | -------------------------------------------------------------------------------- /src/GeometryUtils/GMSPolyline+GeometryUtils.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import GoogleMaps 16 | 17 | public extension GMSPolyline { 18 | 19 | /// Returns whether `coordinate` lies on or near this path within the specified `tolerance` in meters. Tolerance 20 | /// is defaulted to `GMSPath.defaultToleranceInMeters`. 21 | func isOnPolyline(coordinate: CLLocationCoordinate2D, tolerance: Double = GMSPath.defaultToleranceInMeters) -> Bool { 22 | guard let path = self.path else { 23 | return false 24 | } 25 | return path.isOnPath(coordinate: coordinate, geodesic: geodesic, tolerance: tolerance) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.github/workflows/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: Dependabot 16 | on: pull_request 17 | 18 | permissions: 19 | contents: write 20 | 21 | jobs: 22 | test: 23 | uses: ./.github/workflows/test.yml 24 | dependabot: 25 | needs: test 26 | runs-on: ubuntu-latest 27 | if: ${{ github.actor == 'dependabot[bot]' }} 28 | env: 29 | PR_URL: ${{github.event.pull_request.html_url}} 30 | GITHUB_TOKEN: ${{secrets.SYNCED_GITHUB_TOKEN_REPO}} 31 | steps: 32 | - name: approve 33 | run: gh pr review --approve "$PR_URL" 34 | - name: merge 35 | run: gh pr merge --auto --squash --delete-branch "$PR_URL" 36 | -------------------------------------------------------------------------------- /src/Clustering/View/GMUClusterRenderer.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | #import "GMUCluster.h" 19 | 20 | NS_ASSUME_NONNULL_BEGIN 21 | 22 | /** 23 | * Defines a common contract for a cluster renderer. 24 | */ 25 | @protocol GMUClusterRenderer 26 | 27 | // Renders a list of clusters. 28 | - (void)renderClusters:(NSArray> *)clusters; 29 | 30 | // Notifies renderer that the viewport has changed and renderer needs to update. 31 | // For example new clusters may become visible and need to be shown on map. 32 | - (void)update; 33 | 34 | @end 35 | 36 | NS_ASSUME_NONNULL_END 37 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUGeometryContainer.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | #import "GMUGeometry.h" 19 | #import "GMUStyle.h" 20 | 21 | NS_ASSUME_NONNULL_BEGIN 22 | 23 | /** 24 | * Defines a generic geometry container. 25 | */ 26 | @protocol GMUGeometryContainer 27 | 28 | /** 29 | * The geometry object in the container. 30 | */ 31 | @property(nonatomic, readonly) id geometry; 32 | 33 | /** 34 | * Style information that should be applied to the contained geometry object. 35 | */ 36 | @property(nonatomic, nullable) GMUStyle *style; 37 | 38 | @end 39 | 40 | NS_ASSUME_NONNULL_END 41 | -------------------------------------------------------------------------------- /src/Clustering/View/GMUDefaultClusterIconGenerator+Testing.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GMUDefaultClusterIconGenerator.h" 17 | 18 | /* Extensions for testing purposes only. */ 19 | @interface GMUDefaultClusterIconGenerator (Testing) 20 | 21 | /* Draws |text| on top of an |image| and returns the resultant image. */ 22 | - (UIImage *)iconForText:(NSString *)text withBaseImage:(UIImage *)image; 23 | 24 | /** 25 | * Draws |text| on top of a circle whose background color is determined by |bucketIndex| 26 | * and returns the resultant image. 27 | */ 28 | - (UIImage *)iconForText:(NSString *)text withBucketIndex:(NSUInteger)bucketIndex; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /test/common/Model/GMUTestClusterItem.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #if !defined(__has_feature) || !__has_feature(objc_arc) 17 | #error "This file requires ARC support." 18 | #endif 19 | 20 | #import "GMUTestClusterItem.h" 21 | 22 | @implementation GMUTestClusterItem 23 | 24 | - (instancetype)initWithPosition:(CLLocationCoordinate2D)position { 25 | return [self initWithPosition:position title:nil snippet:nil]; 26 | } 27 | 28 | - (instancetype)initWithPosition:(CLLocationCoordinate2D)position title:(NSString *)title snippet:(NSString *)snippet { 29 | _position = position; 30 | _title = title; 31 | _snippet = snippet; 32 | return self; 33 | } 34 | 35 | @end 36 | 37 | -------------------------------------------------------------------------------- /test/unit/Geometry/GMUPointTest.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | #import "GMUPoint.h" 19 | 20 | @interface GMUPointTest : XCTestCase 21 | @end 22 | 23 | static NSString *const kType = @"Point"; 24 | 25 | @implementation GMUPointTest 26 | 27 | - (void)testInitWithCoordinate { 28 | CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(123.456, 456.789); 29 | GMUPoint *point = [[GMUPoint alloc] initWithCoordinate:coordinate]; 30 | XCTAssertEqualObjects(point.type, kType); 31 | XCTAssertEqual(point.coordinate.latitude, coordinate.latitude); 32 | XCTAssertEqual(point.coordinate.longitude, coordinate.longitude); 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /test/resources/GeoJSON/GeoJSON_Polygon_Test.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type":"Polygon", 3 | "coordinates":[ 4 | [ 5 | [ 6 | 10.0, 7 | 10.0 8 | ], 9 | [ 10 | 10.0, 11 | 20.0 12 | ], 13 | [ 14 | 20.0, 15 | 20.0 16 | ], 17 | [ 18 | 20.0, 19 | 10.0 20 | ], 21 | [ 22 | 10.0, 23 | 10.0 24 | ] 25 | ], 26 | [ 27 | [ 28 | 12.5, 29 | 12.5 30 | ], 31 | [ 32 | 12.5, 33 | 17.5 34 | ], 35 | [ 36 | 17.5, 37 | 17.5 38 | ], 39 | [ 40 | 17.5, 41 | 12.5 42 | ], 43 | [ 44 | 12.5, 45 | 12.5 46 | ] 47 | ] 48 | ] 49 | } 50 | -------------------------------------------------------------------------------- /test/common/Model/GMUTestClusterItem.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | #import 18 | 19 | // Simple cluster item implementation for use in tests. 20 | @interface GMUTestClusterItem : NSObject 21 | 22 | @property(nonatomic, readonly) CLLocationCoordinate2D position; 23 | @property(nonatomic, copy, nullable) NSString *title; 24 | @property(nonatomic, copy, nullable) NSString *snippet; 25 | 26 | - (instancetype _Nonnull)initWithPosition:(CLLocationCoordinate2D)position; 27 | - (instancetype _Nonnull)initWithPosition:(CLLocationCoordinate2D)position title:(nullable NSString *)title snippet:(nullable NSString *)snippet; 28 | 29 | @end 30 | 31 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMULineString.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | #import 18 | #import 19 | 20 | #import "GMUGeometry.h" 21 | 22 | NS_ASSUME_NONNULL_BEGIN 23 | 24 | /** 25 | * Instances of this class represent a LineString object. 26 | */ 27 | @interface GMULineString : NSObject 28 | 29 | /** 30 | * The path of the LineString. 31 | */ 32 | @property(nonatomic, readonly) GMSPath *path; 33 | 34 | /** 35 | * Initializes a GMULineString object with a path. 36 | * 37 | * @param path The path of the LineString. 38 | */ 39 | - (instancetype)initWithPath:(GMSPath *)path; 40 | 41 | @end 42 | 43 | NS_ASSUME_NONNULL_END 44 | -------------------------------------------------------------------------------- /src/Heatmap/GMUWeightedLatLng.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #if !defined(__has_feature) || !__has_feature(objc_arc) 17 | #error "This file requires ARC support." 18 | #endif 19 | 20 | #import "GMUWeightedLatLng.h" 21 | #import 22 | 23 | @implementation GMUWeightedLatLng { 24 | GQTPoint _point; 25 | } 26 | 27 | - (instancetype)initWithCoordinate:(CLLocationCoordinate2D)coordinate intensity:(float)intensity { 28 | if ((self = [super init])) { 29 | _intensity = intensity; 30 | GMSMapPoint mapPoint = GMSProject(coordinate); 31 | _point.x = mapPoint.x; 32 | _point.y = mapPoint.y; 33 | } 34 | return self; 35 | } 36 | 37 | - (GQTPoint)point { 38 | return _point; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUPlacemark.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GMUPlacemark.h" 17 | 18 | @implementation GMUPlacemark 19 | 20 | @synthesize geometry = _geometry; 21 | 22 | @synthesize style = _style; 23 | 24 | - (instancetype)initWithGeometry:(id)geometry 25 | title:(NSString *)title 26 | snippet:(NSString *)snippet 27 | style:(GMUStyle *)style 28 | styleUrl:(NSString *)styleUrl { 29 | if (self = [super init]) { 30 | _geometry = geometry; 31 | _title = [title copy]; 32 | _snippet = [snippet copy]; 33 | _style = style; 34 | _styleUrl = [styleUrl copy]; 35 | } 36 | return self; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUGroundOverlay.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GMUGroundOverlay.h" 17 | 18 | @implementation GMUGroundOverlay 19 | 20 | @synthesize type = _type; 21 | 22 | - (instancetype)initWithCoordinate:(CLLocationCoordinate2D)northEast 23 | southWest:(CLLocationCoordinate2D)southWest 24 | zIndex:(int)zIndex 25 | rotation:(double)rotation 26 | href:(NSString *)href { 27 | if (self = [super init]) { 28 | _type = @"GroundOverlay"; 29 | _northEast = northEast; 30 | _southWest = southWest; 31 | _zIndex = zIndex; 32 | _rotation = rotation; 33 | _href = href; 34 | } 35 | return self; 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /src/Clustering/Algo/GMUClusterAlgorithm.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | #import "GMUCluster.h" 19 | #import "GMUClusterItem.h" 20 | 21 | NS_ASSUME_NONNULL_BEGIN 22 | 23 | /** 24 | * Generic protocol for arranging cluster items into groups. 25 | */ 26 | @protocol GMUClusterAlgorithm 27 | 28 | - (void)addItems:(NSArray> *)items; 29 | 30 | /** 31 | * Removes an item. 32 | */ 33 | - (void)removeItem:(id)item; 34 | 35 | /** 36 | * Clears all items. 37 | */ 38 | - (void)clearItems; 39 | 40 | /** 41 | * Returns the set of clusters of the added items. 42 | */ 43 | - (NSArray> *)clustersAtZoom:(float)zoom; 44 | 45 | @end 46 | 47 | NS_ASSUME_NONNULL_END 48 | -------------------------------------------------------------------------------- /src/Clustering/GMUCluster.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | #import 18 | 19 | #import "GMUClusterItem.h" 20 | 21 | NS_ASSUME_NONNULL_BEGIN 22 | 23 | /** 24 | * Defines a generic cluster object. 25 | */ 26 | @protocol GMUCluster 27 | 28 | /** 29 | * Returns the position of the cluster. 30 | */ 31 | @property(nonatomic, readonly) CLLocationCoordinate2D position; 32 | 33 | /** 34 | * Returns the number of items in the cluster. 35 | */ 36 | @property(nonatomic, readonly) NSUInteger count; 37 | 38 | /** 39 | * Returns a copy of the list of items in the cluster. 40 | */ 41 | @property(nonatomic, readonly) NSArray> *items; 42 | 43 | @end 44 | 45 | NS_ASSUME_NONNULL_END 46 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUFeature.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GMUFeature.h" 17 | 18 | @implementation GMUFeature 19 | 20 | @synthesize geometry = _geometry; 21 | @synthesize style = _style; 22 | 23 | - (instancetype)initWithGeometry:(id)geometry 24 | identifier:(NSString * _Nullable)identifier 25 | properties:(NSDictionary * _Nullable)properties 26 | boundingBox:(GMSCoordinateBounds * _Nullable)boundingBox { 27 | if (self = [super init]) { 28 | _geometry = geometry; 29 | _identifier = identifier; 30 | _boundingBox = boundingBox; 31 | _properties = properties ?: [[[NSDictionary alloc] init] copy]; 32 | } 33 | return self; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUPoint.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | #import 18 | 19 | #import "GMUGeometry.h" 20 | 21 | NS_ASSUME_NONNULL_BEGIN 22 | 23 | /** 24 | * Instances of this class represent a Point object. 25 | */ 26 | @interface GMUPoint : NSObject 27 | 28 | /** 29 | * The 2D coordinate of the Point, containing a latitude and longitude. 30 | */ 31 | @property(nonatomic, readonly) CLLocationCoordinate2D coordinate; 32 | 33 | /** 34 | * Initializes a GMUPoint object with a coordinate. 35 | * 36 | * @param coordinate A location with a latitude and longitude. 37 | */ 38 | - (instancetype)initWithCoordinate:(CLLocationCoordinate2D)coordinate; 39 | 40 | @end 41 | 42 | NS_ASSUME_NONNULL_END 43 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUGeometryCollection.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | #import "GMUGeometry.h" 19 | 20 | NS_ASSUME_NONNULL_BEGIN 21 | 22 | /** 23 | * Instances of this class represent a GeometryCollection object. 24 | */ 25 | @interface GMUGeometryCollection : NSObject 26 | 27 | /** 28 | * The array of geometry objects for the GeometryCollection. 29 | */ 30 | @property(nonatomic, readonly) NSArray> *geometries; 31 | 32 | /** 33 | * Initializes a GMUGeometryCollection object with a set of geometry objects. 34 | * 35 | * @param geometries The array of geometry objects. 36 | */ 37 | - (instancetype)initWithGeometries:(NSArray> *)geometries; 38 | 39 | @end 40 | 41 | NS_ASSUME_NONNULL_END 42 | -------------------------------------------------------------------------------- /src/Heatmap/GMUWeightedLatLng.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GQTPointQuadTreeItem.h" 17 | 18 | #import 19 | 20 | NS_ASSUME_NONNULL_BEGIN 21 | 22 | // A quad tree item which represents a data point of given intensity at a given point on the earth's 23 | // surface. 24 | @interface GMUWeightedLatLng : NSObject 25 | 26 | // The intensity of the data point. Scale is arbitrary but assumed to be linear. Intensity three 27 | // should be equivalent to three co-located points of intensity one. 28 | @property(nonatomic, readonly) float intensity; 29 | 30 | // Designated initializer. 31 | - (instancetype)initWithCoordinate:(CLLocationCoordinate2D)coordinate intensity:(float)intensity; 32 | 33 | @end 34 | 35 | NS_ASSUME_NONNULL_END 36 | -------------------------------------------------------------------------------- /samples/SwiftDemoApp/SwiftDemoApp/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /test/resources/GeoJSON/GeoJSON_MultiPolygon_Test.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type":"MultiPolygon", 3 | "coordinates":[ 4 | [ 5 | [ 6 | [ 7 | 102.0, 8 | 2.0 9 | ], 10 | [ 11 | 103.0, 12 | 2.0 13 | ], 14 | [ 15 | 103.0, 16 | 3.0 17 | ], 18 | [ 19 | 102.0, 20 | 3.0 21 | ], 22 | [ 23 | 102.0, 24 | 2.0 25 | ] 26 | ] 27 | ], 28 | [ 29 | [ 30 | [ 31 | 100.0, 32 | 0.0 33 | ], 34 | [ 35 | 101.0, 36 | 0.0 37 | ], 38 | [ 39 | 101.0, 40 | 1.0 41 | ], 42 | [ 43 | 100.0, 44 | 1.0 45 | ], 46 | [ 47 | 100.0, 48 | 0.0 49 | ] 50 | ] 51 | ] 52 | ] 53 | } 54 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUPolygon.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | #import 18 | #import 19 | 20 | #import "GMUGeometry.h" 21 | 22 | NS_ASSUME_NONNULL_BEGIN 23 | 24 | /** 25 | * Instances of this class represent a Polygon object. 26 | */ 27 | @interface GMUPolygon : NSObject 28 | 29 | /** 30 | * The array of LinearRing paths for the Polygon. The first is the exterior ring of the Polygon; any 31 | * subsequent rings are holes. 32 | */ 33 | @property(nonatomic, readonly) NSArray *paths; 34 | 35 | /** 36 | * Initializes a GMUGeoJSONPolygon object with a set of paths. 37 | * 38 | * @param paths The paths of the Polygon. 39 | */ 40 | - (instancetype)initWithPaths:(NSArray *)paths; 41 | 42 | @end 43 | 44 | NS_ASSUME_NONNULL_END 45 | -------------------------------------------------------------------------------- /test/unit/Geometry/GMUGeometryCollectionTest.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | #import 18 | 19 | #import "GMUGeometryCollection.h" 20 | 21 | @interface GMUGeometryCollectionTest : XCTestCase 22 | @end 23 | 24 | static NSString *const kType = @"GeometryCollection"; 25 | 26 | @implementation GMUGeometryCollectionTest 27 | 28 | - (void)testInitWithGeometries { 29 | id geometry = OCMProtocolMock(@protocol(GMUGeometry)); 30 | id secondGeometry = OCMProtocolMock(@protocol(GMUGeometry)); 31 | NSArray> *geometries = @[ geometry, secondGeometry ]; 32 | GMUGeometryCollection *geometryCollection = 33 | [[GMUGeometryCollection alloc] initWithGeometries:geometries]; 34 | XCTAssertEqualObjects(geometryCollection.type, kType); 35 | XCTAssertEqualObjects(geometryCollection.geometries, geometries); 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /src/Clustering/GMUStaticCluster.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #if !defined(__has_feature) || !__has_feature(objc_arc) 17 | #error "This file requires ARC support." 18 | #endif 19 | 20 | #import "GMUStaticCluster.h" 21 | 22 | @implementation GMUStaticCluster { 23 | NSMutableArray> *_items; 24 | } 25 | 26 | - (instancetype)initWithPosition:(CLLocationCoordinate2D)position { 27 | if ((self = [super init])) { 28 | _items = [[NSMutableArray alloc] init]; 29 | _position = position; 30 | } 31 | return self; 32 | } 33 | 34 | - (NSUInteger)count { 35 | return _items.count; 36 | } 37 | 38 | - (NSArray> *)items { 39 | return [_items copy]; 40 | } 41 | 42 | - (void)addItem:(id)item { 43 | [_items addObject:item]; 44 | } 45 | 46 | - (void)removeItem:(id)item { 47 | [_items removeObject:item]; 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /samples/SwiftDemoApp/SwiftDemoApp/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import GoogleMaps 17 | import UIKit 18 | 19 | // Change this key to a valid key registered with the demo app bundle id. 20 | let mapsAPIKey = "" 21 | 22 | @UIApplicationMain 23 | class AppDelegate: UIResponder, UIApplicationDelegate { 24 | 25 | var window: UIWindow? 26 | 27 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { 28 | if mapsAPIKey.isEmpty { 29 | fatalError("Please provide an API Key using mapsAPIKey") 30 | } 31 | GMSServices.provideAPIKey(mapsAPIKey) 32 | let masterViewControler = MasterViewController() 33 | let navigationController = UINavigationController(rootViewController: masterViewControler) 34 | window?.rootViewController = navigationController 35 | return true 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /.github/sync-repo-settings.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # https://github.com/googleapis/repo-automation-bots/tree/main/packages/sync-repo-settings 16 | 17 | rebaseMergeAllowed: true 18 | squashMergeAllowed: true 19 | mergeCommitAllowed: false 20 | deleteBranchOnMerge: true 21 | branchProtectionRules: 22 | - pattern: main 23 | isAdminEnforced: false 24 | requiresStrictStatusChecks: false 25 | requiredStatusCheckContexts: 26 | - 'cla/google' 27 | - 'test' 28 | - 'snippet-bot check' 29 | - 'header-check' 30 | requiredApprovingReviewCount: 1 31 | requiresCodeOwnerReviews: true 32 | - pattern: master 33 | isAdminEnforced: false 34 | requiresStrictStatusChecks: false 35 | requiredStatusCheckContexts: 36 | - 'cla/google' 37 | - 'test' 38 | - 'snippet-bot check' 39 | - 'header-check' 40 | requiredApprovingReviewCount: 1 41 | requiresCodeOwnerReviews: true 42 | permissionRules: 43 | - team: admin 44 | permission: admin 45 | -------------------------------------------------------------------------------- /test/unit/Heatmap/GMUWeightedLatLngTest.swift: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import XCTest 17 | @testable import GoogleMapsUtils 18 | 19 | class GMUWeightedLatLngTest: XCTestCase { 20 | 21 | private var coordinate: CLLocationCoordinate2D! 22 | private var intensity: Float! 23 | 24 | override func setUp() { 25 | super.setUp() 26 | coordinate = CLLocationCoordinate2DMake(10.456, 98.122) 27 | intensity = 11.0 28 | } 29 | 30 | override func tearDown() { 31 | coordinate = nil 32 | intensity = nil 33 | super.tearDown() 34 | } 35 | 36 | func testInitWithCoordinate() { 37 | let weightedLatLng = GMUWeightedLatLng(coordinate: coordinate, intensity: intensity) 38 | let mapPoint: GMSMapPoint = GMSProject(coordinate) 39 | XCTAssertEqual(weightedLatLng.intensity, intensity) 40 | XCTAssertEqual(weightedLatLng.point().x, mapPoint.x) 41 | XCTAssertEqual(weightedLatLng.point().y, mapPoint.y) 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: 'type: bug, triage me' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Thanks for stopping by to let us know something could be better! 11 | 12 | --- 13 | **PLEASE READ** 14 | 15 | If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/). This will ensure a timely response. 16 | 17 | Discover additional support services for the Google Maps Platform, including developer communities, technical guidance, and expert support at the Google Maps Platform [support resources page](https://developers.google.com/maps/support/). 18 | 19 | If your bug or feature request is not related to this particular library, please visit the Google Maps Platform [issue trackers](https://developers.google.com/maps/support/#issue_tracker). 20 | 21 | Check for answers on StackOverflow with the [google-maps](http://stackoverflow.com/questions/tagged/google-maps) tag. 22 | 23 | --- 24 | 25 | Please be sure to include as much information as possible: 26 | 27 | #### Environment details 28 | 29 | 1. Specify the API at the beginning of the title (for example, "Places: ...") 30 | 2. OS type and version 31 | 3. Library version and other environment information 32 | 33 | #### Steps to reproduce 34 | 35 | 1. ? 36 | 37 | #### Code example 38 | 39 | ``` 40 | # example 41 | ``` 42 | 43 | #### Stack trace 44 | ``` 45 | # example 46 | ``` 47 | 48 | Following these steps will guarantee the quickest resolution possible. 49 | 50 | Thanks! 51 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # A workflow that runs tests on every new pull request 16 | name: Run unit tests 17 | 18 | on: 19 | repository_dispatch: 20 | types: [test] 21 | pull_request: 22 | branches: ['*'] 23 | workflow_call: 24 | 25 | jobs: 26 | test: 27 | runs-on: macos-latest 28 | 29 | steps: 30 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 31 | - name: Checkout google-maps-ios-utils 32 | uses: actions/checkout@v3 33 | 34 | - name: Install Dependencies 35 | run: sudo gem install cocoapods 36 | 37 | - name: CocoaPods spec lint 38 | run: pod lib lint Google-Maps-iOS-Utils.podspec 39 | 40 | - name: Run unit tests 41 | run: | 42 | xcodebuild -scheme UnitTest -configuration Debug -destination "platform=iOS Simulator,OS=15.0,name=iPhone 8" build test | xcpretty 43 | 44 | - name: Upload test results to CodeCov 45 | run: bash <(curl -s https://codecov.io/bash) 46 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this library 4 | title: '' 5 | labels: 'type: feature request, triage me' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Thanks for stopping by to let us know something could be better! 11 | 12 | --- 13 | **PLEASE READ** 14 | 15 | If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/). This will ensure a timely response. 16 | 17 | Discover additional support services for the Google Maps Platform, including developer communities, technical guidance, and expert support at the Google Maps Platform [support resources page](https://developers.google.com/maps/support/). 18 | 19 | If your bug or feature request is not related to this particular library, please visit the Google Maps Platform [issue trackers](https://developers.google.com/maps/support/#issue_tracker). 20 | 21 | Check for answers on StackOverflow with the [google-maps](http://stackoverflow.com/questions/tagged/google-maps) tag. 22 | 23 | --- 24 | 25 | **Is your feature request related to a problem? Please describe.** 26 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 27 | 28 | **Describe the solution you'd like** 29 | A clear and concise description of what you want to happen. 30 | 31 | **Describe alternatives you've considered** 32 | A clear and concise description of any alternative solutions or features you've considered. 33 | 34 | **Additional context** 35 | Add any other context or screenshots about the feature request here. 36 | -------------------------------------------------------------------------------- /docs/Carthage.md: -------------------------------------------------------------------------------- 1 | Carthage Installation Steps 2 | =========================== 3 | 4 | 1. Add this repository to your `Cartfile`. 5 | ``` 6 | github "googlemaps/google-maps-ios-utils" 7 | ``` 8 | 9 | 2. Run `carthage update --platform iOS`. 10 | 3. Add the Maps SDK for iOS frameworks into your project by dragging `GoogleMaps.framework`, `GoogleMapsBase.framework` and `GoogleMapsCore.framework` in the `Carthage/Build/iOS` directory into the top level directory of your Xcode project (premium plan customers should also add `GoogleMapsM4B.framework` into the project). 11 | 4. Add the Maps SDK for iOS Utilities framework by dragging `GoogleMapsUtils.framework` in the `Carthage/Build/iOS/Static` directory into the top level directory of your Xcode project. 12 | 5. Add `GoogleMaps.bundle` by dragging `Carthage/Build/iOS/GoogleMaps.framework/Resources/GoogleMaps.bundle` into the top level directory of your Xcode project. 13 | 6. Open the _Build Phases_ tab for your application’s target, and within _Link Binary with Libraries_, add the additional following frameworks: 14 | * Accelerate.framework 15 | * CoreData.framework 16 | * CoreGraphics.framework 17 | * CoreImage.framework 18 | * CoreLocation.framework 19 | * CoreTelephony.framework 20 | * CoreText.framework 21 | * GLKit.framework 22 | * ImageIO.framework 23 | * libc++.tbd 24 | * libz.tbd 25 | * OpenGLES.framework 26 | * QuartzCore.framework 27 | * SystemConfiguration.framework 28 | * UIKit.framework 29 | 7. Open the _Build Settings_ tab for you application’s target, add `-ObjC` in the _Other Linker Flags_ section. 30 | -------------------------------------------------------------------------------- /samples/SwiftDemoApp/SwiftDemoApp/GeoJSONViewController.swift: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import GoogleMaps 17 | import UIKit 18 | import GoogleMapsUtils 19 | 20 | class GeoJSONViewController: UIViewController { 21 | private var mapView: GMSMapView! 22 | private var renderer: GMUGeometryRenderer! 23 | private var geoJsonParser: GMUGeoJSONParser! 24 | 25 | override func loadView() { 26 | let camera = GMSCameraPosition.camera(withLatitude: -28, longitude: 137, zoom: 4) 27 | mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera) 28 | self.view = mapView 29 | guard let path = Bundle.main.path(forResource: "GeoJSON_sample", ofType: "json") else { 30 | NSLog("Resource not available") 31 | return 32 | } 33 | let url = URL(fileURLWithPath: path) 34 | geoJsonParser = GMUGeoJSONParser(url: url) 35 | geoJsonParser.parse() 36 | renderer = GMUGeometryRenderer(map: mapView, geometries: geoJsonParser.features) 37 | renderer.render() 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /.releaserc: -------------------------------------------------------------------------------- 1 | branches: 2 | - main 3 | plugins: 4 | - "@semantic-release/commit-analyzer" 5 | - "@semantic-release/release-notes-generator" 6 | - - "@google/semantic-release-replace-plugin" 7 | - replacements: 8 | - files: 9 | - "./Google-Maps-iOS-Utils.podspec" 10 | from: "s.version = \".*\"" 11 | to: "s.version = \"${nextRelease.version}\"" 12 | 13 | - files: 14 | - "./GoogleMapsUtils.xcodeproj/project.pbxproj" 15 | from: "MARKETING_VERSION = .*;" 16 | to: "MARKETING_VERSION = ${nextRelease.version};" 17 | 18 | - files: 19 | - "Podfile.template" 20 | from: "'Google-Maps-iOS-Utils', '([0-9]+).([0-9]+).([0-9]+)'" 21 | to: "'Google-Maps-iOS-Utils', '${nextRelease.version}'" 22 | 23 | - files: 24 | - "README.md" 25 | from: "(?!6.2.1|4.1.0)([0-9]+).([0-9]+).([0-9]+)" 26 | to: "${nextRelease.version}" 27 | 28 | - files: 29 | - "Package.swift" 30 | from: "v([0-9]+).([0-9]+).([0-9]+)" 31 | to: "v${nextRelease.version}" 32 | - - "@semantic-release/exec" 33 | - verifyConditionsCmd: "pod lib lint" 34 | publishCmd: "pod trunk push" 35 | - - "@semantic-release/git" 36 | - assets: 37 | - "./Google-Maps-iOS-Utils.podspec" 38 | - "./GoogleMapsUtils.xcodeproj/project.pbxproj" 39 | - "*.md" 40 | - "Podfile.template" 41 | - "Package.swift" 42 | - - "@semantic-release/github" 43 | - assets: 44 | - "./GoogleMapsUtils.xcframework.zip" 45 | 46 | options: 47 | debug: true 48 | -------------------------------------------------------------------------------- /samples/SwiftDemoApp/SwiftDemoApp/Sample.swift: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import UIKit 17 | 18 | enum Sample: CaseIterable { 19 | case Clustering 20 | case KML 21 | case GeoJSON 22 | case Heatmaps 23 | } 24 | 25 | extension Sample { 26 | var title: String { 27 | switch self { 28 | case .Clustering: return "Clustering" 29 | case .KML: return "KML" 30 | case .GeoJSON: return "GeoJSON" 31 | case .Heatmaps: return "Heatmaps" 32 | } 33 | } 34 | 35 | var description: String { 36 | switch self { 37 | case .Clustering: return "Marker Clustering" 38 | case .KML: return "KML Rendering" 39 | case .GeoJSON: return "GeoJSON Rendering" 40 | case .Heatmaps: return "Heatmaps" 41 | } 42 | } 43 | 44 | var controller: UIViewController.Type { 45 | switch self { 46 | case .Clustering: return ClusteringViewController.self 47 | case .KML: return KMLViewController.self 48 | case .GeoJSON: return GeoJSONViewController.self 49 | case .Heatmaps: return HeatmapViewController.self 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.google.gmsutils.DevApp 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /app/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | Want to help out? That's awesome! 4 | 5 | The library is open source and lives on GitHub at: 6 | https://github.com/googlemaps/google-maps-ios-utils 7 | Open an issue or fork the library and submit a pull request. 8 | 9 | Keep in mind that before we can accept any pull requests we have to jump 10 | through a couple of legal hurdles, primarily a Contributor License Agreement 11 | (CLA): 12 | 13 | - **If you are an individual writing original source code** 14 | and you're sure you own the intellectual property, 15 | then you'll need to sign an 16 | [individual CLA](https://developers.google.com/open-source/cla/individual). 17 | - **If you work for a company that wants to allow you to contribute your work**, 18 | then you'll need to sign a 19 | [corporate CLA](https://developers.google.com/open-source/cla/corporate) 20 | 21 | Follow either of the two links above to access the appropriate CLA and 22 | instructions for how to sign and return it. 23 | 24 | When preparing your code, make sure to update the AUTHORS and CONTRIBUTORS file 25 | to reflect your contribtion. 26 | 27 | Once we receive your CLA, we'll be able to review and accept your pull requests. 28 | 29 | ### Setup 30 | 1. git clone the repository 31 | 2. Install Carthage if you don't have it installed already 32 | ``` 33 | brew install carthage 34 | ``` 35 | 3. Run `carthage update --platform ios` 36 | 4. There should be 3 schemes: *GoogleMapsUtils*, *DevApp*, and *UnitTest* 37 | * The *GoogleMapsUtils* scheme builds `GoogleMapsUtils.framework` 38 | * The *DevApp* scheme is the test app which uses some features of *GoogleMapsUtils* 39 | * The *UnitTest* scheme runs unit tests 40 | -------------------------------------------------------------------------------- /samples/ObjCDemoApp/ObjCDemoApp/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #if !defined(__has_feature) || !__has_feature(objc_arc) 17 | #error "This file requires ARC support." 18 | #endif 19 | 20 | #import "AppDelegate.h" 21 | 22 | #import "AppApiKey.h" 23 | #import "MasterViewController.h" 24 | 25 | #import 26 | 27 | @interface AppDelegate () 28 | @end 29 | 30 | @implementation AppDelegate 31 | 32 | - (BOOL)application:(UIApplication *)application 33 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 34 | if (kMapsAPIKey.length == 0) { 35 | [NSException raise:NSInvalidArgumentException format:@"Please provide your GMP API key"]; 36 | } 37 | [GMSServices provideAPIKey:kMapsAPIKey]; 38 | 39 | MasterViewController *rootViewController = [[MasterViewController alloc] init]; 40 | UINavigationController *navigationController = 41 | [[UINavigationController alloc] initWithRootViewController:rootViewController]; 42 | navigationController.navigationBar.translucent = NO; 43 | self.window.rootViewController = navigationController; 44 | return YES; 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /samples/SwiftDemoApp/SwiftDemoApp/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/Clustering/Algo/GMUWrappingDictionaryKey.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #if !defined(__has_feature) || !__has_feature(objc_arc) 17 | #error "This file requires ARC support." 18 | #endif 19 | 20 | #import "GMUWrappingDictionaryKey.h" 21 | 22 | @implementation GMUWrappingDictionaryKey { 23 | id _object; 24 | } 25 | 26 | - (instancetype)initWithObject:(id)object { 27 | if ((self = [super init])) { 28 | _object = object; 29 | } 30 | return self; 31 | } 32 | 33 | - (id)copyWithZone:(NSZone *)zone { 34 | GMUWrappingDictionaryKey *newKey = [[self class] allocWithZone:zone]; 35 | if (newKey) { 36 | newKey->_object = _object; 37 | } 38 | return newKey; 39 | } 40 | 41 | // Forwards hash to _object. 42 | - (NSUInteger)hash { 43 | return [_object hash]; 44 | } 45 | 46 | // Forwards isEqual to _object. 47 | - (BOOL)isEqual:(id)object { 48 | if (self == object) return YES; 49 | 50 | if ([object class] != [self class]) return NO; 51 | 52 | GMUWrappingDictionaryKey *other = (GMUWrappingDictionaryKey *)object; 53 | return [_object isEqual:other->_object]; 54 | } 55 | 56 | @end 57 | 58 | -------------------------------------------------------------------------------- /test/unit/Geometry/GMUFeatureTest.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | #import 18 | 19 | #import "GMUFeature.h" 20 | 21 | @interface GMUFeatureTest : XCTestCase 22 | @end 23 | 24 | static NSString *const kIdentifier = @"TestFeature"; 25 | 26 | @implementation GMUFeatureTest 27 | 28 | - (void)testInitWithGeometry { 29 | id geometry = OCMProtocolMock(@protocol(GMUGeometry)); 30 | id boundingBox = OCMClassMock([GMSCoordinateBounds class]); 31 | NSDictionary *properties = @{@"Key1" : @"Value1", @"Key2" : @"Value2"}; 32 | GMUFeature *feature = [[GMUFeature alloc] initWithGeometry:geometry 33 | identifier:kIdentifier 34 | properties:properties 35 | boundingBox:boundingBox]; 36 | XCTAssertEqual(feature.geometry, geometry); 37 | XCTAssertEqualObjects(feature.identifier, kIdentifier); 38 | XCTAssertEqualObjects(feature.properties, properties); 39 | XCTAssertEqual(feature.boundingBox, boundingBox); 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /docs/HeatmapRendering.md: -------------------------------------------------------------------------------- 1 | Heatmap rendering 2 | ========================= 3 | As of version 2.1.0 we have added new features for rendering heatmaps. 4 | Heatmaps make it easy for viewers to understand the distribution and relative 5 | intensity of data points on a map. Rather than placing a marker at each 6 | location, heatmaps use color to represent the distribution of the data. 7 | 8 | In the example below, red represents areas of high concentration of police 9 | stations in Victoria, Australia. 10 | 11 |

12 | A map with a heatmap showing location of police stations 14 |

15 | 16 | ### Heatmap Interpolation 17 | Heatmap interpolation allows developers to create robust heatmaps based on average intensities of given data points. The heatmap interpolation class also allows developers with sparse data sets to produce meaningful heatmaps. Developers can input lists of `GMUWeightedLatLng` objects (or singular) and the class's point generating function will return an array of `GMUWeightedLatLng` that can be added to the existing heatmap. 18 | 19 | Please use this [link](https://github.com/googlemaps/google-maps-ios-utils/blob/master/samples/SwiftDemoApp/SwiftDemoApp/HeatMapInterpolationViewController.swift) to test out the heat map interpolation algorithm! 20 | 21 | In the following image, the data set consists of only four points (indicated by markers); the second-top point is the most intense in the given data set. Every other heat map point in the graph was interpolated. 22 |

23 | Heat map interpolation 25 |

26 | 27 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUStyle.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GMUStyle.h" 17 | 18 | @implementation GMUStyle 19 | 20 | - (instancetype)initWithStyleID:(NSString *)styleID 21 | strokeColor:(UIColor *)strokeColor 22 | fillColor:(UIColor *)fillColor 23 | width:(CGFloat)width 24 | scale:(CGFloat)scale 25 | heading:(CGFloat)heading 26 | anchor:(CGPoint)anchor 27 | iconUrl:(NSString *)iconUrl 28 | title:(NSString *)title 29 | hasFill:(BOOL)hasFill 30 | hasStroke:(BOOL)hasStroke { 31 | if (self = [super init]) { 32 | _styleID = [styleID copy]; 33 | _strokeColor = strokeColor; 34 | _fillColor = fillColor; 35 | _width = width; 36 | _scale = scale; 37 | _heading = heading; 38 | _anchor = anchor; 39 | _iconUrl = [iconUrl copy]; 40 | _title = [title copy]; 41 | _hasFill = hasFill; 42 | _hasStroke = hasStroke; 43 | } 44 | return self; 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /src/Clustering/Algo/GMUNonHierarchicalDistanceBasedAlgorithm.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | #import "GMUClusterAlgorithm.h" 19 | 20 | /** 21 | * A simple clustering algorithm with O(nlog n) performance. Resulting clusters are not 22 | * hierarchical. 23 | * High level algorithm: 24 | * 1. Iterate over items in the order they were added (candidate clusters). 25 | * 2. Create a cluster with the center of the item. 26 | * 3. Add all items that are within a certain distance to the cluster. 27 | * 4. Move any items out of an existing cluster if they are closer to another cluster. 28 | * 5. Remove those items from the list of candidate clusters. 29 | * Clusters have the center of the first element (not the centroid of the items within it). 30 | */ 31 | @interface GMUNonHierarchicalDistanceBasedAlgorithm : NSObject 32 | 33 | /** 34 | * Initializes this GMUNonHierarchicalDistanceBasedAlgorithm with clusterDistancePoints for 35 | * the distance it uses to cluster items (default is 100). 36 | */ 37 | - (instancetype)initWithClusterDistancePoints:(NSUInteger)clusterDistancePoints; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /test/unit/Geometry/GMULineStringTest.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | #import "GMULineString.h" 19 | 20 | @interface GMULineStringTest : XCTestCase 21 | @end 22 | 23 | static NSString *const kType = @"LineString"; 24 | static const CLLocationDegrees kFirstLatitude = 50.0; 25 | static const CLLocationDegrees kFirstLongitude = 45.0; 26 | static const CLLocationDegrees kSecondLatitude = 60.0; 27 | static const CLLocationDegrees kSecondLongitude = 55.0; 28 | 29 | @implementation GMULineStringTest 30 | 31 | - (void)testInitWithCoordinates { 32 | CLLocationCoordinate2D firstCoordinate = 33 | CLLocationCoordinate2DMake(kFirstLatitude, kFirstLongitude); 34 | CLLocationCoordinate2D secondCoordinate = 35 | CLLocationCoordinate2DMake(kSecondLatitude, kSecondLongitude); 36 | GMSMutablePath *path = [[GMSMutablePath alloc] init]; 37 | [path addCoordinate:firstCoordinate]; 38 | [path addCoordinate:secondCoordinate]; 39 | GMULineString *lineString = [[GMULineString alloc] initWithPath:path]; 40 | XCTAssertEqualObjects(lineString.type, kType); 41 | XCTAssertEqualObjects(lineString.path, path); 42 | } 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /app/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /samples/ObjCDemoApp/ObjCDemoApp/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSLocationWhenInUseUsageDescription 6 | 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | UISupportedInterfaceOrientations~ipad 42 | 43 | UIInterfaceOrientationPortrait 44 | UIInterfaceOrientationPortraitUpsideDown 45 | UIInterfaceOrientationLandscapeLeft 46 | UIInterfaceOrientationLandscapeRight 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /samples/ObjCDemoApp/ObjCDemoApp/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /samples/SwiftDemoApp/SwiftDemoApp/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /samples/SwiftDemoApp/SwiftDemoApp/KMLViewController.swift: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import GoogleMaps 17 | import UIKit 18 | import GoogleMapsUtils 19 | 20 | class KMLViewController: UIViewController { 21 | private var mapView: GMSMapView! 22 | private var renderer: GMUGeometryRenderer! 23 | private var kmlParser: GMUKMLParser! 24 | private var geoJsonParser: GMUGeoJSONParser! 25 | 26 | override func loadView() { 27 | let camera = GMSCameraPosition.camera(withLatitude: 37.4220, longitude: -122.0841, zoom: 17) 28 | mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera) 29 | self.view = mapView 30 | guard let path = Bundle.main.path(forResource: "KML_Sample", ofType: "kml") else { 31 | NSLog("Resource not available") 32 | return 33 | } 34 | let url = URL(fileURLWithPath: path) 35 | kmlParser = GMUKMLParser(url: url) 36 | kmlParser.parse() 37 | renderer = GMUGeometryRenderer(map: mapView, 38 | geometries: kmlParser.placemarks, 39 | styles: kmlParser.styles, 40 | styleMaps: kmlParser.styleMaps) 41 | renderer.render() 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /test/unit/Geometry/GMUPlacemarkTest.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | #import 18 | 19 | #import "GMUPlacemark.h" 20 | 21 | @interface GMUPlacemarkTest : XCTestCase 22 | @end 23 | 24 | static NSString *const kTitle = @"Placemark"; 25 | static NSString *const kSnippet = @"A test placemark."; 26 | static NSString *const kStyleUrl = @"#test"; 27 | 28 | @implementation GMUPlacemarkTest 29 | 30 | - (void)testInitWithGeometry { 31 | id geometry = OCMProtocolMock(@protocol(GMUGeometry)); 32 | id style = OCMClassMock([GMUStyle class]); 33 | GMUPlacemark *placemark = [[GMUPlacemark alloc] initWithGeometry:geometry 34 | title:kTitle 35 | snippet:kSnippet 36 | style:style 37 | styleUrl:kStyleUrl]; 38 | XCTAssertEqualObjects(placemark.geometry, geometry); 39 | XCTAssertEqualObjects(placemark.title, kTitle); 40 | XCTAssertEqualObjects(placemark.snippet, kSnippet); 41 | XCTAssertEqualObjects(placemark.style, style); 42 | XCTAssertEqualObjects(placemark.styleUrl, kStyleUrl); 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /app/Samples.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #if !defined(__has_feature) || !__has_feature(objc_arc) 17 | #error "This file requires ARC support." 18 | #endif 19 | 20 | #import "Samples.h" 21 | 22 | #import "BasicViewController.h" 23 | #import "CustomMarkerViewController.h" 24 | #import "GeoJSONViewController.h" 25 | #import "HeatmapViewController.h" 26 | #import "KMLViewController.h" 27 | 28 | @implementation Samples 29 | 30 | + (NSArray *)loadDemos { 31 | NSArray *demos = @[ 32 | [self newDemo:[BasicViewController class] withTitle:@"Basic" andDescription:nil], 33 | [self newDemo:[CustomMarkerViewController class] withTitle:@"Custom Markers" 34 | andDescription:nil], 35 | [self newDemo:[KMLViewController class] withTitle:@"KML Import" andDescription:nil], 36 | [self newDemo:[GeoJSONViewController class] withTitle:@"GeoJSON Import" andDescription:nil], 37 | [self newDemo:[HeatmapViewController class] withTitle:@"Heatmap" andDescription:nil] 38 | ]; 39 | return demos; 40 | } 41 | 42 | + (NSDictionary *)newDemo:(Class) class 43 | withTitle:(NSString *)title 44 | andDescription:(NSString *)description { 45 | return @{ @"controller" : class, @"title" : title, @"description" : description ?: @"" }; 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /src/Geometry/GMUGeoJSONParser.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | NS_ASSUME_NONNULL_BEGIN 19 | 20 | @protocol GMUGeometryContainer; 21 | 22 | /** 23 | * Instances of this class parse GeoJSON data. The parsed features are stored in NSArray objects 24 | * which can then be passed to a GMUGeometryRenderer to display on a Google Map. 25 | */ 26 | @interface GMUGeoJSONParser : NSObject 27 | 28 | /** 29 | * The features parsed from the GeoJSON file. 30 | */ 31 | @property(nonatomic, readonly) NSArray> *features; 32 | 33 | /** 34 | * Initializes a GMUGeoJSONParser with GeoJSON data contained in a URL. 35 | * 36 | * @param url The url containing GeoJSON data. 37 | */ 38 | - (instancetype)initWithURL:(NSURL *)url; 39 | 40 | /** 41 | * Initializes a GMUGeoJSONParser with GeoJSON data. 42 | * 43 | * @param data The GeoJSON data. 44 | */ 45 | - (instancetype)initWithData:(NSData *)data; 46 | 47 | /** 48 | * Initializes a GMUGeoJSONParser with GeoJSON data contained in an input stream. 49 | * 50 | * @param stream The stream to use to access GeoJSON data. 51 | */ 52 | - (instancetype)initWithStream:(NSInputStream *)stream; 53 | 54 | /** 55 | * Parses the stored GeoJSON data. 56 | */ 57 | - (void)parse; 58 | 59 | @end 60 | 61 | NS_ASSUME_NONNULL_END 62 | -------------------------------------------------------------------------------- /src/Clustering/GMUStaticCluster.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | #import "GMUCluster.h" 19 | 20 | NS_ASSUME_NONNULL_BEGIN 21 | 22 | /** 23 | * Defines a cluster where its position is fixed upon construction. 24 | */ 25 | @interface GMUStaticCluster : NSObject 26 | 27 | /** 28 | * The default initializer is not available. Use initWithPosition: instead. 29 | */ 30 | - (instancetype)init NS_UNAVAILABLE; 31 | 32 | /** 33 | * Returns a new instance of the GMUStaticCluster class defined by it's position. 34 | */ 35 | - (instancetype)initWithPosition:(CLLocationCoordinate2D)position NS_DESIGNATED_INITIALIZER; 36 | 37 | /** 38 | * Returns the position of the cluster. 39 | */ 40 | @property(nonatomic, readonly) CLLocationCoordinate2D position; 41 | 42 | /** 43 | * Returns the number of items in the cluster. 44 | */ 45 | @property(nonatomic, readonly) NSUInteger count; 46 | 47 | /** 48 | * Returns a copy of the list of items in the cluster. 49 | */ 50 | @property(nonatomic, readonly) NSArray> *items; 51 | 52 | /** 53 | * Adds an item to the cluster. 54 | */ 55 | - (void)addItem:(id)item; 56 | 57 | /** 58 | * Removes an item to the cluster. 59 | */ 60 | - (void)removeItem:(id)item; 61 | 62 | @end 63 | 64 | NS_ASSUME_NONNULL_END 65 | -------------------------------------------------------------------------------- /samples/SwiftDemoApp/SwiftDemoApp/MasterViewController.swift: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import UIKit 17 | 18 | class MasterViewController: UITableViewController { 19 | 20 | override func viewDidLoad() { 21 | super.viewDidLoad() 22 | self.title = "Demos" 23 | } 24 | 25 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 26 | return Sample.allCases.count 27 | } 28 | 29 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> 30 | UITableViewCell { 31 | let cellIdentifier = "Cell" 32 | let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier) ?? 33 | UITableViewCell(style: .subtitle, reuseIdentifier: cellIdentifier) 34 | 35 | cell.accessoryType = .disclosureIndicator 36 | cell.textLabel?.text = Sample.allCases[indexPath.item].title 37 | cell.detailTextLabel?.text = Sample.allCases[indexPath.item].description 38 | return cell 39 | } 40 | 41 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 42 | if let navigationController = navigationController { 43 | let viewController = Sample.allCases[indexPath.item].controller.init() 44 | navigationController.pushViewController(viewController, animated: true) 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/KMLViewController.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #if !defined(__has_feature) || !__has_feature(objc_arc) 17 | #error "This file requires ARC support." 18 | #endif 19 | 20 | #import "KMLViewController.h" 21 | 22 | #import 23 | #import 24 | 25 | static const double kCameraLatitude = 37.4220; 26 | static const double kCameraLongitude = -122.0841; 27 | 28 | @implementation KMLViewController { 29 | GMSMapView *_mapView; 30 | } 31 | 32 | - (void)loadView { 33 | GMSCameraPosition *camera = 34 | [GMSCameraPosition cameraWithLatitude:kCameraLatitude longitude:kCameraLongitude zoom:17]; 35 | _mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 36 | self.view = _mapView; 37 | } 38 | 39 | - (void)viewDidLoad { 40 | [super viewDidLoad]; 41 | NSString *path = [[NSBundle mainBundle] pathForResource:@"KML_Sample" ofType:@"kml"]; 42 | NSURL *url = [NSURL fileURLWithPath:path]; 43 | GMUKMLParser *parser = [[GMUKMLParser alloc] initWithURL:url]; 44 | [parser parse]; 45 | GMUGeometryRenderer *renderer = [[GMUGeometryRenderer alloc] initWithMap:_mapView 46 | geometries:parser.placemarks 47 | styles:parser.styles]; 48 | [renderer render]; 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /test/unit/Clustering/GMUSimpleClusterAlgorithmTest.swift: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import XCTest 17 | @testable import GoogleMapsUtils 18 | 19 | class GMUSimpleClusterAlgorithmTest: GMUClusterAlgorithmTest { 20 | 21 | private var clustersCount: Int! 22 | private var zoom: Float! 23 | 24 | override func setUp() { 25 | clustersCount = 10 26 | zoom = 3 27 | super.setUp() 28 | } 29 | 30 | override func tearDown() { 31 | clustersCount = nil 32 | zoom = nil 33 | super.tearDown() 34 | } 35 | 36 | func testClustersAtZoomWithDefaultClusterCount() { 37 | let simpleClusterAlgorithm = GMUSimpleClusterAlgorithm() 38 | simpleClusterAlgorithm.add(self.simpleClusterItems()) 39 | simpleClusterAlgorithm.add(self.simpleClusterItems()) 40 | simpleClusterAlgorithm.add(self.simpleClusterItems()) 41 | let clusterItems = simpleClusterAlgorithm.clusters(atZoom: zoom) 42 | XCTAssertEqual(clustersCount, clusterItems.count) 43 | } 44 | 45 | func testClustersAtZoomWithClearingClusterItems() { 46 | let simpleClusterAlgorithm = GMUSimpleClusterAlgorithm() 47 | simpleClusterAlgorithm.add(self.simpleClusterItems()) 48 | simpleClusterAlgorithm.clearItems() 49 | let clusters = simpleClusterAlgorithm.clusters(atZoom: zoom) 50 | XCTAssertEqual(0, clusters.count) 51 | XCTAssertNotEqual(clustersCount, clusters.count) 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUFeature.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | #import 19 | 20 | #import "GMUGeometryContainer.h" 21 | 22 | NS_ASSUME_NONNULL_BEGIN 23 | 24 | /** 25 | * Instances of this class represent a GeoJSON Feature object. 26 | */ 27 | @interface GMUFeature : NSObject 28 | 29 | /** 30 | * The identifier of the feature. 31 | */ 32 | @property(nonatomic, nullable, readonly) NSString *identifier; 33 | 34 | /** 35 | * The properties of the geometry in the feature. 36 | */ 37 | @property(nonatomic, nullable, readonly) NSDictionary *properties; 38 | 39 | /** 40 | * The bounding box of the geometry in the feature. 41 | */ 42 | @property(nonatomic, nullable, readonly) GMSCoordinateBounds *boundingBox; 43 | 44 | /** 45 | * 46 | * @param geometry The geometry object in the feature. 47 | * @param identifier The identifier of the feature. 48 | * @param properties The properties of the geometry in the feature. 49 | * @param boundingBox The bounding box of the geometry in the feature. 50 | */ 51 | - (instancetype)initWithGeometry:(id)geometry 52 | identifier:(NSString * _Nullable)identifier 53 | properties:(NSDictionary * _Nullable)properties 54 | boundingBox:(GMSCoordinateBounds * _Nullable)boundingBox; 55 | 56 | @end 57 | 58 | NS_ASSUME_NONNULL_END 59 | -------------------------------------------------------------------------------- /samples/ObjCDemoApp/ObjCDemoApp/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /src/GeometryUtils/GMSPolygon+GeometryUtils.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import GoogleMaps 16 | 17 | public extension GMSPolygon { 18 | 19 | /// Returns whether or not `coordinate` is inside this polygon. 20 | func contains(coordinate: CLLocationCoordinate2D) -> Bool { 21 | guard let path = self.path else { 22 | return false 23 | } 24 | return path.contains(coordinate: coordinate, geodesic: geodesic) 25 | } 26 | 27 | /// Returns the area of this polygon. 28 | /// - Parameters: 29 | /// - radius: the radius of the sphere. Defaults to `kGMSEarthRadius` 30 | /// - Returns: the area of this polygon, nil if the coordinates composing this polygon is invalid 31 | func area(radius: CLLocationDistance = kGMSEarthRadius) -> Double? { 32 | guard let path = self.path else { 33 | return nil 34 | } 35 | return path.area(radius: radius) 36 | } 37 | 38 | /// The signed area of this path on Earth which is considered. The result 39 | /// is positive if the points of path are in counter-clockwise order, and negative otherwise. 40 | /// - Parameters: 41 | /// - radius: the radius of the sphere. Defaults to `kGMSEarthRadius` 42 | /// - Returns: the signed area of this polygon, nil if the coordinates composing this polygon is invalid 43 | func signedArea(radius: CLLocationDistance = kGMSEarthRadius) -> Double? { 44 | guard let path = self.path else { 45 | return nil 46 | } 47 | return path.signedArea(radius: radius) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /test/unit/Clustering/GMUGridBasedClusterAlgorithmTest.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #if !defined(__has_feature) || !__has_feature(objc_arc) 17 | #error "This file requires ARC support." 18 | #endif 19 | 20 | #import 21 | 22 | #import "GMUClusterAlgorithmTest.h" 23 | 24 | @interface GMUGridBasedClusterAlgorithmTest : GMUClusterAlgorithmTest 25 | @end 26 | 27 | @implementation GMUGridBasedClusterAlgorithmTest 28 | 29 | - (void)testClustersAtZoomLowZoomItemsGroupedIntoOneCluster { 30 | GMUGridBasedClusterAlgorithm *algorithm = [[GMUGridBasedClusterAlgorithm alloc] init]; 31 | NSArray> *items = [self simpleClusterItems]; 32 | [algorithm addItems:items]; 33 | 34 | // At low zoom, there should be 1 cluster. 35 | NSArray> *clusters = [algorithm clustersAtZoom:3]; 36 | XCTAssertEqual(clusters.count, 1); 37 | XCTAssertEqual(clusters[0].items.count, 4); 38 | } 39 | 40 | - (void)testClustersAtZoomHighZoomItemsGroupedIntoMultipleClusters { 41 | GMUGridBasedClusterAlgorithm *algorithm = [[GMUGridBasedClusterAlgorithm alloc] init]; 42 | NSArray> *items = [self simpleClusterItems]; 43 | [algorithm addItems:items]; 44 | 45 | NSArray> *clusters = [algorithm clustersAtZoom:10]; 46 | XCTAssertEqual(clusters.count, 4); 47 | for (int i = 0; i < clusters.count; ++i) { 48 | XCTAssertEqual(clusters[i].items.count, 1); 49 | } 50 | [self assertValidClusters:clusters]; 51 | } 52 | 53 | @end 54 | 55 | -------------------------------------------------------------------------------- /test/unit/Geometry/GMUPolygonTest.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | #import "GMUPolygon.h" 19 | 20 | @interface GMUPolygonTest : XCTestCase 21 | @end 22 | 23 | static NSString *const kType = @"Polygon"; 24 | static const CLLocationDegrees kFirstLatitude = 50.0; 25 | static const CLLocationDegrees kFirstLongitude = 45.0; 26 | static const CLLocationDegrees kSecondLatitude = 55.0; 27 | static const CLLocationDegrees kSecondLongitude = 50.0; 28 | static const CLLocationDegrees kThirdLatitude = 60.0; 29 | static const CLLocationDegrees kThirdLongitude = 55.0; 30 | 31 | @implementation GMUPolygonTest 32 | 33 | - (void)testInitWithCoordinatesArray { 34 | CLLocationCoordinate2D firstCoordinate = 35 | CLLocationCoordinate2DMake(kFirstLatitude, kFirstLongitude); 36 | CLLocationCoordinate2D secondCoordinate = 37 | CLLocationCoordinate2DMake(kSecondLatitude, kSecondLongitude); 38 | CLLocationCoordinate2D thirdCoordinate = 39 | CLLocationCoordinate2DMake(kThirdLatitude, kThirdLongitude); 40 | GMSMutablePath *path = [[GMSMutablePath alloc] init]; 41 | [path addCoordinate:firstCoordinate]; 42 | [path addCoordinate:secondCoordinate]; 43 | [path addCoordinate:thirdCoordinate]; 44 | [path addCoordinate:firstCoordinate]; 45 | NSArray *paths = [NSArray arrayWithObject:path]; 46 | GMUPolygon *polygon = 47 | [[GMUPolygon alloc] initWithPaths:paths]; 48 | XCTAssertEqualObjects(polygon.type, kType); 49 | XCTAssertEqualObjects(polygon.paths, paths); 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUPlacemark.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | #import "GMUGeometryContainer.h" 19 | 20 | NS_ASSUME_NONNULL_BEGIN 21 | 22 | /** 23 | * Represents a placemark which is either a Point, LineString, Polygon, or MultiGeometry. Contains 24 | * the properties and styles of the place. 25 | */ 26 | @interface GMUPlacemark : NSObject 27 | 28 | /** 29 | * The name element of the placemark. 30 | */ 31 | @property(nonatomic, nullable, readonly) NSString *title; 32 | 33 | /** 34 | * The description element of the placemark. 35 | */ 36 | @property(nonatomic, nullable, readonly) NSString *snippet; 37 | 38 | /** 39 | * The StyleUrl element of the placemark; used to reference a style defined in the file. 40 | */ 41 | @property(nonatomic, nullable, readonly) NSString *styleUrl; 42 | 43 | /** 44 | * Initializes a new KMLPlacemark object. 45 | * 46 | * @param geometry The geometry of the placemark. 47 | * @param title The title of the placemark. 48 | * @param snippet The snippet text of the placemark. 49 | * @param style The inline style of the placemark. 50 | * @param styleUrl The url to the style of the placemark. 51 | */ 52 | - (instancetype)initWithGeometry:(id _Nullable)geometry 53 | title:(NSString *_Nullable)title 54 | snippet:(NSString *_Nullable)snippet 55 | style:(GMUStyle *_Nullable)style 56 | styleUrl:(NSString *_Nullable)styleUrl; 57 | 58 | @end 59 | 60 | NS_ASSUME_NONNULL_END 61 | -------------------------------------------------------------------------------- /test/unit/Clustering/GMUClusterAlgorithmTest.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | #import 18 | 19 | @protocol GMUCluster; 20 | 21 | /** 22 | * Base class for cluster algorithm tests. 23 | */ 24 | @interface GMUClusterAlgorithmTest : XCTestCase 25 | 26 | // Randomly shuffle a mutable array. 27 | - (void)shuffleMutableArray:(NSMutableArray *)array; 28 | 29 | // Creates a cluster item at given |location|. 30 | - (id)itemAtLocation:(CLLocationCoordinate2D)location; 31 | 32 | // Randomly generates cluster items around a |location|. 33 | - (NSArray> *)itemsAroundLocation:(CLLocationCoordinate2D)location 34 | count:(int)count 35 | zoom:(double)zoom 36 | radius:(double)screenPoints; 37 | 38 | // Sum of all clusters' item counts. 39 | - (NSUInteger)totalItemCountsForClusters:(NSArray> *)clusters; 40 | 41 | // Asserts 2 clusters do not share common items. 42 | - (void)assertCluster:(id)cluster1 doesNotOverlapCluster:(id)cluster2; 43 | 44 | - (void)assertValidClusters:(NSArray> *)clusters; 45 | 46 | #pragma mark Fixtures 47 | 48 | // Generates a fixed number of items for the simple test cases. 49 | - (NSArray> *)simpleClusterItems; 50 | 51 | // Randomly generates a number of items around fixed centroids. 52 | - (NSArray> *)randomizedClusterItems; 53 | 54 | @end 55 | 56 | -------------------------------------------------------------------------------- /test/unit/Geometry/GMUGroundOverlayTest.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | #import "GMUGroundOverlay.h" 19 | 20 | @interface GMUGroundOverlayTest : XCTestCase 21 | @end 22 | 23 | @implementation GMUGroundOverlayTest 24 | 25 | static NSString *const kType = @"GroundOverlay"; 26 | static NSString *const kHref = @"image.jpg"; 27 | static const int kZIndex = 1; 28 | static const double kRotation = 45.0; 29 | 30 | - (void)testInitWithProperties { 31 | CLLocationCoordinate2D northEast = CLLocationCoordinate2DMake(234.567, 345.678); 32 | CLLocationCoordinate2D southWest = CLLocationCoordinate2DMake(123.456, 456.789); 33 | GMUGroundOverlay *groundOverlay = [[GMUGroundOverlay alloc] initWithCoordinate:northEast 34 | southWest:southWest 35 | zIndex:kZIndex 36 | rotation:kRotation 37 | href:kHref]; 38 | XCTAssertEqualObjects(groundOverlay.type, kType); 39 | XCTAssertEqual(groundOverlay.northEast.longitude, northEast.longitude); 40 | XCTAssertEqual(groundOverlay.northEast.latitude, northEast.latitude); 41 | XCTAssertEqual(groundOverlay.southWest.latitude, southWest.latitude); 42 | XCTAssertEqual(groundOverlay.southWest.longitude, southWest.longitude); 43 | XCTAssertEqual(groundOverlay.zIndex, kZIndex); 44 | XCTAssertEqual(groundOverlay.rotation, kRotation); 45 | XCTAssertEqual(groundOverlay.href, kHref); 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /src/Clustering/Algo/GMUSimpleClusterAlgorithm.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #if !defined(__has_feature) || !__has_feature(objc_arc) 17 | #error "This file requires ARC support." 18 | #endif 19 | 20 | #import "GMUSimpleClusterAlgorithm.h" 21 | 22 | #import "GMUStaticCluster.h" 23 | #import "GMUClusterItem.h" 24 | 25 | static const NSUInteger kClusterCount = 10; 26 | 27 | @implementation GMUSimpleClusterAlgorithm { 28 | NSMutableArray> *_items; 29 | } 30 | 31 | - (instancetype)init { 32 | if ((self = [super init])) { 33 | _items = [[NSMutableArray alloc] init]; 34 | } 35 | return self; 36 | } 37 | 38 | - (void)addItems:(NSArray> *)items { 39 | [_items addObjectsFromArray:items]; 40 | } 41 | 42 | - (void)removeItem:(id)item { 43 | [_items removeObject:item]; 44 | } 45 | 46 | - (void)clearItems { 47 | [_items removeAllObjects]; 48 | } 49 | 50 | - (NSArray> *)clustersAtZoom:(float)zoom { 51 | NSMutableArray> *clusters = 52 | [[NSMutableArray alloc] initWithCapacity:kClusterCount]; 53 | 54 | for (int i = 0; i < kClusterCount; ++i) { 55 | if (i >= _items.count) break; 56 | id item = _items[i]; 57 | [clusters addObject:[[GMUStaticCluster alloc] initWithPosition:item.position]]; 58 | } 59 | 60 | NSUInteger clusterIndex = 0; 61 | for (int i = kClusterCount; i < _items.count; ++i) { 62 | id item = _items[i]; 63 | GMUStaticCluster *cluster = clusters[clusterIndex % kClusterCount]; 64 | [cluster addItem:item]; 65 | ++clusterIndex; 66 | } 67 | return clusters; 68 | } 69 | 70 | @end 71 | 72 | -------------------------------------------------------------------------------- /app/GeoJSONViewController.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #if !defined(__has_feature) || !__has_feature(objc_arc) 17 | #error "This file requires ARC support." 18 | #endif 19 | 20 | #import "GeoJSONViewController.h" 21 | 22 | #import 23 | #import 24 | 25 | static const double kCameraLatitude = 37.4220; 26 | static const double kCameraLongitude = -122.0841; 27 | 28 | @implementation GeoJSONViewController { 29 | GMSMapView *_mapView; 30 | } 31 | 32 | - (void)loadView { 33 | GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:kCameraLatitude 34 | longitude:kCameraLongitude 35 | zoom:1]; 36 | _mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 37 | self.view = _mapView; 38 | } 39 | 40 | - (void)viewDidLoad { 41 | [super viewDidLoad]; 42 | NSString *path = [[NSBundle mainBundle] pathForResource:@"GeoJSON_Sample" ofType:@"geojson"]; 43 | NSString *file = [[NSString alloc] initWithContentsOfFile:path 44 | encoding:NSUTF8StringEncoding 45 | error:nil]; 46 | NSData *data = [file dataUsingEncoding:NSUTF8StringEncoding]; 47 | GMUGeoJSONParser *parser = [[GMUGeoJSONParser alloc] initWithData:data]; 48 | [parser parse]; 49 | GMUGeometryRenderer *renderer = [[GMUGeometryRenderer alloc] initWithMap:_mapView 50 | geometries:parser.features]; 51 | [renderer render]; 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /test/unit/Clustering/GMUWrappingDictionaryKeyTest.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #if !defined(__has_feature) || !__has_feature(objc_arc) 17 | #error "This file requires ARC support." 18 | #endif 19 | 20 | #import 21 | 22 | #import 23 | 24 | #import 25 | 26 | @interface GMUWrappingDictionaryKeyTest : XCTestCase 27 | @end 28 | 29 | @implementation GMUWrappingDictionaryKeyTest 30 | 31 | - (void)testEqualityAndHash { 32 | NSString *object = @"Test object"; 33 | GMUWrappingDictionaryKey *key1 = [[GMUWrappingDictionaryKey alloc] initWithObject:object]; 34 | GMUWrappingDictionaryKey *key2 = [[GMUWrappingDictionaryKey alloc] initWithObject:object]; 35 | 36 | XCTAssertNotEqual(key1, key2); 37 | XCTAssertEqualObjects(key1, key2); 38 | XCTAssertEqual(key1.hash, key2.hash); 39 | } 40 | 41 | - (void)testUnequalityAndHash { 42 | NSString *object1 = @"Test object1"; 43 | GMUWrappingDictionaryKey *key1 = [[GMUWrappingDictionaryKey alloc] initWithObject:object1]; 44 | NSString *object2 = @"Test object2"; 45 | GMUWrappingDictionaryKey *key2 = [[GMUWrappingDictionaryKey alloc] initWithObject:object2]; 46 | 47 | XCTAssertNotEqual(key1, key2); 48 | XCTAssertNotEqualObjects(key1, key2); 49 | XCTAssertNotEqual(key1.hash, key2.hash); 50 | } 51 | 52 | - (void)testCopy { 53 | NSString *object = @"Test object"; 54 | GMUWrappingDictionaryKey *key1 = [[GMUWrappingDictionaryKey alloc] initWithObject:object]; 55 | GMUWrappingDictionaryKey *key2 = [key1 copy]; 56 | 57 | XCTAssertEqualObjects(key1, key2); 58 | XCTAssertEqual(key1.hash, key2.hash); 59 | } 60 | 61 | @end 62 | 63 | -------------------------------------------------------------------------------- /src/Heatmap/GMUGradient.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | NS_ASSUME_NONNULL_BEGIN 19 | 20 | // Represents a mapping of intensity to color. Interpolates between given set intensity and 21 | // color values to produce a full mapping for the range [0, 1]. 22 | @interface GMUGradient : NSObject 23 | 24 | // Number of entries in the generated color map. 25 | @property(nonatomic, readonly) NSUInteger mapSize; 26 | 27 | // The specific colors for the specific intensities specified by startPoints. 28 | @property(nonatomic, readonly) NSArray *colors; 29 | 30 | // The intensities which will be the specific colors specified in colors. 31 | @property(nonatomic, readonly) NSArray *startPoints; 32 | 33 | // Designated initializer. 34 | // 35 | // |colors| and |startPoints| must not be empty, and must have the same number of elements. 36 | // |startPoints| values must be in non-descending order and be float values in the range [0, 1]. 37 | // |mapSize| must be at least two. Using more than 256 * colors.count is unlikely to provide any 38 | // quality improvement. 39 | - (instancetype)initWithColors:(NSArray *)colors 40 | startPoints:(NSArray *)startPoints 41 | colorMapSize:(NSUInteger)mapSize; 42 | 43 | // Generates an array of mapSize colors for the interpolated colors for intensities between 0 and 1 44 | // inclusive. 45 | // If the provided startPoints do not cover the range 0 to 1, lower values interpolate towards 46 | // transparent black and higher values repeat the last provided color. 47 | - (NSArray *)generateColorMap; 48 | 49 | @end 50 | 51 | NS_ASSUME_NONNULL_END 52 | -------------------------------------------------------------------------------- /src/Geometry/Model/GMUGroundOverlay.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | #import 18 | 19 | #import "GMUGeometry.h" 20 | 21 | NS_ASSUME_NONNULL_BEGIN 22 | 23 | /** 24 | * Instances of this class represent a Ground Overlay object. 25 | */ 26 | @interface GMUGroundOverlay : NSObject 27 | 28 | /** 29 | * The North-East corner of the overlay. 30 | */ 31 | @property(nonatomic, readonly) CLLocationCoordinate2D northEast; 32 | 33 | /** 34 | * The South-West corner of the overlay. 35 | */ 36 | @property(nonatomic, readonly) CLLocationCoordinate2D southWest; 37 | 38 | /** 39 | * The Z-Index of the overlay. 40 | */ 41 | @property(nonatomic, readonly) int zIndex; 42 | 43 | /** 44 | * The rotation of the overlay on the map. 45 | */ 46 | @property(nonatomic, readonly) double rotation; 47 | 48 | /** 49 | * The image to be rendered on the overlay. 50 | */ 51 | @property(nonatomic, readonly) NSString *href; 52 | 53 | /** 54 | * Initializes a GMUGroundOverlay object. 55 | * 56 | * @param northEast The North-East corner of the overlay. 57 | * @param southWest The South-West corner of the overlay. 58 | * @param zIndex The Z-Index of the overlay. 59 | * @param rotation The rotation of the overlay. 60 | * @param href The image to be rendered on the overlay. 61 | */ 62 | - (instancetype)initWithCoordinate:(CLLocationCoordinate2D)northEast 63 | southWest:(CLLocationCoordinate2D)southWest 64 | zIndex:(int)zIndex 65 | rotation:(double)rotation 66 | href:(NSString *)href; 67 | 68 | @end 69 | 70 | NS_ASSUME_NONNULL_END 71 | -------------------------------------------------------------------------------- /src/Geometry/GMUKMLParser.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | #import 18 | 19 | #import 20 | 21 | #import "GMUStyleMap.h" 22 | 23 | NS_ASSUME_NONNULL_BEGIN 24 | 25 | @class GMUStyle; 26 | @protocol GMUGeometryContainer; 27 | 28 | /** 29 | * Instances of this class parse KML documents in an event-driven manner. The 30 | * parsed placemarks and styles are stored in NSArray objects which can then be 31 | * passed to a GMUGeometryRenderer to display on a Google Map. 32 | */ 33 | @interface GMUKMLParser : NSObject 34 | 35 | /** 36 | * The placemarks parsed from the KML file. 37 | */ 38 | @property(nonatomic, readonly) NSArray> *placemarks; 39 | 40 | /** 41 | * The styles parsed from the KML file. 42 | */ 43 | @property(nonatomic, readonly) NSArray *styles; 44 | 45 | @property(nonatomic, readonly) NSArray *styleMaps; 46 | 47 | /** 48 | * Parses the stored KML document. 49 | */ 50 | - (void)parse; 51 | 52 | /** 53 | * Initializes a KMLParser with a KML file contained in a URL. 54 | * 55 | * @param url The url containing the KML file. 56 | */ 57 | - (instancetype)initWithURL:(NSURL *)url; 58 | 59 | /** 60 | * Initializes a KMLParser with a KML file contained in a data file. 61 | * 62 | * @param data The data file containing the contents of a KML file. 63 | */ 64 | - (instancetype)initWithData:(NSData *)data; 65 | 66 | /** 67 | * Initializes a KMLParser with a KML file contained in an input stream. 68 | * 69 | * @param stream The stream to use to access the KML file. 70 | */ 71 | - (instancetype)initWithStream:(NSInputStream *)stream; 72 | 73 | @end 74 | 75 | NS_ASSUME_NONNULL_END 76 | -------------------------------------------------------------------------------- /app/MasterViewController.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #if !defined(__has_feature) || !__has_feature(objc_arc) 17 | #error "This file requires ARC support." 18 | #endif 19 | 20 | #import "MasterViewController.h" 21 | 22 | #import "Samples.h" 23 | 24 | @interface MasterViewController () 25 | @end 26 | 27 | @implementation MasterViewController { 28 | NSArray *_demos; 29 | } 30 | 31 | - (void)viewDidLoad { 32 | [super viewDidLoad]; 33 | self.navigationItem.title = @"Demos"; 34 | _demos = [Samples loadDemos]; 35 | } 36 | 37 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 38 | return _demos.count; 39 | } 40 | 41 | - (UITableViewCell *)tableView:(UITableView *)tableView 42 | cellForRowAtIndexPath:(NSIndexPath *)indexPath { 43 | static NSString *cellIdentifier = @"Cell"; 44 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 45 | if (cell == nil) { 46 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle 47 | reuseIdentifier:cellIdentifier]; 48 | [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; 49 | } 50 | 51 | NSDictionary *demo = [_demos objectAtIndex:indexPath.item]; 52 | cell.textLabel.text = demo[@"title"]; 53 | cell.detailTextLabel.text = demo[@"description"]; 54 | 55 | return cell; 56 | } 57 | 58 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 59 | NSDictionary *demo = [_demos objectAtIndex:indexPath.item]; 60 | Class controllerClass = demo[@"controller"]; 61 | UIViewController *controller = [[controllerClass alloc] init]; 62 | [self.navigationController pushViewController:controller animated:YES]; 63 | } 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /src/QuadTree/GQTPointQuadTree.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | #import "GQTBounds.h" 18 | #import "GQTPointQuadTreeItem.h" 19 | 20 | @interface GQTPointQuadTree : NSObject 21 | 22 | /** 23 | * Create a QuadTree with bounds. Please note, this class is not thread safe. 24 | * 25 | * @param bounds The bounds of this PointQuadTree. The tree will only accept items that fall 26 | within the bounds. The bounds are inclusive. 27 | */ 28 | - (id)initWithBounds:(GQTBounds)bounds; 29 | 30 | /** 31 | * Create a QuadTree with the inclusive bounds of (-1,-1) to (1,1). 32 | */ 33 | - (id)init; 34 | 35 | /** 36 | * Insert an item into this PointQuadTree. 37 | * 38 | * @param item The item to insert. Must not be nil. 39 | * @return |NO| if the item is not contained within the bounds of this tree. 40 | * Otherwise adds the item and returns |YES|. 41 | */ 42 | - (BOOL)add:(id)item; 43 | 44 | /** 45 | * Delete an item from this PointQuadTree. 46 | * 47 | * @param item The item to delete. 48 | * @return |NO| if the items was not found in the tree, |YES| otherwise. 49 | */ 50 | - (BOOL)remove:(id)item; 51 | 52 | /** 53 | * Delete all items from this PointQuadTree. 54 | */ 55 | - (void)clear; 56 | 57 | /** 58 | * Retreive all items in this PointQuadTree within a bounding box. 59 | * 60 | * @param bounds The bounds of the search box. 61 | * @return The collection of items within |bounds|, returned as an NSArray 62 | * of id. 63 | */ 64 | - (NSArray *)searchWithBounds:(GQTBounds)bounds; 65 | 66 | /** 67 | * The number of items in this entire tree. 68 | * 69 | * @return The number of items. 70 | */ 71 | - (NSUInteger)count; 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /src/QuadTree/GQTPointQuadTreeChild.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | #import "GQTBounds.h" 18 | #import "GQTPointQuadTreeItem.h" 19 | 20 | /** 21 | * This is an internal class, use |GQTPointQuadTree| instead. 22 | * Please note, this class is not thread safe. 23 | * 24 | * This class represents an internal node of a |GQTPointQuadTree|. 25 | */ 26 | 27 | @interface GQTPointQuadTreeChild : NSObject 28 | 29 | /** 30 | * Insert an item into this PointQuadTreeChild 31 | * 32 | * @param item The item to insert. Must not be nil. 33 | * @param bounds The bounds of this node. 34 | * @param depth The depth of this node. 35 | */ 36 | - (void)add:(id)item 37 | withOwnBounds:(GQTBounds)bounds 38 | atDepth:(NSUInteger)depth; 39 | 40 | /** 41 | * Delete an item from this PointQuadTree. 42 | * 43 | * @param item The item to delete. 44 | * @param bounds The bounds of this node. 45 | * @return |NO| if the items was not found in the tree, |YES| otherwise. 46 | */ 47 | - (BOOL)remove:(id)item withOwnBounds:(GQTBounds)bounds; 48 | 49 | /** 50 | * Retreive all items in this PointQuadTree within a bounding box. 51 | * 52 | * @param searchBounds The bounds of the search box. 53 | * @param ownBounds The bounds of this node. 54 | * @param accumulator The results of the search. 55 | */ 56 | - (void)searchWithBounds:(GQTBounds)searchBounds 57 | withOwnBounds:(GQTBounds)ownBounds 58 | results:(NSMutableArray *)accumulator; 59 | 60 | /** 61 | * Split the contents of this Quad over four child quads. 62 | * @param ownBounds The bounds of this node. 63 | * @param depth The depth of this node. 64 | */ 65 | - (void)splitWithOwnBounds:(GQTBounds)ownBounds atDepth:(NSUInteger)depth; 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /src/Heatmap/GMUHeatmapTileLayer.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | #import "GMUGradient.h" 19 | #import "GMUWeightedLatLng.h" 20 | 21 | NS_ASSUME_NONNULL_BEGIN 22 | 23 | // A tile layer which renders a heat map. 24 | // The heat map uses convolutional smoothing of specific raidus with weighted data points in 25 | // combination with a gradient which maps intensity to colors to dynamically generate tiles. 26 | // Note: tiles are loaded on background threads, but the configuration properties are non-atomic. 27 | // To ensure consistency, the configuration properties are captured when changing the map property. 28 | // In order to change the values of a live layer, the map property must be reset. 29 | // 30 | // Overrides the default value for opacity to be 0.7 and sets the tile size to 512. Changing the 31 | // tile size is not supported. 32 | @interface GMUHeatmapTileLayer : GMSSyncTileLayer 33 | 34 | // Positions and individual intensitites of the data which will be smoothed for display on the 35 | // tiles. 36 | @property(nonatomic, copy) NSArray *weightedData; 37 | 38 | // Radius of smoothing. 39 | // Larger values smooth the data out over a larger area, but also have a greater cost for generating 40 | // tiles. 41 | // It is not recommended to set this to a value greater than 50. 42 | @property(nonatomic) NSUInteger radius; 43 | 44 | // The gradient used to map smoothed intensities to colors in the tiles. 45 | @property(nonatomic) GMUGradient *gradient; 46 | 47 | // The minimum zoom intensity used for normalizing intensities, defaults to 5 48 | @property(nonatomic) NSUInteger minimumZoomIntensity; 49 | 50 | // The maximum zoom intensity used for normalizing intensities, defaults to 10 51 | @property(nonatomic) NSUInteger maximumZoomIntensity; 52 | 53 | @end 54 | 55 | NS_ASSUME_NONNULL_END 56 | -------------------------------------------------------------------------------- /Google-Maps-iOS-Utils.podspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | Pod::Spec.new do |s| 4 | 5 | s.name = "Google-Maps-iOS-Utils" 6 | s.version = "4.2.2" 7 | s.summary = "A utilities library for use with Google Maps SDK for iOS." 8 | s.description = " 9 | This library contains classes that are useful for a wide range of applications 10 | using the Google Maps SDK for iOS. 11 | It is designed to be used with Google Maps SDK for iOS, but it is not 12 | dependent on it. 13 | " 14 | s.homepage = "https://github.com/googlemaps/google-maps-ios-utils" 15 | s.license = { :type => 'Apache 2.0', :file => 'LICENSE' } 16 | s.authors = "Google Inc." 17 | s.platform = :ios, '13.0' 18 | s.source = { :git => "https://github.com/googlemaps/google-maps-ios-utils.git", 19 | :tag => "v#{s.version.to_s}" } 20 | s.requires_arc = true 21 | s.module_name = "GoogleMapsUtils" 22 | s.swift_version = '5.0' 23 | 24 | s.dependency 'GoogleMaps', '~> 7.3' 25 | s.static_framework = true 26 | 27 | s.subspec 'QuadTree' do |sp| 28 | sp.public_header_files = "src/#{sp.base_name}/**/*.h" 29 | sp.source_files = "src/#{sp.base_name}/**/*.{h,m,swift}" 30 | end 31 | 32 | s.subspec 'Clustering' do |sp| 33 | sp.public_header_files = "src/#{sp.base_name}/**/*.h" 34 | sp.source_files = "src/#{sp.base_name}/**/*.{h,m,swift}" 35 | sp.exclude_files = "src/#{sp.base_name}/GMUMarkerClustering.h" 36 | sp.dependency 'Google-Maps-iOS-Utils/QuadTree' 37 | end 38 | 39 | s.subspec 'Geometry' do |sp| 40 | sp.public_header_files = "src/#{sp.base_name}/**/*.h" 41 | sp.source_files = "src/#{sp.base_name}/**/*.{h,m,swift}" 42 | end 43 | 44 | s.subspec 'Heatmap' do |sp| 45 | sp.public_header_files = "src/#{sp.base_name}/**/*.h" 46 | sp.source_files = "src/#{sp.base_name}/**/*.{h,m,swift}" 47 | sp.dependency 'Google-Maps-iOS-Utils/QuadTree' 48 | end 49 | 50 | s.subspec 'GeometryUtils' do |sp| 51 | sp.source_files = "src/#{sp.base_name}/**/*.{h,m,swift}" 52 | end 53 | 54 | s.test_spec 'Tests' do |unit_tests| 55 | unit_tests.source_files = [ 56 | "GoogleMapsUtils/GoogleMapsUtils.h", 57 | "test/common/Model/*.{h,m,swift}", 58 | "test/unit/**/*.{h,m,swift}", 59 | ] 60 | unit_tests.resources = [ 61 | "test/resources/**/*.{geojson,kml}" 62 | ] 63 | unit_tests.pod_target_xcconfig = { 64 | 'SWIFT_OBJC_BRIDGING_HEADER' => "$(PODS_TARGET_SRCROOT)/test/unit/BridgingHeader/UnitTest-Bridging-Header.h" 65 | } 66 | unit_tests.dependency 'OCMock' 67 | end 68 | end 69 | -------------------------------------------------------------------------------- /GoogleMapsUtils.xcodeproj/xcshareddata/xcschemes/GoogleMapsUtils.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 57 | 58 | 59 | 60 | 62 | 63 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/Clustering/View/GMUDefaultClusterIconGenerator.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | #import 18 | 19 | #import "GMUClusterIconGenerator.h" 20 | 21 | NS_ASSUME_NONNULL_BEGIN 22 | 23 | /** 24 | * This class places clusters into range-based buckets of size to avoid having too many distinct 25 | * cluster icons. For example a small cluster of 1 to 9 items will have a icon with a text label 26 | * of 1 to 9. Whereas clusters with a size of 100 to 199 items will be placed in the 100+ bucket 27 | * and have the '100+' icon shown. 28 | * This caches already generated icons for performance reasons. 29 | */ 30 | @interface GMUDefaultClusterIconGenerator : NSObject 31 | 32 | /** 33 | * Initializes the object with default buckets and auto generated background images. 34 | */ 35 | - (instancetype)init; 36 | 37 | /** 38 | * Initializes the object with given |buckets| and auto generated background images. 39 | */ 40 | - (instancetype)initWithBuckets:(NSArray *)buckets; 41 | 42 | /** 43 | * Initializes the class with a list of buckets and the corresponding background images. 44 | * The backgroundImages array should ideally be big enough to hold the cluster label. 45 | * Notes: 46 | * - |buckets| should be strictly increasing. For example: @[@10, @20, @100, @1000]. 47 | * - |buckets| and |backgroundImages| must have equal non zero lengths. 48 | */ 49 | - (instancetype)initWithBuckets:(NSArray *)buckets 50 | backgroundImages:(NSArray *)backgroundImages; 51 | 52 | /** 53 | * Initializes the class with a list of buckets and the corresponding background colors. 54 | * 55 | * Notes: 56 | * - |buckets| should be strictly increasing. For example: @[@10, @20, @100, @1000]. 57 | * - |buckets| and |backgroundColors| must have equal non zero lengths. 58 | */ 59 | - (instancetype)initWithBuckets:(NSArray *)buckets 60 | backgroundColors:(NSArray *)backgroundColors; 61 | 62 | /** 63 | * Generates an icon with the given size. 64 | */ 65 | - (UIImage *)iconForSize:(NSUInteger)size; 66 | 67 | @end 68 | 69 | NS_ASSUME_NONNULL_END 70 | 71 | -------------------------------------------------------------------------------- /src/Geometry/GMUGeometryRenderer.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | #import 19 | 20 | #import "GMUGeometryContainer.h" 21 | #import "GMUStyle.h" 22 | #import "GMUStyleMap.h" 23 | 24 | NS_ASSUME_NONNULL_BEGIN 25 | 26 | /** 27 | * Instances of this class render geometries generated by a GMUKMLParser or 28 | * GMUGeoJSONParser object. These geometries can have specified style information 29 | * applied to them when being rendered. 30 | */ 31 | @interface GMUGeometryRenderer : NSObject 32 | 33 | /** 34 | * Initializes a new renderer. 35 | * 36 | * @param map the Google Map layer to render the geometries onto. 37 | * @param geometries the geometries to be rendered. 38 | */ 39 | - (instancetype)initWithMap:(GMSMapView *)map 40 | geometries:(NSArray> *)geometries; 41 | /** 42 | * Initializes a new renderer. 43 | * 44 | * @param map the Google Map layer to render the geometries onto. 45 | * @param geometries the geometries to be rendered. 46 | * @param styles the styles to be applied to the geometries. 47 | */ 48 | - (instancetype)initWithMap:(GMSMapView *)map 49 | geometries:(NSArray> *)geometries 50 | styles:(NSArray *_Nullable)styles; 51 | /** 52 | * Initializes a new renderer. 53 | * 54 | * @param map the Google Map layer to render the geometries onto. 55 | * @param geometries the geometries to be rendered. 56 | * @param styles the styles to be applied to the geometries. 57 | * @param styleMaps the styleMaps to be applied to the geometries 58 | */ 59 | - (instancetype)initWithMap:(GMSMapView *)map 60 | geometries:(NSArray> *)geometries 61 | styles:(NSArray * _Nullable)styles 62 | styleMaps:(NSArray *_Nullable)styleMaps; 63 | /** 64 | * Renders the geometries onto the Google Map. 65 | */ 66 | - (void)render; 67 | 68 | /** 69 | * Removes the rendered geometries from the Google Map. Markup that was not added by the renderer is 70 | * preserved. 71 | */ 72 | - (void)clear; 73 | 74 | @end 75 | 76 | NS_ASSUME_NONNULL_END 77 | --------------------------------------------------------------------------------