Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using ESRI's MapObjects LT 2 with VFP
Message
De
31/07/2001 04:11:23
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
30/07/2001 17:35:53
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00537430
Message ID:
00537632
Vues:
16
>>>I am trying to use ESRI's ActiveX control MapObjects LT 2 to display a ArcView shape file on a screen form. ESRI's web site only has one example for Visual FoxPro - and it is for the full version of MapObjects 2 instead of the MapObjects LT 2.
>>>
>>>I have a form with the following in the INIT method:
>>>
>>>_VFP.AutoYield = .F.
>>>layer = CREATEOBJECT("MapObjectsLT2.MapLayer")
>>>layer.file = "c:\program files\esri\mapobjectsLT2\samples\data\northeast\necenter.shp"
>>>layer.visible = .F.
>>>THISFORM.oleMap.Layers.Add(layer)
>>>THISFORM.oleMap.Extent = THISFORM.oleMap.FullExtent
>>>
>>>While I don't get any error messages, the form just comes up with a blank white image instead of showing the shape file. I would greatly appreciate any help anyone can offer to get me started in the right direction.
>>>
>>>Thanks,
>>>David
>>
>>Just set layer.visible back to .T. again and the map should show up OK.
>
>Thanks,
>I actually simplied the code to post, and I just realized that I left out the layer.visible = .T. code. I also just realized that I also had a typo on another line which was my real problem.
>
>Once again thanks,
>David

David,
Here it was .t. setting but keep in mind for MO a directory serves as a database and .shp in that dir as GeoDataSets. ie:
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.Refresh
PS: Though 2.0 documentation says it I didn't see any difference with _VFP.Autoyield set to .t.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform