Skip to content
Snippets Groups Projects
Commit 65516f1e authored by Piotr Gawron's avatar Piotr Gawron
Browse files

google maps api canvas JS doc

parent 35de9954
No related branches found
No related tags found
1 merge request!295Resolve "alternative to google maps api way of visualizing maps"
Showing
with 115 additions and 8 deletions
...@@ -13,6 +13,21 @@ var GoogleMapsApiMarker = require('./GoogleMapsApiMarker'); ...@@ -13,6 +13,21 @@ var GoogleMapsApiMarker = require('./GoogleMapsApiMarker');
var GoogleMapsApiPolyline = require('./GoogleMapsApiPolyline'); var GoogleMapsApiPolyline = require('./GoogleMapsApiPolyline');
var GoogleMapsApiRectangle = require('./GoogleMapsApiRectangle'); var GoogleMapsApiRectangle = require('./GoogleMapsApiRectangle');
/**
*
* @param {HTMLElement} element
* @param {Object} options
* @param {number} options.tileSize
* @param {number} options.minZoom
* @param {number} options.height
* @param {number} options.width
* @param {number} options.zoom
* @param {Point} options.center
* @param {Object[]} options.backgroundOverlays
* @constructor
* @extends MapCanvas
*/
function GoogleMapsApiCanvas(element, options) { function GoogleMapsApiCanvas(element, options) {
MapCanvas.call(this, element, options); MapCanvas.call(this, element, options);
...@@ -48,6 +63,10 @@ function GoogleMapsApiCanvas(element, options) { ...@@ -48,6 +63,10 @@ function GoogleMapsApiCanvas(element, options) {
GoogleMapsApiCanvas.prototype = Object.create(MapCanvas.prototype); GoogleMapsApiCanvas.prototype = Object.create(MapCanvas.prototype);
GoogleMapsApiCanvas.prototype.constructor = GoogleMapsApiCanvas; GoogleMapsApiCanvas.prototype.constructor = GoogleMapsApiCanvas;
/**
*
* @param {google.maps.Map} map
*/
GoogleMapsApiCanvas.prototype.setGoogleMap = function (map) { GoogleMapsApiCanvas.prototype.setGoogleMap = function (map) {
this._map = map; this._map = map;
}; };
...@@ -177,14 +196,14 @@ GoogleMapsApiCanvas.prototype.addCenterButton = function () { ...@@ -177,14 +196,14 @@ GoogleMapsApiCanvas.prototype.addCenterButton = function () {
* *
* @param {google.maps.LatLng} latLng * @param {google.maps.LatLng} latLng
* coordinates in LatLng format * coordinates in LatLng format
* @param {number} z * @param {number} zoom
* zoom level at which we want to find coordinates of tile * zoom level at which we want to find coordinates of tile
* @return {Point} coordinates of a tile * @return {Point} coordinates of a tile
*/ */
GoogleMapsApiCanvas.prototype.latLngToTile = function (latLng, z) { GoogleMapsApiCanvas.prototype.latLngToTile = function (latLng, zoom) {
var self = this; var self = this;
var worldCoordinate = self.fromLatLngToPoint(latLng); var worldCoordinate = self.fromLatLngToPoint(latLng);
var pixelCoordinate = new Point(worldCoordinate.x * Math.pow(2, z), worldCoordinate.y * Math.pow(2, z)); var pixelCoordinate = new Point(worldCoordinate.x * Math.pow(2, zoom), worldCoordinate.y * Math.pow(2, zoom));
return new Point(Math.floor(pixelCoordinate.x / self.getOptions().tileSize), Math return new Point(Math.floor(pixelCoordinate.x / self.getOptions().tileSize), Math
.floor(pixelCoordinate.y / self.getOptions().tileSize)); .floor(pixelCoordinate.y / self.getOptions().tileSize));
}; };
...@@ -467,6 +486,8 @@ GoogleMapsApiCanvas.prototype.isDrawingOn = function () { ...@@ -467,6 +486,8 @@ GoogleMapsApiCanvas.prototype.isDrawingOn = function () {
/** /**
* Sets selectedArea on this map. * Sets selectedArea on this map.
* *
*
* @param {Object} area
*/ */
GoogleMapsApiCanvas.prototype.setSelectedArea = function (area) { GoogleMapsApiCanvas.prototype.setSelectedArea = function (area) {
this._selectedArea = area; this._selectedArea = area;
...@@ -475,6 +496,7 @@ GoogleMapsApiCanvas.prototype.setSelectedArea = function (area) { ...@@ -475,6 +496,7 @@ GoogleMapsApiCanvas.prototype.setSelectedArea = function (area) {
/** /**
* Returns selectedArea on this map. * Returns selectedArea on this map.
* *
* @returns {Object}
*/ */
GoogleMapsApiCanvas.prototype.getSelectedArea = function () { GoogleMapsApiCanvas.prototype.getSelectedArea = function () {
return this._selectedArea; return this._selectedArea;
......
...@@ -11,7 +11,9 @@ var logger = require('../../../logger'); ...@@ -11,7 +11,9 @@ var logger = require('../../../logger');
* @param {GoogleMapsApiMarker} [options.marker] * @param {GoogleMapsApiMarker} [options.marker]
* @param {string} options.id * @param {string} options.id
* @param {GoogleMapsApiCanvas} options.map * @param {GoogleMapsApiCanvas} options.map
*
* @constructor * @constructor
* @extends InfoWindow
*/ */
function GoogleMapsApiInfoWindow(options) { function GoogleMapsApiInfoWindow(options) {
InfoWindow.call(this, options); InfoWindow.call(this, options);
......
...@@ -14,7 +14,8 @@ var logger = require('../../../logger'); ...@@ -14,7 +14,8 @@ var logger = require('../../../logger');
* @param {string} options.id * @param {string} options.id
* @param {GoogleMapsApiCanvas} options.map * @param {GoogleMapsApiCanvas} options.map
* @returns {GoogleMapsApiMarker} * @constructor
* @extends {Marker}
*/ */
function GoogleMapsApiMarker(options) { function GoogleMapsApiMarker(options) {
......
...@@ -6,6 +6,16 @@ var Bounds = require('../Bounds'); ...@@ -6,6 +6,16 @@ var Bounds = require('../Bounds');
// noinspection JSUnusedLocalSymbols // noinspection JSUnusedLocalSymbols
var logger = require('../../../logger'); var logger = require('../../../logger');
/**
* @param {MapCanvas} options.map
* @param {Point[]} options.path
* @param {string} options.strokeColor
* @param {number} options.strokeWeight
* @param {number} options.strokeOpacity
*
* @constructor
* @augments {Polyline}
*/
function GoogleMapsApiPolyline(options) { function GoogleMapsApiPolyline(options) {
Polyline.call(this, options); Polyline.call(this, options);
...@@ -28,10 +38,18 @@ function GoogleMapsApiPolyline(options) { ...@@ -28,10 +38,18 @@ function GoogleMapsApiPolyline(options) {
GoogleMapsApiPolyline.prototype = Object.create(Polyline.prototype); GoogleMapsApiPolyline.prototype = Object.create(Polyline.prototype);
GoogleMapsApiPolyline.prototype.constructor = GoogleMapsApiPolyline; GoogleMapsApiPolyline.prototype.constructor = GoogleMapsApiPolyline;
/**
*
* @param {google.maps.Polyline} polyline
*/
GoogleMapsApiPolyline.prototype.setGooglePolyline = function (polyline) { GoogleMapsApiPolyline.prototype.setGooglePolyline = function (polyline) {
this._polyline = polyline; this._polyline = polyline;
}; };
/**
*
* @returns {google.maps.Polyline}
*/
GoogleMapsApiPolyline.prototype.getGooglePolyline = function () { GoogleMapsApiPolyline.prototype.getGooglePolyline = function () {
return this._polyline; return this._polyline;
}; };
...@@ -53,11 +71,20 @@ GoogleMapsApiPolyline.prototype.hide = function () { ...@@ -53,11 +71,20 @@ GoogleMapsApiPolyline.prototype.hide = function () {
this.getGooglePolyline().setMap(null); this.getGooglePolyline().setMap(null);
} }
}; };
/**
*
* @returns {boolean}
*/
GoogleMapsApiPolyline.prototype.isShown = function () { GoogleMapsApiPolyline.prototype.isShown = function () {
var googlePolyline = this.getGooglePolyline(); var googlePolyline = this.getGooglePolyline();
return googlePolyline.getMap() !== null && googlePolyline.getMap() !== undefined; return googlePolyline.getMap() !== null && googlePolyline.getMap() !== undefined;
}; };
/**
*
* @returns {Bounds}
*/
GoogleMapsApiPolyline.prototype.getBounds = function () { GoogleMapsApiPolyline.prototype.getBounds = function () {
var result = new Bounds(); var result = new Bounds();
for (var i = 0; i < this.getGooglePolyline().getPath().getLength(); i++) { for (var i = 0; i < this.getGooglePolyline().getPath().getLength(); i++) {
...@@ -68,6 +95,10 @@ GoogleMapsApiPolyline.prototype.getBounds = function () { ...@@ -68,6 +95,10 @@ GoogleMapsApiPolyline.prototype.getBounds = function () {
return result; return result;
}; };
/**
*
* @param {Object} options
*/
GoogleMapsApiPolyline.prototype.setOptions = function (options) { GoogleMapsApiPolyline.prototype.setOptions = function (options) {
this.getGooglePolyline().setOptions(options); this.getGooglePolyline().setOptions(options);
}; };
......
...@@ -8,7 +8,15 @@ var logger = require('../../../logger'); ...@@ -8,7 +8,15 @@ var logger = require('../../../logger');
/** /**
* *
* @param options * @param {MapCanvas} options.map
* @param {Bounds} options.bounds
* @param {MapCanvas} options.fillOpacity
* @param {number} options.id
* @param {number} options.strokeWeight
* @param {string} options.fillColor
* @param {string} options.strokeColor
* @param {number} options.strokeOpacity
*
* @constructor * @constructor
* @extends Rectangle * @extends Rectangle
*/ */
...@@ -37,10 +45,18 @@ function GoogleMapsApiRectangle(options) { ...@@ -37,10 +45,18 @@ function GoogleMapsApiRectangle(options) {
GoogleMapsApiRectangle.prototype = Object.create(Rectangle.prototype); GoogleMapsApiRectangle.prototype = Object.create(Rectangle.prototype);
GoogleMapsApiRectangle.prototype.constructor = GoogleMapsApiRectangle; GoogleMapsApiRectangle.prototype.constructor = GoogleMapsApiRectangle;
/**
*
* @param {google.maps.Rectangle} rectangle
*/
GoogleMapsApiRectangle.prototype.setGoogleRectangle = function (rectangle) { GoogleMapsApiRectangle.prototype.setGoogleRectangle = function (rectangle) {
this._rectangle = rectangle; this._rectangle = rectangle;
}; };
/**
*
* @returns {google.maps.Rectangle}
*/
GoogleMapsApiRectangle.prototype.getGoogleRectangle = function () { GoogleMapsApiRectangle.prototype.getGoogleRectangle = function () {
return this._rectangle; return this._rectangle;
}; };
...@@ -62,6 +78,11 @@ GoogleMapsApiRectangle.prototype.hide = function () { ...@@ -62,6 +78,11 @@ GoogleMapsApiRectangle.prototype.hide = function () {
this.getGoogleRectangle().setMap(null); this.getGoogleRectangle().setMap(null);
} }
}; };
/**
*
* @returns {boolean}
*/
GoogleMapsApiRectangle.prototype.isShown = function () { GoogleMapsApiRectangle.prototype.isShown = function () {
var googleRectangle = this.getGoogleRectangle(); var googleRectangle = this.getGoogleRectangle();
return googleRectangle.getMap() !== null && googleRectangle.getMap() !== undefined; return googleRectangle.getMap() !== null && googleRectangle.getMap() !== undefined;
...@@ -78,6 +99,10 @@ GoogleMapsApiRectangle.prototype.setBounds = function (bounds) { ...@@ -78,6 +99,10 @@ GoogleMapsApiRectangle.prototype.setBounds = function (bounds) {
this.getGoogleRectangle().setBounds(latLngBounds); this.getGoogleRectangle().setBounds(latLngBounds);
}; };
/**
*
* @returns {Bounds}
*/
GoogleMapsApiRectangle.prototype.getBounds = function () { GoogleMapsApiRectangle.prototype.getBounds = function () {
var latLngBounds = this.getGoogleRectangle().getBounds(); var latLngBounds = this.getGoogleRectangle().getBounds();
var result = new Bounds(); var result = new Bounds();
...@@ -86,6 +111,10 @@ GoogleMapsApiRectangle.prototype.getBounds = function () { ...@@ -86,6 +111,10 @@ GoogleMapsApiRectangle.prototype.getBounds = function () {
return result; return result;
}; };
/**
*
* @param {Object} options
*/
GoogleMapsApiRectangle.prototype.setOptions = function (options) { GoogleMapsApiRectangle.prototype.setOptions = function (options) {
this.getGoogleRectangle().setOptions(options); this.getGoogleRectangle().setOptions(options);
}; };
......
"use strict"; "use strict";
var MapCanvas = require('./MapCanvas'); var MapCanvas = require('./MapCanvas');
var Marker = require('./Marker');
// noinspection JSUnusedLocalSymbols // noinspection JSUnusedLocalSymbols
var logger = require('../../logger'); var logger = require('../../logger');
......
...@@ -221,7 +221,7 @@ OpenLayerCanvas.prototype.createLayers = function (options) { ...@@ -221,7 +221,7 @@ OpenLayerCanvas.prototype.createLayers = function (options) {
} }
}) })
}); });
layer.on('change:visible', function (e) { layer.on('change:visible', function () {
if (layer.getVisible()) { if (layer.getVisible()) {
return self.callListeners("maptypeid_changed"); return self.callListeners("maptypeid_changed");
} }
...@@ -272,6 +272,11 @@ OpenLayerCanvas.prototype.createRectangle = function (options) { ...@@ -272,6 +272,11 @@ OpenLayerCanvas.prototype.createRectangle = function (options) {
return new OpenLayerRectangle(options); return new OpenLayerRectangle(options);
}; };
/**
*
* @param options
* @returns {OpenLayerPolyline}
*/
OpenLayerCanvas.prototype.createPolyline = function (options) { OpenLayerCanvas.prototype.createPolyline = function (options) {
options.map = this; options.map = this;
options.source = this._polylineLayer.getSource(); options.source = this._polylineLayer.getSource();
......
...@@ -92,6 +92,10 @@ OpenLayerPolyline.prototype.getBounds = function () { ...@@ -92,6 +92,10 @@ OpenLayerPolyline.prototype.getBounds = function () {
return new Bounds(p1, p2); return new Bounds(p1, p2);
}; };
/**
*
* @param options
*/
OpenLayerPolyline.prototype.setOptions = function (options) { OpenLayerPolyline.prototype.setOptions = function (options) {
var self = this; var self = this;
self._options = Object.assign(self._options, options); self._options = Object.assign(self._options, options);
......
...@@ -5,8 +5,8 @@ var logger = require('../../logger'); ...@@ -5,8 +5,8 @@ var logger = require('../../logger');
/** /**
* *
* @param {number} x * @param {number|string||Point} x
* @param {number} y * @param {number|string} [y]
* @constructor * @constructor
*/ */
function Point(x, y) { function Point(x, y) {
......
...@@ -37,6 +37,7 @@ Rectangle.prototype.getBounds = function () { ...@@ -37,6 +37,7 @@ Rectangle.prototype.getBounds = function () {
throw new Error("Not implemented"); throw new Error("Not implemented");
}; };
// noinspection JSUnusedLocalSymbols
/** /**
* *
* @param {Bounds} bounds * @param {Bounds} bounds
...@@ -45,6 +46,7 @@ Rectangle.prototype.setBounds = function (bounds) { ...@@ -45,6 +46,7 @@ Rectangle.prototype.setBounds = function (bounds) {
throw new Error("Not implemented"); throw new Error("Not implemented");
}; };
// noinspection JSUnusedLocalSymbols
/** /**
* *
* @param {Object} options * @param {Object} options
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
var Promise = require("bluebird"); var Promise = require("bluebird");
/**
* @typedef {Object} google.maps.Marker
*/
/* exported logger */ /* exported logger */
// noinspection JSUnusedLocalSymbols // noinspection JSUnusedLocalSymbols
...@@ -154,6 +158,12 @@ var google = { ...@@ -154,6 +158,12 @@ var google = {
this.setContent = function () { this.setContent = function () {
}; };
}, },
/**
*
* @param options
* @returns {google.maps.Marker}
* @constructor
*/
Marker: function (options) { Marker: function (options) {
this.options = options; this.options = options;
this.position = options.position; this.position = options.position;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment