我用冷聚力来绘制一个 go角地图,我想用不同的彩色标识做事。
Using Google Maps API v3
这部法典是行之有效的,但所有1个标识——绿色总是显示的——我无法看到不同的颜色。
Thoughts? Thanx for any input
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script type="text/javascript">
var locations =
[
<cfloop query=due>
<cfoutput>
<cfquery name="info" datasource="data">
SELECT * FROM data
WHERE id = #due.id#
</cfquery>
<cfif info.gpslat is not "">["#info.id#", #info.gpslat#, #info.gpslong#, #info.id#],</cfif>
</cfoutput>
</cfloop>
];
var map = new google.maps.Map(document.getElementById( map ), {
zoom: 14,
center: new google.maps.LatLng(51.19, -114.48),
mapTypeId: google.maps.MapTypeId.HYBRID
});
var infowindow = new google.maps.InfoWindow();
<cfloop query=due>
<cfquery name="info" datasource="data">
SELECT * FROM data
WHERE id = #due.id#
</cfquery>
var marker, i;
<cfif info.gpslat is not "">
<cfif due.data is yes >
var image = red.png ;
</cfif>
<cfif due.data is no >
var image = green.png ;
</cfif>
</cfif>
</cfloop>
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,
icon: image
});
google.maps.event.addListener(marker, click , (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
</script>