mirror of
https://github.com/mapgears/ol3-google-maps.git
synced 2026-02-01 17:45:59 +00:00
Add themed gmap support, i.e. styles for Google Maps
This commit is contained in:
parent
4fb95e65db
commit
1c9c6f9774
@ -31,7 +31,8 @@ olgmx.layer = {};
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* mapTypeId: (google.maps.MapTypeId.<(number|string)>|string|undefined)
|
||||
* mapTypeId: (google.maps.MapTypeId.<(number|string)>|string|undefined),
|
||||
* styles: (Array.<google.maps.MapTypeStyle>|undefined)
|
||||
* }}
|
||||
* @api
|
||||
*/
|
||||
@ -45,3 +46,11 @@ olgmx.layer.GoogleOptions;
|
||||
* @api
|
||||
*/
|
||||
olgmx.layer.GoogleOptions.prototype.mapTypeId;
|
||||
|
||||
|
||||
/**
|
||||
* The Google Maps styles to apply to the map
|
||||
* @type {Array.<google.maps.MapTypeStyle>|undefined}
|
||||
* @api
|
||||
*/
|
||||
olgmx.layer.GoogleOptions.prototype.styles;
|
||||
|
||||
@ -410,6 +410,14 @@ olgm.herald.Layers.prototype.toggleGoogleMaps_ = function() {
|
||||
if (found) {
|
||||
// set mapTypeId
|
||||
this.gmap.setMapTypeId(found.getMapTypeId());
|
||||
// set styles
|
||||
var styles = found.getStyles();
|
||||
if (styles) {
|
||||
this.gmap.setOptions({'styles': styles});
|
||||
} else {
|
||||
this.gmap.setOptions({'styles': null});
|
||||
}
|
||||
|
||||
// activate
|
||||
this.activateGoogleMaps_();
|
||||
} else {
|
||||
|
||||
@ -25,6 +25,12 @@ olgm.layer.Google = function(opt_options) {
|
||||
this.mapTypeId_ = options.mapTypeId !== undefined ? options.mapTypeId :
|
||||
google.maps.MapTypeId.ROADMAP;
|
||||
|
||||
/**
|
||||
* @type {?Array.<google.maps.MapTypeStyle>}
|
||||
* @private
|
||||
*/
|
||||
this.styles_ = options.styles ? options.styles : null;
|
||||
|
||||
};
|
||||
goog.inherits(olgm.layer.Google, ol.layer.Group);
|
||||
|
||||
@ -35,3 +41,11 @@ goog.inherits(olgm.layer.Google, ol.layer.Group);
|
||||
olgm.layer.Google.prototype.getMapTypeId = function() {
|
||||
return this.mapTypeId_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {?Array.<google.maps.MapTypeStyle>}
|
||||
*/
|
||||
olgm.layer.Google.prototype.getStyles = function() {
|
||||
return this.styles_;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user