掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
国土地理院地図をクリックして緯度・経度を取得したい (ID:42491)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
mizukiさん質問がきっかけで、こちらのプログラムも解決しました。 自分は、しばらくHTMLから遠ざかっていましたが、以前のmizukiの質問・回答、今回の「もしも」さんの回答をDelphiとHTMLを組合わせると、いろいろなことが出来ることを再確認しました。 それにしても、「もしも」さんの回答は鮮やかでした。ありがとうございました。 当方で行ったことを簡略化すると次のとおりです。 Formのusesに MSHTML を追加。 Button1: TButton; Edit1: TEdit; Edit2: TEdit; WebBrowser1: TWebBrowser;を配置する。 以下、コートは次のとおりです。 ---------------------------------- unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.OleCtrls, SHDocVw, Vcl.StdCtrls, MSHTML; type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; Edit2: TEdit; WebBrowser1: TWebBrowser; procedure FormShow(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private 宣言 } procedure Get_Longitude_Latitude; public { Public 宣言 } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin Get_Longitude_Latitude; end; procedure TForm1.FormShow(Sender: TObject); begin WebBrowser1.Navigate('http://watchizu.gsi.go.jp/watchizu.html?longitude=139.81&latitude=35.71'); end; procedure TForm1.Get_Longitude_Latitude; var Document: IHTMLDocument3; ND,NM, ED,EM: Integer; NS,ES: Double; begin Document := WebBrowser1.Document as IHTMLDocument3; if Assigned(Document) then begin ND := StrToInt(Document.getElementById('ND').innerText); NM := StrToInt(Document.getElementById('NM').innerText); NS := StrToFloat(Document.getElementById('NS').innerText); ED := StrToInt(Document.getElementById('ED').innerText); EM := StrToInt(Document.getElementById('EM').innerText); ES := StrToFloat(Document.getElementById('ES').innerText); Edit1.Text := Format('北緯%3d度%.2d分%f秒', [ND,NM,NS]); Edit2.Text := Format('東経%3d度%.2d分%f秒', [ED,EM,ES]); end; end; end.
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.