| 开发者 | jamesb7 |
|---|---|
| 更新时间 | 2026年12月4日 01:37 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
[waymorphic_map lat="51.5074" lng="-0.1276" zoom="11" label="London"]
A map from an address:
[waymorphic_map address="10 Downing Street, London" zoom="16" style="bright"]
A map with many markers. Without lat and lng, the view fits the markers:
[waymorphic_map height="500"] [waymorphic_marker lat="48.8584" lng="2.2945"]<strong>Eiffel Tower</strong>[/waymorphic_marker] [waymorphic_marker lat="48.8606" lng="2.3376" open="true"]The Louvre[/waymorphic_marker] [waymorphic_marker address="Cathédrale Notre-Dame de Paris"]Notre-Dame[/waymorphic_marker] [/waymorphic_map]
Attributes of [waymorphic_map]:
lat, lng - the centre of the map. lon and long are other names for lng.address - an address or place name, used when lat and lng are not given. A marker shows the place.zoom - 0 (the world) to 22. The default is in the settings. When the view fits two or more markers, zoom is the upper limit of the view (15 when it is not given).style - positron, bright, liberty, dark or fiord.height - a CSS length such as 400px or 60vh. A number is in pixels. A percentage is not a height.width - a CSS length such as 300px or 50%. A number is in pixels.height and width are px, vh, vw, dvh, svh, lvh, dvw, svw, lvw, vmin, vmax, em, rem and ch (and % for the width). Other values, such as calc(), give the default.marker - true puts a marker at the centre.label - popup text for the marker at the centre.controls - false hides the zoom and fullscreen buttons.scroll_zoom - true lets plain scroll zoom the map. Without it, ctrl or cmd + scroll zooms the map, and on a touch screen two fingers move the map (one finger scrolls the page).interactive - false makes a still map.title - the name of the map for screen readers.popup_title - false: the popup of a marker does not start with the title of the marker.cluster - true puts markers that are near to each other in a group.list - true shows the list of the markers below the map.locator - true shows the search for the nearest markers above the map.radius - the first distance of the search. The default is 25.unit - km or mi, for the search and the list.filter - true shows a button for each marker category.directions - true adds a directions link to the popups and the list. The link opens the map service of the settings. Or give the service: google, apple, waze or osm. Or choice: the visitor selects the service from a list.locate - true shows the button that goes to the position of the visitor.animation - drop or bounce, for all the markers.colour - the colour of the marker at the centre, such as #d63638.[waymorphic_marker]: lat and lng, or address; open="true" shows the popup when the page opens. The text between the tags is the popup. Optional: title (the name in the list and the first line of the popup), category, colour (such as #d63638), icon (the URL of a picture to use as the marker) and animation (drop or bounce). A marker with no popup text can have a slash at the end and no closing tag: [waymorphic_marker lat="51.5" lng="-0.12" /].
Use straight quotes (") in the shortcodes. A user who can edit the page sees a message below the map when an address was not found, when a position is not valid, or when the search found an address very far from the places of the map that have a lat and a lng (the map must have two such places, or a centre with a lat and a lng). Visitors do not see this message. The search gives the place that it knows best: write the town in an address, and the area or the full name of the country when other towns have the same name (address="Buckingham Palace, London", address="Boston, Lincolnshire"). Write United Kingdom and United States, not UK and USA. In a very large country, a correct town can be that far: with the full name of its area or of its country in the address (address="Perth, Western Australia"), it gets no message.
Shapes
Put the shape shortcodes in [waymorphic_map]. The points are latitude,longitude pairs with ; between them. The text between the tags is the popup of the shape.
[waymorphic_map] [waymorphic_polygon points="51.50,-0.20; 51.55,-0.12; 51.50,-0.05" colour="#008a20"]The area we deliver to[/waymorphic_polygon] [waymorphic_line points="51.50,-0.20; 51.52,-0.10; 51.51,0.00" colour="#d63638" width="4"] [waymorphic_circle lat="51.5074" lng="-0.1276" radius="500"] [waymorphic_rectangle points="51.48,-0.20; 51.49,-0.15"] [/waymorphic_map]
[waymorphic_polygon] - three or more points, 500 at most.[waymorphic_line] - two or more points, 500 at most.[waymorphic_circle] - lat and lng, or address, and radius in metres.[waymorphic_rectangle] - two opposite corners.colour (the outline), width (the outline, in pixels). Polygons, circles and rectangles: fill (the colour of the inside) and opacity (0 to 1).[waymorphic_heatmap] - points, 5000 at most. A point can have a weight as a third number: 51.5,-0.12,3. Optional: radius in pixels (the default is 30) and opacity (0 to 1).[waymorphic_map cluster="true" list="true"] [waymorphic_file url="https://example.com/wp-content/uploads/shops.csv" category="Shops" colour="#008a20"] [waymorphic_file url="https://example.com/wp-content/uploads/walk.gpx"] [/waymorphic_map]
[waymorphic_file] shows the markers, lines and areas of a CSV, GeoJSON, KML or GPX file. The browser of the visitor gets the file each time the page opens, so a change to the file shows on the map. Ten files for each map at most.
lat (or latitude), lng (or lon, longitude), and the optional title (or name), description, category, colour and icon. A position is a number: 51.5074, 51,5074, or 0.1276 W. A row whose position has other text does not show.colour and category on the shortcode are for the markers that have none in the file.cluster="true". The map draws only the markers that are not in a group, and stays quick.[waymorphic_map locator="true" list="true" filter="true" directions="true" unit="mi" radius="10"] [waymorphic_marker address="10 Downing Street, London" title="London shop" category="Shops"]Open 9 to 5[/waymorphic_marker] [waymorphic_marker lat="53.4808" lng="-2.2426" title="Manchester depot" category="Depots"] [/waymorphic_map]
External service
This plugin shows maps from the Waymorphic Map tile server, https://tiles.waymorphic.com. The author of this plugin operates this server.
address in a shortcode, your WordPress site sends that address to the search of the server and keeps the position for one year. If the search does not find the address, the site asks again after one day. If the search does not answer, the site asks again after five minutes.locator), the browser of the visitor sends the search text to the server, with the centre of the markers of the map: the server prefers places near the markers. With "Use my location", the position stays in the browser.directions) is a link to the map service that you select in the settings, on the shortcode or in the block:
https://www.google.com/maps/dir/ (privacy policy)https://maps.apple.com/ (privacy policy)https://www.waze.com/ul (privacy policy)https://www.openstreetmap.org/directions (privacy policy)waymorphic_map_directions_services filter changes the list of the services.
The terms of use of the service are its fair use rules. The same rules have the privacy statement of the service ("No tracking"): the server has no accounts, no cookies and no analytics, and it keeps the usual access logs for a short time to operate the service. The service is free and best effort: there is no uptime guarantee. If you run your own Waymorphic Map server, you can set its URL in Settings > Waymorphic Map.
Map data © OpenStreetMap contributors, with the OpenMapTiles schema. The credit in the corner of each map is a licence requirement. Do not remove it.
[waymorphic_map address="10 Downing Street, London" zoom="16"].list="true", locator="true", filter="true" and directions="true".No. There is no account, no key and no quota.
Yes. Keep the credit on the map and use the service as a map. Bulk downloads of tiles are not permitted.
Select one of the five styles for each map, or set the default style in the settings.
This prevents the map from catching the scroll of the page. Hold ctrl (or cmd on a Mac) and scroll, or use the buttons. To change this, set "Scroll to zoom" on the block, or scroll_zoom="true" on the shortcode.
Yes. Set locator="true" and list="true" on the shortcode, or the same options in the "Features" panel of the block. Visitors type an address and see the nearest markers with their distances.
You select it: Google Maps, Apple Maps, Waze or OpenStreetMap. Set the service for all maps in Settings > Waymorphic Map, or for one map with directions="google" on the shortcode or in the "Features" panel of the block. With directions="choice", the visitor sees the list of the services and selects one.
Yes. These parts keep their look in each theme: the usual CSS rules of a theme or of the site do not change them. To change them, set CSS variables in Appearance > Customize > Additional CSS, for example:
.wp-block-waymorphic-map { --waymorphic-map-accent: #b32d2e; --waymorphic-map-radius: 0; --waymorphic-map-list-height: 480px; }
The variables are --waymorphic-map-accent, --waymorphic-map-accent-text, --waymorphic-map-text, --waymorphic-map-muted, --waymorphic-map-surface, --waymorphic-map-border, --waymorphic-map-line, --waymorphic-map-radius, --waymorphic-map-font-size, --waymorphic-map-list-height, --waymorphic-map-scheme (light or dark: the parts that the browser draws, such as the scroll bar of the list, for a dark --waymorphic-map-surface), --waymorphic-map-popup-accent (the colour of the links in a popup; a popup is white on each site, so set this colour when the accent colour is light) and --waymorphic-map-scroll-space (the space above the map after a click on a row of the list, for a header that stays at the top of the window). For a change that the variables do not make, write !important in your CSS rule.
Yes. Open the "Shapes" panel, select a type and click the map. For a heatmap, use the shortcode.
Yes, as a line. Import a GPX or KML file of the route, or draw a line. The plugin does not calculate a route between two addresses: the directions link opens a map service (Google Maps, Apple Maps, Waze or OpenStreetMap) for that.
Export the markers as a CSV file, make sure that the first row has lat and lng columns, then use "Import a file" in the block.
Yes. The waymorphic_map_config filter changes the configuration of a map, waymorphic_map_tiles_url changes the tile server, and waymorphic_map_directions_services changes the map services of the directions link. The address that the waymorphic_map_directions_url filter gives must start with http or https. A map element that you write by hand (not with the block or the shortcode) starts only with a style from the tile server of the site: the waymorphic_map_trusted_addresses filter adds other addresses. A classic theme that makes a map in a template (with waymorphic_map_render() or do_shortcode()) must call wp_enqueue_style( 'waymorphic-map' ) in a function on wp_enqueue_scripts: without this, the styles of the map load after the map. In JavaScript, each map element has its MapLibre map in the waymorphicMap property.
Send an email to contact@waymorphic.com.
$template global variable of WordPress. To know if a block template made a page, it uses the wp_is_block_theme() and did_filter() functions of WordPress. The styles of a map load as before.function_exists() test. The first active copy loads these functions, and all the copies use them.waymorphic-map. The block, the shortcodes, the settings and the maps do not change.wp-free-maps or free-maps-waymorphic-map). Then empty your page cache. The settings and the maps stay. If you delete the older version before you activate this version, the settings go back to the defaults (the maps stay).directions="google", or the "Features" panel of the block).!important in your rules.lat and a lng ("Brighton Pier, Brighton" in New Zealand on a map of shops in England).gx:Track), and KML positions with spaces.lon and long are accepted for lng, and a decimal comma is accepted in lat and lng.animation on the map shortcode is for the markers of files too. The result text of the search shows the distance that the visitor selected ("12.5 km", not "13 km").dvh, svh, lvh, dvw, svw, lvw, vmin, vmax and ch for the height and the width.waymorphic-map:ready event when its map is ready. WaymorphicMap.addShapes() adds shapes to a map that has shapes.free-maps-waymorphic-map in this version. Version 1.1.0 had the name wp-free-maps. Version 1.2.1 changed the name again: see its entry for the upgrade steps.title now starts with the title, if the first line of the popup text does not have it. A marker with a title and no popup text now has a popup with its title. Set popup_title="false" on the map shortcode to turn this off.[waymorphic_polygon], [waymorphic_line], [waymorphic_circle] and [waymorphic_rectangle] shortcodes. In the block, draw them on the map.[waymorphic_file] shortcode.[waymorphic_heatmap] shortcode.