2017-01-15 14 views
-3

GoogleマップライブラリでDelphi Xe4を使用しています。顧客がdbgridで扱うサンプルアプリケーションを作成しました。私はウェブブラウザが割り当てられていません

をしたのDBGridイベントで

手順TForm1.DBGrid1DblClick(送信者:TObjectを); var endereco:string; pesquisarendereco:string;

WebBrowser1.Enabled := True; 
    GMMap1.Active := True; 

    if dsClienteEndereco.DataSet.RecordCount > 0 then 

    begin 

    GMGeoCode1.Geocode(qryClienteEndereco.FieldByName('ENDERECORESIDENCIA').AsString); 
    endereco := qryClienteEnderecoENDERECORESIDENCIA.Value; 

    GMMarker1.Items[dsClienteEndereco.DataSet.Recno].CenterMapToMarker; 

    pesquisarendereco:='http://maps.google.com/maps?q='+endereco; 
    WebBrowser1.Navigate(pesquisarendereco); 

    end; 

終わりを始めます。

しかし、私がダブルクリックすると、私にメッセージが表示されます:webbrowser not assinged。

どうすれば解決できますか?

ベスト アンダーソン

+0

エラーメッセージは何ですか。それを完全に、そのままにしてください。 –

+0

こんにちは、メッセージは:WebBrowserが割り当てられていません。私がOKをクリックすると、アプリケーションに戻ります。 –

+1

地図とブラウザを関連付ける必要があります。 –

答えて

1

GMMarker1を経由して、マップにアイテムを追加する前に、ジオコーダは、有効な座標を返すことを確認する必要があります。有効な座標を取得すると、GMMarker1コンポーネントは、ジオコーダーから緯度と経度を使用してマーカーを追加すると予測します。これを試してみてください:

WebBrowser1.Enabled := True; 
    GMMarker1.Map := GMMap1; 
    GMMap1.WebBrower := WebBrowser1; 
    GMMap1.Active := True; 

    if dsClienteEndereco.DataSet.RecordCount > 0 then 
    begin 

     GMGeoCode1.Geocode(qryClienteEndereco.FieldByName('ENDERECORESIDENCIA').AsString); 
     If GmGeoCode1.Count <> 0 then 
     begin 
     endereco := qryClienteEnderecoENDERECORESIDENCIA.Value; 
     GMMarker1.Add(GmGeoCode1[0].Geometry.Location.Lat, GmGeoCode1[0].Geometry.Location.Lng, endereco); 
     GMMarker1.items[GMMarker1.Count-1].CenterMapToMarker; 

     // you shouldn't need these lines, the WebBrowser should navigate on its own 
     //pesquisarendereco:='http://maps.google.com/maps?q='+endereco; 
     //WebBrowser1.Navigate(pesquisarendereco); 
     end; 

    end; 
+0

私はあなたのコードを変更しました。アプリケーションを実行するとエラーメッセージ "DoMap is undefined"が返されます。続行するにはYesをクリックし、エラー80020101のために操作を完了できませんでした。 –

+0

私はリンクhttp://stackoverflow.com/questions/26467638/gmlib-google-maps-infowindow-errorとhttp://stackoverflow.com/questions/37175704/gmlib-could-not-complete-theoperation -due-to-error-80020101-v1-5-3とアプリケーションが動作します。今、私はマップ上のアドレスショーのクリックを開くが、マップが1ミリ秒をリフレッシュしているようだ。これをどのように変更できますか?クリックした場合のみ変更できますか? –

+0

質問を更新してあなたの現在のコードをすべて含める必要があります。 –

-1

私はDBGridのダブルクリックを変更:

procedure TformHistoricoRotas.DBGrid1DblClick(Sender: TObject); 

var 
endereco : string; 
pesquisarendereco : string; 
Marker :TMarker; 

begin  

WebBrowser1.Enabled := True; 
GMMarker1.Map := GMMap1; 
GMMap1.WebBrowser := WebBrowser1; 

GMMap1.Active := True; 
if dsClienteEndereco.DataSet.RecordCount > 0 then 
begin 
GMGeoCode1.Geocode(qryClienteEndereco.FieldByName('ENDERECORESIDENCIA').AsString); 
If GmGeoCode1.Count <> 0 then 
begin 
endereco := IntToStr(qryClienteEnderecoPRIORIDADE.Value)+', '+qryClienteEnderecoCHECKOUT.Value+', '+qryClienteEnderecoENDERECORESIDENCIA.Value; 
GMMarker1.Add(GmGeoCode1[0].Geometry.Location.Lat, GmGeoCode1[0].Geometry.Location.Lng, endereco); 
//GMMarker1.Add(GmGeoCode1[0].Geometry.Location.Lat, GmGeoCode1[0].Geometry.Location.Lng, endereco); 
GMMarker1.items[GMMarker1.Count-1].CenterMapToMarker; 
GMMap1.Precision := 30; 
end; 
end; 
end; 

、それが働きました。

ここで、ウェブブラウザ内のGoogleマップに表示されるdbgridの行をクリックします。