Hinzufügen von Tabs in Infofenstern (Google Maps API, Google Fusion Tables - KML-Import)
Ich habe das Gefühl, dass ich näher komme, aber hier etwas verpasse. Meine Quelldaten (Polygondaten) befinden sich in Fusionstabellen, und ich möchte ein Informationsfenster mit 2 Registerkarten erstellen und Daten aus der Tabelle in diese Tabelle aufrufen. Eine Reihe von Beispielen gesehen (siehe:https://fusion-tables-users-group.googlegroups.com/attach/ec0975e69edcfb96/infowindow_tabs_5.html?pli=1&view=1&part=4 zum einen), also ich hoffe das ist machbar ...
Mein Code (von der Initialisierungsfunktion) ist unten. Im Moment versuche ich speziell, die Werte (mit e.row) aus dem Feld 'ROOF_TOTAL' abzufragen, um sie in Tab 1 (für erste Testzwecke) einzufügen.
function initialize() {
// set the geocoder variable equal to the instance of the google maps geocoder object
geocoder = new google.maps.Geocoder();
//declare variables for map set up
map = new google.maps.Map (document.getElementById('hatfield_map'), {
center: new google.maps.LatLng(42.37098, -72.59818),
zoom: 17,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
// Set up a styles array to fill in color for the different polygon types based on the query
// of the value 'TYPE' in the FusionTable...
var layer = new google.maps.FusionTablesLayer({
query:{
select: 'geometry',
from: 'TABLE-ID'
},
// suppressInfoWindows: true
// Set up the stroke color and opacity of all polygons...
styles: [{
polygonOptions: {
strokeColor: '#00ffff',
strokeOpacity: .4,
strokeWeight: .5
}]
suppressInfoWindows: true
});
var infowindow = new google.maps.InfoWindow({
});
// create a custom infowindow, Add a click listener that creates a new infowindow
google.maps.event.addListener(layer, "click", function(e) {
'<ul style="font-size:12px;">' +
'<li><a href="#tab-1"><span>Potential Power Capacity</span>
</a></li>' +
'<li><a href="#tab-2"><span>Two</span></a></li>' +
'</ul>' +
'<div id="tab-1">' +
'<p>' + e.row['TOTAL_ROOF'].value + " "+ '</p>' +
'</div>';
infowindow.setContent(contentString);
infowindow.setPosition(e.latLng);
//Infowindow-opening event handler
infowindow.open(map);
$(".tabs").tabs();
});
layer.setMap(map);
}