VEMap.ImportShapeLayerData Method

You are not viewing the latest version of the AJAX control. Bing Maps AJAX V7 is the recommended JavaScript control for Bing Maps. If you need this documentation, it is available in as a CHM or PDF download.

Imports data from a GeoRSS feed, Bing Maps (https://maps.live.com) collection, or KML URL.

VEMap.ImportShapeLayerData(shapeSource, callback, setBestView);

Parameters

Parameter Description

shapeSource

A VEShapeSourceSpecification Class object specifying the imported shape data.

callback

The function that is called after the data has been imported.

setBestView

A Boolean value that specifies whether the map view is changed to the best view for the layer.

Return Value

This method returns nothing. The imported data is passed as a VEShapeLayer Class object to the function specified by callback.

Remarks

If the specified layer has not already been added to the map, this method adds it automatically. If the GeoRSS feed URL, Bing Maps collection GUID, or XML URL is invalid, this method throws an exception.

To set the map view to the best view on the imported shapes, add the shapes to an empty layer.

For more information about supported file formats, see the VEDataType Enumeration topic.

Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

      <script type="text/javascript" src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.3"></script>

      <script type="text/javascript">
         var map = null;
         var layerid=1;
         
         function GetMap()
         {
            map = new VEMap('myMap');
            map.LoadMap();
         }   

         function AddMyLayer(type)
         {
            var l = new VEShapeLayer();
            var veLayerSpec = new VEShapeSourceSpecification(type, document.getElementById('txtSource').value, l);
            map.ImportShapeLayerData(veLayerSpec, onFeedLoad, 1);
         }

         function onFeedLoad(feed)
         {
            alert('RSS or Collection loaded. There are '+feed.GetShapeCount()+
               ' items in this list.');
         }
      </script>
   </head>
   <body onload="GetMap();">
      <div id='myMap' style="position:relative; width:400px; height:400px;"></div>
      <INPUT id="txtSource" type="text" value="546E7E30AC2C5011!451" name="txtSource">
      <INPUT id="loadCollection" type="button" value="Load VE Collection" 
         onclick="AddMyLayer(VEDataType.VECollection);">
   </body>
</html>

See Also

Reference

VEDataType Enumeration

Concepts

VEShapeSourceSpecification Class