问题描述
本人初学MO,现在用C#做一个中国地图的练习,现已知道怎样显示地理坐标和投影坐标,用GeoCoordSys和ProjCoordSys。使用如下代码设置地图使用地理坐标系显示。ESRI.MapObjects2.Core.GeoCoordSysgcs=newGeoCoordSysClass();gcs.Type=GeographicCoordSysConstants.moGeoCS_WGS1984;axMap1.CoordinateSystem=gcs;但是给地图使用这些坐标系后,添加标记点功能就不好用了(不设置地图坐标系时,添加标记点功能好用的)请问如何解决此问题?另外看教程说可以转换坐标系,但是给的例子都是VB的代码,看不懂,能给C#代码就更好了,请高手帮忙,指点。转贴的先看一下下面的帖子,里面有的就不用转了,谢谢!http://topic.csdn.net/u/20091026/14/715b9666-bd1b-429e-a020-fd94f4a3c0d9.html
解决方案
解决方案二:
地图坐标系应该跟数据坐标系吻合吧!!!
解决方案三:
数据坐标系是什么?我只知道设置地理坐标系(GeoCoordSys)和设置投影坐标系(ProjCoordSys)。
解决方案四:
MO没怎么用过.MapX的话,添加标注的图层有范围设置的。不在范围内的会添加不了不知道MO是不是也有这个问题
解决方案五:
MapObjects2.GeoTransformation这个类有会用的么?教程上就是用这个类转换的。可惜是VB的代码看不太懂。
解决方案六:
把VB代码贴出来,大家帮你翻译。
解决方案七:
DimfromPTasNewMapObjects2.pointDimtoPTasNewMapObjects2.pointDimcurMapasIntegerDimsymPTasNewMapObjects2.SymbolDimgcsasNewMapObjects2.GeoCoordSysDimpcsasNewMapObjects2.ProjCoordSysPrivateFuntiontransformPoint(directionAsMapObjects2.DirectionConstants,ptlnAsMapObjects2.Point)AsPoint'Here,anappropriateGeoTransformationiscreatedfortransformingtheselected'Point.ThisshouldbechangedappropriatelyfortheCoordinateSystemofyourMap2MapLayer.DimmyGTasNewMapObjects2.GeoTransformationDimgcsBJ54asNewMapObjects2.GeoCoordSysDimgceWGS84asNewMapObjects2.GeoCoordSysgcsBJ54.Type=moGeoCS_Beijing1954gceWGS84.Type=moGeoCS_WGS1984SetmyGT.ToGeoCoordSys=gcsWGS84SetmyGT.FromGeoCoordSys=gcsBJ54myGT.Method=moMethod_PositionVectormyGT.SetParametermoParm_DeltaX,24myGT.SetParametermoParm_DeltaY,-123myGT.SetParametermoParm_DeltaZ,-94myGT.SetParametermoParm_RotationX,-0.02myGT.SetParametermoParm_RotationY,-0.25myGT.SetParametermoParm_RotationZ,-0.13myGT.SetParametermoParm_DeltaScale,1myGT.direction=moDirection_ForwardmyGT.Name="BJ54_To_WGS1984"'myGT.Type=moGeoTransformation_Tokyo_To_WGS1984_3'Settheappropriatedirection,FromGeoCoordSysandToGeoCoordSysmyGT.direction=direction'ACoordinateSystemmaybeeitherProjCoordSysorGeoCoordSys.'WeneedtocheckifthetypebeforeassigningtheFromGeoCoordSysandToGeoCoordSysDimmap1ProjectedasBooleanDimmap2ProjectedasBooleanIfMap1.CoordinateSystem.IsProjectedThenmap1Projected=TrueElsemap1Projected=FalseEndIfIfMap2.CoordinateSystem.IsProjectedThenmap2Projected=TrueElsemap2Projected=FalseEndIf'IfchangingfromWGS1984tootherdatumIfdirection=moDirection_ForwardThenIfmap1ProjectedThenmyGT.FromGeoCoordSys=Map1.CoordinateSystem.GeoCoordSysElsemyGT.FromGeoCoordSys=Map1.CoordinateSystemEndIfIfmap2ProjectedThenmsGT.ToGeoCoordSys=Map2.CoordinateSystem.GeoCoordSysElsemsGT.ToGeoCoordSys=Map2.CoordinateSystemEndIfSettransformPoint=Map2.CoordinateSystem.Transform(Map1.CoordinateSystem,fromPt,,myGT)ElseIfdirection=moDirection_ReverseThenIfmap1ProjectedThenmsGT.ToGeoCoordSys=Map1.CoordinateSystem.GeoCoordSysElsemsGT.ToGeoCoordSys=Map1.CoordinateSystemEndIfIfmap2ProjectedThenmyGT.FromGeoCoordSys=Map2.CoordinateSystem.GeoCoordSysElsemyGT.FromGeoCoordSys=Map2.CoordinateSystemEndIfSettransformPoint=Map2.CoordinateSystem.Transform(Map2.CoordinateSystem,fromPt,,myGT)EndIfEndFunction--------------------------------------------------------------------PrivateSubMap1_AfterTrackingLayerDraw(ByValhDCAsstdole.OLE_HANDLE)If(NotfromPtIsNothing)AndcurMap=1Thensym.Color=moBlueMap1.DrawShapefromPt,symEndIfIf(NottoPtIsNothing)AndcurMap=2Thensym.Color=moRedMap1.DrawShapetoPt,symEndIfEndSub----------------------------------------------------------------------PrivateSubMap1_MouseDown(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)SetfromPt=Map1.ToMapPoint(X,Y)SettoPt=transformPoint(moDirection_Forward,fromPt)curMap=1Map1.TrackingLayer.Refresh(true)Map2.TrackingLayer.Refresh(true)EndSub-----------------------------------------------------------------------PrivateSubMap2_AfterTrackingLayerDraw(ByValhDCAsstdole.OLE_HANDLE)If(NotfromPtIsNothing)AndcurMap=2Thensym.Color=moBlueMap2.DrawShapefromPt,symEndIfIf(NottoPtIsNothing)AndcurMap=1Thensym.Color=moRedMap2.DrawShapetoPt,symEndIfEndSub----------------------------------------------------------------------PrivateSubMap2_MouseDown(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)SetfromPt=Map2.ToMapPoint(X,Y)SettoPt=transformPoint(moDirection_Reverse,fromPt)curMap=2Map1.TrackingLayer.Refresh(true)Map2.TrackingLayer.Refresh(true)EndSub-----------------------------------------------------------------------PrivateSubForm_Load()'Map1shouldcontainaMapLayerbasedontheWGS1984Datum,forexampletheWorldCountriessampledataset.Dimdc1AsNewMapObjects2.DataConnectionDimmlyr1AsNewMapObjects2.MapLayerDimmlyr2AsNewMapObjects2.MapLayerdc1.Database=App.PathSetmlyr1.GeoDataset=dc1.FindGeoDataset("china")Map1.Layers.Addmlyr1Setmlyr2.GeoDataset=dc1.FindGeoDataset("china_prj")Map2.Layers.Addmlyr2'Map2shouldcontainaMapLayerbasedonadifferentDatum'YoushouldensuretheCoordinateSystemofbothlayersissetcorrectly.pcs.Type=moProjCS_Beijing1954GK_17NMap2.Layers(0).CoordinateSystem=pcsgcs.Type=moGeoCS_WGS1984Map1.Layers(0).CoordinateSystem=gcs'HeretheCoordinateSystemofeachmapissettotheCoordinateSystemofitsMapLayerMap1.CoordinateSystem=Map1.Layers(0).CoordinateSystemMap2.CoordinateSystem=Map2.Layers(0).CoordinateSystemWithsym.SymbolType=moPointSymbol.Size=4.Outline=False.Style=moTriangleMarkerEndWithEndSub
解决方案八:
请高手帮忙翻译成C#代码,感激不尽!
解决方案九:
mark
解决方案十:
唉!哪个高手来帮帮忙啊!!!
解决方案十一:
回复内容太短了!学习...