【发布时间】:2023-03-08 03:14:01
【问题描述】:
我希望能够调整地图类型控件的位置。我把它设置在右上角,但是我需要将它降低大约 50 像素。我阅读了自定义控件,您可以填充 DIV,非自定义控件呢?我可以扩展控件吗?
以下是 API 为控件生成的 HTML:
<div class="gmnoprint" style="margin: 5px; z-index: 11; position: absolute; cursor: pointer; text-align: left; top: 0px; right: 0px;">
<div style="width: 80px; position: relative; overflow: hidden; border: 1px solid black;">
<div style="color: black; font-family: Arial,sans-serif; -moz-user-select: none; font-size: 12px; background-color: white; padding: 0px 5px; font-weight: bold; border-width: 1px; border-style: solid; border-color: rgb(112, 112, 112) rgb(208, 208, 208) rgb(208, 208, 208) rgb(112, 112, 112);" title="Change map style">Map<img style="position: absolute; right: 4px; top: 4px; display: block;" src="http://maps.gstatic.com/intl/en_us/mapfiles/down-arrow.gif"></div>
</div>
<div style="border: 1px solid black; width: 80px; display: none;">
<div style="color: black; font-family: Arial,sans-serif; -moz-user-select: none; font-size: 12px; background-color: white; padding: 1px 5px;" title="Show street map">Map</div>
<div style="color: black; font-family: Arial,sans-serif; -moz-user-select: none; font-size: 12px; background-color: white; padding: 1px 5px;" title="Show satellite imagery">Satellite</div>
<div style="color: black; font-family: Arial,sans-serif; -moz-user-select: none; font-size: 12px; background-color: white; padding: 1px 5px;" title="Show imagery with street names">Hybrid</div>
<div style="color: black; font-family: Arial,sans-serif; -moz-user-select: none; font-size: 12px; background-color: white; padding: 1px 5px;" title="Show street map with terrain">Terrain</div>
</div></div>
作为临时解决方案,我使用以下 jquery 代码来更改此特定控件的填充:
$('[title="Change map style"]').parent().css('padding-top', '36px');
远非理想,但在这种情况下可以完成工作:/
【问题讨论】:
-
@Sjoerd 标记 this 和 Google Maps API V3 custom controls position 的可能重复项是不合逻辑的。重复的可能是这个较新的问题..