I have a GoogleMaps page where I load geoJSON points into. These geoJSON points have a property called "waterlevel" which I want to display in an info-box when the cursor is on top of that point.
I currently can get the info-box to update its "text" based on the waterlevel property of each point no problem. The problem I have is that I would like the info-box to say "Water Level = #" rather than just "#".
I have tried making a div tag inside of the info-box div in the body, which says the static text "Water Level = ". The problem is that it will only display when the map originally loads. As soon as I mouse over any point, the whole text gets replaced by a # (magnitude of the waterlevel property).
How can I concatenate the "Water Level = " string with the geoJSON property?
Here's my code:
//Grab the geoJSON points and their properties
var script = document.createElement('script');
script.setAttribute('src',
'http://127.0.0.1:8000/geojson.json');
document.getElementsByTagName('head')[0].appendChild(script);
// Set mouseover event for each Point
map.data.addListener('mouseover', function(event) {
document.getElementById('info-box').textContent =
event.feature.getProperty('waterlevel');
});
//MUCH LATER IN THE CODE
<body>
<div id="map-canvas"></div>
<div id="info-box"><div style="overflow:hidden;line-height:1.35;min-width:200px;"><b>Water Level = </b></div>?</div>
</body>