谷歌地图..在asp.net中 [英] Google maps.. in asp.net
本文介绍了谷歌地图..在asp.net中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用了一个类来显示aspx页面中的地图..而且我已经从cs页面发送了一个数据表..
接下来的事情是。我只想在点击每一个时显示一条消息标记。
班级代码就在下面...
使用系统;
使用 System.Collections.Generic;
使用 System.Linq;
使用 System.Web;
使用 System.Data;
/// < 摘要 >
/// GPSLib的汇总说明
/// < / summary >
public static class gmap
{
public static 字符串 PlotGPSPoints(DataTable tblPoints)
{
try
{
字符串位置= ;
字符串 sJScript = ;
int i = 0 ;
foreach (DataRow r in tblPoints.Rows)
{
// 绕过空行
如果(r [ lat]。ToString()。Trim()。Length == < span class =code-digit> 0 )
continue ;
string 纬度= r [ 长的跨度>]的ToString();
string 经度= r [ lat 跨度>]的ToString();
string name = r [ 名称 跨度>]的ToString();
// 为此记录在地图上创建一行JavaScript标记
Locations + = Environment.NewLine + @
path.push(new google.maps。 LatLng( + Latitude + , +经度+ @ ));
var marker + i.ToString()+ @ = new google.maps.Marker({
position:new google.maps.LatLng( + Latitude + , +经度+ @ ),
title:'Click to see',
map:map
}); ;
i ++;
}
// 构建最终脚本
sJScript = @ < script type ='text / javascript'>
var poly;
var map;
function initialize(){
var cmloc = new google.maps.LatLng(22.5697,88.3697);
var myOptions = {
zoom:11,
center:cmloc,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map (document.getElementById('map_canvas'),myOptions);
var polyOptions = {
strokeColor:'blue',
strokeOpacity:0.0 ,
strokeWeight:0
}
poly = ne w google.maps.Polyline(polyOptions);
poly.setMap(map);
var path = poly.getPath();
+地点+ @
}
< / script>;
return sJScript;
}
catch (例外情况)
{
throw ex;
}
}
}
解决方案
http://www.aspdotnet-suresh.com/2013/01/adding-animated-markers- to-google-maps.html [ ^ ]
http://www.c-sharpco rner.com/uploadfile/shabdarghata/google-maps-control-for-asp-net-part-i/ [ ^ ]
Google Maps API V3 for ASP.NET [ ^ ] < br $> b $ b
使用带有c#的asp.net中的谷歌地图 [ ^ ]
http://www.aspsnippets.com/Articles/ASPNet-Google-Maps-V3-with -Multiple-Markers-Database-Example.aspx
i已经成功解决了我的问题..
I have uses a class for showing map in aspx page.. And i have send a datatable from cs page..
Next thing is .I just want to display a message on click of every marker.
the code of class is just below...
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; /// <summary> /// Summary description for GPSLib /// </summary> public static class gmap { public static String PlotGPSPoints(DataTable tblPoints) { try { String Locations = ""; String sJScript = ""; int i = 0; foreach (DataRow r in tblPoints.Rows) { // bypass empty rows if (r["lat"].ToString().Trim().Length == 0) continue; string Latitude = r["long"].ToString(); string Longitude = r["lat"].ToString(); string name = r["Name"].ToString(); // create a line of JavaScript for marker on map for this record Locations += Environment.NewLine + @" path.push(new google.maps.LatLng(" + Latitude + ", " + Longitude + @")); var marker" + i.ToString() + @" = new google.maps.Marker({ position: new google.maps.LatLng(" + Latitude + ", " + Longitude + @"), title: 'Click to see' , map: map });"; i++; } // construct the final script sJScript = @"<script type='text/javascript'> var poly; var map; function initialize() { var cmloc = new google.maps.LatLng(22.5697, 88.3697); var myOptions = { zoom: 11, center: cmloc, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById('map_canvas'), myOptions); var polyOptions = { strokeColor: 'blue', strokeOpacity: 0.0, strokeWeight: 0 } poly = new google.maps.Polyline(polyOptions); poly.setMap(map); var path = poly.getPath(); " + Locations + @" } </script>"; return sJScript; } catch (Exception ex) { throw ex; } } }解决方案http://www.aspdotnet-suresh.com/2013/01/adding-animated-markers-to-google-maps.html[^]
http://www.c-sharpcorner.com/uploadfile/shabdarghata/google-maps-control-for-asp-net-part-i/[^]
Google Maps API V3 for ASP.NET[^]
using google maps in asp.net with c#[^]
http://www.aspsnippets.com/Articles/ASPNet-Google-Maps-V3-with-Multiple-Markers-Database-Example.aspx
i have solved my problem succesfully..
这篇关于谷歌地图..在asp.net中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文