The MapView is the Control that renders a map. It requires and HTMLElement to be associated with and this is normally a <DIV> with an id that we declare in the web page. You create a MapView like this:
JavaScript Copy Code |
---|
// create a new instance of the mapView |
Copy Code |
---|
view.showZoomController = true; |
A map with the zoom controller (on the left) and the layer controller (on the right).
MapView has several collections which are defined by the decorations, overlays and mapLayers properties.
The decorations property holds all Decoration-s that are defined for this MapView. These are Bubble and Marker instances.
The mapLayers holds all MapLayer instances. MapLayer-s are responsible for rendering tile images that are returned by the TMS (tile map server).
The overlays property holds all DecorationLayer instances. These are the layers that hold Marker-s and Bubble-s.
The layerLoad is raised when the MapLayer that renders the chosen map by the TMS has loaded completely. The viewLoad event is raised when all DecorationLayer-s have been loaded.
When the user clicks on the map or hovers over it the click and hover event are respectively raised. Here is how you handle the click event:
JavaScript Copy Code |
---|
view.click.addEventListener(mapViewClickHandler); function mapViewClickHandler( sender, args ) |
The panTo method pans the map to a new center location, specified by a LatLong instance. The scrollTo method scrolls the client area of the map to a new center point, specified by a Point instance, and the scrollBy method scrolls the client area by the specified amount.
Each map works in geographical coordinates while the mapView control has client coordinates. You can convert between the two with the latLongToClient and clientToLatLong methods.