I am trying to create a Text Label, for each of the markers created from my GeoJSON with the following code...
function init() {
var mapCanvas = document.getElementById('myMap');
var map;
var image = "http://maps.google.com/mapfiles/ms/micons/blue.png";
var userCenter = new google.maps.LatLng(-29.789615, 30.822422);
var mapOptions = {
draggable: true,
zoomControl: true,
scrollwheel: true,
disableDoubleClickZoom: false,
zoom: 18,
center: userCenter
};
map = new google.maps.Map(mapCanvas, mapOptions);
var customLayer = new google.maps.Data();
map.data.addGeoJson(jsonData);
map.data.setStyle({
title: '#',
icon: image,
map: map,
});
map.data.forEach(function(feature) {
var point = new google.maps.LatLng(feature.getProperty('coordinates'))
var name = feature.getProperty('GPSLogs_ro')
var mark = new google.maps.Marker({
position: point,
title: '#',
icon: image,
map: map,
draggable: false,
});
});
// customLayer.setMap(map);
}
google.maps.event.addDomListener(window, 'load', init);
var jsonData = { //only showing one point from json to save space
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature",
"properties": { "gpslogid": 106,
"createddat": "2015\/07\/02 13:37:40.000",
"lat": -29.788272, "lon": 30.823182,
"GPSLogs_st": "2015\/07\/02 13:36:49.000",
"GPSLogs_ro": "IMPANGELE",
"GPSLogs_is": "False\r",
"id": 622,
"xmin": 30.821820, "xmax": 30.821920,
"ymin": -29.789654, "ymax": -29.789554 },
"geometry": { "type": "Point",
"coordinates": [ 30.821919004535157, -29.789652962174948 ] } }
]
}
This code is adapted from https://stackoverflow.com/questions/32893734/google-maps-javascript-v3-21-trouble-displaying-geojson-features,
Now that I have my markers adding to the map, I want to assign them a Text Box type label, containing the var name = feature.getProperty('GPSLogs_ro') content.
The closest thing I have found is https://stackoverflow.com/questions/3953922/is-it-possible-to-write-custom-text-on-google-maps-api-v3 however I try to apply it, and no labels appear, just the markers, I am sure I am doing it wrong!