13 Replies Latest reply: Mar 18, 2014 12:03 PM by David Young

I have read over all the great examples on creating a googlemaps and I have been successful. I have 6000 acct with latitude and longitude values. I have found some examples of how to calculate the distance between two acct.  The question I have is are there some examples of how I can select any account, plug in a distance and get all the accounts within that distance.  Please advise.

David

Hi,

Are you talking about straight line distance or traffic distance ?

Straight Line.  I have the distance formula figured out already but what I dont know is how to select an Acct Number down, have it go to find the Lat and Long, enter the distance of choice, and then return all accts with that distance.

Ok, I've an example to do something like this.

I try to share it with you asap

David,

I don't want to take points from brault.christopher, so keep the "correct answer" for him.  I just want to say that you're almost there already, since you have the formula.  If it is a table, use calculated dimension like this:
if(<your distance formula here> <= vDistance, AccountID)
And, check "suppress when value is null".
As for the expressions, it could be anything you want - Account name, the same distance formula, etc.

By changing the variable vDistance (use input box) you'll get different results.

Regards,
Michael

HI Michael,

When you say distance formula are you saying the:

ACOS(SIN([Latitude]*Pi()/180)..........

David

A sort of.  Here how it looks in my case:

milefactor*acos(sin(latitude/rc)*sin(lat1/rc) + cos(latitude/rc)*cos(lat1/rc)*cos(longitude/rc - long1/rc))

where variables are

milefactor           3963                                 radius of the planet in miles (so the distance is in miles)

lat1                  =avg(SelectLatitude)          SelectLatitude is of the center point

long1               =avg(SelectLongitude)       SelectLongitude is of the center point

For center point selection, I use a data island that has three fields - full address of the center point (it could be a copy of account name in your case, use different field name or use approach with alternate sets), SelectLatitude, and SelectLongitude.

And, latitude and longitude are the fields, coordinate of Accounts in this case

Hi Michael,

Is there any way you can post a small sample qvw file of your data for me to review.  I have only been trying to figure these maps out for a few weeks and would love to see another example.  Even if it is only 10 data points.

David

Hi Mike,

Thanks for the information. Is there any way you can share a small example of what you do.

David

David,

Can you upload a data set?  Data points (no matter how you call them, plus latitude/longitude for each), in Excel file.

Hi Mike,

Here is a small data set.

• Re: Re: Distance on Googlemaps

See attached.

Make selections in center point, change Distance in input box, and see the result in the table.

Regards,

Michael

Mike,

You are the man.  Thank you so much.

David

I'll try to explain what i do in my app :

I have a field called "CR" with longitude and latitude.

I've defined an alternate State call CR1. I use a listBox with this alternate State to select only ONE CR

then i show :

In one straight table, all CR with the distance in km with this expression :

if(CR=only({CR1}CR),0,

if(isnull(atan2(sqrt(sqr(cos(latitude*pi()/180)*sin(longitude*pi()/180-Lon1))

+sqr(cos(Lat1)*sin(latitude*pi()/180)-sin(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1)))

,sin(Lat1)*sin(latitude*pi()/180)+cos(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1))*6371), '999',

num(atan2(sqrt(sqr(cos(latitude*pi()/180)*sin(longitude*pi()/180-Lon1))

+sqr(cos(Lat1)*sin(latitude*pi()/180)-sin(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1)))

,sin(Lat1)*sin(latitude*pi()/180)+cos(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1))*6371

,'0')))

From this expression you can create a listbox with an expression like this one :

=class(aggr(if(CR=only({CR1}CR),0,

if(isnull(atan2(sqrt(sqr(cos(latitude*pi()/180)*sin(longitude*pi()/180-Lon1))

+sqr(cos(Lat1)*sin(latitude*pi()/180)-sin(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1)))

,sin(Lat1)*sin(latitude*pi()/180)+cos(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1))*6371), '999',

num(atan2(sqrt(sqr(cos(latitude*pi()/180)*sin(longitude*pi()/180-Lon1))

+sqr(cos(Lat1)*sin(latitude*pi()/180)-sin(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1)))

,sin(Lat1)*sin(latitude*pi()/180)+cos(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1))*6371

,'0')))

,CR)

,10,'km')

You can use it to filter in a map for example.

In google map, i change the color of each point with this expression :

=if(CR=only({CR1}CR),vGris,

aggr( if(

if(CR=only({CR1}CR),vGris,

if(isnull(atan2(sqrt(sqr(cos(latitude*pi()/180)*sin(longitude*pi()/180-Lon1))

+sqr(cos(Lat1)*sin(latitude*pi()/180)-sin(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1)))

,sin(Lat1)*sin(latitude*pi()/180)+cos(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1))*6371), '999',

num(atan2(sqrt(sqr(cos(latitude*pi()/180)*sin(longitude*pi()/180-Lon1))

+sqr(cos(Lat1)*sin(latitude*pi()/180)-sin(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1)))

,sin(Lat1)*sin(latitude*pi()/180)+cos(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1))*6371

,'0')))<=10,Color(1),

if(

if(CR=only({CR1}CR),vGris,

if(isnull(atan2(sqrt(sqr(cos(latitude*pi()/180)*sin(longitude*pi()/180-Lon1))

+sqr(cos(Lat1)*sin(latitude*pi()/180)-sin(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1)))

,sin(Lat1)*sin(latitude*pi()/180)+cos(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1))*6371), '999',

num(atan2(sqrt(sqr(cos(latitude*pi()/180)*sin(longitude*pi()/180-Lon1))

+sqr(cos(Lat1)*sin(latitude*pi()/180)-sin(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1)))

,sin(Lat1)*sin(latitude*pi()/180)+cos(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1))*6371

,'0')))<=20,color(2),

if(

if(CR=only({CR1}CR),vGris,

if(isnull(atan2(sqrt(sqr(cos(latitude*pi()/180)*sin(longitude*pi()/180-Lon1))

+sqr(cos(Lat1)*sin(latitude*pi()/180)-sin(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1)))

,sin(Lat1)*sin(latitude*pi()/180)+cos(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1))*6371), '999',

num(atan2(sqrt(sqr(cos(latitude*pi()/180)*sin(longitude*pi()/180-Lon1))

+sqr(cos(Lat1)*sin(latitude*pi()/180)-sin(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1)))

,sin(Lat1)*sin(latitude*pi()/180)+cos(Lat1)*cos(latitude*pi()/180)*cos(longitude*pi()/180-Lon1))*6371

,'0')))<=50,color(3),color(4))))

,CR)

)

I hope this help. I can't share a qvw because i didn't achieve it with fake data...