<script type="text/javascript">
   
    $(document).ready(function() {
        var latitude = <%=Model.Latiude %>;
        var longitude = <%=Model.Longitude %>;
                
        if ((latitude == 0) || (longitude == 0))
        {
            LoadMap();
            }
        else{
            LoadMap(latitude, longitude, mapLoaded);
    }
    
}
      
   function mapLoaded() {
        var title = "<%= Html.Encode(Model.Title) %>";
        var address = "<%= Html.Encode(Model.Address) %>";
    
        LoadPin(center, title, address);
        map.SetZoomLevel(14);
    } );
      
</script>

解决方案 »

  1.   

    你有看Model.Latiude 返回的是数字还是字符么
      

  2.   

    IE8可以调试的 打个断点 F5自己调试
      

  3.   

    返回的事double型数字啊、、、
      

  4.   

    我要的就是这个类型,传入的是坐标,应该是double的吧
      

  5.   

    哥哥, 你这个 LoadMap(latitude, longitude, mapLoaded);
     
    mapLoaded 哪里赋值的?LoadPin(center, title, address);center 哪里赋值的?
      

  6.   

    mapLoaded下面那个mapLoaded()方法,没看见?
    center是LoadPin()方法的参数,显示中间的意思、、、、、、、、、、、
    貌似不用定义吧!!
      

  7.   

    /// <reference path="jquery-1.2.6.js" />var map = null;
    var points = [];
    var shapes = [];
    var center = null;function LoadMap(latitude, longitude, onMapLoaded) {
        map = new VEMap('theMap');
        options = new VEMapOptions();
        options.EnableBirdseye = false;    // Makes the control bar less obtrusize.
        map.SetDashboardSize(VEDashboardSize.Small);    if (onMapLoaded != null)
            map.onLoadMap = onMapLoaded;    if (latitude != null && longitude != null) {
            center = new VELatLong(latitude, longitude);
        }    map.LoadMap(center, null, null, null, null, null, null, options);
    }function LoadPin(LL, name, description) {
        var shape = new VEShape(VEShapeType.Pushpin, LL);    //Make a nice Pushpin shape with a title and description
        shape.SetTitle("<span class=\"pinTitle\"> " + escape(name) + "</span>");
        if (description !== undefined) {
            shape.SetDescription("<p class=\"pinDetails\">" +
            escape(description) + "</p>");
        }
        map.AddShape(shape);
        points.push(LL);
        shapes.push(shape);
    }function FindAddressOnMap(where) {
        var numberOfResults = 20;
        var setBestMapView = true;
        var showResults = true;    map.Find("", where, null, null, null,
               numberOfResults, showResults, true, true,
               setBestMapView, callbackForLocation);
    }function callbackForLocation(layer, resultsArray, places,
                hasMore, VEErrorMessage) {    clearMap();    if (places == null)
            return;    //Make a pushpin for each place we find
        $.each(places, function(i, item) {
            var description = "";
            if (item.Description !== undefined) {
                description = item.Description;
            }
            var LL = new VELatLong(item.LatLong.Latitude,
                            item.LatLong.Longitude);        LoadPin(LL, item.Name, description);
        });    //Make sure all pushpins are visible
        if (points.length > 1) {
            map.SetMapView(points);
        }    //If we've found exactly one place, that's our address.
        if (points.length === 1) {
            $("#Latitude").val(points[0].Latitude);
            $("#Longitude").val(points[0].Longitude);
        }
    }function clearMap() {
        map.Clear();
        points = [];
        shapes = [];
    }function FindDinnersGivenLocation(where) {
        map.Find("", where, null, null, null, null, null, false,
           null, null, callbackUpdateMapDinners);
    }function callbackUpdateMapDinners(layer, resultsArray, places, hasMore, VEErrorMessage) {
        $("#dinnerList").empty();
        clearMap();
        var center = map.GetCenter();    $.post("/Search/SearchByLocation", { latitude: center.Latitude,
            longitude: center.Longitude
        }, function(dinners) {
            $.each(dinners, function(i, dinner) {            var LL = new VELatLong(dinner.Latitude, dinner.Longitude, 0, null);            var RsvpMessage = "";            if (dinner.RSVPCount == 1)
                    RsvpMessage = "" + dinner.RSVPCount + " RSVP";
                else
                    RsvpMessage = "" + dinner.RSVPCount + " RSVPs";            // Add Pin to Map
                LoadPin(LL, '<a href="/Dinners/Details/' + dinner.DinnerID + '">'
                            + dinner.Title + '</a>',
                            "<p>" + dinner.Description + "</p>" + RsvpMessage);            //Add a dinner to the <ul> dinnerList on the right
                $('#dinnerList').append($('<li/>')
                                .attr("class", "dinnerItem")
                                .append($('<a/>').attr("href",
                                          "/Dinners/Details/" + dinner.DinnerID)
                                .html(dinner.Title)).append(" (" + RsvpMessage + ")"));
            });        // Adjust zoom to display all the pins we just added.
            if (points.length > 1) {
                map.SetMapView(points);
            }        // Display the event's pin-bubble on hover.
            $(".dinnerItem").each(function(i, dinner) {
                $(dinner).hover(
                    function() { map.ShowInfoBox(shapes[i]); },
                    function() { map.HideInfoBox(shapes[i]); }
                );
            });
        }, "json");
    }
     贴出JS文件
      

  8.   

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NerdDinner.Models.Dinners>" %><script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2" type="text/javascript"></script><script src="/Scripts/Map.js" type="text/javascript"></script><div id="theMap" style="width:520px">
    </div><script type="text/javascript">
       
        $(document).ready(
        
           function() {
            var latitude = <%=Model.Latiude %>;
            var longitude = <%=Model.Longitude %>;
                    
            if ((latitude == 0) || (longitude == 0))
            {
                LoadMap();
                }
            else{
                LoadMap(latitude, longitude, mapLoaded);
        }
        
    });
          
       function mapLoaded() {
            var title = "<%= Html.Encode(Model.Title) %>";
            var address = "<%= Html.Encode(Model.Address) %>";
        
            LoadPin(center, title, address);
            map.SetZoomLevel(14);
        } 
          
    </script>
    页面全部代码,已经在上面的。
      

  9.   

    你引用jquery框架的 代码呢
      

  10.   

    不会用firebug 就自己费点心 alert()找null值吧……
      

  11.   

    对呀 你的代码要用到jquery的呀 你没引用啊
      

  12.   

    你是不是还要让我先安装Firefox 再用firebug ?
      

  13.   


    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NerdDinner.Models.Dinners>" %>
    <script type="text/javascript" src="../JSLibrary/jquery-1.4.2.min.js"></script>
    <script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2" type="text/javascript"></script><script src="/Scripts/Map.js" type="text/javascript"></script><div id="theMap" style="width:520px">
    </div><script type="text/javascript">
        
      $(document).ready(
        
      function() {
      var latitude = <%=Model.Latiude %>;
      var longitude = <%=Model.Longitude %>;
        
      if ((latitude == 0) || (longitude == 0))
      {
      LoadMap();
      }
      else{
      LoadMap(latitude, longitude, mapLoaded);
      }
        
    });
        
      function mapLoaded() {
      var title = "<%= Html.Encode(Model.Title) %>";
      var address = "<%= Html.Encode(Model.Address) %>";
        
      LoadPin(center, title, address);
      map.SetZoomLevel(14);
      }  
        
    </script>
      

  14.   

    <script src="/Scripts/Map.js" type="text/javascript"></script>
    不是这个么?
      

  15.   

    你这个页面用了jquery 你在哪有引用jquery-1.2.6.js
      

  16.   

    你丫的 代码是你写的吗  你这是基于jquery框架的  要引用jquery.js
      

  17.   

    function mapLoaded() {
      var title = "<%= Html.Encode(Model.Title) %>";
      var address = "<%= Html.Encode(Model.Address) %>";
        
      LoadPin(center, title, address);
      map.SetZoomLevel(14);在这里加个} 少半个中括号
    这个 mapLoaded() 函数没结束标签 
      

  18.   

    靠,哪知道要引用那么多啊,现在行了。那个jquery1.4没放在那个文件夹,
    我擦
    你谁哦,说撒、、、、、、、、、
      

  19.   

    或者这样写 <script type="text/javascript">
        
      $(document).ready(function() {
      var latitude = <%=Model.Latiude %>;
      var longitude = <%=Model.Longitude %>;
        
      if ((latitude == 0) || (longitude == 0))
      {
      LoadMap();
      }
      else{
      LoadMap(latitude, longitude, mapLoaded);
      }
        
    });
        
      function mapLoaded() {
      var title = "<%= Html.Encode(Model.Title) %>";
      var address = "<%= Html.Encode(Model.Address) %>";
        
      LoadPin(center, title, address);
      map.SetZoomLevel(14);
      } 
        
    </script> 
     
      

  20.   

    哈哈,楞哦。给你啦,lz没钱没分。一个吊asp.net mvc1.0搞伤我
    是不是小孩啊?
      

  21.   

    IE8可以调试的 打个断点 F5自己调试