Gaya visual peta baru akan segera tersedia di Google Maps Platform. Perubahan pada gaya visual peta ini mencakup palet warna default baru dan peningkatan pada pengalaman dan kegunaan peta. Semua gaya peta akan otomatis diperbarui pada Maret 2025. Untuk mengetahui informasi selengkapnya tentang ketersediaan dan cara ikut menggunakan versi terbaru ini lebih awal, lihat artikel
Gaya peta baru untuk Google Maps Platform .
Kirim masukan
Peristiwa lapisan fitur
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Contoh ini menunjukkan batas peta untuk
GMSFeatureTypeLocality
, dan menerapkan
fungsi delegasikan yang menata gaya klik
poligon. Hasilnya menampilkan jendela peringatan info dengan data peristiwa.
Penting: Fitur yang tidak terlihat tidak memicu peristiwa klik. Poligon harus memiliki
nilai alfa minimal agar dapat diketuk.
Swift
class SampleViewController : UIViewController {
private lazy var mapView : GMSMapView = GMSMapView ( frame : . zero , mapID : GMSMapID ( identifier : "YOUR_MAP_ID" ), camera : GMSCameraPosition ( latitude : 40 , longitude : - 80 , zoom : 12 ))
override func loadView () {
view = mapView
let style = FeatureStyle ( fill : . orange . withAlphaComponent ( 0.5 ), stroke : . orange , strokeWidth : 2 )
mapView . featureLayer ( of : . locality ) . style = { _ in style }
mapView . delegate = self
}
}
extension SampleViewController : GMSMapViewDelegate {
func mapView ( _ mapView : GMSMapView , didTap features : [Feature ], in featureLayer : FeatureLayer<Feature> , atLocation : CLLocationCoordinate2D ) {
let toast = UIAlertController ( title : "Clicked places" , message : ( features . compactMap { ( $ 0 as ? PlaceFeature ) ? . placeID }) . joined ( separator : ", " ), preferredStyle : . alert )
present ( toast , animated : true , completion : nil )
}
}
Objective-C
@interface SampleViewController : UIViewController <GMSMapViewDelegate >
@end
@implementation SampleViewController
- ( void ) loadView {
GMSMapView * mapView = [ GMSMapView mapWithFrame : CGRectZero mapID : [ GMSMapID mapIDWithIdentifier : @"YOUR_MAP_ID" ] camera : [ GMSCameraPosition cameraWithLatitude : 40 longitude : -80 zoom : 12 ]];
mapView . delegete = self ;
GMSFeatureStyle * style = [ GMSFeatureStyle styleWithFillColor : [[ UIColor orangeColor ] colorWithAlphaComponent : 0.5 ] strokeColor : [ UIColor orangeColor ] strokeWidth : 2.0 ];
[ mapView featureLayerOfFeatureType : GMSFeatureTypeLocality ]. style = ^ ( GMSPlaceFeature * feature ) { return style ; };
self . view = mapView ;
}
- ( void ) mapView: ( GMSMapView * ) mapView didTapFeatures: ( NSArray<id<GMSFeature> > * ) features inFeatureLayer: ( GMSFeatureLayer * ) featureLayer atLocation: ( CLLocationCoordinate2D ) location {
NSMutableArray<NSString *> * places = [ NSMutableArray array ];
for ( id<GMSFeature> feature in features ) {
if ( ! [ feature isKindOfClass : [ GMSPlaceFeature class ]]) { continue ; }
NSString * placeID = (( GMSPlaceFeature * ) feature ). placeID ;
[ places addObject : placeID ];
}
UIAlertController * toast = [ UIAlertController alertControllerWithTitle : @"Clicked places" message : [ places componentsJoinedByString : @", " ] preferredStyle : UIAlertControllerStyleAlert ];
[ self presentViewController : toast animated : YES completion : nil ];
}
Kirim masukan
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0 , sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0 . Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers . Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2024-08-21 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Informasi yang saya butuhkan tidak ada"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Terlalu rumit/langkahnya terlalu banyak"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Sudah usang"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"Masalah terjemahan"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Masalah kode / contoh"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Lainnya"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Mudah dipahami"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Memecahkan masalah saya"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Lainnya"
}]
Ada masukan untuk kami?
{"lastModified": "Terakhir diperbarui pada 2024-08-21 UTC."}
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2024-08-21 UTC."]]