Leaflet Map
Add a map generated with LeafletJS: an open-source JavaScript library for mobile-friendly interactive maps. Map tiles are provided by default through OpenStreetMap, or MapQuest (with an app key). Can be set per map with shortcode attributes or through the dashboard settings.
Maps
Simplemente crea un mapa con:
[leaflet-map]
Busca una dirección con:
[leaflet-map address="chicago"]
¿Conoces la latitud y longitud de una ubicación? Úsalos (y un nivel de zoom) con:
[leaflet-map lat=44.67 lng=-63.61 zoom=5]
Añade un marcador debajo del shortcode de tu mapa, así:
[leaflet-map]
[leaflet-marker]
¿Quieres más? Haz más (y ajusta el mapa para contenerlos a todos):
[leaflet-map fitbounds]
[leaflet-marker address="tokyo"]
[leaflet-marker address="oslo"]
[leaflet-marker address="cairo"]
[leaflet-marker address="toronto"]
Incluso puedes añadir mensajes emergentes (a cualquier forma) con sus nombres:
[leaflet-map fitbounds]
[leaflet-marker address="tokyo"]Tokyo[/leaflet-marker]
[leaflet-marker address="oslo"]Oslo[/leaflet-marker]
...
Añade un enlace a los mensajes emergentes de la misma manera que añadirías cualquier otro enlace con el editor de WordPress.
Otras figuras, GeoJSON y KML
Add a line to the map by adding [leaflet-line]
. You can specify the postions with a list separated by semi-colon ;
or bar |
using lat/lng: [leaflet-line latlngs="41, 29; 44, 18"]
or addresses: [leaflet-line addresses="Istanbul; Sarajevo"]
, or x/y coordinates for image maps.
Add a circle to the map by adding [leaflet-circle]
. You can specify the position using lat
and lng
and the radius in meters using radius
. You can also customize the style using Leaflet’s Path options. Example: [leaflet-circle message="max distance" lng=5.117909610271454 lat=52.097914814706094 radius=17500 color="#0DC143" fillOpacity=0.1]
.
Or you can add a geojson shape via a url (make sure you are allowed to access it if it’s not hosted on your own server): [leaflet-geojson src="https://example.com/path/to.geojson"]
. Add custom popups with field names; try out the default src file and fields like so:
[leaflet-map fitbounds]
[leaflet-geojson]{name}[/leaflet-geojson]
name is a property on that GeoJSON, and it can be accessed with curly brackets and the property name.
Image Maps
Alternatively, you could use a plain image for visitors to zoom and pan around with [leaflet-image src="path/to/image/file.jpg"]
. See screenshots 3 – 5 for help setting that up.
Más
Check out other examples on the Shortcode Helper page in the Leaflet Map admin section.
¡Consulta el código fuente y más detalles en GitHub!