ThinkGeo.com    |     Documentation    |     Premium Support

Adding BaseShape as Feature on Map

When trying to plot a project coordinate system on the web map I have been encountering a problem with the shape showing correctly. I am using Visual Studio 2008 C#. 


Here is an example straight from my solution:       


for (int j = 0; j < _ProjectList.GPSCoordinateList.Count; j++)

      {


                 PointShape upperleftpoint = new PointShape(_ProjectList.GPSCoordinateList[j].WestLongitude, _ProjectList.GPSCoordinateList[j].NorthLatitude);

                 PointShape lowerrightpoint = new PointShape(_ProjectList.GPSCoordinateList[j].EastLongitude, _ProjectList.GPSCoordinateList[j].SouthLatitude);




                 RectangleShape rectShape = new RectangleShape(upperleftpoint, lowerrightpoint);

                     

                 Map1.EditLayer.Features.Add(_ProjectList.SubdivCode + j, new Feature(rectShape, _ProjectList.ProjectID + "." + j));



                 Marker marker = new Marker(rectShape.GetCenterPoint());


      }


Now, the values for a specific example coming in are: WestLongitude(-112.232190914766), NorthLatitude(33.6757), EastLongitude(-112.225855765649), SouthLatitude(33.6407743278834).


The Marker center point is X(-112.2290233402075), Y(33.6582371639417) and maps correctly, but the actual rectangle shape maps far off from the points gathered. It actually seems as if the shape layers move when zooming and get further away when zooming out. 


Please..... Anyone with any suggestions????


Thanks in advance!



Cruz,


Your c# code works well. The problem might be in the HTML.

 

If I just drag and drop the map in the page, the result is fine with your code. But if the map is inside a div or a table which is marked “Align=’center’”, I see the problem you described. For example, with the following code in aspx, I recreated your issue. (see Figure 1)


< div align=”center” >
< cc1:Map ID=”Map1” runat=”server” height=”477px” width=”729px” >
< /cc1:Map >
< /div >


 


 

The best way to solve it is adding the “textAlign: Left” style to map control, as following. The result is like Figure 2

 < cc1:Map ID=”Map1” runat=”server” height=”477px” width=”729px” style=”text-align:left” >



Here is my test sample (in VS2008, C#). Have a look at the aspx file to see how to make it work. 

 

In the next beta we will make sure the map control write out the align left style be default.  Thanks for finding and reporting this.

 

Ben.



72-LayerMovesWhenZoomingForCruz.zip (98.3 KB)