Pronto habrá nuevas opciones para el diseño de mapas disponibles en Google Maps Platform. Esta actualización del diseño de mapas incluye una nueva paleta de colores predeterminada, así como mejoras en la experiencia y la usabilidad del mapa. Todos los diseños de mapa se actualizarán automáticamente en marzo de 2025. Para obtener más información sobre la disponibilidad y cómo habilitar esta actualización antes, consulta
Nuevo diseño de mapa para Google Maps Platform .
Enviar comentarios
Eventos de la capa de componentes
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Selecciona la plataforma:
Android
iOS
JavaScript
Este ejemplo muestra los límites del mapa para
GMSFeatureTypeLocality
e implementa
función delegate que define el diseño del elemento
polígono. El resultado muestra una ventana de alerta de información con los datos del evento.
Importante: Los componentes invisibles no activan eventos de clic. Los polígonos deben tener un
valor alfa mínimo para que se puedan presionar.
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 ];
}
Enviar comentarios
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons , y los ejemplos de código están sujetos a la licencia Apache 2.0 . Para obtener más información, consulta las políticas del sitio de Google Developers . Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2024-08-21 (UTC)
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Falta la información que necesito"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Muy complicado o demasiados pasos"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Desactualizado"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"Problema de traducción"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Problema con las muestras o los códigos"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Otro"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Fácil de comprender"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Resolvió mi problema"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Otro"
}]
¿Quieres brindar más información?
{"lastModified": "\u00daltima actualizaci\u00f3n:\u00a02024-08-21 (UTC)"}
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Falta la información que necesito","missingTheInformationINeed","thumb-down"],["Muy complicado o demasiados pasos","tooComplicatedTooManySteps","thumb-down"],["Desactualizado","outOfDate","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Problema con las muestras o los códigos","samplesCodeIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2024-08-21 (UTC)"]]