1

I load a VectorLayer which contain coordinate location point.

Now, I have a VectorLayer and I would like to get the point location on a item of this layer in order to center a map to this point.

Is it possible ?

  • 1
    Do you want to center on a specific item, or just any random item, or do you want all items visible in the map view? – til_b Feb 2 '16 at 16:02
  • No just a specific item of this layer. I have the ItemID for this. – user1501990 Feb 2 '16 at 18:06
1

try this:

var provider = vectorLayer.DataSource;
var geometry = p.GetGeometryByID(fid);
var location = geometry.Centroid.Coordinate;
//map.Center = location; 
mapBox1.Map.Center = location; 
mapBox1.Refresh();
  • Thanks. it's almots that, but the function GetGeometryByID take an integer argument which determinate the feature object ID. In my case, I have the ID of my object, which represente the IdColumn. – user1501990 Feb 8 '16 at 9:38
  • The Shapefile provider derives from FilterProvider. You can assign a FilterDelegate function that evaluates the feature data for any attribute you like. p.FilterDelegate = dr => dr["IdColumn"] == IdValue; – FObermaier Feb 10 '16 at 14:17
0

I am not familiar with sharpmap, but from the available documentation I guess you could do as follows:

  1. Get the envelope of the point
  2. call map.ZoomToBox(Envelope) with the envelope as a parameter.

Probably (1) can be achieved by calling something like

new Envelope(-9.205626, -9.123736, 38.690993, 38.740837)

with the point coordinates as parameters. Or maybe the Point object has a .envelope property.

  • Thanks. Effectivelly, for center the map, we have to set the enveloppe like you said. But, I don't know how to retrieve the enveloppe of a specific point. – user1501990 Feb 3 '16 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.