Need Sample to show steetmap, building, ect.

Topics: SharpMap Project, WinForms Controls
Jun 15, 2010 at 3:42 AM

Hallo Sharpmap team, I extreamly appreciate to all of you, I want to try to use sharpmap in my job, can I get sample code to show citymap like on citymap.png on http://sharpmap.codeplex.com/wikipage?title=Screenshots&referringTitle=Home 

Regards

Coordinator
Jun 16, 2010 at 12:02 PM

Hello d2ng,

I just added a new sample to the WinFormSamples project, which might give you an idea of how to do that.

To see it work, you have to get the latest source.

Hth FObermaier

Jun 20, 2010 at 12:23 PM

Thank you very much for your quick replay FObermaier,

I have already running your ShapefileSampleOsm sample, Great, Excellent.

I have some questions, please explain to me :

1. How can I draw Text like Disclaimer, but base on my Lat/Long, give me example please.

2. Map.MaxZoom ?

3. Map.MinZoom ?

4. VectorLayer (MaxVisible, MinVisible, SRID) ?

Sorry for many question, because I'm new to GIS.

Thanks

Coordinator
Jun 20, 2010 at 1:34 PM

1.) To draw text on your map based on attribute data and feature location you have to use LabelLayer. I havn't done that for the OSM example yet, but you can find examples in almost all of the other vector based samples to get you started.

2./3.) If you set MaxZoom and MinZoom Map properties you specify the Zoom range that can be displayed. In the ShapeFileOsm Sample the MaxZoom property is set to some portion of the maximum layer extent to prevent from zooming too far out.

4. The MaxZoom and MinZoom properties refer to the visible area on the map in real units. If your coordinates are in Lat/Long and you set the MaxZoom property to e.g. 60, your layer will be displayed if the visible area of the map is no more than 60.
If you set the MinZoom property to 30 your layer will be displayed if the visible area is larger than 30. If you set both, it will be displayed in between 30 and 60. The SRID value is an identifier for the SpatialReferenceSystem and is only for information.
Since your coordinates are lat/long, it is probably 4326.

Hth FObermaier

 

Jun 21, 2010 at 6:51 AM

Thanks for your help Fobermaier

Now, I can showing the Map, Street Name, moving the car base on Lat/Long, but I need to show the car name top of the car object in the map,

so if I use the LaberLayer as you suggest, I can't find the property for setting Lat/Long base on moving car Lat/Long.

Could you tell me how do this?

Thanks,

Coordinator
Jun 21, 2010 at 8:20 AM

d2ng, what kind of provider do you use for your moving car?

Jul 12, 2010 at 6:54 AM
For moving a car, I Use Sharpmap.Geometries.GeometryCollection, and add SharpMap.Geometries.Point(Long, Lat) on my timer every 1 second.
Coordinator
Jul 12, 2010 at 8:05 AM

I would suggest you do the following:

  • Create a second SharpMap.Map object. You have to take care that this map is synchonized with the "background" map in terms of size and viewport
  • For this map, create a new VectorLayer and LabelLayer using GeometryFeatureProvider based on some FeatureDataTable.
  • Add/Delete/Modify its entries every timeinterval you like and use GetMap() function to get the renderd map.
  • Display that image on top of your "background" map.

Hth FObermaier

Jul 13, 2010 at 1:54 AM

So, I have to make two Map on my map, but I still confuse, how to combine two map into the final single map as you suggest?

could you please give me sample code to do this?

I'm waiting for your response.

Thanks alot

 

Coordinator
Jul 13, 2010 at 8:00 AM

Something along the lines

//Get image of background map
//TODO: Cache this Image;
System.Drawing.Bitmap bg = backgroundMap.GetMap();

//Get current image of moveable cars
//TODO: update this frequently
System.Drawing.Bitmap mc = moveableCarsMap.GetMap();
mc.MakeTransparent(moveableCarsMap.BackColor);

//Compose the final image
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(bg);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp);
g.DrawImageUnscaled(bg, 0, 0);
g.DrawImageUnscaled(mc, 0, 0);
g.Dispose();

Hth FObermaier

Jul 16, 2010 at 8:57 AM

Thanks alot FObermaier

I use MapImage control to show map,

How do set the compose/final image to MapImage, I did not see properti in MapImage to set this,

Could you help me please,

Thanks

 

Coordinator
Jul 16, 2010 at 9:04 PM

There is no property in MapImage to compose the final image. You'll have to customize the control

  • Add a second map object, make sure that it is always synchronized in terms of viewport, scale, etc.
  • Add a timer component, set the update interval, every interval call the Refresh() method of MapImage control
  • Place the code above in the appropriate place of the Refresh method. Add caching of backgroundMap!

Hth FObermaier

 

Jul 26, 2010 at 6:35 AM

Thanks alot for your help FObermaier, but now I still difficult to customize the control like you said before,

But I will try later.

Now I implement the geofencing and I used the geometry.Contains and geometry.Within method with the my polygon and check if the my point(long, lat) in my polygon,

but these Method always return false, I already check the same method in SQL Server 2008 with the geography.Intersect() method and then return true, so this mean

my point is inside the polygon, why the sharpmap geometry,Contains() and geometry.Within() return false ?,

I also try to use another geometry method, that is geometry.Intersects() and I got exception of type 'System.NotImplementedException' occurred in SharpMap.dll and

I try to see the SharpMap source code it right not implement.

 

please advice me.

Thanks

 

Coordinator
Jul 26, 2010 at 6:59 AM
Edited Jul 26, 2010 at 8:57 AM

Hello d2ng,

spatial relations are not implemented for SharpMap.Geometries. You can perform basic tests on their BoundingBox'es, if you need more than that you'll have to use NetTopologySuite.

Hth FObermaier

Jul 29, 2010 at 1:49 AM

Thanks alot FObermaier,

- How to convert the Zoom value eg. 0.054... to meters or km, so I know how close I'm with the map ?

- How to add North, East, South, and West button for example in the upper right corner of the map.

 

Thanks,

d2ng

Coordinator
Jul 29, 2010 at 8:53 AM

Hi d2ng,

 

1.) If your coordinates are in degrees this might help you on conversion. Another posibility would be to use Proj.NET for reprojection of your data.

2.) Just place some controls on the control and modify the Map.Center property accordingly. You might need to call MapImage.Refresh() in order to update the display

Hth FObermaier

Aug 2, 2010 at 9:48 AM

Thanks alot for your help FObermaier,

If I use the street with double lines in my road Shape file, how to draw it with the same nice looking like you give me OSM sample in SharpMap ?

 

Thanks

d2ng

 

Coordinator
Aug 17, 2010 at 8:59 AM

Hello d2ng,

I'm afraid I don't understand what you mean.

cheers FObermaier