0

Googleマップv3でカスタムマーカー画像を回転させる方法を4〜5時間グーグルで調べた後、ここにこの質問を投稿しています。例を挙げて解決策を提案してください。

4

3 に答える 3

-5
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;


public partial class NewFolder1_Rotatev3 : System.Web.UI.Page
{
string line;
System.IO.StreamReader file = null;
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        file = new System.IO.StreamReader("D:\\GoogleMapsDemo\\Files\\closepoints.txt");
        ScriptManager.RegisterStartupScript(Page, typeof(Page), "_ShowHideBusiJust_", "i();", true);
        Session["file"] = file;
    }
}
protected void Timer1_Tick(object sender, EventArgs e)
{
    file = (System.IO.StreamReader)Session["file"];
    string[] strdata = null;
    line = file.ReadLine();
    if (line != null)
    {
        strdata = line.Split('\t');
        string j = strdata[0];
        string k = strdata[1];
        Session["Lat"] = j;
        Session["Long"] = k;
        int R = 6371; // km
        double lat1 =HiddenField1.Value != null ? Convert.ToDouble(HiddenField1.Value) : 0;
        double lat2 = Convert.ToDouble(j);
        double lon1 = HiddenField2.Value != null ? Convert.ToDouble(HiddenField2.Value) : 0;
        double lon2 =Convert.ToDouble(k);
        if (!(lat2 == 0 && lon2 == 0))
            {

            var dLat = DegreeToRadian((lat2 - lat1));
            var dLon = DegreeToRadian((lon2 - lon1));
            lat1 = DegreeToRadian(lat1);
            lat2 = DegreeToRadian(lat2);
            var a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) +
            Math.Sin(dLon / 2) * Math.Sin(dLon / 2) * Math.Cos(lat1) * Math.Cos(lat2);
            var c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
            var d = R * c;
            var y = Math.Sin(dLon) * Math.Cos(lat2);
            var x = Math.Cos(lat1) * Math.Sin(lat2) -
                    Math.Sin(lat1) * Math.Cos(lat2) * Math.Cos(dLon);
            var brng = (Math.Atan2(y, x));
            var last = RadianToDegree(brng);
            Label2.Text = Convert.ToString(d);
            string i = Convert.ToString(last);
            Session["Angle"] = i;
            string script = string.Format("i({0},{1},{2});",
                              i.ToString(), j.ToString(), k.ToString());
        ClientScript.RegisterStartupScript(this.GetType(), "RefreshOpener", script, true);
        //System.Threading.Thread.Sleep(1000);
        //strdata[0]   - Latitude
        //strdata[1]   - Langitude
            }

    }
    else
    {
        string i = Convert.ToString(Session["Angle"]);
        string j = Convert.ToString(Session["Lat"]);
        string k = Convert.ToString(Session["Long"]);
        string script = string.Format("i({0},{1},{2});",
                              i.ToString(), j.ToString(), k.ToString());
        ClientScript.RegisterStartupScript(this.GetType(), "RefreshOpener", script, true);
        Timer1.Enabled = false;

    }
    Session["file"] = file;
}
 private double DegreeToRadian(double angle)
{
    return Math.PI * angle / 180.0;
}
private double RadianToDegree(double angle)
{
    return angle * (180.0 / Math.PI);
}

}
于 2013-01-15T06:20:49.050 に答える