Search
MapView.scrollTo Method
See Also
 






Scrolls the map to a new center point.

Namespace: MindFusion.Mapping
File: MapView.js

 Syntax

JavaScript  Copy Code

function scrollTo (center)

 Parameters

center

Point. A Point instance representing the client position of the new map center.

 Example

The following example creates a new MapView using a <DIV> element called "mapview" that we've declared in the HTML code of the page. It handles the click event and scrolls to the clicked point:

JavaScript  Copy Code

// create a new instance of the mapView
var view = new m.MapView(document.getElementById("mapView"));
view.theme = "light";

// create a map layer
var l = new m.MapLayer("Map");
l.urlTemplate = "http://d.tile.stamen.com/terrain/{z}/{x}/{y}.png";
l.attribution = 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.';
view.layers.add(l);

view.click.addEventListener(mapViewClickHandler);

function mapViewClickHandler( sender, args )
{
      view.scrollTo( args.position );
}

 See Also