I apologize if this is basic, but I have very limited javascript knowledge.
I'm making a map that loads GeoJSON data that I created in ArcGIS reformatted to GeoJSON using ogr2ogr. I've got the map loading and showing the point markers from my GeoJSON file, and I've even got a styleFeature()
function to set styling on the features based on their properties.
The problem I'm having is trying to have infowindows pop up when a point feature is clicked on.
I have successfully used the code to set a event listener and update the contents of a div with the information from a clicked feature:
map.data.loadGeoJson('http://www.myurl.com/file.json');
map.data.setStyle(styleFeature);
map.data.addListener('click', function(event) {
var myHTML = event.feature.getProperty('Description');
document.getElementById('info-box').innerHTML = myHTML;
});
What'd I'd like to do instead is have an event that launches an infowindow like this, which doesn't work:
map.data.loadGeoJson('http://www.myurl.com/file.json');
map.data.setStyle(styleFeature);
map.data.addListener('click', function(event) {
var myHTML = event.feature.getProperty('Description');
var infowindow = new google.maps.InfoWindow({content: myHTML});
});
My dataset consists of over a thousand points so hard-coding the infowindows doesn't work, and I haven't seen any examples that show how to create an array of infowindows as the features are looped through in the function called by setStyle()
either.
I know this has to do with my lack of understanding scope, events, and object arrays, but I'm just hitting a wall.
Any help would be appreciated.