"Zoom In" – to Points on Map
Recently there have several Forum posts asking how to find all the points that are within a radius of a point and to be able to "zoom in" on the map – something like “I want to identify client locations are within 20 miles of each of our 5 office locations of our plant locations” –
Not an uncommon question – and very solvable with Tableau – but being able to "Zoom in" requires a bit of a hack
Like a lot of solutions in Tableau, you need to think backward. First, we need to determine the distance from each office to each client location in the data – Then apply a filter that eliminates the points a greater distance away. Not difficult but a lot of data
Step 1 – Shape the Data
You need to have the longitude and latitude of each office and each client location – sorry you won’t be able to use the Tableau generated longs and lats in calculations, so they need to be loaded with the data – keep the files separate – one for the office and one for the client locations.
To get the solution we need to determine the distance from each office location to every client site and will require connecting the files with a Cartesian join
The join expands the data set with a separate row for each client location/office site combination
Step 2 – Determine the distance from the office to each client
I’ve used a LOD that looks at each Office location and determines the distance to every Client location
{ FIXED [Client Loc ID],[Office Loc ID] :avg(3959 * ACOS(
SIN(RADIANS([Client Lat])) * SIN(RADIANS(([Office Lat]))) +
COS(RADIANS([Client Lat])) * COS(RADIANS(([Office Lat]))) *
COS(RADIANS(([Office Long]))-RADIANS([Client Long]))) )}
Note: I used the explicit formula rather than the Distance spatial function added in version 2019 –
The fixed LOD can be read in words as "for each combination of the office and client location" calculate the “as the crow flies distance flies using a complex trig formula —
Step 3 Create a Parameter to enter the radius and a filter based on the parameter
I used a floating-point parameter and used a range up to 60 miles with steps of 10 miles – you can use whatever fits your analysis
Then add a simple filter that limits the distance between the city center to the value in the parameter – place it on the filter shelf and set it to TRUE
[Distance Office to Client]<= [Enter Radius]
Step 4 – Create the Map
The Viz is a dual-axis map – one layer contains the Client locations the other the Office sites
Filters are added on the Office site location and the Boolean distance filter.
I made the Office locations stars – could be any shape – and I use the State dimension to vary the color of the client locations
Step 5 – the Zoom feature
Finally, the Zoom feature is controlled by the radius – the smaller the radius the more the user "Zooms" in and conversely larger radii will "Zoom Out" BUT you MUST UNPIN the map and UNSELECT the Pan and Zoom on the Map Options to avoid the map being locked at a zoom level and office location
I have a similar map on my Tableau Public site at
https://public.tableau.com/profile/jim.dehner#!/vizhome/Findclientswithinradius_v10_5/Interactivemap
Feel free to download it (or any other file on the site) to use as a model
Jim