简体   繁体   English

如何使用完全相同的Google地图样式和PIN码位置?

[英]How to use exactly the same google maps style and PIN locations?

I want to use the same style and PIN locations for a client's website map just like this : http://www.bekaerttextiles.com/en 我想对客户的网站地图使用相同的样式和PIN位置,就像这样: http://www.bekaerttextiles.com/en : http://www.bekaerttextiles.com/en
But I can't see anything related to map except google maps apis file. 但除了google maps apis文件外,我看不到任何与地图相关的信息。 How is it generating this map? 如何生成此地图? There's not any json or javascript related to PIN locations and their lat-long. 没有与PIN位置及其经纬度相关的json或javascript。 nor the white style of map. 也不是白色的地图样式。

You can design your map by adding styles to the config object (The second parameter in new google.maps.Map ). 您可以通过将styles添加到config对象( new google.maps.Map的第二个参数)来设计地图。 See the docs 查看文件

Note: The marker icon is a private image so you should create one by your own. 注意:标记图标是私人图像,因此您应该自己创建一个。 ( http://www.bekaerttextiles.com/build/web/images/marker.svg ) http://www.bekaerttextiles.com/build/web/images/marker.svg

The styles you are looking for are: 您正在寻找的样式是:

[
  {
    "featureType": "water",
    "elementType": "geometry.fill",
    "stylers": [
      {
        "color": "#F2F0E9"
      }
    ]
  },
  {
    "featureType": "water",
    "elementType": "labels",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  },
  {
    "featureType": "landscape",
    "elementType": "all",
    "stylers": [
      {
        "color": "#ffffff"
      }
    ]
  },
  {
    "featureType": "administrative",
    "elementType": "all",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  },
  {
    "featureType": "poi",
    "elementType": "all",
    "stylers": [
      {
        "color": "#ffffff"
      }
    ]
  },
  {
    "featureType": "road",
    "elementType": "all",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  },
  {
    "featureType": "transit",
    "elementType": "all",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  }
]

And the live example: 还有现场示例:

 function initMap() { var uluru = {lat: -25.363, lng: 131.044}; var map = new google.maps.Map(document.getElementById('map'), { zoom: 1, center: uluru, styles: styles }); var marker = new google.maps.Marker({ position: uluru, map: map }); } var styles = [ { "featureType": "water", "elementType": "geometry.fill", "stylers": [ { "color": "#F2F0E9" } ] }, { "featureType": "water", "elementType": "labels", "stylers": [ { "visibility": "off" } ] }, { "featureType": "landscape", "elementType": "all", "stylers": [ { "color": "#ffffff" } ] }, { "featureType": "administrative", "elementType": "all", "stylers": [ { "visibility": "off" } ] }, { "featureType": "poi", "elementType": "all", "stylers": [ { "color": "#ffffff" } ] }, { "featureType": "road", "elementType": "all", "stylers": [ { "visibility": "off" } ] }, { "featureType": "transit", "elementType": "all", "stylers": [ { "visibility": "off" } ] } ]; 
 #map { height: 400px; width: 100%; } 
 <h3>My Google Maps Demo</h3> <div id="map"></div> <script async defer src="https://maps.googleapis.com/maps/api/js?callback=initMap"> </script> 

http://output.jsbin.com/fiqapa http://output.jsbin.com/fiqapa

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM