Select to view content in your preferred language

Bing Maps and Overview widget

1312
6
Jump to solution
12-13-2012 01:41 PM
ChrisMarston
Deactivated User
I am currently displaying Bing Aerial on main map and want to make my overview as Bing Roads, does anyone know how I would code this? Using Flexviewer 3.0

This is what I have coded but it keeps displaying the Bing Aerial in both maps:

<configuration>
    <!-- possible values for initialstate: open or closed (default) -->
    <initialstate>open</initialstate>
    <!-- by default it will use the same basemap as current main map,
         you can hardcode as below if you wish -->
<type="bing" visible="true" key="AjR14SXBBY1RWMyZ9riZJltB3DqUcyUVt_a4ulRXKz-O5sdsQHMVnbjWH964C8Ls" style="road" culture="en-US" />
</configuration>

Thanks All
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RhettZufelt
MVP Notable Contributor
Well, if you have the source code, it looks fairly simple:

In my overviewMapWidget.xml I have the following:

<?xml version="1.0"?>
<configuration>
    <!-- possible values for initialstate: open or closed (default) -->
    <initialstate>open</initialstate>
    <!-- by default it will use the same basemap as current main map,
         you can hardcode as below if you wish -->
         
       <bing key="your_key_here"/>

       <layer label="Bing" type="bing" visible="true" style="road" culture="en-US" url="placeholder@here.there"/>


</configuration>
basically assinging a nonexistet (dummy) url to the bing layer tag and providing my Bing key. (url can be any non-null)

This will then test for if (url) as true and send it to this part of the OverviewMapComponent.mxml (otherwise, it goes straight to loading from Basemaps):

                    if (url)
                    {
                        useBaseMapLayer = false;
                        type = configXML.layer.@type;
                        useProxy = configXML.layer.@useproxy[0] && configXML.layer.@useproxy == "true";
                        switch (type.toLowerCase())
                        {
                            case "tiled":
                            {
                                var tiledlayer:ArcGISTiledMapServiceLayer = new ArcGISTiledMapServiceLayer(url);
                                tiledlayer.alpha = alpha;
                                if (proxyUrl && useProxy)
                                {
                                    tiledLayer.proxyURL = proxyUrl;
                                }
                                overviewMap.addLayer(tiledlayer);
                                break;
                            }
                            case "dynamic":
                            {
                                var dynlayer:ArcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer(url);
                                dynlayer.alpha = alpha;
                                if (proxyUrl && useProxy)
                                {
                                    dynlayer.proxyURL = proxyUrl;
                                }
                                overviewMap.addLayer(dynlayer);
                                break;
                            }
  case "bing":
  {
   var veTiledLayer:VETiledLayer = new VETiledLayer();
   veTiledLayer.alpha = alpha;
   veTiledLayer.id = label;
   veTiledLayer.visible = visible;
   veTiledLayer.key = configXML.bing.@key;
                        veTiledLayer.mapStyle = configXML.layer.@style;
   if (style)
   {
    veTiledLayer.mapStyle = style;
   }
   if (culture)
   {
    veTiledLayer.culture = culture;
   }
   overviewMap.addLayer(veTiledLayer);
   break;
   }
                        }
                    }
                    else


The red text is the code I added (copied from several lines below in the same file) and modified the .key to get it from the config. Also modified it to get style, otherwise, you ONLY get streets. This way, it lets you pick "road", "aerial", or "aerialWithLabels".

This is working for me, I have the Bing streets layer in my overview map (nothing else), and it zooms/pans as expected regardless of what basemaps I have visible in the main viewer.

R_

View solution in original post

0 Kudos
6 Replies
RhettZufelt
MVP Notable Contributor
The overview map is going to use layers you have loaded in the main config.

See this post:  http://forums.arcgis.com/threads/30788-Static-Overview-Map?p=105461#post105461 to see how to "pick" what service(s) show in the overview map to make it "static".

This post is for the 2.4 version, but I incorporated these changes into 3.0 and is working fine (though I haven't tested Bing maps to make sure it works with them).

Hope this helps,

R_
0 Kudos
RhettZufelt
MVP Notable Contributor
It appears as if the OverviewMapComponent.mxml tests for presence of url, if so, it loads the hardcoded service.  If not, it loads basemaps.

So, since Bing is built in and you don't supply a url, it doesn't appear as if you can hardcode it to utlize Bing maps unless you can come up with the url to the service or re-write the source so that it doesn't exclude it.

R_
0 Kudos
RhettZufelt
MVP Notable Contributor
Well, if you have the source code, it looks fairly simple:

In my overviewMapWidget.xml I have the following:

<?xml version="1.0"?>
<configuration>
    <!-- possible values for initialstate: open or closed (default) -->
    <initialstate>open</initialstate>
    <!-- by default it will use the same basemap as current main map,
         you can hardcode as below if you wish -->
         
       <bing key="your_key_here"/>

       <layer label="Bing" type="bing" visible="true" style="road" culture="en-US" url="placeholder@here.there"/>


</configuration>
basically assinging a nonexistet (dummy) url to the bing layer tag and providing my Bing key. (url can be any non-null)

This will then test for if (url) as true and send it to this part of the OverviewMapComponent.mxml (otherwise, it goes straight to loading from Basemaps):

                    if (url)
                    {
                        useBaseMapLayer = false;
                        type = configXML.layer.@type;
                        useProxy = configXML.layer.@useproxy[0] && configXML.layer.@useproxy == "true";
                        switch (type.toLowerCase())
                        {
                            case "tiled":
                            {
                                var tiledlayer:ArcGISTiledMapServiceLayer = new ArcGISTiledMapServiceLayer(url);
                                tiledlayer.alpha = alpha;
                                if (proxyUrl && useProxy)
                                {
                                    tiledLayer.proxyURL = proxyUrl;
                                }
                                overviewMap.addLayer(tiledlayer);
                                break;
                            }
                            case "dynamic":
                            {
                                var dynlayer:ArcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer(url);
                                dynlayer.alpha = alpha;
                                if (proxyUrl && useProxy)
                                {
                                    dynlayer.proxyURL = proxyUrl;
                                }
                                overviewMap.addLayer(dynlayer);
                                break;
                            }
  case "bing":
  {
   var veTiledLayer:VETiledLayer = new VETiledLayer();
   veTiledLayer.alpha = alpha;
   veTiledLayer.id = label;
   veTiledLayer.visible = visible;
   veTiledLayer.key = configXML.bing.@key;
                        veTiledLayer.mapStyle = configXML.layer.@style;
   if (style)
   {
    veTiledLayer.mapStyle = style;
   }
   if (culture)
   {
    veTiledLayer.culture = culture;
   }
   overviewMap.addLayer(veTiledLayer);
   break;
   }
                        }
                    }
                    else


The red text is the code I added (copied from several lines below in the same file) and modified the .key to get it from the config. Also modified it to get style, otherwise, you ONLY get streets. This way, it lets you pick "road", "aerial", or "aerialWithLabels".

This is working for me, I have the Bing streets layer in my overview map (nothing else), and it zooms/pans as expected regardless of what basemaps I have visible in the main viewer.

R_
0 Kudos
ChrisMarston
Deactivated User
Rhett,

Thanks for the workaround, however when I change my OverviewMapWidget.xml code, I get a blank overview map. Any other suggestions?

Thanks,

Chris
0 Kudos
ChrisMarston
Deactivated User
Working now, thanks Rhett!
0 Kudos
RhettZufelt
MVP Notable Contributor
No problem,

Since you said you are using Bing as main map, then you will have the Bing logo on there so probably not an issue.

Not sure if you are allowed to have Bing displayed without the logo, even if only in overview.

I don't use Bing, so haven't looked into the agreement, but you might want to make sure your usage doesn't violate it.  Suspect if your only basemap options are Bing, it wouldn't be a problem.

R_
0 Kudos