This shortcode will display a form that you can use to add locations from the frontend of your website. This was introduced in version 3 as a replacement of the v2 shortcode [progress_map_add_location_form]
.
The shortcode [cspm_frontend_form]
supports the following parameters:
map_id
post_id
post_type
embed
center_at
zoom
width
height
map_style
initial_map_style
window_resize
A string name that represents the unique ID of the map.
- Do not use the string name
frontend_form_map
! That name is reserved for the main map of the form. - If the attribute
map_id
was not defined, the plugin will call the default ID of the form’s map. - If the attribute
map_id
was not defined and two instances (maps) were called in the same page, the plugin will confuse between them and none of the instances will work.
If you want to save the coordinates using PHP, this is the code you need to use to save your locations:
if(class_exists('CspmFrontendForm') && isset($_POST[CSPM_LATITUDE_FIELD], $_POST[CSPM_LONGITUDE_FIELD])){
$CspmFrontendForm = CspmFrontendForm::this();
$CspmFrontendForm->cspm_save_frontend_location(array(
'post_id' => THE_POST_ID,
'latitude' => esc_attr($_POST[CSPM_LATITUDE_FIELD]),
'longitude' => esc_attr($_POST[CSPM_LONGITUDE_FIELD]),
'post_type' => THE_POST_TYPE_NAME,
));
}
The post ID to which you want to add coordinates. If not used, the plugin will use the ID of the last inserted post but please note that this is not 100% guaranteed.
Example: [cspm_frontend_form post_id="150"]
The post type name of the post to which you want to add the coordinates. When not used, the plugin will use your “Main content type”.
Example: [cspm_frontend_form post_type="post"]
Possible values areyes
, no
. If you want to embed the frontend form inside another form, use this shortcode attribute and use the option yes
. This will also hide the “Add location” button of the form.
Example: [cspm_frontend_form embed="yes"]
Override the default center point of the map by providing other coordinates (latitude & longitude).
Example 1: [cspm_frontend_form center_at="51.510879,-0.117813"]
The width of the map in pixels.
Example: [cspm_frontend_form width="500px"]
The height of the map in pixels.
Example: [cspm_frontend_form height="500px"]
Define the zoom of the map (from 0
to 19
).
Example: [cspm_frontend_form zoom="13"]
The skin of the map. To get the style name, follow these steps:
- Click on the menu “Progress Map”. Wait for the page to load!
- Click on the menu “Default Map style settings”
- Click the link “Demo” next to the style you like. A new page/window will open, the URL of that page/window holds the style name as the last attribute. So if the URL looks like
http://snazzymaps.com/style/42/apple-maps-esque
, the style name will beapple-maps-esque
.
Example: [cspm_frontend_form map_style="apple-maps-esque"]
The initial style of the map. Possible values are ROADMAP
, SATELLITE
, TERRAIN
, HYBRID
, custom_style
.
Example: [cspm_frontend_form initial_map_style="TERRAIN"]