【发布时间】:2012-12-23 11:23:26
【问题描述】:
我在http://www.gfmap.com 有一个网站,它显示了无麸质餐厅、商店、面包店等。它是从一个包含 20,000 多件商品的 Fusion Table 上运行的。
我想知道是否可以根据类别(餐厅等)更改 Google 地图图标颜色
这是代码...
<script type="text/javascript">
var initialLocation;
var companyLocale = new google.maps.LatLng(-33.869629, 151.206955);
var localArray = [companyLocale];
var noGeo = new google.maps.LatLng(51.506325, -0.127144);
var map;
var layerl0;
function initialize() {
map = new google.maps.Map(document.getElementById('themap'),
{
zoom: 12
});
if(navigator.geolocation) {
browserSupportFlag = true;
navigator.geolocation.getCurrentPosition(function(position) {
initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
map.setCenter(initialLocation);
}, function() {
handleNoGeolocation(browserSupportFlag);
});
}else {
handleNoGeolocation();
}
function handleNoGeolocation() {
initialLocation = noGeo;
localArray.unshift(initialLocation);
map.setCenter(initialLocation);
}
var style = [
{
featureType: 'administrative.land_parcel',
elementType: 'all',
stylers: [
{ visibility: 'off' }
]
}
];
var styledMapType = new google.maps.StyledMapType(style, {
map: map,
name: 'Styled Map'
});
map.mapTypes.set('map-style', styledMapType);
map.setMapTypeId('map-style');
layerl0 = new google.maps.FusionTablesLayer({
query: {
select: "'location'",
from: 4015038
},
map: map
});
}
function changeMapl0() {
var searchString = document.getElementById('search-string-l0').value.replace(/'/g, "\\'");
layerl0.setOptions({
query: {
select: "'location'",
from: 4015038,
where: "'Type' = '" + searchString + "'"
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
function ga() {
var address = document.getElementById('q').value;
if (address != ''){
var geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': address + ' AU'}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
if (results[0].geometry.location_type == google.maps.GeocoderLocationType.APPROXIMATE){
map.setZoom(12);
} else {map.setZoom(12);}
}
else {alert("Sorry, we can't find that place using Google.");}
});
}
}
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-31494612-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
我认为答案与Custom Google Map Icon If Value >=1 这篇帖子有关,但我无法让它发挥作用。我不懂 JavaScript,而且我真的只是尽我所能一起破解了这个网站。
任何帮助表示赞赏。
谢谢
马特
【问题讨论】:
-
你应该重新格式化你的代码块,它很难阅读
标签: google-maps-api-3 google-fusion-tables