dc = CreateObject("MapObjects2.DataConnection") dc.Database = 'c:\ESRI\Samples\Data\USA' if (dc.Connect) layer = createobject("MapObjects2.MapLayer") layer.GeoDataset = dc.FindGeoDataset('States') sym = layer.Symbol sym.Color = moYellow thisform.OleMap.Layers.Add(layer) layer = createobject("MapObjects2.MapLayer") layer.GeoDataset = dc.FindGeoDataset('Counties') sym = layer.Symbol sym.Color = moLightGray thisform.OleMap.Layers.Add(layer) layer = createobject("MapObjects2.MapLayer") layer.GeoDataset = dc.FindGeoDataset('Capitals') sym = layer.Symbol sym.Color = moNavy thisform.OleMap.Layers.Add(layer) layer = createobject("MapObjects2.MapLayer") layer.GeoDataset = dc.FindGeoDataset('USHigh') sym = layer.Symbol sym.Color = moRed thisform.OleMap.Layers.Add(layer)A more generic one is like (I use this one to quickly check any dataset):
* Initialize ARC or shp dir lcDir = getdir() If empty(lcDir) Return .f. Endif Thisform.lstLayers.Clear && A listbox to list layers in database With thisform.OleMap.Layers && Remove existing layers for jx = .Count-1 to 0 step -1 .Remove(jx) endfor Endwith with Thisform .dc = .null. .dc = CreateObject("MapObjects2.DataConnection") * DbType is an optiongroup specifying ARC or shp .dc.Database = iif(thisform.DbType.Value = 1, '[arc]','')+lcDir If (.dc.Connect) && If connected add layernames to a listbox For ix=0 to .dc.GeoDataSets.Count-1 .lstLayers.AddItem(.dc.GeoDataSets.Item(ix).Name) Endfor Else Return .f. Endif endwith * Show selected layers button click (list has moverbars for layer order) With thisform.lstLayers For ix = 1 to .Listcount If .Selected(ix) layer = createobject("Mapobjects2.MapLayer") layer.GeoDataset = thisform.dc.FindGeoDataset(.List(ix)) Thisform.OleMap.Layers.Add(layer) Endif Endfor Endwith thisform.OrderLayers() && Custom method to order layers thisform.OleMap.RefreshPS: Though 2.0 documentation says it I didn't see any difference with _VFP.Autoyield set to .t.