Skip to content


Repository files navigation

CMB2 Roadway Segments

CMB2 Roadway Segments Banner

This plugin adds a new CMB2 fieldtype for drawing roadway segments onto a map and provides a shortcode for display.

In Action


This plugin extends CMB2 by adding a new fieldtype called 'snapmap' that allows the user to highlight segments of roadway using Google's snap-to-road API. It also allows the user to drop a map pin in the same field. This data can then be displayed on the front-end using the [snapmap] shortcode.

This plugin requires CMB2 and a Google Maps API key.

The Google Maps API key must have access to the Google Maps JavaScript API.

Unless you disable the associated features during plugin configutation, you will also need to enable:

  • Google Maps Roads API
  • Google Places API Web Service


  • Allows developers to integrate Google Maps with Wordpress via CMB2.
  • Allows site admins to provide custom maps styles and specify which map controls to include on the front-end.
  • Provides an option to exclude the Google Maps JS API if already loaded.


Visit the wiki for documentation about adding the field to CMB2 and displaying maps on your site.


  1. Plugin settings.
  2. The CMB2 field.
  3. Front-end display via shortcode.


  1. Upload the cmb2-roadway-segments folder to the /wp-content/plugins/ directory
  2. Activate the plugin through the 'Plugins' menu in WordPress
  3. Add a snapmap field to a CMB2 metabox.
  4. Place [snapmap] anywhere in a post's content to render a map.

Frequently Asked Questions

Does this plugin support custom map markers?

Yes, but only by using the template tag.

Can I display a map of all map markers?

Also yes, but only by using the template tag.




  • The jQuery UI theme is now loaded from CDN, matching the current bundled version of jQuery UI.
  • The encoded polygon string is now fully removed, as encoded polygons now appear to break the map.



  • The encoded polygon string is no longer used for display. Instead, the coordinate array is used.


This release includes tweaks to circle geometry opacity and adds support to hide the map marker's tooltip field via a field argument.


This release includes an early release of the CMB2_RS_Map class, which can be used to better build complex maps.



  • Added a plugin option to disable features in the map editor requiring use of geocoding. If disabled, the Places API Web Service will not need to be enabled for the provided API key.
  • Added a plugin option to disable snap-to-road functionality. If disabled, the Roads API will not need to be enabled for the provided key.
  • Reformated over 1000 lines of code to adhere to Wordpress core code standards.


Added the capability of attaching content to the map by CSS ID using the snapmap_build_single() function.


Added the capability to display multiple maps on one page using the snapmap_build_single() function by passing a unique ID for additional maps.


Added the ability to enable the terrain overlay for maps generated by the snapmap_build_single() function.


  • Added support for including retina map markers when using the snapmap_build_single() function. This is accomplished by including $marker['scaledSize']


GeoJSON copy-and-paste:

  • Added a field to paste raw geojson type / coordinate data into (under the Tools panel below the map). If the data type is LineString, pasted data will automatically be converted into a Google Maps compatiable JSON array and overwrite the polyline (Roadway Segment) field value. This functionality will be extended to other geometry types for the 0.9.7 release.


  • Added fallbacks for tooltips. When being used for a single post, the title of the post containing the pin is displayed in the tooltip. When using queries, the post title followed by a link to the post is displayed.


  • Added the ability to draw polygons on the map when the "limit_drawing" argument is not set. As a result, the geometry library is now required.
  • Modified circle stroke and fill lables to reflect the inclusion of polygons.
  • Fixed missing fill and stoke variables in output functions.
  • Fixed a bug that prevented polylines, polygons, and circles from being rendered on query-based maps.


  • Added the ability to draw circles on the map when the "limit_drawing" argument is not set
  • Added fields to specify circle stroke and fill colors to the plugin's settings page
  • Fixed invalid use of array keys in the shortcode function


  • Added new 'disable_snap' field argument. When used, the snapToRoads API will not be called when drawing polylines
  • Wrapped conditionals using the limit_drawing array key with isset() to ensure that the editor correctly renders


  • Fixed invalid use of array keys


  • Initial release.


This plugin adds a new CMB2 fieldtype for drawing roadway segments onto a map and provides a shortcode for display.







No packages published