Con le nuove Api di Google Maps è semplice integrare una mappa statica
Per chi non conoscesse il servizio, è bene fare un passo indietro. Le Google Maps Static esistono da molto tempo, diciamo 2 anni. Permettono, come nel caso di un embed di una mappa dinamica, di integrare all’interno del sito web mappe con marker, gestioen livello di zoom e tutto il resto.
La funzione static è usata sopratutto all’interno di social network e client social. Viene usata per esempio su twitter per mostrare la geolocalizzazione di un utente. In fondo che bisogno c’è di scomodare una mappa “dinamica” quando la posizione è ben “ancorata”.
Come detto, la funzione static Maps è presente da molto tempo, ed adesso, con l’arrivo della V3 delle Api Google Maps permette di essere ancora più fruibile. Molti infatti sono i parametri non più necessari. E cosa non da poco, non necessitano più di una Maps API key.
Per generare una immagine come quella in alto il codice è davvero semplice
<img src=”http://maps.google.com/maps/api/staticmap?center=Firenze,IT&zoom=8&size=512×512&maptype=roadmap&sensor=false&markers=Firenze,IT” alt=”Mappa statica di Firenze, Italia” />
I valori necessari, se non si crea un marker come si vede dal semplice codice in alto sono “center”, che può essere passato sia come coordinata geografica (es. “40.714728,-73.998672) che come nome località e zoom.
Ecco la lista completa
- size (required) defines the rectangular dimensions of the map image. This parameter takes a string of the form valuexvalue where horizontal pixels are denoted first while vertical pixels are denoted second. For example, 500×400 defines a map 500 pixels wide by 400 pixels high. If you create a static map that is 100 pixels wide or smaller, the “Powered by Google” logo is automatically reduced in size.
- format (optional) defines the format of the resulting image. By default, the Static Maps API creates PNG images. There are several possible formats including GIF, JPEG and PNG types. Which format you use depends on how you intend to present the image. JPEG typically provides greater compression, while GIF and PNG provide greater detail. For more information, see Image Formats.
- maptype (optional) defines the type of map to construct. There are several possible maptype values, including roadmap, satellite, hybrid, and terrain. For more information, see Static Maps API Maptypes below.
- mobile (optional) specifies whether the map will be displayed on a mobile device. Valid values are true or false. Maps displayed on mobile devices may use different tilesets optimized for those devices. For more information, see Mobile Maps below.
- language (optional) defines the language to use for display of labels on map tiles. Note that this parameter is only supported for some country tiles; if the specific language requested is not supported for the tile set, then the default language for that tileset will be used.
Feature Parameters:
- markers (optional) define one or more markers to attach to the image at specified locations. This parameter takes a single marker definition with parameters separated by the pipe character (|). Multiple markers may be placed within the same markers parameter as long as they exhibit the same style; you may add additional markers of differing styles by adding additional markers parameters. Note that if you supply markers for a map, you do not need to specify the (normally required) center and zoom parameters. For more information, see Static Map Markers below.
- path (optional) defines a single path of two or more connected points to overlay on the image at specified locations. This parameter takes a string of point definitions separated by the pipe character (|). You may supply additional paths by adding additional path parameters. Note that if you supply a path for a map, you do not need to specify the (normally required) center and zoom parameters. For more information, see Static Map Paths below.
- visible (optional) specifies one or more locations that should remain visible on the map, though no markers or other indicators will be displayed. Use this parameter to ensure that certain features or map locations are shown on the static map.
Tutte le specifiche sono qui.
Se l'articolo ti è piaciuto, potresti approfondire leggendo anche:
- Dal satellite,nuove immagini di Haiti rilasciate su Google Maps
- Mappa delle vacanze con foto grazie ad Holiday Maps
Articolo scritto da Massimiliano
Mancini. Mi occupo di Web Marketing, divulgazione, posizionamento sui
motori di ricerca e molto altro. Vuoi sapere qualcosa su di me? Clicca
qui.
Twitti?
Allora seguimi!
Condividi l'articolo su Twitter o su Facebook Condividi
Ti è piaciuto questo articolo? Perché non lasci un commento e continui la discussione, oppure iscriviti ai feed e riceverai gli articoli sul tuo feed reader. Oppure Condividi su Facebook, Twitter, Email ecc..



Commenti
Ancora nessun commento.
Pubblica commento