ThinkGeo.com    |     Documentation    |     Premium Support

Add markers (lat/lon) using google maps layers (meters)

Hi



I have to add many markers to a map layer (Mercator-google ) I tried with the code below but markers dont show the markers are (Lat/lon) and I tried to convert to meters but I have no results  can anyone help me with some example or help to change this?



thanks



regards











                GoogleMapsOverlay googleMapsOverlay = new GoogleMapsOverlay();




                mapHolder.MapUnit = GeographyUnit.Meter;




                mapHolder.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255));




                mapHolder.ThreadingMode = MapThreadingMode.SingleThreaded;




                mapHolder.CurrentExtent = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962);




                Proj4Projection proj4 = new Proj4Projection();




                proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);




                proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();




                InMemoryMarkerOverlay inMemoryMarkerOverlay = new InMemoryMarkerOverlay();




                inMemoryMarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.Image = Properties.Resources.AQUA;  




                inMemoryMarkerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;




                // add many locations lat,long





                Feature newFeature = new Feature(32.642776, -115.431203);



               


                


                inMemoryMarkerOverlay.FeatureSource.Projection = proj4;


                inMemoryMarkerOverlay.FeatureSource.BeginTransaction();


                inMemoryMarkerOverlay.FeatureSource.AddFeature(newFeature);


                inMemoryMarkerOverlay.FeatureSource.CommitTransaction();



                googleMapsOverlay.MapType = GoogleMapsMapType.RoadMap;



                mapHolder.Overlays.Add(googleMapsOverlay);


                inMemoryMarkerOverlay.MapControl = mapHolder;



                mapHolder.Overlays.Add("MarkerOverlay", inMemoryMarkerOverlay);



                mapHolder.Refresh();   




Hi Daniel, 
  
 Please convert the feature to 900913 projection before add it to map. 
  
 Feature newFeature = new Feature(32.642776, -115.431203); // This coordinate should under 4326 
  
 Regards, 
  
 Don

can you give an example about this conversion?



I have many points in lat/lon



can I convert to 4326 format on fly?





thanks

Hi Daniel, 
  
 You can convert that on fly, the conversion is simple like this: 
  
      Proj4Projection proj4 = new Proj4Projection(); 
             proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); 
             proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString(); 
             proj4.Open(); 
  
             Feature newFeature = proj4.ConvertToExternalProjection(new Feature(32.642776, -115.431203)); 
  
 Regards, 
  
 Don