views:

379

answers:

3

When you embed a Google Map on a web page, copyright text is included on the map.

If you embed a map with a small width, the copyright text extends outside of the <div>, instead of wrapping onto two lines within it.

This is the HTML that Google Maps inserts for the copyright text:

<div style="-moz-user-select: none; z-index: 0; position: absolute; right: 3px; bottom: 2px; color: black; font-family: Arial,sans-serif; font-size: 11px; white-space: nowrap; text-align: right;" dir="ltr">
    <span></span>
    <span>Map data &copy;2010  LeadDog Consulting, Europa Technologies - </span>
    <a href="http://www.google.com/intl/en_ALL/help/terms_maps.html" target="_blank" class="gmnoprint terms-of-use-link" style="color: rgb(119, 119, 204);">Terms of Use</a>
    <span></span>
</div>

I’ve tried using jQuery to select this HTML based on its contents (using :contains()) and style it differently, but none of the styles are applied in IE 8. They’re applied fine in IE 7 and Firefox.

$('.map_placeholder div:contains("Map data ")').css({'white-space': 'normal', 'margin-left': '70px', 'width': '210px', 'border-top': 'solid 10px #c00'});
  • Any idea what’s up with IE 8?
  • Do you know other methods to achieve the same result?
+3  A: 
div span { white-space: normal;}
David Andersson
I don't have IE8 so haven't tried it.
David Andersson
Ah yes: that’s the style I’m trying to apply in IE 8, but none of the styles seem to be taking effect.
Paul D. Waite
Doh, sorry: I was still thinking in JavaScript terms. Just sticking this in the stylesheet, which is what you were saying, will do it. I’ve made the rule a bit more specific to the map, but otherwise this is spot on.
Paul D. Waite
+1  A: 

You should be able to set overflow:hidden on the outer div and nothing will extend outside its box.

I'd be careful with removing/styling the copyright text though, since it is likely a breach of Google's TOS.

DisgruntledGoat
Using the white-space: normal approach, the whole text will (likely, depending on size) be visible within the map. However, I agree with DisgruntledGoat, read the TOS.
David Andersson
Yeah, I’m definitely looking for the copyright text to be visible — even aside from the TOS issues, it’d still look bad if it was clipped.
Paul D. Waite
+1  A: 

Just tested this, and it works. Overwrite the inline css with the following:

div[style]{
 font-size: inherit !important;
 white-space: inherit !important;
}


span[style]{
 white-space: inherit !important;
}

a[style]{
 color: inherit !important;
}

span { white-space: normal; }
superUntitled
Ah yes: turns out just the last line will do it in this case.
Paul D. Waite