【发布时间】:2015-09-08 14:00:37
【问题描述】:
我正在尝试使用 Google Maps JS API 创建一个小应用程序。我正在使用数据层从 GeoJSON 文件中加载一堆点。
文件似乎可以正常加载,地图正在显示,但map.data.setstyle()中设置的图标不会显示。
function init() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 17,
center: new google.maps.LatLng(35.042248, -80.662319),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
map.data.setStyle(function(feature) {
var theaterName = feature.getProperty('name');
return {
icon: {
url: "maps.gstatic.com/mapfiles/ms2/micons/marina.png",
}
visible: true,
clickable: true,
title: theaterName
};
});
}
【问题讨论】:
-
嗨,Sara,欢迎来到 StackOverflow。提问时请务必发布相关代码。如果您需要帮助,请继续点击编辑按钮并在其中输入一些代码。
-
function init(){ map = new google.maps.Map(document.getElementById('map'),{ zoom: 17, center: new google.maps.LatLng(35.042248, -80.662319) , mapTypeId: google.maps.MapTypeId.ROADMAP }); map.data.setStyle(function(feature) { var TheaterName = feature.getProperty('name'); return { icon: {url:"maps.gstatic.com/mapfiles/ms2/micons/marina.png",} 可见:真,可点击:真,标题:剧院名 }; }); }
-
@sara - 我的意思是你问题下的编辑按钮。请不要在 copmments 中发布代码块。
-
你添加了
标签: php google-maps-api-3 geojson marker