Skip to content

Commit 0f993d8

Browse files
added proper attribution to custom map types
1 parent f49bdff commit 0f993d8

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

js/gmaps_extentions.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,43 @@ google.maps.DropDownControl = function(options) {
169169
clearTimeout(ctx.hideTimeout);
170170
});
171171
};
172+
173+
// simple status control
174+
175+
google.maps.StatusTextControl = function(options) {
176+
this.options = options || {
177+
text: "",
178+
map: null,
179+
position: 0,
180+
fontSize: "10px",
181+
};
182+
183+
this.div_ = document.createElement('div');
184+
this.div_.style.cssText = "display: none";
185+
this.div_.innerHTML = "<div style='opacity: 0.7; width: 100%; height: 100%; position: absolute;'>" +
186+
"<div style='width: 1px;'></div>" +
187+
"<div style='width: auto; height: 100%; margin-left: 1px; background-color: rgb(245, 245, 245);'></div></div>";
188+
189+
var div = document.createElement('div');
190+
div.style.cssText = 'position: relative; padding-right: 6px; padding-left: 6px;' +
191+
' font-family: Roboto, Arial, sans-serif; color: rgb(68, 68, 68);' +
192+
' white-space: nowrap; direction: ltr; text-align: right;' +
193+
' font-size: ' + this.options.fontSize;
194+
195+
this.span_ = document.createElement('span');
196+
div.appendChild(this.span_);
197+
this.div_.appendChild(div);
198+
199+
// update text
200+
this.setText(this.options.text);
201+
202+
// add control
203+
if(this.options.map)
204+
this.options.map.controls[options.position].push(this.div_);
205+
};
206+
207+
google.maps.StatusTextControl.prototype.setText = function(text) {
208+
this.options.text = text;
209+
this.span_.innerHTML = text;
210+
this.div_.style.display = (text === "") ? "none" : "block";
211+
};

js/tracker.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,17 @@ function load() {
362362
}));
363363
}
364364

365+
var customTileAttr = new google.maps.StatusTextControl({
366+
text: '',
367+
map: map,
368+
position: google.maps.ControlPosition.BOTTOM_RIGHT,
369+
});
370+
371+
google.maps.event.addListener(map, 'maptypeid_changed', function() {
372+
var id = this.getMapTypeId();
373+
customTileAttr.setText((id in maptypes) ? maptypes[id][1] : '');
374+
});
375+
365376
// initialize period menu
366377
tmpC = new google.maps.DropDownControl({
367378
map: map,

0 commit comments

Comments
 (0)