2风格的地图在谷歌地图api v3
2 styled map in Google maps api v3?
首先,我是法国人,我的英语很差....
我会有2 style地图在我的网站:我的代码是:
<script type="text/javascript">
// Detection du navigateur utilisé, ainsi que l'affichage
<?php include("browser.js");?>
// Début de la création de la map
function initialiser() {
<?php include("cartes.js");?>
var Night = new google.maps.StyledMapType(Nuit,{name: "Nuit"});
var Map = new google.maps.StyledMapType(Plan,{name: "Plan"});
// Propriétés des identificateurs prédéfinis permettant de définir des options d'affichage
var options = {
center: new google.maps.LatLng(49.894524, 2.30195),
zoom: 13,
mapTypeControlOptions: {
mapTypeIds: [google.maps.MapTypeId.Plan, 'map_style1', 'map_style2', ]
}
};
// Constructeur de la carte dans lequel la carte doit s'afficher ainsi que les options
var carte = new google.maps.Map(document.getElementById("carte"), options);
carte.mapTypes.set('map_style2', Night);
carte.setMapTypeId('map_style2');
carte.mapTypes.set('map_style1', Map);
carte.setMapTypeId('map_style1');
<?php include("geolocalisation.js");?>
<?php include("voitures.js");?>
}
但问题是,2风格的地图在那里,但不是所有的时间工作…也许这是这个api的极限?
最可能的问题是:
mapTypeControlOptions: {
mapTypeIds: [google.maps.MapTypeId.Plan, 'map_style1', 'map_style2', ]
}
已知的maptypeid是:HYBRID, ROADMAP, SATELLITE和TERRAIN。你有Plan
你可以把它改成:
mapTypeControlOptions: {
mapTypeIds: [
google.maps.MapTypeId.ROADMAP, 'map_style1', 'map_style2'
]
}
因此,假设您在某处定义了样式Nuit
和Plan
,如:
var Nuit = [{ ...features style... }];
var Plan = [{ ...features style... }];
我会把你的init函数改成:
function initialiser() {
<?php include("cartes.js");?>
var nightMap = new google.maps.StyledMapType(Nuit,{name: "Nuit"});
var planMap = new google.maps.StyledMapType(Plan,{name: "Plan"});
var options = {
center: new google.maps.LatLng(49.894524, 2.30195),
zoom: 13,
mapTypeControlOptions: {
mapTypeIds: [
google.maps.MapTypeId.ROADMAP, 'map_style1', 'map_style2'
]
}
};
var carte = new google.maps.Map(document.getElementById("carte"), options);
carte.mapTypes.set('map_style2', nightMap);
carte.setMapTypeId('map_style2');
carte.mapTypes.set('map_style1', planMap);
carte.setMapTypeId('map_style1');
<?php include("geolocalisation.js");?>
...
相关文章:
- 谷歌地图API v3不适用于移动浏览器或PhoneGap
- 标记的实时更新,无需加载页面谷歌地图API V3
- 覆盖在赢得'不允许点击下面的标记,谷歌地图api v3
- 谷歌地图Api和JS代码不工作
- 谷歌地图API-InfoBubble赢得't关闭-关闭()不会'不起作用
- 如何在多承诺链中处理谷歌地图API V3事件
- 谷歌地图api和gMapsLatLonPicker
- 谷歌地图API-“;toGeoJson”;返回几何体为null的对象
- 谷歌地图API v3:Initial View is Fine,but Gray Box with No Map if
- 为什么谷歌地图API's方法未从RequireJS中正确调用
- 使用谷歌地图api计算距离并将其设置在表格中<td>
- 使用谷歌地图API和phonegap显示当前位置+方向
- 使用谷歌地图api v3自动完成字段(法国大道、邮编、城市)
- 谷歌地图API标记没有标记我的位置
- 使用谷歌地图api 3为MapTypeId.TERRAIN分离按钮
- 在JQuery中使用谷歌地图Api事件/侦听器
- 在Ionic应用程序上使用$.getScript加载谷歌地图Api
- 我该如何解决“;未捕获引用错误:谷歌没有定义"?(谷歌地图API)
- 谷歌地图API-显示具有不同图标的标记
- 如何停止地图移动时,鼠标悬停在标记在谷歌地图API 3