In trying to keep things really simple to program, I tried to use the Serialize Cursor but found the result to be incompatible with Google's specification. The data tag "Rows" in their world is labeled "markers". Trying to tweek the result file once the data is serialized seemed more cumbersome than my second choice. Also, because VFP free tables have an eight character fieldname limit, I can't spell out "longitude" with was another problem.
My second attempt was to create an EMPTY object, AddProperties for the fields I needed to serialize then SCAN through the data building an ARRAY of objects with my data. This went fine until I tried to serialize the array. I tried passing it by referance @laArray but found all the rows to be serialized wit hte same data.
In the end, I SCAN through my cursor, create a correctly labeled object, pass the object to the serializer and concatenate the result to my lcOutPut string. This works just fine!
Here is the sample code:
loMapMarker = CREATEOBJECT('Empty')ADDPROPERTY(loMapMarker,'latitude')ADDPROPERTY(loMapMarker,'longitude')ADDPROPERTY(loMapMarker,'icon')ADDPROPERTY(loMapMarker,'title')ADDPROPERTY(loMapMarker,'content')SELECT * FROM myData into tCursor1 loSerializer = CREATEOBJECT("wwJsonSerializer") lcJSON = ''SCAN loMapMarker.Latitude = tCursor1.lat loMapMarker.Longitude = tCursor1.lng DOCASECASE tCursor1.Status = 'Approved' loMapMarker.Icon = 'green.png'CASE ... loMapMarker.Title = tCursor1.CaseNum lcContent = '' lcContent = lcContent + [<span style="font-size:9pt"><b>Case:</b> ] + ALLTRIM(tCursor1.CaseNum) +'</span><br>' lcContent = lcContent + [<span style="font-size:9pt"><b>Address:</b> ] + ALLTRIM(tCursor1.Address) +'</span><br>' loMapMarker.Content = lcContent * format data lcJSON = lcJSON + IIF(EMPTY(lcJSON),'',',') + loSerializer.Serialize(loMapMarker)ENDSCAN lcJSON = '{"markers":[ ' + lcJSON + ']}' lnBytes = STRTOFILE(lcJSON,'x:\web site path\myCaseMap.json') return lnBytes
Let me know if you want the stand alone HTML Map file to try out - it is very cool! I can now switch out the data and keep away from a WC generated map page with embedded data. This means the map page can live on any public server so long as the page points to local or remote data.
Onward('I have concrete to pour')!<s>
--hm
--hm