MapPress is a WordPress plugin that provides an interface to Google Maps and easily allows you to insert detailed Google Maps into WordPress posts or pages. We have a site that provides password auditing services called QD Tools and on the homepage there is a map that lists the city, state/province, and country of our customers. I have been using MapPress Pro for a long time because it offers lots of extra features and MapPress itself is such an awesome plugin I like supporting the developer. Anyhow the Google Map on the QD Tools homepage is has over 1,000 markers and continues to grow. I wanted to modify the default MapPress/Google Maps marker that was being used but there is no way in MapPress to retroactively change this so the instructions below explain how to do this.
Modify All Existing MapPress Markers For A Single Map:
To accomplish this task you need to have MapPress Pro and understand the basics of mysqldump and vi from the Linux command line. The below example was completed on a Linux server running Ubuntu 12.04 LTS x86_64. The process consists of dumping the contents of the MapPress table, modifying the contents, and then uploading again. It should be noted that I am only using a single map so if there are multiple maps the below instructions will modify the markers for all maps if those markers have not already been set to something else custom. However if you are able to accomplish the below process then it is likely true as well that you would be able to extract a single maps contents, modify it, and then merge it back in with the other map data before dumping it back into MySQL.
**Note** Please backup your entire WordPress MySQL database before beginning the steps below. You can never have too many backups!
Create Custom Icon Or Pick Standard Icon:
To create a custom icon just make a PNG image that is 32 pixels by 32 pixels and upload it to “/path/to/wordpress/wp-content/plugins/mappress-google-maps-for-wordpress/icons. If you would rather pick one of the other marker icons that comes with MapPress Pro then search for it in the mappress-google-maps-for-wordpress/pro/standard_icons folder. You will need to know the correct name of the file itself to complete the process below.
Dump MapPress MySQL Data To SQL File:
- mysqldump -u root -p wordpress mappress_maps > mappress-maps.sql
The above will dump the entire MapPress table to a single SQL file. Now in this file we are going to open it, modify the default marker, and then import the data back into the WordPress database. First I would suggest backing up the SQL file so if any mistakes are made or things don’t turn out as expected you can always restore to the original data. Next open the SQL file in vi and then you will run the below search and replace command to update the MapPress marker data.
Open MapPress SQL File In vi:
- vi mappress-map.sql
To enter into the vi search prompt you need to click a single colon or “:” without the quotes.
Use vi Search & Replace To Modify All Google Map Marker Strings:
Once the above string is entered click the enter button and you will see output of how many strings have been replaced similar to “944 substitutions on 1 line” which lets you know that you were successful. Remember to replace the dot.png with whatever custom icon you have uploaded or if you wanted to use a standard MapPress icon it would be something like “red-dot” I believe but you will need to verify that before continuing.
Save MapPress SQL File:
The above command will write the file and quit vi. Now that you have successfully modified the contents of the MapPress SQL table we need to reimport the data and see if the markers are in fact updated. Use the command below to merge the MapPress SQL table back into the WordPress MySQL database.
Save MapPress SQL File:
- mysql -u root -p wordpress < mappress-maps.sql
Now go visit the WordPress page where your MapPress Google Map exists and see if the markers have in fact been modified! An example of custom markers on a MapPress Pro Google Map can be viewed by clicking here to view the Question Defense Tools Password Auditing Service Customer LocatioN Map.