关于google map显示图标

bj-alex 2013-02-17 10:33:50
想从数据库中将经纬度表的值,显示在地图中。
前台代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="display.aspx.cs" Inherits="display" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>position</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var map;
var marker;
function initialize()
{
var myLatlng = new google.maps.LatLng(39.858, 117.128);
var myOptions = {
zoom:12,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map"),myOptions);
}
<% GetRootIDArray(); %>;
var infowindow = new google.maps.InfoWindow();
for (i = 0; i < mycars.length; i++)
{
var myLatLng = new google.maps.LatLng(mycars[i][0],mycars[i][1])
marker = new google.maps.Marker({
map: map,
position: myLatLng

});
(function (i, marker) {
google.maps.event.addListener(marker, 'click', function () {
infowindow.setContent("Message" + i);
infowindow.open(map, marker);
});

})(i, marker);
marker.setMap(map);
}

</script>
</head>

<body onload="initialize()">
<form id="form1" runat="server">
<div id="map" style="width: 1024px; height: 650px">
</div>
</form>
</body>
</html>
后台代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.UI.HtmlControls;


public partial class display : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void GetRootIDArray()
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connection"].ConnectionString);
conn.Open();
SqlCommand cmd = new SqlCommand("select jingdu, weidu from GPSinfo", conn);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adp.Fill(ds);
System.Text.StringBuilder text = new System.Text.StringBuilder();
if (ds.Tables.Count > 0)
{
Response.Write("var mycars=new Array();");

for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
text.AppendFormat("mycars[{0}] = new Array('{1}','{2}');", i.ToString(), ds.Tables[0].Rows[i]["weidu"].ToString(), ds.Tables[0].Rows[i]["jingdu"].ToString());
}

text.Remove(text.Length - 1, 1);
Response.Write(text);
}
}
}

现在问题是,图标不显示。
...全文
120 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
bj-alex 2013-02-18
  • 打赏
  • 举报
回复
在前台代码的<% GetRootIDArray();%>;这里,有个警告提示:Expected expression。不明白怎么回事,难道原因在这儿?
bj-alex 2013-02-18
  • 打赏
  • 举报
回复
图标就是GPSinfo中的点坐标,结果没有报错,地图显示出来了,但是,点坐标却没有显示。
yyl8781697 2013-02-18
  • 打赏
  • 举报
回复
什么图标,GPSinfo表里面的点吗?? LZ把最后生成的html看下 是否有报啥js出错啥的

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧