Skip to content

Instantly share code, notes, and snippets.

@koogawa
Last active April 5, 2018 14:15
Show Gist options
  • Save koogawa/5071555 to your computer and use it in GitHub Desktop.
Save koogawa/5071555 to your computer and use it in GitHub Desktop.
Google Maps SDK for iOS の使い方(Swift 4対応) ref: https://qiita.com/koogawa/items/adc2dd19015586bda39b
source 'https://github.com/CocoaPods/Specs.git'
target 'YOUR_APPLICATION_TARGET_NAME_HERE' do
pod 'GoogleMaps'
pod 'GooglePlaces'
end
mapView_.mapType = kGMSTypeSatellite;
import GoogleMaps
GMSMarkerOptions *markerOptions = [[GMSMarkerOptions alloc] init];
markerOptions.position = CLLocationCoordinate2DMake(35.6662026, 139.7312591);
markerOptions.title = @"東京ミッドタウン";
markerOptions.snippet = @"東京都港区赤坂9−7−1";
[self.mapView addMarkerWithOptions:markerOptions];
mapView_.mapType = kGMSTypeSatellite;
let marker = GMSMarker()
marker.position = CLLocationCoordinate2D(latitude: -33.86, longitude: 151.20)
marker.title = "Sydney"
marker.snippet = "Australia"
marker.map = mapView
GMSMarkerOptions *markerOptions = [[GMSMarkerOptions alloc] init];
markerOptions.position = CLLocationCoordinate2DMake(-33.86, 151.20);
markerOptions.title = @"Sydney";
markerOptions.snippet = @"Australia";
markerOptions.map = mapView;
func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(id<GMSMarker>)marker;
func mapView(_ mapView: GMSMapView, didTapInfoWindowOf marker: GMSMarker) {
- (void)mapView:(GMSMapView *)mapView
didTapInfoWindowOfMarker:(id<GMSMarker>)marker;
let path = GMSMutablePath()
path.add(CLLocationCoordinate2D(latitude:37.36, longitude: -122.0))
path.add(CLLocationCoordinate2D(latitude:37.45, longitude: -122.0))
path.add(CLLocationCoordinate2D(latitude:37.45, longitude: -122.2))
path.add(CLLocationCoordinate2D(latitude:37.36, longitude: -122.2))
path.add(CLLocationCoordinate2D(latitude:37.36, longitude: -122.0))
let rectangle = GMSPolyline(path: path)
rectangle.map = mapView
GMSMutablePath *path = [GMSMutablePath path];
[path addCoordinate:CLLocationCoordinate2DMake(37.36, -122.0)];
[path addCoordinate:CLLocationCoordinate2DMake(37.45, -122.0)];
[path addCoordinate:CLLocationCoordinate2DMake(37.45, -122.2)];
[path addCoordinate:CLLocationCoordinate2DMake(37.36, -122.2)];
[path addCoordinate:CLLocationCoordinate2DMake(37.36, -122.0)];
GMSPolyline *rectangle = [GMSPolyline polylineWithPath:path];
rectangle.map = mapView;
@import GoogleMaps;
- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(id<GMSMarker>)marker;
GMSServices.provideAPIKey("YOUR_API_KEY")
- (void)mapView:(GMSMapView *)mapView
didTapInfoWindowOfMarker:(id<GMSMarker>)marker;
[GMSServices provideAPIKey:@"YOUR_API_KEY"];
GMSPolylineOptions *rectangle = [GMSPolylineOptions options];
GMSMutablePath *path = [GMSMutablePath path];
[path addCoordinate:CLLocationCoordinate2DMake(35.6662026, 139.7312591)];
[path addCoordinate:CLLocationCoordinate2DMake(35.6762026, 139.7312591)];
[path addCoordinate:CLLocationCoordinate2DMake(35.6762026, 139.7412591)];
[path addCoordinate:CLLocationCoordinate2DMake(35.6662026, 139.7412591)];
[path addCoordinate:CLLocationCoordinate2DMake(35.6662026, 139.7312591)];
rectangle.path = path;
[self.mapView addPolylineWithOptions:rectangle];
let camera = GMSCameraPosition.camera(withLatitude: -33.86, longitude: 151.20, zoom: 6.0)
let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
view = mapView
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
self.view = mapView;
mapView.isMyLocationEnabled = true
mapView.myLocationEnabled = YES;
mapView.mapType = .satellite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment