Hi Rossko:
acctually I make my code more simple :
Javascript code :
var latlngArray = null;
var ThisCarDeviceId = null;
var AutoScaleFlagBool = null;
function load(y, x) {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(x, y), 17);
map.setMapType(G_HYBRID_MAP);
map.addControl(new GSmallMapControl());
map.addControl(new GScaleControl());
map.addControl(new GMapTypeControl());
map.addControl(new GOverviewMapControl());
var ppgicon = new new GIcon(G_DEFAULT_ICON);
ppgicon.src = strimg;
ppgicon.iconSize = new GSize(24, 24);
ppgicon.iconAnchor = new GPoint(12, 12);
ppgicon.infoWindowAnchor = new GPoint(0, 24);
ppgicon.transparent = null;
ppgicon.imageMap = null;
var latlng = new GLatLng(y, x);
if (!isDefined(latlngArray)) {
latlngArray = new Array();
}
latlngArray.push(latlng);
if (isDefined(ThisCarDeviceId))
if (ThisCarDeviceId == deviceid) {
DESTINATION_MARKER = new GMarker(latlng, ppgicon);
map.addOverlay(DESTINATION_MARKER);
}
}
******my C# code(gmap.aspx.cs) ***********
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Globalization;
using System.Collections;
using System.Data.SqlClient;
using System.Text;
using System.Web.Configuration;
public partial class _Default : System.Web.UI.Page
{
#region OtherClass 其他類別
public class CarDataClass
{
public CarDataClass(string x, string y)
{
X = x;
Y = y;
DeviceId = deviceid;
}
private string deviceid = "";
public string DeviceId
{
get
{
return deviceid;
}
set
{
deviceid = value;
}
}
private string x = "";
public string X
{
get
{
return x;
}
set
{
x = value;
}
}
private string y = "";
public string Y
{
get
{
return y;
}
set
{
y = value;
}
}
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
}
#region RetailTimeTracking即時追蹤
private void GetTrackingInfo()
{
string DB_CONN_STR =
ConfigurationManager.ConnectionStrings["AVLConnectionString"].ConnectionString;
SqlConnection storeConn = new SqlConnection();
SqlCommand cmd = storeConn.CreateCommand();
SqlDataReader dr = null;
ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
"ClearMSG", "ClearCar();", true);
try
{
storeConn.ConnectionString = DB_CONN_STR;
storeConn.Open();
string SqlStr = "SELECT TOP 1 X,Y FROM Tracking WHERE
DeviceNumber='358244017664774' ORDER BY TimeStamp DESC";
cmd.CommandText = SqlStr.ToString();
cmd.Connection = storeConn;
cmd.CommandType = CommandType.Text;
cmd.Parameters.Clear();
dr = cmd.ExecuteReader();
if (dr.Read())
{
CarDataClass carData = new CarDataClass("","");
carData.X = dr["X"].ToString();
carData.Y = dr["Y"].ToString();
ScriptManager.RegisterClientScriptBlock(this,
this.GetType(), "msg", "load(" + Convert.ToDecimal(carData.Y) / 1000000 + ","
+ Convert.ToDecimal(carData.X) / 1000000 +"');", true);
}
}
catch (Exception ex)
{
ex.Message.ToString();
}
finally
{
if (dr != null)
{
dr.Close();
dr.Dispose();
}
cmd.Dispose();
storeConn.Close();
storeConn.Dispose();
}
}
#endregion
}
My page link is : http://219.84.151.30/gmap.aspx
need help;
Rossko <[email protected]> wrote:
>
> > what is wrong in that code ..please help.
>
> No idea. Perhaps the data is wrong, rather than the code. Can't tell
> with a code snippet out of context. How about letting us see your
> page in action in posting a URL to it?
>
http://groups.google.com/group/Google-Maps-API/web/suggested-posting-guidelines
>
> As a starter, do you realise this usage -
> var map = null;
> function load( ....) {
> var map = ....
> makes two different variables called 'map', one global and one local
> to the function ?
>
> cheers, Ross K
>
> >
>
Tamer Hatoum;
Web Developer and Programmer;
Qatar Navigator Est;
Tel: +974 6026267;
[email protected]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---