No method for SetMapView?

Last post 4/22/2008 11:26:20 PM by ripple. 7 replies. << Back to Web.Maps.VE v1.0 General
12/13/2007 6:02:58 AM
scottaday

No method for SetMapView?

This was a javascript function I relied on, just wondering if it was available through the control.

Thanks

12/14/2007 5:41:12 AM
scottaday

Re:No method for SetMapView?

And yes, I did notice the "MapView" object on the control.  It's always null and is readonly :(

Anybody?

12/19/2007 10:38:13 PM
scottaday

Re:No method for SetMapView?

I'm going to make the assumption this is not going to be implemented any time soon and will use javascript / hidden textboxes for a workaround in the mean time.  We're going live Jan 1 and can't wait any longer.
12/19/2007 11:10:07 PM
Chris Pietschmann

Re:No method for SetMapView?

The MapView property of the Map control is read-only because it is meant to be used to tell what map view is currently being shown during an asynchornous postback. There currently hasn't been any plan to add a SetMapView method to the map.

1/5/2008 12:09:28 AM
Chris Pietschmann

Re:No method for SetMapView?

The SetMapView method is only available from within JavaScript in the current version (v1.00.04) of Web.Maps.VE.

Here's a code example of using it to center the map on all the plotted shapes when the map initially loads:

<Simplovation:Map runat="server" ID="Map1" OnClientMapLoaded="mapLoaded" />
<script type="text/javascript">
// This method is run once the map has completed loading on the page
function mapLoaded()
{
    var map = $find("<%=Map1.ClientID%>");
    //This code will center the map on all the shapes that are plotted
    var locations = new Array();
    for(var a = 0; a < map.get_Map().GetShapeLayerCount(); a++)
    {
        for(var b = 0; b < map.get_Map().GetShapeLayerByIndex(a).GetShapeCount(); b++)
        {
            Array.addRange(locations, map.get_Map().GetShapeLayerByIndex(a).GetShapeByIndex(b).GetPoints());
        }
    }
    if (locations.length != 0)
        map.get_Map().SetMapView(locations);
}
</script>

4/13/2008 2:29:19 PM
ripple

Re:No method for SetMapView?

Has this functionality ever been built into the control?

In a lot of instances, we are populating the map with markers after the initial map load and would like to re-center and set the zoom accordingly based on the markers that are present.

What other workarounds are available, for after the inital map load?

Thanks,

Matt

4/18/2008 4:58:35 PM
ripple

Re:No method for SetMapView?

Chris, based on another post in this forum, you mentioned it was better to use the MapLoaded() event rather than OnClientMapLoaded because sometimes, it fires before it really is complete.

My question is, what is the syntax you use to get the javascript function to fire within a vb code block?

Protected Sub Map1_MapLoaded(ByVal sender As Object, ByVal e As Simplovation.Web.Maps.VE.MapLoadedEventArgs) Handles Map1.MapLoaded

        'run the javascript function here?????

    End Sub


4/22/2008 11:26:20 PM
ripple

Re:No method for SetMapView?

Well, I did a little research here considering there have been no support responses:

Protected Sub Map1_MapLoaded(ByVal sender As Object, ByVal e As Simplovation.Web.Maps.VE.MapLoadedEventArgs) Handles Map1.MapLoaded

        'Center and zoom the map appropriately
        ScriptManager.RegisterStartupScript(Me, Me.GetType(), "Startup", "SetMap1View()", True)

    End Sub

The problem with doing this method, is you can actually see the map render and then after the fact it sets the zoom and appropriate centerpoint.  So, for those using the commercial service for VE, you have a tile rendering to begin with, and then another one when it changes the zoom and centerpoints.  So, that is:  Tiles x 2 to figure out what your transaction cost is.