Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google map api v3 background color

Tags:

google-maps

I have placed a custom map png on google map. I have removed everything from google maps to only display my custom map. The background color is a light blue and I want to change it to white. Here is the code:

function initialize() {

  var myLatLng = new google.maps.LatLng(39, -98.5);
  var myOptions = {
    maxZoom: 4,
    minZoom: 4,
    zoom: 4,

    panControl: false,
    draggable: false,
        center: myLatLng,
    disableDefaultUI: true,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
    backgroundColor: '#FFFFFF'
  };

  var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  var mapStyles = [
  {
    featureType: "all",
    stylers: [
      { visibility: "off" }]
    }];

map.setOptions({styles: mapStyles});
}

It only flashes white then changes to a light blue. How do I set it to white or transparent?

like image 823
rstewart Avatar asked Feb 21 '12 00:02

rstewart


People also ask

Can I color code Google Maps?

To color-code your map, just use the same method for the icons – click on the destination and when the box pops up, just click on whatever color you want to make it. You can make all restaurants blue, all shopping pink, all parks green, etc.

Can you customize Google Maps API?

Easily create your styleThe new Google Maps APIs Styling Wizard helps you to create a map style in a few clicks. Use one of our pre-built styles or create your own style from scratch.


1 Answers

You can just set backgroundColor: 'none'

var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 11,
    center: {lat: 41.876, lng: -87.624},
    backgroundColor: 'none'
  });
like image 146
Roman Avatar answered Oct 04 '22 21:10

Roman