MAPVIEW
Methods of the prop Z, viewmode="mapview"
Attributes to put in the props of the content collection:
ATTRIBUTES | |
---|---|
mapview-address=“true” | POI Address |
mapview-latitude=“true” | POI Latitude |
mapview-longitude=“true” | POI Longitude |
mapview-marker-icon=“true” | POI icon |
ATTRIBUTES |
---|
zoom-to-my-location: with a true value it makes zoom to the current position, with a false value it doesn´t make zoom to the current position and it tries all the POIs are seen. |
Show-pois: with a false value it doesn´t show the POIs drawer. |
mapview-embedded: with a “true” value, this attribute embed the map in the collection where it has been defined. Value by default, false. |
on-map-clicked: attribute to define the node when we make click on the map to be able to execute an action. |
Example:
Definimos en el prop type="Z" el siguiente atributo: on-map-clicked="onMapClicked" Nodo que ejecutar este atributo: <onMapClicked show-wait-dialog="false" refresh="false"> <action name="runscript"> <param name="nLatitude" /> <!--- parametro que recoge la latitud --> <param name="nLongitude" /> <!--- parametro que recoge la longuitud --> <script> var window = ui.getView(self); ui.showToast("onMapClicked(), nLatitude: " + nLatitude + " nLongitude: " + nLongitude); </script> </action> </onMapClicked>
METHODS:
isUserLocationEnabled
Method that returns if the user has the geolocation enabled.
Example:
var ventana = ui.getView(self); if (ventana != null) { ui.showToast("Enabled: " + ventana.MAP_MAPA.isUserLocationEnabled()); }
enableUserLocation
Method that enables the device geolocation.
Example:
var ventana = ui.getView(self); if (ventana != null) { ventana.MAP_MAPA.enableUserLocation(); }
disableUserLocation
Method that disables the device geolocation.
Example:
var ventana = ui.getView(self); if (ventana != null) { ventana.MAP_MAPA.disableUserLocation(); }
drawLine
Method that draws a line by connecting the point passed as parameter.
PARAMETERS | Definition |
---|---|
PARAMETER 1 | Identifying name of the line. |
PARAMETER 2 | Color of the line to be drawn. |
PARAMETER 3 | Type of line to be drawn. |
PARAMETER 4 | From the fourth parameter onwards, it defines the points by which the line is going to be guided in this format (Latitude,Longitude). |
Example:
var ventana = ui.getView(self); ventana.MAP_MAPA.drawLine("ruta 1", "#FF00FF", "dashed", 40.4167747, -3.70379019, 41.3850632, 2.1734035); ventana.MAP_MAPA.drawLine("ruta 1", "#FF0000", "normal", 40.4167747, -3.70379019, 43.3850632, 3.1734035); ventana.MAP_MAPA.drawLine("ruta 2", "#FFFF00", "normal", 39.4167747, -2.70379019, 42.3850632, 2.0004035);
drawRoute
Method that draws a route that connects two points .
PARAMETERS | Definition |
---|---|
PARAMETER 1 | Identifying name of the route. |
PARAMETER 2 | Latitude of the destination point. |
PARAMETER 3 | Longitude of the destination point. |
PARAMETER 4 | Latitude of the destination point. |
PARAMETER 5 | Longitude of the destination point. |
PARAMETER 6 | Type of line to be drawn. |
PARAMETER 7 | Color of the line to be drawn. |
Example:
var ventana = ui.getView(self); ventana.MAP_MAPA.drawRoute("ruta 1", 40.4167747, -3.70379019, 41.3850632, 2.1734035, "walking", "#FFFF00"); ventana.MAP_MAPA.drawRoute("ruta 2", 40.4167747, -3.70379019, 39.3850632, -2.1734035, "walking", "#FFFF00");
clearLine
Method that clears the line to be drawn with drawLine.
PARAMETER | Identifying name of the line. |
Example:
var ventana = ui.getView(self); ventana.MAP_MAPA.clearLine("ruta 1");
clearAllLines
Method that clears all the lines drawn with drawLine.
Example:
var ventana = ui.getView(self); ventana.MAP_MAPA.clearAllLines();
clearRoute
Method that clears the route drawn with drawRoute.
PARAMETER | Identifying name of the route. |
Example:
var ventana = ui.getView(self); ventana.MAP_MAPA.clearRoute("ruta 1");
clearAllRoutes
Method that clears all the lines drawn with drawRoute.
Example:
var ventana = ui.getView(self); ventana.MAP_MAPA.clearAllRoutes();
addMarker
It adds a mark in the coordinates passed as parameter.
PARAMETERS | Definition |
---|---|
PARAMETER 1 | It defines the latitude. |
PARAMETER 2 | It defines the longitude. |
Example:
var ventana = ui.getView(self); ventana.MAP_MAPA.addMarker(40.4167747, -3.70379019);
setOnMapClickedListener
It defines the function when we make click on the map.
Example:
var ventana = ui.getView(self); ventana.MAP_MAPA.setOnMapClickedListener(function(nLatitude, nLongitude) { ui.showToast("onMapClicked(), nLatitude: " + nLatitude + " nLongitude: " + nLongitude); ventana.MAP_MAPA.addMarker(nLatitude, nLongitude); });