LoginSignup
10
12

More than 5 years have passed since last update.

【Google Maps JavaScript API v3】地図をオリジナルデザインにカスタマイズ【StyledMapType】

Posted at

デモ:http://mo49.tokyo/qiita/20160517/featureOpts.html

var customMapTypeId = 'custom_style';
var mapOptions = {
  zoom: 12,
  center: {lat: 40.674, lng: -73.946},  // Brooklyn.
  scaleControl: true,
  mapTypeControlOptions: {
    mapTypeIds: [google.maps.MapTypeId.ROADMAP, customMapTypeId]
  },
  mapTypeId: customMapTypeId
};
// オリジナルデザイン
var featureOpts = [
  {
    stylers: [
      { hue: '#FFF700' },
      { visibility: 'simplified' },
      { gamma: 0.5 },
      { weight: 0.5 }
    ]
  },
  {
    elementType: 'labels',
    stylers: [
      { visibility: 'simplified' }
    ]
  },
  {
    featureType: 'road.local',
    stylers: [
      { color: '#FFF700' }
    ]
  }
];
// オリジナルデザインの名前
var styledMapOptions = {
    name: "My Style"
};

// オリジナルデザインをセット
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
var customMapType = new google.maps.StyledMapType(featureOpts, styledMapOptions);
map.mapTypes.set(customMapTypeId, customMapType);
map.setMapTypeId(customMapTypeId);

ジェネレーターでつくるのが良い
Google Maps Colorizr

参考
Simple styled maps
スタイル化されたマップ
Googleマップをイラストマップみたいにしたい。

10
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
12