这是我正在使用的代码无效。获取地图,但没有标记,即使它们正确显示在屏幕上:
<script type="text/javascript">
function ConvertToImage2(btnExport) {
html2canvas($('#dvReport').get(0), {
logging: true, //Enable log (use Web Console for get Errors and Warings)
useCORS: true,
onrendered: function (canvas) {
var base64 = canvas.toDataURL();
$("[id*=hfImageData]").val(base64);
__doPostBack(btnExport.name, "");
}
});
return false;
}
</script>
<div class="row">
<div id="dvReport" class="col-md-6 col-xs-12" style="background-color: white">
<div class="col-md-6 col-xs-12" style="text-align: center; clear: left">
<asp:Label ID="label4" runat="server" Text="VATS TRACKING REPORT" BackColor="White"></asp:Label>
</div>
<div>
<asp:Label ID="label1" runat="server" Text="Date:" BackColor="White" Font-Size="Small"></asp:Label><br />
<asp:Label ID="label2" runat="server" Text="User:" BackColor="White" Font-Size="Small"></asp:Label><br />
<asp:Label ID="label3" runat="server" Text="Violation Code:" BackColor="White" Font-Size="Small"></asp:Label>
</div>
<div class="col-md-6 col-xs-12">
<cc2:GMap ID="GMap1" runat="server" Width="900px" Height="480px" enableServerEvents="true" OnServerEvent="GMap1_ServerEvent" />
</div>
</div>
</div>
答案 0 :(得分:0)
根据此tutorial,您应该有Marker
类,它为您提供了为用户显示给定位置的标记的选项。此示例显示如何创建简单标记。
var marker = new google.maps.Marker
(
{
position: new google.maps.LatLng(-34.397, 150.644),
map: map,
title: 'Click me'
}
);
<强>更新强>
[code language=”csharp”]
protected void Page_Load(object sender, EventArgs e)
{
string markers=GetMarkers();
Literal1.Text = @"
<script type=’text/javascript’>
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(28.3213, 77.5435),
zoom: 2,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var myMap = new google.maps.Map(document.getElementById(‘mapArea’),
mapOptions);"
+markers+
@"}
</script>";
}
protected string GetMarkers()
{
string markers = "";
using (SqlConnection con = new
SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConString"].ConnectionString))
{
SqlCommand cmd = new SqlCommand("SELECT Latitude, Longitude, City FROM Locations", con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
int i = 0;
while (reader.Read())
{
i++;
markers +=
@"var marker"+i.ToString()+@" = new google.maps.Marker({
position: new google.maps.LatLng("+reader["Latitude"].ToString() + ", " +
reader["Longitude"].ToString() +"),"+
@"map: myMap,
title:’" + reader["City"].ToString() + "’});";
}
}
return markers;
}
[/code]