I understand your frustration. It seems that no matter where you live, there are dogs barking at all hours of the day and that's something you'll have to to live with. I live in a small village and it's very quiet....Apart from the dogs. There's always a dog barking at any given time, and if they could hold a tune it would be nice, but they can't so it's quite annoying.
Many people in Spain treat a dog as something to guard their property and not a cherished member of the family, so instead of being curled up at their owner's feet while they watch tv, they are outside in the yard or garden barking at everything that they hear. Of course, there are plenty of responsible dog owners here who love their pets, keep them indoors at night and don't have them bark at all hours, but they are the minority.
As regards to a law about this, good luck with that one. You could complain but I doubt you'll have any joy. I once commented to my partner about a neighbour's dog barking non-stop and whether we could do something about it, but she said that although there is a law about dogs barking outside, a yard is not classed as being outside (even though it is) so nothing could be done. Barking dogs is part of the soundtrack to living in Spain, it's something you learn to live with, after all if it's not one dog in one house, it'll be another dog in another house.