123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "AppGlobalF.h"
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "ITSLangTransF.h"
- #pragma hdrstop
- #include "FRAME_GoogleMapF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "GMClasses"
- #pragma link "GMMap"
- #pragma link "GMMapVCL"
- #pragma link "GMLinkedComponents"
- #pragma link "GMMarker"
- #pragma link "GMMarkerVCL"
- #pragma link "cxCheckBox"
- #pragma link "cxButtons"
- #pragma link "cxContainer"
- #pragma link "cxControls"
- #pragma link "cxEdit"
- #pragma link "cxGraphics"
- #pragma link "cxLabel"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma link "dxSkinBlack"
- #pragma link "dxSkinBlue"
- #pragma link "dxSkinCaramel"
- #pragma link "dxSkinCoffee"
- #pragma link "dxSkinDarkRoom"
- #pragma link "dxSkinDarkSide"
- #pragma link "dxSkinFoggy"
- #pragma link "dxSkinGlassOceans"
- #pragma link "dxSkiniMaginary"
- #pragma link "dxSkinLilian"
- #pragma link "dxSkinLiquidSky"
- #pragma link "dxSkinLondonLiquidSky"
- #pragma link "dxSkinMcSkin"
- #pragma link "dxSkinMoneyTwins"
- #pragma link "dxSkinOffice2007Black"
- #pragma link "dxSkinOffice2007Blue"
- #pragma link "dxSkinOffice2007Green"
- #pragma link "dxSkinOffice2007Pink"
- #pragma link "dxSkinOffice2007Silver"
- #pragma link "dxSkinOffice2010Black"
- #pragma link "dxSkinOffice2010Blue"
- #pragma link "dxSkinOffice2010Silver"
- #pragma link "dxSkinsCore"
- #pragma link "dxSkinSeven"
- #pragma link "dxSkinSharp"
- #pragma link "dxSkinSilver"
- #pragma link "dxSkinStardust"
- #pragma resource "*.dfm"
- TFRAMEGoogleMap *FRAMEGoogleMap;
- //---------------------------------------------------------------------------
- __fastcall TFRAMEGoogleMap::TFRAMEGoogleMap(TComponent* Owner)
- : TFrame(Owner)
- {
- LangTrans->Translate(this, ITSDb_GetConnection());
- ITSSkin_Load((TForm*)this);
- LoadLocalSkin();
- FOnDrawFacilityClick = NULL;
- FOnZoomChangeClick = NULL;
- memset((char*) & FPrev, 0x00, sizeof(FPrev));
- memset((char*) & FExtent, 0x00, sizeof(FExtent));
- FExtent.Extent = true;
- FExtent.TotCnt = 0;
- FExtent.CurIdx = 0;
- FMapZoom = g_GisInfo.nZoomLevel;
- FBaseZoom = FMapZoom;
- GMMap1->RequiredProp->Zoom = FBaseZoom;
- GMMap1->RequiredProp->Center->Lat = g_GisInfo.dCenterX;
- GMMap1->RequiredProp->Center->Lng = g_GisInfo.dCenterY;
- FMapTypeId = mtTERRAIN;
- LblZoom->Caption = "Zoom: " + String(FMapZoom) + " ";
- FCenLatLng = new TLatLng(GMMap1->RequiredProp->Center->Lat, GMMap1->RequiredProp->Center->Lng);
- FMapBounds = new TLatLngBounds(0, 0, 0, 0);
- FCenterLat = GMMap1->RequiredProp->Center->Lat;
- FCenterLng = GMMap1->RequiredProp->Center->Lng;
- //LoadGisMap();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::LoadLocalSkin()
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::LoadGisMap()
- {
- if (!GMMap1->Active)
- {
- try {
- if (ImgLoading->Picture->Graphic->ClassName() == "TGIFImage")
- ((TGIFImage *)ImgLoading->Picture->Graphic)->Animate = true;
- Application->ProcessMessages();
- ImgLoading->Visible = true;
- } catch(...) {}
- GMMap1->Active = true;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::SetLinkLevel(int ALinkLevel)
- {
- FLinkLevel = ALinkLevel;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::ShowHideTrafficLayer(bool AShow)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::SelectObjectByPos(double dPosX, double dPosY, bool bArrow/*=false*/)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::SelectObjectByPos()
- {
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFRAMEGoogleMap::SelectLinkByPos(int X, int Y, String &ALinkId)
- {
- return false;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFRAMEGoogleMap::GetLevelLinkId(int ALinkLevel, String &sLinkId, int X, int Y)
- {
- return false;
- }
- //---------------------------------------------------------------------------
- int __fastcall TFRAMEGoogleMap::GetLayerIndex()
- {
- return 0;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::SelGisItem(int AType, String AId)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::OnCloseQuery(bool &CanClose)
- {
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFRAMEGoogleMap::AddExtentQ(double ALat, double ALng, int FZoom)
- {
- TMapExtent *pExt = &FExtent.extent[FExtent.TotCnt];
- pExt->Lat = ALat;
- pExt->Lng = ALng;
- pExt->Zoom = (short)FZoom;
- if (FPrev.Lat == pExt->Lat && FPrev.Lng == pExt->Lng && FPrev.Zoom == pExt->Zoom)
- {
- return false;
- }
- // MAPDEBUG("AddExtentQ: " + String(FExtent.TotCnt));
- FPrev.Lat = pExt->Lat;
- FPrev.Lat = pExt->Lng;
- FPrev.Zoom = pExt->Zoom;
- FExtent.TotCnt++;
- if (FExtent.TotCnt >= D_EXT_QUEUE_SIZE)
- {
- FExtent.TotCnt = D_EXT_QUEUE_SIZE;
- memcpy((char*) & FExtent.extent[0], (char*) & FExtent.extent[1], sizeof(TMapExtent) * D_EXT_QUEUE_SIZE);
- }
- FExtent.CurIdx = FExtent.TotCnt - 1;
- if (FExtent.TotCnt > 1)
- {
- // BtnZoomPrev->Enabled = true;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- /*!
- * @fn TFRMFC090000::PrevExtentQ
- * @brief PrevExtentQ
- * @param void
- * @return bool 결과
- */
- bool __fastcall TFRAMEGoogleMap::PrevExtentQ()
- {
- FExtent.Extent = false;
- if (FExtent.CurIdx <= 0)
- {
- FExtent.CurIdx = 0;
- return false;
- }
- FExtent.CurIdx--;
- if (FExtent.CurIdx == 0)
- {
- // BtnZoomPrev->Enabled = false;
- }
- try
- {
- TMapExtent *pExt = &FExtent.extent[FExtent.CurIdx];
- if (GMMap1->Active)
- {
- GMMap1->SetCenter(pExt->Lat, pExt->Lng);
- GMMap1->RequiredProp->Zoom = (int)pExt->Zoom;
- }
- // BtnZoomNext->Enabled = true;
- }
- catch(...)
- {
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFRAMEGoogleMap::NextExtentQ()
- {
- FExtent.Extent = false;
- if (FExtent.CurIdx >= FExtent.TotCnt - 1)
- {
- FExtent.CurIdx = FExtent.TotCnt - 1;
- return false;
- }
- FExtent.CurIdx++;
- if (FExtent.CurIdx == FExtent.TotCnt - 1)
- {
- // BtnZoomNext->Enabled = false;
- }
- try
- {
- TMapExtent *pExt = &FExtent.extent[FExtent.CurIdx];
- if (GMMap1->Active)
- {
- GMMap1->SetCenter(pExt->Lat, pExt->Lng);
- GMMap1->RequiredProp->Zoom = (int)pExt->Zoom;
- }
- // BtnZoomPrev->Enabled = true;
- }
- catch(...)
- {
- }
- return true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::WebBrowser1DownloadComplete(TObject *Sender)
- {
- // 웹페이지 스크롤바 없애기
- #if 0
- try
- {
- Variant vBody;
- Variant vObj = WebBrowser1->OleObject;
- String strDocCompatMode = vObj.OlePropertyGet("document").OlePropertyGet("compatMode");
- if (SameText(strDocCompatMode, "CSS1Compat"))
- vBody = vObj.OlePropertyGet("Document").OlePropertyGet("documentElement");
- else
- vBody = vObj.OlePropertyGet("Document").OlePropertyGet("body");
- vBody.OlePropertyGet("style").OlePropertySet("overflow", "hidden");
- }
- catch(Exception &e)
- {
- }
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::GMMap1AfterPageLoaded(TObject *Sender, bool First)
- {
- if (First)
- {
- GMMap1->DoMap();
- GMMap1->Tag = 1;
- PnlToolbar->Enabled = true;
- ImgLoading->Visible = false;
- try {
- if (ImgLoading->Picture->Graphic->ClassName() == "TGIFImage")
- ((TGIFImage *)ImgLoading->Picture->Graphic)->Animate = false;
- } catch(...) {}
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::GMMap1BoundsChanged(TObject *Sender, TLatLngBounds *NewBounds)
- {
- if (FMapBounds)
- {
- FMapBounds->SW->Lat = NewBounds->SW->Lat;
- FMapBounds->SW->Lng = NewBounds->SW->Lng;
- FMapBounds->NE->Lat = NewBounds->NE->Lat;
- FMapBounds->NE->Lng = NewBounds->NE->Lng;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::GMMap1ZoomChanged(TObject *Sender, int NewZoom)
- {
- FMapZoom = NewZoom;
- try
- {
- int nLineWidth;
- if (FMapZoom > 14)
- nLineWidth = 5;
- else
- nLineWidth = 3;
- #if 0
- if (nLineWidth == FLineWidth)
- return;
- FLineWidth = nLineWidth;
- try
- {
- GMPolyline1->Map = NULL;
- int nPolylines = GMPolyline1->Count;
- for (int ii = nPolylines - 1; ii >= 0; ii--)
- {
- TPolyline *pTmpLine = GMPolyline1->Items[ii];
- pTmpLine->StrokeWeight = FLineWidth;
- }
- }
- __finally
- {
- GMPolyline1->Map = GMMap1;
- }
- #endif
- if (FExtent.Extent)
- {
- AddExtentQ(GMMap1->RequiredProp->Center->Lat, GMMap1->RequiredProp->Center->Lng, NewZoom);
- }
- FExtent.Extent = true;
- }
- catch(...)
- {
- }
- LblZoom->Caption = "Zoom: " + String(FMapZoom) + " ";;
- if (FOnZoomChangeClick) FOnZoomChangeClick(Sender);
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::GMMap1DragEnd(TObject *Sender)
- {
- if (FExtent.Extent)
- {
- AddExtentQ(GMMap1->RequiredProp->Center->Lat, GMMap1->RequiredProp->Center->Lng, GMMap1->RequiredProp->Zoom);
- }
- FExtent.Extent = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::BtnMapToJpgClick(TObject *Sender)
- {
- try
- {
- if (GMMap1->Active)
- {
- SaveDialog1->FileName = Now().FormatString("YYYYMMDDHHNNSS") + ".jpg";
- if (SaveDialog1->Execute())
- {
- GMMap1->SaveToJPGFile(SaveDialog1->FileName);
- }
- }
- } catch(Exception &e) { }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::BtnMoveMapToCenterClick(TObject *Sender)
- {
- // 지도 중앙으로 이동
- try
- {
- if (GMMap1->Active)
- {
- int nZoom = GMMap1->VisualProp->ZoomCtrl->Position;
- GMMap1->SetCenter(FCenLatLng);
- if (FExtent.Extent)
- {
- AddExtentQ(GMMap1->RequiredProp->Center->Lat, GMMap1->RequiredProp->Center->Lng, GMMap1->RequiredProp->Zoom);
- }
- FExtent.Extent = true;
- }
- } catch(Exception &e) { }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::BtnMoveDefBoundsClick(TObject *Sender)
- {
- // 지도 기본영역으로 이동
- try
- {
- if (GMMap1->Active)
- {
- GMMap1->SetCenter(FCenLatLng);
- GMMap1->RequiredProp->Zoom = FBaseZoom;
- if (FExtent.Extent)
- {
- AddExtentQ(GMMap1->RequiredProp->Center->Lat, GMMap1->RequiredProp->Center->Lng, GMMap1->RequiredProp->Zoom);
- }
- FExtent.Extent = true;
- }
- } catch(Exception &e) { }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::BtnZoomInClick(TObject *Sender)
- {
- try
- {
- if (GMMap1->Active)
- {
- GMMap1->RequiredProp->Zoom = FMapZoom + 1;
- }
- } catch(Exception &e) { }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::BtnZoomOutClick(TObject *Sender)
- {
- try
- {
- if (GMMap1->Active)
- {
- if (FMapZoom > 0)
- {
- GMMap1->RequiredProp->Zoom = FMapZoom - 1;
- }
- }
- } catch(Exception &e) { }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::BtnZoomPrevClick(TObject *Sender)
- {
- PrevExtentQ();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::BtnZoomNextClick(TObject *Sender)
- {
- NextExtentQ();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::GMMap1CenterChanged(TObject *Sender, TLatLng *LatLng,
- double X, double Y)
- {
- FCenterLat = LatLng->Lat;
- FCenterLng = LatLng->Lng;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::RemoveMarker(TGMMarker *AMarker)
- {
- TGMMarker *pObjMarker = (TGMMarker*)AMarker;
- try
- {
- pObjMarker->Map = NULL;
- int nObjs = pObjMarker->Count;
- for (int ii = nObjs - 1; ii >= 0; ii--)
- {
- pObjMarker->Items[ii]->Visible = false;
- pObjMarker->Delete(ii);
- }
- pObjMarker->Clear();
- }
- catch(Exception &e)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::ChkDrawGisClick(TObject *Sender)
- {
- if (FOnDrawFacilityClick) FOnDrawFacilityClick(Sender);
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEGoogleMap::GMMap1MouseMove(TObject *Sender, TLatLng *LatLng,
- double X, double Y)
- {
- FLat = LatLng->Lat;
- FLng = LatLng->Lng;
- }
- //---------------------------------------------------------------------------
|