On my webpage, I have a Google map that displays all markers using the map.data.loadGeoJson
method.
Each marker is linked to its respective details page with the following code:
map.data.addListener('click', function(event) {
var id = event.feature.getProperty('name');
window.location.href = 'submission-details.php?submission_id='+id;
});
(The 'name' property in the json file serves as the ID for each submission).
Now, I want the details page to also show a map, but only with one marker specific to that particular submission.
Since my json type is feature collection, I believe I need a way to target individual features from the collection instead of using map.data.loadGeoJson
, which shows all markers at once.
I'm unsure about the next steps and haven't been able to find similar queries. Any assistance would be greatly appreciated!
UPDATE Thank you, Duncan.
I have added the following:
map.data.loadGeoJson('../photo_share/upload/file.json', {},function() {
map.data.getFeatureById(53);
map.data.getFeatureById(53).getProperty('name');
console.log(map.data.getFeatureById(53));
console.log(map.data.getFeatureById(53).getProperty('name'));
});
google.maps.event.addDomListener(window, "load", initMap3);
While this displays in the console log, I am still unsure how to use it to show only the specific marker, as all markers are currently being displayed.