gpt4 book ai didi

javascript - 谷歌地图 - 使用自定义 json 样式*和* TERRAIN View

转载 作者:数据小太阳 更新时间:2023-10-29 06:13:03 25 4
gpt4 key购买 nike

所以我创建了一些自定义 JSON 来使海洋呈现更饱和的蓝色,但现在似乎无法将 map 默认设置为 TERRAIN View ,它只是转到标准 ROADMAP View ,似乎无法正常工作为什么会这样,有什么想法吗?

function initialize() {

// Create an array of styles.
var blueOceanStyles = [
{
featureType: "water",
stylers: [
{ hue: "#4b83d4" },
{ saturation: 53 }
]
}
];

// Create a new StyledMapType object, passing it the array of styles,
// as well as the name to be displayed on the map type control.
var blueOceanType = new google.maps.StyledMapType(blueOceanStyles,
{name: "Blue Oceans"});

// Create a map object, and include the MapTypeId to add
// to the map type control.
var mapOptions = {
zoom: 5,
center: new google.maps.LatLng(50, 0),
disableDefaultUI: true,
mapTypeId: google.maps.MapTypeId.TERRAIN,
mapTypeControlOptions: {
mapTypeIds: [google.maps.MapTypeId.TERRAIN, 'blue_oceans']
}
};
var map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);

//Associate the styled map with the MapTypeId and set it to display.
map.mapTypes.set('blue_oceans', blueOceanType);
map.setMapTypeId('blue_oceans');
}

最佳答案

你的最后一行:

  map.setMapTypeId('blue_oceans');

这会导致 map 类型重置为您的 map 类型为您的 blue_oceans map 类型。您是否正在尝试创建两种不同的 map 类型?或者您只想要符合您风格的地形类型?如果是后者,试试这个:

      function initialize() {

// Create an array of styles.
var blueOceanStyles = [
{
featureType: "water",
stylers: [
{ hue: "#4b83d4" },
{ saturation: 53 }
]
}
];

// Create a map object, and include the MapTypeId to add
// to the map type control.
var mapOptions = {
zoom: 5,
center: new google.maps.LatLng(50, 0),
mapTypeId: google.maps.MapTypeId.TERRAIN
};
var map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);

//Associate the styled map with the MapTypeId and set it to display.
map.setOptions({styles: blueOceanStyles});
}

关于javascript - 谷歌地图 - 使用自定义 json 样式*和* TERRAIN View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9076820/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com