Disable CSS Styles in Google Maps (3.14) Infowindow

前端 未结 11 1026
再見小時候
再見小時候 2021-02-05 02:39

In google maps version 3.14 there are some new css rules added for the custom infowindow. I use the infobox plugin and now many of my elements styles are overwritten.

Fo

11条回答
  •  日久生厌
    2021-02-05 03:06

    From what I can see the new css rules are guaranteed to break styling for all markers, controls and info windows web wide, so maybe this will not remain in the 3.exp version long enough become part of an official release. In the meantime to protect you self against breaking changes like this. You should probably do two things:

    1 Set a version on your link to the maps api. Something like

    
    

    will make sure that you are always accessing the current release version of the maps API. If you want to be more conservative you can specify the major and minor releases as well. If you specify a major and minor version then you can test updates to the maps API as part of your regular release schedule. If you are accessing the maps API as part of a wrapped mobile application then you cant control when your users update your app, so you will probably want to just set v=3 and then try to insulate your app from changes in the maps css (see 2. below)

    2 Style your markers, controls, or info windows so that you better control the styling. For example, if you have a marker with html like

    ...

    You can prevent the maps API from setting you font size by a css rule like

    div.my-marker {
      font-size: 18px;
      ...
    }
    

    Note, given maps API styles like

    .gm-style div {
      font-size: 11px;
      ...
    }
    

    you will have to specify the absolute sizes of you elements, relative measurements, like em's wont protect you against potential changes to, for example, font-size: 11px;

提交回复
热议问题