VEMap.Import3DModel 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.

Cc966728.Important(en-us,MSDN.10).gifImportant:
On November 2, 2010, the end-of-life was announced for the 3D control. Effective December 1, 2011, the 3D control will no longer function. The full announcement is found at: http://www.bing.com/community/site_blogs/b/maps/archive/2010/11/02/changes-to-bird-s-eye-and-3d-maps.aspx

Imports a model data file and displays a 3D model on the map.


VEMap.Import3DModel(modelShapeSource, callback, latLong, orientation, scale);

Parameters

Parameter Description

modelShapeSource

A VEModelSourceSpecification Class object specifying the model data to import.

callback

The name of the function that is called after the data has been imported. See below for the arguments received by the callback.

latLong

A VELatLong Class object that specifies the point at which to place the origin of the model.

orientation

A VEModelOrientation Class object that specifies the orientation of the model on the map.

scale

A VEModelScale Class object that specifies the scale of the model.

A VEShape Class object corresponding to the pushpin associated with the 3D model. This is also returned to the function specified in the callback parameter.

The function defined in the callback parameter receives the following arguments, in the order shown:

  • A VEShape Class object corresponding to the pushpin associated with the 3D model. This is the same object returned by the Import3DModel method.

  • A VEModelStatusCode Enumeration value indicating the status of the 3D model import. This status code only indicates if the model data was successfully imported. It does not indicate whether or not the model rendered properly.

3D models support VEShape Class methods that have pushpin support.

Information about file support is found in the VEModelFormat Enumeration topic.

The function specified in the callback parameter is called if the user switches to VEMapMode.Mode3D from VEMapMode.Mode2D.

The function specified in the callback parameter is called when the following methods are used: VEShape.Show Method, VEShape.SetZIndex Method, VEShape.SetMaxZoomLevel Method, VEShape.SetMinZoomLevel Method, VEShape.ShowIcon Method, and VEShape.HideIcon Method.

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

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

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

         function AddModel(type)
         {
            var center = map.GetCenter();

            var layer = new VEShapeLayer();
            var modelSpec = new VEModelSourceSpecification(VEModelFormat.OBJ, document.getElementById('txtSource').value, layer);
            map.Import3DModel(modelSpec, onModelLoad, center, null, null);

            // Zoom in so you can see the model
            map.SetZoomLevel(16);
         }

         function onModelLoad(model, status)
         {
            if (status == VEModelStatusCode.Success)
            {
               alert("The 3D model has been loaded.");
            }
            
            if (status == VEModelStatusCode.InvalidURL)
            {
               alert("The URL given for the model data is invalid.");
            }
            
            if (status == VEModelStatusCode.Failed)
            {
               alert("There was a problem loading the 3D model.");
            }
         }
 
      </script>
   </head>
   <body onload="GetMap();">
      <div id='myMap' style="position:relative; width:600px; height:400px;"></div>
      <input id="txtSource" type="text" value="http://dev.live.com/virtualearth/sdk/model/house.obj" name="txtSource">
      <input id="btnAddModel" type="button" value="Load 3D Model" 
         onclick="AddModel();">
   </body>
</html>

Show: