<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>
$(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>
解决方案 »
- 把几个bmp合成gif
- 急问:绝对路径与IIS中虚拟目录的问题!
- .aspx页面和.cs的关系
- 请问如何进行三个dropdownlist的三级关联?
- 我没分了,可是我我真的着急用这个答案,谢谢大家了。。。。。。
- 每次从sql server中读取一条数据在页面显示,用DataTable还是SqlDataReader对服务器的压力小?
- 高分请教c#+asp.net WebService 和关于net Remoting的问题,问题解决后马上结贴!谢谢!
- webgrid保存问题
- 个位数加0,十位数不加0
- 有关-------TREEVIEW--------的几点疑惑,请指教。
- 有人学过cognos吗?
- 合并单元格后,TD的宽度出现差异
mapLoaded 哪里赋值的?LoadPin(center, title, address);center 哪里赋值的?
center是LoadPin()方法的参数,显示中间的意思、、、、、、、、、、、
貌似不用定义吧!!
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文件
</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>
页面全部代码,已经在上面的。
<%@ 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>
不是这个么?
var title = "<%= Html.Encode(Model.Title) %>";
var address = "<%= Html.Encode(Model.Address) %>";
LoadPin(center, title, address);
map.SetZoomLevel(14);在这里加个} 少半个中括号
这个 mapLoaded() 函数没结束标签
我擦
你谁哦,说撒、、、、、、、、、
$(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>
是不是小孩啊?