开发者 | gsarig |
---|---|
更新时间 | 2024年5月27日 06:11 |
捐献地址: | 去捐款 |
PHP版本: | 7.4 及以上 |
WordPress版本: | 6.5 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
[ootb_query]
as an alternative way to use the aforementioned Query Maps feature (see the FAQ for more info).No. That's the point, actually. Just install the plugin and start adding maps. Keep in mind, though, that as stated on the OpenStreetMap Tile Usage Policy, OSM’s own servers are run entirely on donated resources and they have strictly limited capacity. Using them on a site with low traffic will probably be fine. Nevertheless, you are advised to create an account to MapBox and get a free API Key.
You can find the style URL on Mapbox Studio. There, use the "Share" button, and under "Developer resources", copy the "Style URL". It should look like that: mapbox://styles/username/style-id
. You can declare a global style on the plugin's settings, to be used as a default for all the maps, or you can set a custom style for each map, by using the block's settings panel.
To add a location, left-click on the map for a while, until you see the prompt saying "Release to drop a marker here". On browsers that support it, the cursor transforms from hand to crosshair, to make it even more apparent. As long as the prompt is visible, it means that releasing the click will drop the marker at that spot. That slight delay has been added to prevent you from accidentally adding markers all over the place with every click. Alternatively, you can use the map's place search functionality.
Click on the marker to open up its popup. There, you will see the "Remove" button.
Check under the "Map behavior" section, at the blocks' settings at the sidebar on the right. It's toggled off by default, that's probably why you missed it.
First of all, you will need to create an account to OpenAI and get an API key. Then, go to the plugin's settings page and paste your key there. After that, you can start adding markers by using commands in natural language. Just say "please" to activate (e.g. "Please, show me where GOT was filmed"). Please keep in mind, though, that it's like asking ChatGPT: the answers you get might not always be 100% reliable, and you should always double-check to confirm their accuracy. Read more.
On the block's side panel, Select the "Map data" panel and click on the "Fetch locations" button. This will automatically retrieve on the frontend all the markers from your posts (you can also select a specific post type from the dropdown). The block will be locked from editing, as the markers will be dynamically retrieved from the selected posts. If you don't want that, there is a "Stop syncing" button that will unlock the block, drop the markers on the map and allow you to edit.
The shortcode [ootb_query]
allows you to display a dynamic map, which retrieves markers from other posts or post types. Just add it to a post or page and you're good to go. By default, it will fetch the markers from the 100 most recent posts. The shortcode supports the following attributes:
geodata
, if you want to retrieve the posts based on their Location custom meta field, or block
, to retrieve posts containing map blocks in their content. The default option, which will be used if the attribute is omitted, is block
.post
.100
.400px
.openstreetmap
, mapbox
and stamen
. The default value is an empty string which falls back to openstreetmap
.markers
, polygon
and polyline
. The default value is an empty string, which will fall back to markers
.true
or false
. The default value is an empty string, which falls back to true
.true
or false
. The default value is an empty string, which falls back to true
.true
or false
. The default value is an empty string, which falls back to true
.true
or false
. The default value is an empty string, which falls back to true
.https://www.example.com/my-custom-icon.png
). The default value is an empty string, which retrieves the default marker.
Here's an example of how you can use it:[ootb_query post_type="post" post_ids="1,2,3,4" height="400px" provider="mapbox" maptype="polygon" touchzoom="true" scrollwheelzoom="true" dragging="true" doubleclickzoom="true" marker="https://www.example.com/my-custom-icon.png"]
Glad you asked! There are a few hooks that you can use to further customize the plugin's behavior. Here they are:
ootb_query_post_type
: Allows you to change the post type that the plugin will query for markers. By default, it is set to post
. You can pass multiple post types as an array. Example:
add_filter( 'ootb_query_post_type', function() { return array( 'post', 'page' ); } );
ootb_query_posts_per_page
: Allows you to change the number of posts that the plugin will query for markers. By default, it is set to 100
. Example:
add_filter( 'ootb_query_posts_per_page', function() { return 500; } );
ootb_query_extra_args
: Allows you to add extra arguments to the query that the plugin will use to retrieve markers. By default, it is set to an empty array. Example:
add_filter(
'ootb_query_extra_args',
function() {
return [
'tax_query' => [
[
'taxonomy' => 'people',
'field' => 'slug',
'terms' => 'bob'
]
];
}
);
Keep in mind that the extra args will be merged with the default ones, so you don't have to worry about overriding them. In fact, the args that are required for the query to work, cannot be overridden.[ootb_query]
to retrieve the aforementioned Query Maps feature (see the FAQ for more info).react-leaflet
script to v.4.2.1
.react-leaflet
script to v.4.2.0
str_contains
with strpos
, for better backwards compatibility with older versions of PHP / WordPress.@wordpress/create-block
instead of create-guten-block
, which isn't supported anymore.Leaflet
and react-leaflet
to their latest versions (Leaflet 1.9.3 and react-leaflet 4.1.0).