How to put markers on maps

This is part of the Step by Step Guides to get started with some of the more complex topics on this site. The full story on map markers can be found at Mapping and adding markers to maps

 

What you need

GoogleMapping.xlsm from the Download Complete Projects page

 

Objective

To take a set of addresses in Excel, where their latitude and longitude have already been geocoded, and plot them on Google Maps.

 

Steps

All Mapping activities,  are controlled by 2 parameter sheets. One is general, and tells the procedures how to deal with the data returned from the various mapping providers (geoCodingParameters worksheet) and the other is specific to particular sets of data or desired results (in this case ‘step by step parameters’)

  • Go to the step by Step MasterTab. This is where you enter the data to be placed on a map . You’ll find some example data that looks like this. The columns in Yellow were already completed in How to Geocode addresses using Google Maps, the latitude and longtitude would already have been calculated. Now you need to provide data in the orange columns, Namely a label – this will be what is shown when you mouseover the Google Maps Marker, and content – This will be what is shown when you click on the related marker. The example below calculates some appropriate html formatting in column D from other fields populated by the geoCoding process using this formul, but you should use whatever you want to show in the infoBubble

 

="<b>" & C2 & "</b><br>" & SUBSTITUTE(O2,",","<br>") & "<br>"

  • Hit the markers button and a map will be shown like this. Click on a point and your data appears in a popup info box

  • No more steps. That’s all there is to it.

 

What just happened ?

An html file containing some javaScript and your data was created and a browser was kicked off. The name of the file and the browser to use are controlled by parameters in the parameter sheet. The created file can be used standalone or put on a web site. It contains everything needed to be

 

VBA code

The code associated with the markers button can be found in the GoogleMark module, and looks like this.

Public Sub stepByStepMarking()
    googleMarkingExample "Step by Step Parameters"
End Sub

What Next

Read more about the detail of how all this works and walk through the source code at Mapping and adding markers to maps or see some more Step by Step Guides (see below).

In the meantime why not join our forum, follow the blog or follow me on twitter to ensure you get updates when they are available.

More Step by Step Guides