Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/420.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 设置我的谷歌地图样式时遇到问题_Javascript_Json_Google Maps Api 3 - Fatal编程技术网

Javascript 设置我的谷歌地图样式时遇到问题

Javascript 设置我的谷歌地图样式时遇到问题,javascript,json,google-maps-api-3,Javascript,Json,Google Maps Api 3,我整个星期都在尝试设计我的谷歌地图,我在兜圈子!我有想要使用的JSON值,但不知道如何将它们添加到javascript中!我还想让缩放栏控件位于窗口的右侧,而不是左侧,因为我的地图是一个完整的页面背景,所以在左侧,它隐藏在站点内容div后面 有人能帮忙吗 :) 我要添加的JSON是: [{stylers:[{saturation:-90},{gamma:0.87}]}] 我的地图代码是: <script type="text/javascript"> //<![CDATA[

我整个星期都在尝试设计我的谷歌地图,我在兜圈子!我有想要使用的JSON值,但不知道如何将它们添加到javascript中!我还想让缩放栏控件位于窗口的右侧,而不是左侧,因为我的地图是一个完整的页面背景,所以在左侧,它隐藏在站点内容div后面

有人能帮忙吗

:)

我要添加的JSON是:

[{stylers:[{saturation:-90},{gamma:0.87}]}]

我的地图代码是:

<script type="text/javascript">
//<![CDATA[

if (GBrowserIsCompatible()) { 

  // A function to create the marker and set up the event window
  // Dont try to unroll this function. It has to be here for the function closure
  // Each instance of the function preserves the contends of a different instance
  // of the "marker" and "html" variables which will be needed later when the event triggers.    
  function createMarker(point,html) {
    var marker = new GMarker(point);
    GEvent.addListener(marker, "click", function() {
      marker.openInfoWindowHtml(html);
    });
    return marker;
  }

  // Display the map, with some controls and set the initial location 
  var map = new GMap2(document.getElementById("map"));
  map.addControl(new GLargeMapControl());
  map.addControl(new GMapTypeControl());
  map.setCenter(new GLatLng(50.826910965853585, -0.13648152351379395), 16);




  // Set up the markers with info windows 

  var point = new GLatLng(50.826910965853585, -0.13648152351379395);
  var marker = createMarker(point,'<div style="width:300px">text for pop up here....</div>')
  map.addOverlay(marker);





}







// display a warning if the browser was not compatible
else {
  alert("Sorry, the Google Maps API is not compatible with this browser");
}

// This Javascript is based on code provided by the
// Community Church Javascript Team
// http://www.bisphamchurch.org.uk/   
// http://econym.org.uk/gmap/

//]]>
</script>

//
试试:


基于:

问题是您试图使用Maps API V2,该版本不提供设置地图样式的功能。如前所述,此代码将帮助您设置Maps API V3映射的样式:


由于V2已不推荐使用,因此您无论如何都应该切换。要开始使用V3地图,请查看。

这个家伙的博客有很多关于谷歌地图的例子。非常感谢你的反馈,我还以为我在使用V3 d'oh!
var myStyles = [
  {
    featureType: "all",
    stylers: [ { saturation: -90 }, { gamma: 0.87 }
  }
];

map.setOptions({styles: myStyles });