Multiple markers with OpenStreetMap in WordPress
Most time you just want to show a map with a marker on your site, the WP OSM Plugin brings all you need for such a map. If you there is the need to show more than one marker in a map you should use a KML file. A basic file which can be modified come with the WP OSM Plugin, all you have to do is to download this file and adapt it.
Steps to show multiple marker in your map
- download the KML file from your osm plugin directory
- modify the KML file to your needs with your markers
- upload the KML file to your uploads directory
- generate the shortcode in the WP OSM Plugin shortcode generator
- copy / paste the shortcode to your post/page
Download the KML file from your osm plugin directory
The KML sample file is located in:
Modify the KML file to your needs with your markers
Open the KML file in a texteditor, there are, two icon styles and three markers stored in the file.
Go to https://www.latlong.net/ to get the coordinates for your marker and copy lat and lon to the marker in the KML file.
Upload the KML file to your uploads directory
Once you have saved the file upload it to your uploads folder – you must not save any data in the osm plugin folder since this folder is deleted at every update. Copy the URL of your file to the clipboard.
Generate the shortcode in the WP OSM Plugin shortcode generator
Go to the post/page you want to show the map with your marker and generate the shortcode with the URL of your KML file. Copy/paste the shortcode to your post/page.
The shortcode will look somehow like this:
[osm_map_v3 map_center="autolat,autolon" zoom="autozoom" width="100%" height="450" file_list="https://Yourdomain/wp-content/uploads/MarkerSample.kml" file_color_list="none" control="scaleline" map_border="thin solid green" file_title="MarkerSample.kml"]