Questions about any of this. Email me: jmattox@genconsult.com

-- Build this string for your MapData Array

Example of what a MapData string my look like. Only the Lat & lng are required. Everything else can be added by you with your choice of field name and data. --

{ lat: 33.1529988, lng: -97.6883671, name: "Joe Smith", address: "100 Main St, Paradise, TX 76073, USA"},
{ lat: 32.9172628, lng: -96.6997799, name: "Fred Smith", address: "510 N Plano Rd, Garland, TX 75042, USA"},
{ lat: 33.0254475, lng: -96.6989655, name: "Sam Smith", address: "1840 K Ave, Plano, TX 75074, USA"}

 

-- Example SQL COde starts here

declare @SalesRepID int = '[querystring:SalesRepID]'
declare @MapData varchar(max) =
(
select 
'{'+
' lat: '+Customer.Latitude+', lng: '+Customer.Longitude+','+
' name: "'+Customer.Firstname+' '+Customer.Lastname+'"'+','+
' address: "'+Customer.formattedaddress+'"'+  
'},'
from app.Customer
join app.SalesRep on SalesRep.ID=Customer.SalesRep  
where SalesRep.ID=@SalesRepID  and
Customer.Latitude is not null
for xml path('')
)

select @MapData as 'MapData'