# Class: modelit.mapviewer.MapViewer

### Extends: matlab.mixin.SetGet & handle

## DESCRIPTION:

A panel with a map generated from a tile source.

#

## Properties

ButtonDownFcn | function |
      Mouse-click callback
contrast | number between 0 and 100. |
      Number from 0-100 fading factor for the background 100 displays
      the original image, 0 image is faded away completely
currentPoint | number[2,3] |
      Location of mouse pointer
EXPERIMENTAL | boolean, default value: false. |
      Toggle between alphadata and contrast factor for testing
handle (Read-only) | Handle of the uipanel in which the map is displayed. |
hittest | string |
      Respond to captured mouse clicks
MAXTILES | integer |
      Maximum number of tiles to store in the array of tiles.
PickableParts | Ability to capture mouse clicks |
type | string |
      For inspection.
UIContextMenu | ContextMenu |
WGS84Corners | /ows:WGS84Corners |
      When zooming out to maximum extent, zoom out to bounding box, or
      box around plotted items, whatever  is larger.
      copied from:
      <ows:WGS84Corners>
      <ows:LowerCorner>-1.65729160235431 48.0405018704265</ows:LowerCorner>
      <ows:UpperCorner>11.2902578747914 55.9136415748388</ows:UpperCorner>
xlim | number[2] |
      Minimum and maximum x-axis limits
ylim | number[2] |
      Minimum and maximum y-axis limits
ZLim | number[2] |
      ZLim of layer axis

# Public Method: delete

## DESCRIPTION:

DELETE Delete a handle object. DELETE(H) deletes all handle objects in array H. After the delete function call, H is an array of invalid objects. See also MODELIT.MAPVIEWER.MAPVIEWER, MODELIT.MAPVIEWER.MAPVIEWER/ISVALID, CLEAR Help for modelit.mapviewer.MapViewer/delete is inherited from superclass handle

# Public Method: MapViewer

## DESCRIPTION:

A panel with a map generated from a tile source.

## CALL:

obj = MapViewer(parent, varargin)

## INPUT:

parent | handle |
    parent Figure
varargin | any |
    property-value pairs with valid properties for a uipanel
    or the MapViewers tilesource.

## OUTPUT:

obj | any |
    modelit.mapviewer.MapViewer

## EXAMPLE:

        m = modelit.mapviewer.MapViewer(gcf, 'visible', 'off');
        setVisibleRectangle(m, [ 2.4558   50.7183    5.7675    2.6999]);

        COMPABILITY WITH AXES, MIGRATION ISSUES
        In many cases an application can be ported from "axes" based to
        "MapViewer" based by only replacing "axes" with "MapViewer" and
        making sure all line, text and patch command explictly specify
        the parent object. This makes sure that MapViewer methods line,
        text and patch are invoked.
        There are a view extra things to look out for.
        -1-
        A mapViewer object is not a Handle Graphics object. Its handle
        cannot be gound through findobj
        -2-
        Although MapViewer overloads plotting commands like line, patch
        and text, it does not automatically overload the set command for
        these objects.
        Example:
          h=line( ...'parent',map)
          set(h,'xdata',x,'ydata',y)
        This will not result in transforming x and y correctlty
        -3-
        Using "get" on object that are plotted ia MapViewer may not give
        a usefull result.
        Examples:
        get(h,'parent') returns axes handle, not MapViewer object. Tip:
        use HWIN=ancestor(hax,'figure') instead.
        het(h,'xdata') returns pixel coordinates not "real" coordinates
        -4-
        Only properties that are common to axes and uipanel can be
        used in a call to MapViewer.

        Documentation for modelit.mapviewer.MapViewer/MapViewer
           doc modelit.mapviewer.MapViewer

# Public Method: getAxesHandle

## DESCRIPTION:

Return handle of data axes in mapviewer object (added 20210115)

# Public Method: isWGS

## DESCRIPTION:

Export WGS property of tile source

# Public Method: LatToY

## DESCRIPTION:

Transforms latitude coordinate to pixel coordinate y

# Public Method: LonToX

## DESCRIPTION:

Transforms longitude coordinate to pixel coordinate x

# Public Method: YToLat

## DESCRIPTION:

Transforms pixel coordinate Y to latitude

# Public Method: XToLon

## DESCRIPTION:

Transforms pixel coordinate X to longitude.

# Public Method: contextmenuCache

## DESCRIPTION:

Create a context menu that can be added to layer selector

# Public Method: setTilesource

## DESCRIPTION:

Set the source from which the map tiles are retrieved.

## CALL:

setTilesource(obj, value)

## INPUT:

obj | modelit.mapviewer.Mapviewer |
value | modelit.mapviewer.AbstractTileSource |

## OUTPUT:

        No output.

# Public Method: setContrast

## DESCRIPTION:

Set contrast of tiles.

## CALL:

setContrast(obj, value)

## INPUT:

obj | modelit.mapviewer.Mapviewer |
value | number |
    between 0 completely white or 100 no fading at all.

## OUTPUT:

        No output.

# Public Method: setControls

## DESCRIPTION:

setControls - show or hider zoom buttons

# Public Method: colormap

## DESCRIPTION:

Redirect to layer.

# Public Method: findobj

## DESCRIPTION:

Redirect findobj to axes created by MapViewer, so that line object can be found using tag.

# Public Method: lm_linkobj

## DESCRIPTION:

Redirect to Modelit lm_linkobj.

# Public Method: zoomtool

## DESCRIPTION:

Redirect to Modelit zoomtool.

# Private Method: zoomCallback

## DESCRIPTION:

Callback of the zoombuttons.

## CALL:

zoomCallback(obj, mode)

## INPUT:

obj | modelit.mapviewer.MapViewer |
mode | string |
    'zoomin' or 'zoomout'

## OUTPUT:

       No output

# Private Method: findTile

## DESCRIPTION:

Get tile from cache or from server.

## CALL:

tile = findTile(obj, x, y, zoomlevel)

## INPUT:

obj | modelit.mapviewer.MapViewer |
x | any |
    Integer
y | any |
    Integer
zoomlevel | any |
    Integer with zoomlevel.

## OUTPUT:

tile | any |
    modelit.mapviewer.Tile or a
    string with the tile url if the Tile has not been loaded yet.

# Private Method: reposition

## DESCRIPTION:

Resize function of uipanel that holds map. Reposition axes and adjust axes' xlim and ylim.

## CALL:

tile = reposition(obj)

## INPUT:

obj | modelit.mapviewer.MapViewer |

## OUTPUT:

       No output.

# Private Method: getTilesInView

## DESCRIPTION:

Get index and zoomlevel of the tiles that are in the current view.

## CALL:

tile = getTilesInView(obj)

## INPUT:

obj | modelit.mapviewer.MapViewer |

## OUTPUT:

S | any |
    [Nx3] matrix with [x y zoomlevel].

# Private Method: makeTile

## DESCRIPTION:

Set the cdata and alpha of a tile. The current cdata wa set to "hourglass"

# Private Method: tileCompleted

## DESCRIPTION:

Executed when a new image has been downloaded.

# Private Method: tileProgress

## DESCRIPTION:

Executed when there is a progress event from the worker.

# Private Method: tileError

## DESCRIPTION:

Executed when a request for a new Tile has failed.

# Private Method: tileInitialized

## DESCRIPTION:

Executed when a new tile is about to be downloaded. I.e. the threadpoolexecutor started the download. A new tile with an hourglass is created in this function.

# Private Method: repaint

## DESCRIPTION:

Repaint tiles by downloading and displaying map images.

## CALL:

repaint(obj)

## INPUT:

obj | any |
    modelit.mapviewer.MapViewer

## OUTPUT:

       No output.

# Private Method: zoomtool_move

## DESCRIPTION:

Function called in case of "pan" action

## CALL:

zoomtool_move(obj, ISSCALE)

## INPUT:

obj | any |
    modelit.mapviewer.MapViewer

## OUTPUT:

       No output.

# Public Method: text

## DESCRIPTION:

Plot text on the map.

## CALL:

h = text(xdata, ydata, varargin) h = text(xdata, ydata, zdata, varargin)

## INPUT:

varargin | any |
    Parameter-value pairs with valid text properties.

## OUTPUT:

h | any |
    Handle of the text object.

# Public Method: image

## DESCRIPTION:

Plot an image on the map.

## CALL:

any valid syntax to invoke image. Except "image(Cdata)"

## INPUT:

varargin | any |
    Parameter-value pairs with valid patch properties.

## OUTPUT:

h | any |
    Handle of the image.

# Public Method: patch

## DESCRIPTION:

Plot a patch on the map.

## CALL:

h = patch(xdata, ydata, varargin) h = patch(xdata, ydata, zdata, varargin)

## INPUT:

varargin | any |
    Parameter-value pairs with valid patch properties.

## OUTPUT:

h | any |
    Handle of the patch.

# Public Method: line

## DESCRIPTION:

Plot a line on the map.

## CALL:

h = line(xdata, ydata, varargin) h = line(xdata, ydata, zdata, varargin)

## INPUT:

varargin | any |
    Parameter-value pairs with valid line properties.

## OUTPUT:

h | any |
    Handle of the plotted line.

# Public Method: getxydata

## DESCRIPTION:

Get x or y data from object in the map.

## CALL:

val = getxydata(obj, h, prop)

## INPUT:

obj | modelit.mapviewer.Mapviewer |
h | any |
    handle of line, patch or image
prop | any |
    valid object property.

## OUTPUT:

val | any |
    Value of property.

# Public Method: setxydata

## DESCRIPTION:

Set x or y data of object in the map.

## CALL:

setxydata(obj, h, varargin)

## INPUT:

obj | modelit.mapviewer.Mapviewer |
h | any |
    handle of line, patch or image
varargin | any |
    name value pairs. These will be transferred to hg oobject
    h, with the exception of xdata and ydata. these will be
    transformed first.

# Public Method: cla

## DESCRIPTION:

Clear the axis with lines, patches and text.

## CALL:

cla(obj)

## INPUT:

obj | modelit.mapviewer.Mapviewer |

## OUTPUT:

       No direct output, the layer with lines, patches etc is active

# Public Method: axes

## DESCRIPTION:

Activate axis with lines, patches and text.

## CALL:

axes(obj)

## INPUT:

obj | modelit.mapviewer.Mapviewer |

## OUTPUT:

       No direct output, the layer with lines, patches etc is active.

# Public Method: setZoomlevel

## DESCRIPTION:

Set the zoomlevel.

## CALL:

setZoomlevel(obj, zoomlevel)

## INPUT:

obj | any |
    modelit.mapviewer.MapViewer
zoomlevel | any |
    Integer with zoomlevel.

## OUTPUT:

       No output

# Public Method: getZoomlevel

## DESCRIPTION:

Get the zoomlevel.

## CALL:

zoomlevel = getZoomlevel(obj)

## INPUT:

obj | any |
    modelit.mapviewer.MapViewer

## OUTPUT:

zoomlevel | any |
    Integer with zoomlevel.

# Public Method: setPivotCenter

## DESCRIPTION:

Set pivot at relative coordinate xn, yn to coordinate lon, lat.

## CALL:

setPivotCenter(obj, lon, lat, xn, yn, REPAINT)

## INPUT:

obj | any |
    modelit.mapviewer.MapViewer
lon | any |
    Double with longitude of center of the view.
xn | any |
yn | any |
lat | any |
    Double with latitude of center of the view.
REPAINT | boolean |
    if true then repaint the MapViewer.

## OUTPUT:

       No output

# Public Method: setCenter

## DESCRIPTION:

Set center of view.

## CALL:

setCenter(obj, lon, lat, REPAINT)

## INPUT:

obj | any |
    modelit.mapviewer.MapViewer
lon | any |
    Double with longitude of center of the view.
lat | any |
    Double with latitude of center of the view.
REPAINT | boolean |
    if true then repaint the MapViewer.

## OUTPUT:

       No output

# Public Method: getCenter

## DESCRIPTION:

Get center of view.

## CALL:

[lon, lat] = getCenter(obj)

## INPUT:

obj | any |
    modelit.mapviewer.MapViewer

## OUTPUT:

lon | any |
    Double with longitude of center of the view.
lat | any |
    Double with latitude of center of the view.

# Public Method: setVisibleRectangle

## DESCRIPTION:

Set center and zoomlevel such that the given rectangle is completely visible.

## CALL:

setVisibleRectangle(obj, rect)

## INPUT:

obj | any |
    modelit.mapviewer.MapViewer
rect | any |
    [left bottom width height] in latitude and longitude.
REPAINT | any |
    If false, calling module will do repaint. Skip repaint
    here.

## OUTPUT:

       No direct output, the given rectangle is completely visible.

# Public Method: getVisibleRectangle

## DESCRIPTION:

Get current view rectangle.

## CALL:

rect = getVisibleRectangle(obj, zm)

## INPUT:

obj | any |
    modelit.mapviewer.MapViewer
zm | any |
    <number> zoomlevel

## OUTPUT:

rect | any |
    [left bottom width height] in latitude and longitude.

# Public Method: getVisibleBox

## DESCRIPTION:

Get current coordinates of Mapviever viewport.

## CALL:

box = getVisibleBox(obj, zm)

## INPUT:

obj | any |
    modelit.mapviewer.MapViewer
zm | any |
    <integer> optional, with the zoomlevel, default
    obj.zoomlevel

## OUTPUT:

box | any |
    [xlim(1) xlim(2) ylim(1) ylim(2)] in local coordinate
    system.

# Public Method: setViewportCorners

## DESCRIPTION:

set viewport though lower-left and upper-right corner

# Public Method: getViewportCorners

## DESCRIPTION:

get local coordinates of lower-left and upper-right corner of Mapviewer viewport.

# Public Method: ancestor

## DESCRIPTION:

Get hg ancestor of this panel.

## CALL:

P = ancestor(obj, varargin)

## INPUT:

obj | any |
    modelit.mapviewer.MapViewer

## OUTPUT:

p | any |
    handle with this panel's hg object.

# Private Method: removeTile

## DESCRIPTION:

Remove a tile with given index from the array of tiles.

## CALL:

removeTile(obj, index)

## INPUT:

obj | any |
    modelit.mapviewer.MapViewer
index | any |
    Integer with index in obj.tiles of the tile to be removed.

## OUTPUT:

       No output.

# Private Method: addTile

## DESCRIPTION:

Add tile to array of tiles in the MapViewer.

## CALL:

addTile(obj, tile)

## INPUT:

       obj: <modelit.mapviewer.MapViewer>            %

tile | modelit.mapviewer.Tile |
    the tile to add to the array of tiles in the MapViewer.

## OUTPUT:

       No output

# Private Method: positionZoombuttons

## DESCRIPTION:

Position zoombuttons in MapViewer.

## CALL:

positionZoombuttons(obj, dummy, event)

## INPUT:

obj | any |
    modelit.mapviewer.MapViewer
dummy | any |
    default Matlab callback argument, not used.
event | any |
    Callback event, with information on the new position of the MapViewer axis.

## OUTPUT:

       No output