Don't use js to get the mapid. You already have it in OS.
Give a name to the Map WebBlock you're using and the just refer to it name.id (like with an input).
To place the marker, I'd also suggest OS actions instead of JS code). The desired sequence of actions is (I made it in two days just before sending it to production and it is working live for almost a year now so I recommend it) :
AddCoordinateMarkerToMap (place a dot in the map)
AddMarkerEvent (make an onclick event to the spot)
AddMarkerToBounds (helps defining the needed space)
FitMapToBounds (adjust map based in dots)
Give a name to the Map WebBlock you're using and the just refer to it name.id (like with an input).
To place the marker, I'd also suggest OS actions instead of JS code). The desired sequence of actions is (I made it in two days just before sending it to production and it is working live for almost a year now so I recommend it) :
AddCoordinateMarkerToMap (place a dot in the map)
AddMarkerEvent (make an onclick event to the spot)
AddMarkerToBounds (helps defining the needed space)
FitMapToBounds (adjust map based in dots)