Linking two data frames

3664
4
12-06-2011 12:14 AM
ZarehDemirdjian
New Contributor III
Hello,

Is there any script, to link two data frames together?

I have Dataframe1 that contains layers like streets, parcels...
and I have Dataframe2 that a small one next to Dataframe1 that contains only the streets layer.
So what i want is, when i do any zooming or paning in the Datafram1, see the same thing happens in Dataframe2.

I want a script to run on ArcGIS 9.3.1 OR 10

Thanks in advance,

Zareh
0 Kudos
4 Replies
KenBuja
MVP Esteemed Contributor
Take a look at this thread in the old forums about linking data frames
0 Kudos
BrianBottoms
New Contributor
Hi,
Doing what you suggest might be better done at design time and not in a script.

If you go to the properties of the small data frame and click the Extent Indicators tab, you can link one data frame to the other. If you then go to the Data Frame tab and select the Extent drop-down specifying 'Other Data Frame' (ver. 10), the small data frame will mirror the other's behavior. It might be worth playing with the settings available to see if you can get what you want.

If you need to really get at the data frame, one possibility is to link the frames at design time (like above) then in code check a data frames locator rectangle collection to get at and set the other data frames properties - something like below...

Dim pLR As ILocatorRectangle
Dim pMFRef As IMapFrame

pGraphContainer.Reset()
                pElement = pGraphContainer.Next
                While Not pElement Is Nothing
                    If TypeOf pElement Is IMapFrame Then
                        pMapFrame = pElement
                  
                            If pMapFrame.LocatorRectangleCount > 0 Then
                                pLR = pMapFrame.LocatorRectangle(0)
                                pMFRef = pLR.MapFrame
                                pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentScale
                                pMapFrame.MapScale = df.Scale  'edit to desired scale
                                pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentDefault
                            End If
                       
                    End If
                    pElement = pGraphContainer.Next
                End While
            Next
0 Kudos
BrianBottoms
New Contributor
Oops - sorry I just did a really bad job of cut and paste with the code. Below is hopefully slightly less bad...

It is worth mentioning that this code has changed behavior between ArcGIS versions and turned out to be a bug. I'm  posting it to demonstrate one method to jump from one map frame to another related map frame.

Dim pLR As ILocatorRectangle
Dim pMFRef As IMapFrame

pGraphContainer.Reset()
                pElement = pGraphContainer.Next
                While Not pElement Is Nothing
                    If TypeOf pElement Is IMapFrame Then
                        pMapFrame = pElement
                  
                           
                            If pMapFrame.LocatorRectangleCount > 0 Then
                                pEnv = pElement.Geometry.Envelope
                                pLR = pMapFrame.LocatorRectangle(0)
                                pMFRef = pLR.MapFrame
                                pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentBounds
                                pMapFrame.MapBounds = pMFRef.MapBounds
                                'resetting the size here stops the scale from being slightly off on resize.
                                pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentDefault
                                pElement.Geometry = pEnv 'Reset the position of the dataframe.
                                pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentScale
                                pMapFrame.MapScale = df.Scale 'edit to desired scale
                                pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentDefault
                            End If
                       
                       
                    End If
                    pElement = pGraphContainer.Next
                End While
            Next
0 Kudos
ZarehDemirdjian
New Contributor III
Oops - sorry I just did a really bad job of cut and paste with the code. Below is hopefully slightly less bad...

It is worth mentioning that this code has changed behavior between ArcGIS versions and turned out to be a bug. I'm  posting it to demonstrate one method to jump from one map frame to another related map frame.

Dim pLR As ILocatorRectangle
Dim pMFRef As IMapFrame

pGraphContainer.Reset()
                pElement = pGraphContainer.Next
                While Not pElement Is Nothing
                    If TypeOf pElement Is IMapFrame Then
                        pMapFrame = pElement
                  
                           
                            If pMapFrame.LocatorRectangleCount > 0 Then
                                pEnv = pElement.Geometry.Envelope
                                pLR = pMapFrame.LocatorRectangle(0)
                                pMFRef = pLR.MapFrame
                                pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentBounds
                                pMapFrame.MapBounds = pMFRef.MapBounds
                                'resetting the size here stops the scale from being slightly off on resize.
                                pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentDefault
                                pElement.Geometry = pEnv 'Reset the position of the dataframe.
                                pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentScale
                                pMapFrame.MapScale = df.Scale 'edit to desired scale
                                pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentDefault
                            End If
                       
                       
                    End If
                    pElement = pGraphContainer.Next
                End While
            Next


Thank you I tried the 1st graphical method and it worked pretty well, I found a VB Script that synchronises between the data frames, but it turned to have a bug probably because of versions problem.
Thanks again,
0 Kudos