| 开发者 | mapsemble |
|---|---|
| 更新时间 | 2026年10月23日 21:08 |
| PHP版本: | 8.0 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPL-2.0-or-later |
| 版权网址: | 版权信息 |
[mapsemble map="…"] shortcode, or the mapsemble_embed() template function. No setup on this site is needed: the block lists your account's maps, a typed id works for any public map, and [mapsemble map="sample"] renders a real, fully populated sample map before you have entered any credentials at all. Your account's maps are listed under Mapsemble → Maps, where locations for maps hosted on Mapsemble are edited in the Mapsemble location editor, which opens from your admin in a new tab with the map beside it — this works on a local development site too.
Or build a map from this site's content
Add a map under Mapsemble → Built from this site to make a post type the map's data: give posts a location and Mapsemble fetches them from a public endpoint on your site, with the cards rendered from your own templates. Always-on filters, visitor filter mappings, sort options and marker style properties shape the feed per map. This is the advanced option: it needs a publicly reachable site, and the Pro plan on the Mapsemble side — nothing is blocked before then; visitors see an upgrade notice over the map until the account is upgraded.
Editing follows the data: maps hosted on Mapsemble are edited in the Mapsemble editor (opened from Mapsemble → Maps in your admin); maps built from this site are edited by editing the posts themselves.
Shaping a site-fed map
A map built from this site does not have to serve the whole post type:
map takes a Mapsemble map id (or sample); id takes a site-fed map's WordPress id, shown ready to copy on the Built from this site list:
[mapsemble map="0198…" height="60vh" scroll_capture="mobile"] or [mapsemble id="123"]mapsemble_embed( '0198…' ) / the_mapsemble_embed( 'sample' ) for any map by id, or mapsemble_map( 123 ) / the_mapsemble_map( 123 ) for a map built from this site.height and the two offsets take a CSS length (50vh, 480px, 2rem). scroll_capture is none or mobile, and turns the map into a sticky section: scroll gestures over it move the card list instead of the page. While scroll capture is on, the map sticks at the top offset — that is how you clear a fixed site header. While the map fills the visible screen, both offsets are also taken off its height, leaving room above and below it — as long as the minimum height leaves that room. Leave any of them out and the map keeps its own default.
Two more attributes shape the embed:
fill_viewport="false" stops the map from growing to the visible viewport. Normally height is a minimum: the map is at least that tall and grows to fill the visible screen. With fill_viewport="false" it is the exact height — height="300px" makes a 300px map.filters seeds the map's filters on load, as a JSON object of filter slug to value. Quote it with single quotes so the editor does not mangle the JSON: [mapsemble id="123" filters='{"category":"parks"}']. An unreadable value is ignored. In the block, both live in the sidebar; in mapsemble_map(), pass filters as a native array.[mapsemble id="123" height="60vh"].From your Mapsemble account. Styling, clustering, filters and layout are configured in the Mapsemble map builder. This plugin decides only where the locations come from, and renders the content cards when they come from this site.
Editors, by default. Maintaining locations is content work, so it has its own capability (edit_mapsemble_map_data) that the administrative ones deliberately do not imply — the person adding locations does not need the screen holding your API credentials. Administrators hold both.
Yes. Copy templates/card.php from the plugin into your theme as mapsemble/card.php and adjust it. Developers can also use the mapsemble_card_html, mapsemble_card_css_urls and mapsemble_card_data filters.
Yes. Choose the "Custom fields (latitude/longitude meta keys)" location source and name the two meta keys — that covers Metabox.io, Pods, imported data and hand-rolled meta. An ACF Google Map field has its own named source. For computed cases, the mapsemble_post_coordinates filter remains. After switching sources, run "Reindex locations" on the map.
Yes. The widget's interface strings ("Filters", "Search", "Sort by", …) run through the plugin's mapsemble text domain, so a .po file for your language translates them; English sites send nothing extra. Developers can add or override strings with the mapsemble_widget_translations filter.
A map whose locations live in Mapsemble works on a local site with no extra setup: nothing on the Mapsemble side ever fetches from your server.
A map built from this site's content does not, because the Mapsemble service has to reach your feed. Expose the site through a tunnel and define MAPSEMBLE_REMOTE_BASE_URL in wp-config.php; the plugin then hands Mapsemble that address instead of your local one.
Two more constants exist for people running the Mapsemble service itself locally. MAPSEMBLE_APP_BASE points the plugin at another Mapsemble host; TLS is still verified against it. MAPSEMBLE_SSL_VERIFY set to false switches that verification off — define it only for a local stack whose certificate the WordPress container does not trust, never on a public site.
The sample map is the exception: it always loads from app.mapsemble.com whatever MAPSEMBLE_APP_BASE says. A stack that publishes its own copy can point it elsewhere with the mapsemble_sample_app_base filter.
Yes — define MAPSEMBLE_CLIENT_ID and MAPSEMBLE_CLIENT_SECRET in wp-config.php and the settings fields become read-only. One caveat: credentials set that way never pass through the settings form, which is what normally clears the cached access token and plan details. After changing them, delete the mapsemble_token, mapsemble_token_failed, mapsemble_remote_maps, mapsemble_feature_flags and mapsemble_backoff transients — from code, \Mapsemble\Api\Client::forget_account_caches() drops exactly that set, as the settings form and the connect flow do — or the plugin keeps answering for the previous account for up to fifteen minutes.
The feed is a standard WordPress meta query and is comfortable up to roughly ten thousand geo-tagged posts. Beyond that, use a persistent object cache. The entropy sort option additionally needs MySQL 8 or MariaDB 10.2 for its window function; on older databases it degrades to a stable per-map random order. The filter option pickers group over meta values, capped at ten options per lookup.
For site-fed maps only: mapsemble/v1/features (the GeoJSON feed), mapsemble/v1/feature (one rendered card) and mapsemble/v1/filter/options (values for a mapped filter). All serve published, geo-tagged content that the map's own conditions admit — a post excluded by an always-on filter answers 404 exactly like a missing one. Maps whose locations live in Mapsemble answer 404 on all three. Responses carry Cache-Control: public, max-age=60 and an ETag; the cache is refreshed when a served post, its terms, or the map's settings change, and developers can tune or disable it with the mapsemble_feed_cache_ttl filter.
The editor shows a chosen map live in a frame served by this site to a request that carries no login cookie — the block editor isolates itself in Chromium browsers, and the frame's request goes out without cookies. Anything that turns such requests away before WordPress parses them keeps the preview out: a maintenance or "members only" plugin that redirects logged-out visitors on init, or HTTP basic auth in front of a staging site. The published page is unaffected; the map still renders there.
height is the map's exact height, on existing blocks too; with it on, the sidebar calls it "Minimum height".MAPSEMBLE_CLIENT_ID defined in wp-config.php, saving the settings no longer wipes the stored client ID; a save that only changes the uninstall choice keeps the cached token and map list.0 no longer drops out and lets the map serve every post.mapsemble/v1/geocode and mapsemble/v1/map-filters, for users who can edit posts; the loadErrorText widget setting is gone.019c09be-4113-7222-95d8-c616d8d7efc1) and always loads from app.mapsemble.com, even when MAPSEMBLE_APP_BASE points elsewhere. A block or shortcode using sample picks the new map up on the next render.MAPSEMBLE_APP_BASE. Local stacks whose certificate the container does not trust must now define MAPSEMBLE_SSL_VERIFY as false — a DDEV site that relied on the old implicit behaviour will fail to connect until it does.Cache-Control and an ETag (a browser revalidating gets a bodiless 304). Saving, trashing or deleting a served post, changing one of its terms, or saving the map configuration refreshes it; logged-in requests bypass it.Retry-After says (at most five minutes) before asking again, instead of retrying on every admin screen.mapsemble_map_config_saved action (MapConfig $config, string $previous_map_id) fires after a configuration's meta is written; mapsemble_feed_cache_ttl filter tunes or disables the feed cache; mapsemble_sample_app_base filter for a self-hosted Mapsemble that publishes its own copy of the sample; MAPSEMBLE_SSL_VERIFY constant; Client::forget_account_caches() drops every account-derived transient; CI fails when the version is stated inconsistently.[mapsemble map="…"], and mapsemble_embed(). A map id bound to a site-fed configuration automatically serves from this site.[mapsemble map="sample"] — that renders before any credentials are entered.mapsemble_widget_settings filter's second argument is now MapConfig|null — null for embeds of maps this site has no configuration for. Type-hinted callbacks need widening.mapsemble/v1/filter/options endpoint — the map's filter widgets now narrow the served posts.fill_viewport and filters options on the block, shortcode and template functions.