×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Aug 2013
    Posts
    1

    Get zoom level and center of map from points and their distance in meters

    Hi, I am not good at math so please help me with this. I have distance in meters and I need to calculate zoom level and center to map from this. How can I do that? I started with this but now I am completly lost:

    var sCoord = new GeoCoordinate(startPoint.X, startPoint.Y);
    var eCoord = new GeoCoordinate(latitude, longitude);
    var distance = sCoord.GetDistanceTo(eCoord);

    I don't know math formula for recalculating distance to zoom level of map and then how to get center of map from that points (startPoint, and second point made from lat and lng).

    Thanks

  2. #2
    Registered User
    Join Date
    Jun 2013
    Posts
    52

    Re: Get zoom level and center of map from points and their distance in meters

    Not sure if I understand it correctly... but I'm guessing you just want to be sure that the map zooms in so it will show both coordinates nicely?
    If so, you can use the SetView() method of the Map control.

    So the code will be

    List<GeoCoordinate> geoCoordinates = new List<GeoCoordinate>();
    geoCoordinates.Add(sCoord);
    geoCoordinates.Add(eCoord);
    LocationRectangle locationRectangle = LocationRectangle.CreateBoundingRectangle(geoCoordinates);
    this.MapName.SetView(locationRectangle);

Similar Threads

  1. Zoom level in OviMaps
    By nicowitteman in forum Symbian
    Replies: 1
    Last Post: 2013-02-13, 09:48
  2. zoom level change event
    By upixsoul in forum [Archived] Maps API for Javascript
    Replies: 1
    Last Post: 2012-10-09, 16:43
  3. How to calculate distance between to geo points in j2me?
    By kalki in forum Mobile Java General
    Replies: 3
    Last Post: 2010-04-02, 11:17
  4. how to get the distance between two points
    By xyzsun in forum Mobile Java General
    Replies: 2
    Last Post: 2005-05-16, 07:23

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×