我在http://www.gfmap.com有一个网站,它显示了无麸质餐厅、商店、面包店等。它在 Fusion Table 上运行,有 20,000 多件商品。
我想知道是否可以根据类别(餐厅等)更改 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 并且真的只是尽我所能一起破解了这个网站。
任何帮助表示赞赏。
谢谢
马特