Answer this question

VEMap.GetMapView Method

  • dagfari

    How would you go about doing this with a BirdseyeScene Is there a way to determine the LatLong's of the top left and bottom right of the scene, similar to what you can do with the normal map I've tried using something like this, but it doesn't seem to be working as expected:

    latTopLeft = map.GetBirdseyeScene().PixelToLatLong(0,0,map.GetZoomLevel());

    Any help would be greatly appreciated.


  • ReneeC

    Yah... of course - thanks again!
    I was just thinking loud about the possibility to maintain the state (view) of the map across viewstate in an ASP.NET webapp with a thing like:
    map.GetViewState.ToString or
    var vs = map.GetViewState(); vs.ToString();
    in order to serialize and write the viewstate to a hidden HTML field in a simple and quick way.
    but who really needs it, will do it attribute by attribute anyway :-p

    cheers hafi23


  • LouArnold

    Unfortunately, due to contractural oblications with the company that provides the BE images, we cannot expose the LatLong infomation for individual BE images.


  • heyram

    Agreed that the name "GetMapView" suggests that more information is stored in the object. I'll pass that on to the team. In the meanwhile, you can get all the info you want by calling:

    VEMap.GetZoomLevel()

    VEMap.GetMapStyle()

    and

    VEMap.GetCenter()


  • rsdu

    Yeah, I admit the documention is a bit thin there right now (it's high on my list of up-coming fixes).

    The short answer: GetMapView returns a VELatLongRectangle object. Guess what VELatLongRectangle isn't in the SDK. So here you go:

    There are 2 properties you can play with: TopLeftLatLong and BottomRightLatLong. Of course, they define the top left and bottom right corners of the current map view.

    map.onMapLoad = TestMapView();

    function TestMapView() {

    try

    {

    var v = map.GetMapView();

    alert(v.TopLeftLatLong);

    alert(v.BottomRightLatLong);

    }

    catch (e)

    {

    alert(e.message);

    }

    }


  • butterfly13

    I just worked with the GetMapView object and noticed that not all Properties work as expected. At least when converting the LatLongs to Pixel for checking whether a pushpin is visible on the map or not. The Y value of the pixel of v.TopLeftLatLong allways returned a value somehow around 782px -)
    maybe this is the reason, why it's not yet in the doc ;-)

    this was my try to check whether a pushpin is on the map or not:
    ---------------------------------------------------------
    this.PinOnMapView = function(wl)
    {
    var v = this.Map.GetMapView();
    var pinPx = this.Map.LatLongToPixel(wl.LatLong);
    var mapTopLeftPx = this.Map.LatLongToPixel(v.TopLeftLatLong);
    var mapBottomRightPx = this.Map.LatLongToPixel(v.BottomRightLatLong);
    alert("pinPx:: x: " + pinPx.x + " - y: " + pinPx.y);
    if(((pinPx.x >= mapTopLeftPx.x) && (pinPx.x <= mapBottomRightPx.x)))
    {
    if(((pinPx.y >= parseInt(mapTopLeftPx.y)) && (pinPx.y <= mapBottomRightPx.y)))
    {
    alert("NaN " + parseInt(mapTopLeftPx.y));
    alert("TRUE");
    return true;
    }
    else
    {
    alert("FALSE :: Y");
    alert("mapTopLeftPx:: y: " + mapTopLeftPx.y);
    alert("mapBottomRightPx:: y: " + mapBottomRightPx.y);
    return false;
    }
    }
    else
    {
    alert("FALSE :: X");
    alert("mapTopLeftPx:: x: " + mapTopLeftPx.x);
    alert("mapBottomRightPx:: x: " + mapBottomRightPx.x);
    return false;
    }
    }
    ---------------------------------------------------------

    finally I got around with calculating the TopLeft and BottomRight points starting from the map center all the rest is still the same!

    cheers hafi23




  • Rekar

    First of all, thanks for the good answer! but... i would have expected to find a Center point (VELatLong), ZoomLevel, MapStyle etc. in order to store the "map view" before and rebuild "map view" after postback. is there maybe coming s/t like that to better support asp.net just for curiosity! cause implementing VE to keep status through postback needs a lot of client side scripting :-(

    anyway - thx for your quick response!
    hafi23


  • VEMap.GetMapView Method