I want to implement something by Google maps and I need to know if setMap is alreay set or is null. How can I implement something like this:
if (marker.setMap == null)
{
marker.setMap(map);
}
You have to call the getMap function, not check if the setMap function is null. This will toggle the marker:
if (marker.getMap() == null) marker.setMap(map);
else marker.setMap(null);
or even
if (!marker.getMap()) marker.setMap(map);
else marker.setMap(null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With