Em breve, a Plataforma Google Maps usará a nova estilização de mapas. Essa atualização inclui uma nova paleta de cores padrão e melhorias nas experiências de mapa e na usabilidade. Todos os estilos de mapa serão atualizados automaticamente em março de 2025. Para mais informações sobre a disponibilidade e como ativar logo, consulte
Novo estilo de mapa para a Plataforma Google Maps .
Envie comentários
Eventos da camada de elementos
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Selecione a plataforma:
Android
iOS
JavaScript
Este exemplo mostra limites do mapa para
GMSFeatureTypeLocality
e implementa o
função delegate que define o estilo do
polígono. O resultado mostra uma janela de alerta de informações com os dados do evento.
Importante :os recursos invisíveis não acionam eventos de clique. Os polígonos devem ter um
um valor Alfa mínimo para que sejam tocáveis.
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 ];
}
Envie comentários
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons , e as amostras de código são licenciadas de acordo com a Licença Apache 2.0 . Para mais detalhes, consulte as políticas do site do Google Developers . Java é uma marca registrada da Oracle e/ou afiliadas.
Última atualização 2024-08-21 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Não contém as informações de que eu preciso"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Muito complicado / etapas demais"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Desatualizado"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"Problema na tradução"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Problema com as amostras / o código"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Outro"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Fácil de entender"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Meu problema foi resolvido"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Outro"
}]
Quer enviar seu feedback?
{"lastModified": "\u00daltima atualiza\u00e7\u00e3o 2024-08-21 UTC."}
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2024-08-21 UTC."]]