ThinkGeo.com    |     Documentation    |     Premium Support

Lat Long Point at Google Map Layer

Dear All,


I am tryiyng to plot a LAT LONG on google map layer. For that I have used following Attached code:




 


 


 


 



The Points are plotted but its fall outside location, while the same lat long I am plooting on google map, its plotted on location. Please help in what is the missing part in my code, so that points can be plot as desired location.



 



 


 



Hello Sanjay,


Thanks for your post, the reason is your coordinate data is not the meter format, so you need use projection to transform it.


Please try the code below:



                Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
                Map1.CurrentExtent = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962);
                Map1.MapUnit = GeographyUnit.Meter;
            
                BingMapsOverlay bingMapsOverlay = new BingMapsOverlay("BingMaps Map");
                bingMapsOverlay.JavaScriptLibraryUri = new Uri(ConfigurationManager.AppSettings["BingMapsUri"]);
                bingMapsOverlay.MapType = BingMapsStyle.Road;

                Proj4Projection proj4 = new Proj4Projection();
                proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
                proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
                InMemoryFeatureLayer pointLayer = new InMemoryFeatureLayer();
                pointLayer.FeatureSource.Projection = proj4;
                double Longitude = -95.2809;
                double Latitude = 38.9543;
                Feature GPSFeature = new Feature(new PointShape(Longitude, Latitude));
                pointLayer.InternalFeatures.Add(GPSFeature);

                pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.PointType = PointType.Bitmap;
                pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.Image = new GeoImage(MapPath("~/SampleData/USA/United States.png"));
                pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

                LayerOverlay dynamicOverlay = new LayerOverlay("DynamicOverlay");
                dynamicOverlay.Layers.Add("ShapeLayer", pointLayer);
                dynamicOverlay.IsBaseOverlay = false;

                Map1.CustomOverlays.Add(bingMapsOverlay);
                Map1.CustomOverlays.Add(dynamicOverlay);

Regards,


Gary



Dear Gary, 
  
 Thanks for Reply. 
  
 What is the format of Meter Map data. Please give example. Can I convert my cordinate data as per google map required format, becuase I set the projection and still, its not supporing. 
  
  Dim latitude As Double 
         Dim longitude As Double 
         Dim FileName As String = RootFolderName & "\Images\Aqua.png" 
         Dim winformsMap1 As WinformsMap = DirectCast(Me.WinformsMap1, WinformsMap) 
         Dim pointLayer As InMemoryFeatureLayer = Nothing 
  
         Dim txtLatitude As String = "27.13102" 
         Dim txtLongitude As String = "78.00735" 
         latitude = Convert.ToDouble(txtLatitude, CultureInfo.InvariantCulture) 
         longitude = Convert.ToDouble(txtLongitude, CultureInfo.InvariantCulture) 
        pointLayer = DirectCast(winformsMap1.FindFeatureLayer("PointLayer"), InMemoryFeatureLayer) 
         Dim proj4 As Proj4Projection = New Proj4Projection 
         proj4.InternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(4326) 
         proj4.ExternalProjectionParametersString = ManagedProj4Projection.GetGoogleMapParametersString() 
 Try 
             If pointLayer Is Nothing Then 
                 pointLayer = New InMemoryFeatureLayer 
                 pointLayer.Open() 
                 pointLayer.Columns.Add(New FeatureSourceColumn("ID")) 
                 pointLayer.Close() 
                 pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.PointType = PointType.Bitmap 
                 pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.Image = New GeoImage(FileName) 
                 pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20 
                 Dim dynamicOverlay As New LayerOverlay() 
                 dynamicOverlay.Layers.Add("PointLayer", pointLayer) 
                 dynamicOverlay.IsBase = False 
                 winformsMap1.Overlays.Add("PointOverlay", dynamicOverlay) 
             End If 
         Catch ex As KeyNotFoundException 
             pointLayer = New InMemoryFeatureLayer 
             pointLayer.Open() 
             pointLayer.Columns.Add(New FeatureSourceColumn("ID")) 
             pointLayer.Close() 
             pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.PointType = PointType.Bitmap 
             pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.Image = New GeoImage(FileName) 
             pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20 
             Dim dynamicOverlay As New LayerOverlay() 
             dynamicOverlay.Layers.Add("PointLayer", pointLayer) 
             dynamicOverlay.IsBase = False 
             winformsMap1.Overlays.Add("PointOverlay", dynamicOverlay) 
         Finally 
             SearchId = SearchId + 1 
             Dim feature As New Feature(longitude, latitude, SearchId) 
             feature.ColumnValues.Add("ID", SearchId) 
             pointLayer.InternalFeatures.Add(SearchId, feature) 
             pointLayer.FeatureSource.Projection = proj4 
             winformsMap1.CenterAt(New PointShape(longitude, latitude)) 
             winformsMap1.Refresh(winformsMap1.Overlays("PointOverlay")) 
         End Try 
  
 Please reply. 
 Regards 
 Sanjay

Hello Sanjay, 
  
 It will work as soon as you set the right projection to pointlayer. What’s the situation you met? It did’nt shows on the map, or actually it shows but you didn’t see it because your extent is in wrong place? Because I saw this code: 
  
 winformsMap1.CenterAt(New PointShape(longitude, latitude))  
  
 This PointShape didn’t get the projection transform, could you please remove this and zoom the map to the right place and have a check? 
  
 Regards, 
  
 Gary