Moroccans have had plenty of exposure to other cultures - mainly via satellite TV - to develop their own view about foreign sexual and social norms. At the same time, they value very highly the idea that a Moroccan girl is a virgin until her wedding night. So, in light of the 'freedom' women enjoy in Western films and TV, it is not uncommon for Moroccan men to see foreign women as "loose", and also not uncommon for Moroccan men to try and take advantage of what they see as "looseness".
What some Western women view as sexual harassment in Morocco - catcalls, direct propositions, hissing and out-and-out staring - are more likely to be viewed by Moroccan men as barely conscious actions. Thus, for many non-Muslim women alone in Morocco, her relationship to men, especially in public (as this is seen as 'open territory'), can become a major personal issue.
If I can offer some advise on this subject that I have obtained from my Moroccan female contacts - don't react. Do not acknowledge them - at all. Ignore them as best you can. Western women often feel as though they should not have to 'tone down' in public, but in some instances, if you're out and about alone, it might be worth the 'price'. This will not always get rid of the unwanted behaviour, but in many cases it should assist. It is also important to dress modestly and respect the culture of the country you are in.
Be aware that for Moroccan women, being seen drinking alcohol in a bar or hotel alone or smoking in public is seen as "hshuma" - shameful. Foreign women are, generally speaking, placed outside of this, but will get stared at, as it is uncommon - especially in this region outside of the summer season.